unit Main_ViewU;
interface
uses
Game,
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls;
type
TMain_View =
class( TForm )
DiceEyes_Label : TLabel;
PlayerSum_Label : TLabel;
RollDice_Button : TButton;
procedure RollDice_ButtonClick( Sender : TObject );
procedure FormCreate( Sender : TObject );
procedure FormDestroy( Sender : TObject );
procedure FormShow( Sender : TObject );
private
FDice : TDice;
FPlayer : TPlayer;
procedure ShowPlayer( APlayer : TPlayer );
procedure ShowDice( ADice : TDice );
public
end;
var
Main_View : TMain_View;
implementation
{$R *.dfm}
{ TForm1 }
procedure TMain_View.FormCreate( Sender : TObject );
begin
FDice := TStandardDice.Create;
FPlayer := TPlayer.Create;
end;
procedure TMain_View.FormDestroy( Sender : TObject );
begin
FPlayer.Free;
FDice.Free;
end;
procedure TMain_View.FormShow( Sender : TObject );
begin
ShowPlayer( FPlayer );
ShowDice( FDice );
end;
procedure TMain_View.RollDice_ButtonClick( Sender : TObject );
begin
FPlayer.RollDice( FDice );
ShowDice( FDice );
ShowPlayer( FPlayer );
end;
procedure TMain_View.ShowDice( ADice : TDice );
begin
DiceEyes_Label.Caption := IntToStr( ADice.Eyes );
end;
procedure TMain_View.ShowPlayer( APlayer : TPlayer );
begin
PlayerSum_Label.Caption := IntToStr( APlayer.Sum );
end;
end.