Skip to content

Commit

Permalink
Repay.
Browse files Browse the repository at this point in the history
  • Loading branch information
devapromix committed Jul 10, 2022
1 parent 359096c commit 3079bae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Sources/Game/TransportTycoon.Game.pas
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ TGame = class(TObject)
const AMoney: Integer); overload;
procedure LoadSettings;
procedure SaveSettings;
procedure Repay;
end;

var
Expand Down Expand Up @@ -128,6 +129,12 @@ procedure TGame.ModifyMoney(const ValueEnum: TValueEnum; const AMoney: Integer);
FMoney := FMoney + AMoney;
end;

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

procedure TGame.ModifyMoney(const AMoney: Integer);
begin
FMoney := FMoney + AMoney;
Expand Down
7 changes: 5 additions & 2 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, 'R', 'REPAY');
AddButton(26, 'ESC', 'CLOSE');

DrawBar;
Expand All @@ -102,7 +103,9 @@ procedure TSceneFinances.Update(var Key: Word);
if (Key = TK_MOUSE_LEFT) then
if (GetButtonsY = MY) then
begin
if (MX >= 35) and (MX <= 45) then
if (MX >= 29) and (MX <= 37) then
Key := TK_R;
if (MX >= 41) and (MX <= 51) then
Key := TK_ESCAPE;
end;
case Key of
Expand All @@ -115,7 +118,7 @@ procedure TSceneFinances.Update(var Key: Word);
TK_B:
;
TK_R:
;
Game.Repay;
end;

end;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Scenes/TransportTycoon.Scenes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ implementation
TransportTycoon.Scene.Ships,
TransportTycoon.Scene.Ship,
TransportTycoon.Scene.ShipDepot,
TransportTycoon.Scene.BuildMenu;
TransportTycoon.Scene.BuildMenu;

procedure TScene.DrawText(const X, Y: Integer; Text: string;
const Align: Integer = TK_ALIGN_LEFT);
Expand Down

0 comments on commit 3079bae

Please sign in to comment.