Skip to content

Commit

Permalink
Borrow.
Browse files Browse the repository at this point in the history
  • Loading branch information
devapromix committed Jul 10, 2022
1 parent 3079bae commit c143278
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
15 changes: 14 additions & 1 deletion Sources/Game/TransportTycoon.Game.pas
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ TGame = class(TObject)
procedure LoadSettings;
procedure SaveSettings;
procedure Repay;
procedure Borrow;
end;

var
Expand Down Expand Up @@ -131,8 +132,11 @@ procedure TGame.ModifyMoney(const ValueEnum: TValueEnum; const AMoney: Integer);

procedure TGame.Repay;
begin
if Loan >= 10000 then
if (FLoan >= 10000) and (FMoney >= 10000) then
begin
FLoan := FLoan - 10000;
FMoney := FMoney - 10000;
end
end;

procedure TGame.ModifyMoney(const AMoney: Integer);
Expand Down Expand Up @@ -167,6 +171,15 @@ procedure TGame.Step;
FVehicles.Step;
end;

procedure TGame.Borrow;
begin
if Loan < MaxLoan then
begin
FLoan := FLoan + 10000;
FMoney := FMoney + 10000;
end;
end;

procedure TGame.Clear;
begin
FTurn := 0;
Expand Down
13 changes: 6 additions & 7 deletions Sources/Scenes/TransportTycoon.Scene.Finances.pas
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ procedure TSceneFinances.Render;
DrawMoney(38, 24, Game.Money - Game.Loan);
terminal_composition(TK_OFF);

AddButton(26, 'B', 'BORROW');
AddButton(26, 'R', 'REPAY');
AddButton(26, 'ESC', 'CLOSE');

Expand All @@ -103,20 +104,18 @@ procedure TSceneFinances.Update(var Key: Word);
if (Key = TK_MOUSE_LEFT) then
if (GetButtonsY = MY) then
begin
if (MX >= 29) and (MX <= 37) then
if (MX >= 22) and (MX <= 31) then
Key := TK_B;
if (MX >= 35) and (MX <= 43) then
Key := TK_R;
if (MX >= 41) and (MX <= 51) then
if (MX >= 47) and (MX <= 57) then
Key := TK_ESCAPE;
end;
case Key of
TK_ESCAPE:
Scenes.SetScene(scWorld);
TK_I:
;
TK_C:
;
TK_B:
;
Game.Borrow;
TK_R:
Game.Repay;
end;
Expand Down

0 comments on commit c143278

Please sign in to comment.