private void InitiateRepayment(bool full, bool custom = false) { if (loanManager.IsBorrowing && loanManager.Balance > 0) { //check if player wants to repay in full. if (custom) { Game1.activeClickableMenu = new NumberSelectionMenu(I18n.Msg_Startrepay(), (val, cost, farmer) => { //if user chooses to repay full amount from custom menu if (val == loanManager.Balance) { StartBorrow(3, "Key_Repay"); return; } if (Game1.player.Money >= val) { Game1.player.Money -= val; loanManager.AmountRepaid += val; loanManager.Balance -= val; //recalculate daily amount in case balance is lower than daily repayment loanManager.AmountRepaidToday += val; AddMessage(I18n.Msg_Payment_Complete(val.ToString("N0")), HUDMessage.achievement_type); } Game1.activeClickableMenu = null; }, -1, 1, loanManager.Balance, Math.Min(loanManager.DailyAmount, loanManager.Balance)); } else if (full) { if (Game1.player.Money >= loanManager.Balance) { //Repays the remaining balance Game1.player.Money -= loanManager.Balance; loanManager.InitiateReset(); AddMessage(I18n.Msg_Payment_Full(), HUDMessage.achievement_type); } else { AddMessage(I18n.Msg_Payment_Failed(loanManager.Balance.ToString("N0")), HUDMessage.error_type); } repayProcess = false; return; } //Check if you are still in loan contract else if (loanManager.Balance > 0) { int moneyToRepay = loanManager.CalculateAmountToPayToday; //If player has enough Money for the daily deduction amount if (Game1.player.Money >= moneyToRepay) { //Checks if the balance is greater than or equal to the daily repayment amount if (loanManager.Balance > moneyToRepay) { Game1.player.Money -= moneyToRepay; loanManager.AmountRepaid += moneyToRepay; loanManager.Balance -= moneyToRepay; } else { //Repays the remaining balance Game1.player.Money -= loanManager.Balance; loanManager.IsBorrowing = false; AddMessage(I18n.Msg_Payment_Full(), HUDMessage.achievement_type); } loanManager.HasPaid = true; if (loanManager.Duration > 0) { loanManager.Duration--; } loanManager.LateDays = 0; } else { if (Config.LatePaymentChargeRate != 0) { loanManager.LateChargeRate = Config.LatePaymentChargeRate; loanManager.LateChargeAmount = (int)loanManager.CalculateLateFees; AddMessage(I18n.Msg_Payment_Failed(loanManager.DailyAmount.ToString("N0")), HUDMessage.error_type); if (loanManager.LateDays == 0) { AddMessage(I18n.Msg_Payment_Missed1(loanManager.LateChargeAmount.ToString("N0")), HUDMessage.error_type); loanManager.LateDays++; } else { AddMessage(I18n.Msg_Payment_Missed2(loanManager.LateChargeAmount.ToString("N0")), HUDMessage.error_type); loanManager.Balance += loanManager.LateChargeAmount; } } loanManager.HasPaid = false; } } } }