private async Task RepayLoan() { int maxPayment = Math.Max(Player.Gold, Player.loan); int minPayment; int timeLeft = (int)(Player.dueDate - Player.TimeDays + 0.02); if (timeLeft > 0) { minPayment = 0; } else { minPayment = (int)(Player.loan * .3 + 0.5); if (minPayment > Player.Gold) { minPayment = Player.Gold; if (Player.Gold > 30) { minPayment -= 10; } } } var paymentAmount = await LendingPresentation.PaymentPrompt(Player.loan, timeLeft, minPayment, maxPayment); if (paymentAmount > Player.loan) { paymentAmount = Player.loan; } Player.Gold -= paymentAmount; Player.loan -= paymentAmount; if (Player.loan <= 0) { await LendingPresentation.DisplayLoanRepaid(); } else if (minPayment == 0) { await LendingPresentation.DisplayDebtRemainder(Player.loan, timeLeft); } else if (paymentAmount >= minPayment) { Player.dueDate = (int)Player.TimeDays + 14; await LendingPresentation.DisplayLoanExtension(); } else { await LendingPresentation.DisplayFailureToPay(); } }
public async Task OfferLoan() { var amount = await LendingPresentation.PromptBorrow(MaxLoan); if (amount <= 0) { return; } Player.Gold += amount; Player.loan = (int)(amount * 1.5); Player.dueDate = (int)(Player.TimeDays + 0.999) + 120; await LendingPresentation.DisplayNewLoan(amount, Player.loan, 120); }
protected override async Task <bool> SpeakImplAsync() { LendingPresentation.InitializeWindow(); await TextArea.PrintLine(); if (Player.loan == 0) { await OfferLoan(); } else { await RepayLoan(); } return(true); }