From 3079baeafeccb8e5487be4e49c518a18e04059df Mon Sep 17 00:00:00 2001 From: devapromix Date: Sun, 10 Jul 2022 09:38:22 +0300 Subject: [PATCH] Repay. --- Sources/Game/TransportTycoon.Game.pas | 7 +++++++ Sources/Scenes/TransportTycoon.Scene.Finances.pas | 7 +++++-- Sources/Scenes/TransportTycoon.Scenes.pas | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/Game/TransportTycoon.Game.pas b/Sources/Game/TransportTycoon.Game.pas index 0340bda..0694378 100644 --- a/Sources/Game/TransportTycoon.Game.pas +++ b/Sources/Game/TransportTycoon.Game.pas @@ -55,6 +55,7 @@ TGame = class(TObject) const AMoney: Integer); overload; procedure LoadSettings; procedure SaveSettings; + procedure Repay; end; var @@ -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; diff --git a/Sources/Scenes/TransportTycoon.Scene.Finances.pas b/Sources/Scenes/TransportTycoon.Scene.Finances.pas index 31198e3..3edec65 100644 --- a/Sources/Scenes/TransportTycoon.Scene.Finances.pas +++ b/Sources/Scenes/TransportTycoon.Scene.Finances.pas @@ -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; @@ -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 @@ -115,7 +118,7 @@ procedure TSceneFinances.Update(var Key: Word); TK_B: ; TK_R: - ; + Game.Repay; end; end; diff --git a/Sources/Scenes/TransportTycoon.Scenes.pas b/Sources/Scenes/TransportTycoon.Scenes.pas index 377eb75..4f013fb 100644 --- a/Sources/Scenes/TransportTycoon.Scenes.pas +++ b/Sources/Scenes/TransportTycoon.Scenes.pas @@ -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);