Class Loan

java.lang.Object
mekhq.campaign.finances.Loan

public class Loan extends Object
TODO : Update loan baseline based on latest Campaign Operations Rules
  • Constructor Details

  • Method Details

    • getInstitution

      public String getInstitution()
    • setInstitution

      public void setInstitution(String institution)
    • getReferenceNumber

      public String getReferenceNumber()
    • setReferenceNumber

      public void setReferenceNumber(String referenceNumber)
    • getPrincipal

      public Money getPrincipal()
    • setPrincipal

      public void setPrincipal(Money principal)
    • getRate

      public int getRate()
    • setRate

      public void setRate(int rate)
    • getYears

      public int getYears()
    • setYears

      public void setYears(int years)
    • getFinancialTerm

      public FinancialTerm getFinancialTerm()
    • setFinancialTerm

      public void setFinancialTerm(FinancialTerm financialTerm)
    • getCollateral

      public int getCollateral()
    • setCollateral

      public void setCollateral(int collateral)
    • getRemainingPayments

      public int getRemainingPayments()
    • setRemainingPayments

      public void setRemainingPayments(int remainingPayments)
    • getPaymentAmount

      public Money getPaymentAmount()
    • setPaymentAmount

      public void setPaymentAmount(Money paymentAmount)
    • getNextPayment

      public LocalDate getNextPayment()
    • setNextPayment

      public void setNextPayment(LocalDate nextPayment)
    • isOverdue

      public boolean isOverdue()
    • setOverdue

      public void setOverdue(boolean overdue)
    • determineCollateralAmount

      public Money determineCollateralAmount()
    • determineRemainingValue

      public Money determineRemainingValue()
    • calculateAmortization

      public void calculateAmortization()
    • paidLoan

      public void paidLoan()
    • checkLoanPayment

      public boolean checkLoanPayment(LocalDate today)
    • getBaseLoan

      public static Loan getBaseLoan(int rating, boolean simulateGrayMonday, LocalDate date)
      Computes and returns a base loan object based on the player's rating, the current date, and campaign-specific conditions such as the Gray Monday event.

      This method determines the loan terms that the player is eligible for based on their performance rating and whether the game is simulating the Gray Monday event. If the Gray Monday event is active, a special predatory loan with significantly higher interest rates and penalties is offered. Otherwise, the loan terms are progressively better as the player's rating improves.

      The returned Loan object contains all relevant terms such as the principal, interest rate, repayment duration, financial term, and associated penalty.

      Parameters:
      rating - The player's performance rating as an integer. Defaults to higher loan penalties and stricter terms for lower ratings.
      simulateGrayMonday - A boolean flag that indicates whether the Gray Monday event is active, which impacts loan terms significantly.
      date - The current in-game date as a LocalDate object, used to determine if Gray Monday conditions apply.
      Returns:
      A Loan object representing the player's base loan terms based on their rating and event conditions.
    • getInterestBracket

      public static int[] getInterestBracket(int rating)
    • getCollateralBracket

      public static int[] getCollateralBracket(int rating)
    • getMaxYears

      public static int getMaxYears(int rating)
      Determines the maximum number of years by clamping the given rating to a valid range.

      This method returns a value that ensures the input rating falls within the specified range of 1 to 7. Ratings below 1 are clamped to 1, and ratings above 7 are clamped to 7. The clamped value is directly returned.

      The clamped values coincide with the Experience Level ordinals (Ultra-Green, Green, etc). This means a Veteran-rated campaign (ordinal 4) could take up to a 4-year loan.

      Parameters:
      rating - the input rating value to be clamped.
      Returns:
      the clamped rating, guaranteed to be a value between 1 and 7 (inclusive).
    • getCollateralIncrement

      public static int getCollateralIncrement(int rating, boolean interestPositive)
    • recalculateCollateralFromInterest

      public static int recalculateCollateralFromInterest(int rating, int interest)
    • recalculateInterestFromCollateral

      public static int recalculateInterestFromCollateral(int rating, int collateral)
    • writeToXML

      public void writeToXML(PrintWriter pw, int indent)
    • generateInstanceFromXML

      public static Loan generateInstanceFromXML(Node wn)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object