Example #1
0
        private static void OverdueLoan(int regionIndex)
        {
            // Try to repay the loan off player's account
            int transferAmount = (int)Math.Min(DaggerfallBankManager.GetLoanedTotal(regionIndex), DaggerfallBankManager.GetAccountTotal(regionIndex));

            DaggerfallBankManager.MakeTransaction(TransactionType.Repaying_loan_from_account, transferAmount, regionIndex);
            if (!DaggerfallBankManager.HasLoan(regionIndex))
            {
                return;
            }

            // Only apply reputation drop once
            if (DaggerfallBankManager.HasDefaulted(regionIndex))
            {
                return;
            }

            // Set hasDefaulted flag (Note: Does not seem to ever be set in classic)
            DaggerfallBankManager.SetDefaulted(regionIndex, true);

            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            // Should that be weighted by the amount?
            playerEntity.LowerRepForCrime(regionIndex, PlayerEntity.Crimes.LoanDefault);
        }
Example #2
0
 void UpdateLabels()
 {
     inventoryAmount.Text = playerEntity.GetGoldAmount().ToString();
     accountAmount.Text   = DaggerfallBankManager.GetAccountTotal(regionIndex).ToString();
     loanAmountDue.Text   = DaggerfallBankManager.GetLoanedTotal(regionIndex).ToString();
     loanDueBy.Text       = DaggerfallBankManager.GetLoanDueDateString(regionIndex);
 }
 void UpdateLabels()
 {
     inventoryAmount.Text = playerEntity.GetGoldAmount().ToString();
     if (playerEntity.WagonItems.Contains(ItemGroups.Currency, (int)Currency.Gold_pieces))
     {
         int wagonGold = playerEntity.WagonItems.GetItem(ItemGroups.Currency, (int)Currency.Gold_pieces).stackCount;
         inventoryAmount.Text += " (+" + wagonGold + ")";
     }
     accountAmount.Text = DaggerfallBankManager.GetAccountTotal(regionIndex).ToString();
     loanAmountDue.Text = DaggerfallBankManager.GetLoanedTotal(regionIndex).ToString();
     loanDueBy.Text     = DaggerfallBankManager.GetLoanDueDateString(regionIndex);
 }
Example #4
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);
                            }
                        }
                    }
                }
            }
        }
        public static DaggerfallMessageBox CreateBankingStatusBox(IUserInterfaceWindow previous = null)
        {
            const string textDatabase = "DaggerfallUI";

            DaggerfallMessageBox bankingBox = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, previous);

            bankingBox.SetHighlightColor(DaggerfallUI.DaggerfallUnityStatDrainedTextColor);
            List <TextFile.Token> messages = new List <TextFile.Token>();
            bool found = false;

            messages.AddRange(GetLoansLine(
                                  TextManager.Instance.GetText(textDatabase, "region"),
                                  TextManager.Instance.GetText(textDatabase, "account"),
                                  TextManager.Instance.GetText(textDatabase, "loan"),
                                  TextManager.Instance.GetText(textDatabase, "dueDate")));
            messages.Add(TextFile.NewLineToken);
            for (int regionIndex = 0; regionIndex < DaggerfallBankManager.BankAccounts.Length; regionIndex++)
            {
                if (DaggerfallBankManager.GetAccountTotal(regionIndex) > 0 || DaggerfallBankManager.HasLoan(regionIndex))
                {
                    TextFile.Formatting formatting = DaggerfallBankManager.HasDefaulted(regionIndex) ? TextFile.Formatting.TextHighlight : TextFile.Formatting.Text;
                    messages.AddRange(GetLoansLine(ShortenName(MapsFile.RegionNames[regionIndex], 12), DaggerfallBankManager.GetAccountTotal(regionIndex).ToString(), DaggerfallBankManager.GetLoanedTotal(regionIndex).ToString(), DaggerfallBankManager.GetLoanDueDateString(regionIndex), formatting));
                    found = true;
                }
            }
            if (!found)
            {
                TextFile.Token noneToken = TextFile.CreateTextToken(TextManager.Instance.GetText(textDatabase, "noAccount"));
                messages.Add(noneToken);
                messages.Add(TextFile.NewLineToken);
            }
            bankingBox.SetTextTokens(messages.ToArray());
            bankingBox.ClickAnywhereToClose = true;
            return(bankingBox);
        }