Example #1
0
        public static void CheckOverdueLoans(uint lastGameMinutes)
        {
            uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            for (int regionIndex = 0; regionIndex < DaggerfallBankManager.BankAccounts.Length; regionIndex++)
            {
                long paymentDueMinutes = DaggerfallBankManager.GetLoanDueDate(regionIndex);

                if (paymentDueMinutes != 0)
                {
                    if (paymentDueMinutes < gameMinutes)
                    {
                        Debug.Log("loan overdue " + paymentDueMinutes + " < " + gameMinutes);
                        OverdueLoan(regionIndex);
                    }
                    else
                    {
                        long lastRemainingMonths = (paymentDueMinutes - lastGameMinutes) / MinutesPerMonth;
                        long remainingMonths     = (paymentDueMinutes - gameMinutes) / MinutesPerMonth;
                        if (remainingMonths < lastRemainingMonths)
                        {
                            // Months left before due date
                            int[] sendReminderMonths = { 6, 3, 1 };
                            if (Array.Exists(sendReminderMonths, month => lastRemainingMonths >= month && remainingMonths < month))
                            {
                                // Send letters before due date instead?
                                DaggerfallUI.AddHUDText(String.Format(TextManager.Instance.GetLocalizedText("loanReminder"),
                                                                      DaggerfallBankManager.GetLoanedTotal(regionIndex)), loanReminderHUDDelay);
                                DaggerfallUI.AddHUDText(String.Format(TextManager.Instance.GetLocalizedText("loanReminder2"),
                                                                      remainingMonths + 1, MapsFile.RegionNames[regionIndex]), loanReminderHUDDelay);
                            }
                        }
                    }
                }
            }
        }