unit FrameCharCreate2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
DB, DBTables, StdCtrls, Mask, DBCtrls, ExtCtrls, jpeg;
type
TFrame2CharCreate =
class(TFrame)
GroupBoxCharProperties: TGroupBox;
LabelMU: TLabel;
LabelKL: TLabel;
LabelCH: TLabel;
LabelGE: TLabel;
LabelKK: TLabel;
ButtonRandomize: TButton;
ButtonCharCreateFrame2Next: TButton;
ButtonCharCreateFrame2Back: TButton;
LabelHeader: TLabel;
LabelDescription: TLabel;
Timer1: TTimer;
ImageCharCreate: TImage;
EditMU: TEdit;
EditKL: TEdit;
EditCH: TEdit;
EditGE: TEdit;
EditKK: TEdit;
GroupBoxMoney: TGroupBox;
LabelDukaten: TLabel;
LabelSilbertaler: TLabel;
LabelHeller: TLabel;
LabelKreuzer: TLabel;
ButtonMoneyRandomize: TButton;
EditSilber: TEdit;
EditKreuzer: TEdit;
EditHeller: TEdit;
EditDukaten: TEdit;
Timer2: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure ButtonRandomizeClick(Sender: TObject);
procedure ButtonMoneyRandomizeClick(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private-Deklarationen }
procedure GetCount (Sender: TObject);
procedure GetCountMoney (Sender: TObject);
public
{ Public-Deklarationen }
var editCount: Byte;
var editCountMoney: Byte;
end;
implementation
{$R *.dfm}
procedure TFrame2CharCreate.ButtonMoneyRandomizeClick(Sender: TObject);
begin
if EditKreuzer.Text = '
'
then
begin
editCountMoney := 0;
end;
if ButtonMoneyRandomize.Tag = 0
then
begin
ButtonMoneyRandomize.Tag := 1;
Timer2.Enabled := True;
end
else
begin
if ButtonMoneyRandomize.Tag = 1
then
begin
ButtonMoneyRandomize.Tag := 0;
Timer2.Enabled := False;
Inc(editCountMoney);
end;
end;
if (editCountMoney = 1)
and (ButtonMoneyRandomize.Tag = 0)
then
begin
ButtonMoneyRandomize.Enabled := False;
end;
end;
procedure TFrame2CharCreate.ButtonRandomizeClick(Sender: TObject);
begin
if EditMU.Text = '
'
then
begin
editCount := 0;
end;
if ButtonRandomize.Tag = 0
then
begin
ButtonRandomize.Tag := 1;
Timer1.Enabled := True;
end
else
begin
if ButtonRandomize.Tag = 1
then
begin
ButtonRandomize.Tag := 0;
Timer1.Enabled := False;
Inc(editCount);
end;
end;
if (editCount = 5)
and (ButtonRandomize.Tag = 0)
then
begin
ButtonRandomize.Enabled := False;
end;
end;
procedure TFrame2CharCreate.GetCount(Sender: TObject);
var
i: Integer;
begin
// Zufallsgenerator init
Randomize;
// Zufälligen Wert ermitteln
i := Random(6) + 1;
i := i+7;
if editCount = 0
then
begin
EditMU.Text := IntToStr(i);
end
else
begin
if editCount = 1
then
begin
EditKL.Text := IntToStr(i);
end
else
begin
if editCount = 2
then
begin
EditCH.Text := IntToStr(i);
end
else
begin
if editCount = 3
then
begin
EditGE.Text := IntToStr(i);
end
else
begin
if editCount = 4
then
begin
EditKK.Text := IntToStr(i);
end;
end;
end;
end;
end;
end;
procedure TFrame2CharCreate.GetCountMoney(Sender: TObject);
var
iSilber: Integer;
begin
// Zufallsgenerator init
Randomize;
// Vermögen auswürfteln
iSilber := Random(6) + 1;
iSilber := (iSilber + 6) * 10;
EditSilber.Text := IntToStr(iSilber);
// Währungs-Einheiten umrechnen
if iSilber > 10
then
begin
EditDukaten.Text := IntToStr(iSilber - 10);
end;
end;
procedure TFrame2CharCreate.Timer1Timer(Sender: TObject);
begin
GetCount(Sender);
end;
procedure TFrame2CharCreate.Timer2Timer(Sender: TObject);
begin
GetCountMoney(Sender);
end;
end.