Class Contract

java.lang.Object
mekhq.campaign.mission.Mission
mekhq.campaign.mission.Contract
Direct Known Subclasses:
AtBContract

public class Contract extends Mission
Contracts - we need to track static amounts here because changes in the underlying campaign don't change the figures once the ink is dry
  • Field Details

  • Constructor Details

    • Contract

      public Contract()
    • Contract

      public Contract(String name, String employer)
  • Method Details

    • getOverheadCompName

      public static String getOverheadCompName(int i)
    • getEmployer

      public String getEmployer()
    • setEmployer

      public void setEmployer(String s)
    • getLength

      public int getLength()
      Returns the contract length in months.
      Returns:
      the number and corresponding length of the contact in months as an integer
    • setLength

      public void setLength(int m)
    • getStartDate

      public LocalDate getStartDate()
    • setStartDate

      public void setStartDate(LocalDate d)
    • getEndingDate

      public LocalDate getEndingDate()
    • setEndDate

      public void setEndDate(LocalDate endDate)
    • setStartAndEndDate

      public void setStartAndEndDate(LocalDate startDate)
      This sets the Start Date and End Date of the Contract based on the length of the contract and the starting date provided
      Parameters:
      startDate - the date the contract starts at
    • getMultiplier

      public double getMultiplier()
    • setMultiplier

      public void setMultiplier(double s)
    • getTransportComp

      public int getTransportComp()
    • getTransportCompString

      public String getTransportCompString()
    • setTransportComp

      public void setTransportComp(int s)
    • getStraightSupport

      public int getStraightSupport()
    • getStraightSupportString

      public String getStraightSupportString()
    • setStraightSupport

      public void setStraightSupport(int s)
    • getOverheadComp

      public int getOverheadComp()
    • setOverheadComp

      public void setOverheadComp(int s)
    • getCommandRights

      public ContractCommandRights getCommandRights()
    • setCommandRights

      public void setCommandRights(ContractCommandRights commandRights)
    • getBattleLossComp

      public int getBattleLossComp()
    • getBattleLossCompString

      public String getBattleLossCompString()
    • setBattleLossComp

      public void setBattleLossComp(int s)
    • getSalvagePct

      public int getSalvagePct()
    • getSalvagePctString

      public String getSalvagePctString()
    • setSalvagePct

      public void setSalvagePct(int s)
    • isSalvageExchange

      public boolean isSalvageExchange()
    • setSalvageExchange

      public void setSalvageExchange(boolean b)
    • canSalvage

      public boolean canSalvage()
    • getSalvagedByUnit

      public Money getSalvagedByUnit()
    • setSalvagedByUnit

      public void setSalvagedByUnit(Money l)
    • addSalvageByUnit

      public void addSalvageByUnit(Money l)
    • subtractSalvageByUnit

      public void subtractSalvageByUnit(Money money)
    • getSalvagedByEmployer

      public Money getSalvagedByEmployer()
    • setSalvagedByEmployer

      public void setSalvagedByEmployer(Money l)
    • addSalvageByEmployer

      public void addSalvageByEmployer(Money l)
    • getSigningBonusPct

      public int getSigningBonusPct()
    • setSigningBonusPct

      public void setSigningBonusPct(int s)
    • getAdvancePct

      public int getAdvancePct()
    • setAdvancePct

      public void setAdvancePct(int s)
    • payMRBCFee

      public boolean payMRBCFee()
    • getMrbcFeePercentage

      public int getMrbcFeePercentage()
    • setMRBCFee

      public void setMRBCFee(boolean b)
    • getTotalAmountPlusFeesAndBonuses

      public Money getTotalAmountPlusFeesAndBonuses()
    • getTotalAmountPlusFees

      public Money getTotalAmountPlusFees()
    • getTotalAmount

      public Money getTotalAmount()
    • getAdvanceAmount

      public Money getAdvanceAmount()
    • getTotalAdvanceAmount

      public Money getTotalAdvanceAmount()
      Returns:
      total amount that will be paid on contract acceptance.
    • setAdvanceAmount

      protected void setAdvanceAmount(Money amount)
    • getFeeAmount

      public Money getFeeAmount()
    • setFeeAmount

      protected void setFeeAmount(Money amount)
    • getBaseAmount

      public Money getBaseAmount()
    • setBaseAmount

      public void setBaseAmount(Money amount)
    • getOverheadAmount

      public Money getOverheadAmount()
    • setOverheadAmount

      protected void setOverheadAmount(Money amount)
    • getSupportAmount

      public Money getSupportAmount()
    • setSupportAmount

      protected void setSupportAmount(Money amount)
    • getTransitAmount

      public Money getTransitAmount()
    • setTransitAmount

      public void setTransitAmount(Money amount)
    • getTransportAmount

      public Money getTransportAmount()
    • setTransportAmount

      protected void setTransportAmount(Money amount)
    • getSigningBonusAmount

      public Money getSigningBonusAmount()
    • setSigningBonusAmount

      protected void setSigningBonusAmount(Money amount)
    • setSystemId

      public void setSystemId(String n)
      Overrides:
      setSystemId in class Mission
    • isActiveOn

      public boolean isActiveOn(LocalDate date, boolean excludeEndDateCheck)
      Overrides:
      isActiveOn in class Mission
    • getJumpPath

      @Nullable public JumpPath getJumpPath(Campaign c)
      Gets the currently calculated jump path for this contract, only recalculating if it's not valid any longer or hasn't been calculated yet.
    • getCachedJumpPath

      @Nullable public JumpPath getCachedJumpPath()
    • setCachedJumpPath

      public void setCachedJumpPath(@Nullable JumpPath cachedJumpPath)
    • getMonthlyPayOut

      public Money getMonthlyPayOut()
    • getTotalMonthlyPayOut

      public Money getTotalMonthlyPayOut(Campaign c)
      Parameters:
      c - campaign loaded
      Returns:
      the cumulative sum the estimated monthly incomes - expenses
    • getTravelDays

      public int getTravelDays(Campaign campaign)
      Calculates the number of days required for travel based on the current campaign state.

      This method determines if a valid destination system is set, computes if the command circuit should be used, retrieves the jump path, and totals the travel time (including recharge, start, and end times). The result is rounded to two decimal places and then to the nearest whole day.

      Parameters:
      campaign - the Campaign instance containing context such as date, location, and command circuit options
      Returns:
      the total number of travel days required; returns 0 if there is no valid system to travel to
    • getLengthPlusTravel

      public int getLengthPlusTravel(Campaign c)
      Parameters:
      c - campaign loaded
      Returns:
      the approximate number of months for a 2-way trip + deployment, rounded up
    • getTotalEstimatedOverheadExpenses

      public Money getTotalEstimatedOverheadExpenses(Campaign c)
      Parameters:
      c - campaign loaded
      Returns:
      the cumulative sum of estimated overhead expenses for the duration of travel + deployment
    • getTotalEstimatedMaintenanceExpenses

      public Money getTotalEstimatedMaintenanceExpenses(Campaign c)
      Parameters:
      c - campaign loaded
      Returns:
      the cumulative sum of estimated maintenance expenses for the duration of travel + deployment
    • getEstimatedPayrollExpenses

      public Money getEstimatedPayrollExpenses(Campaign c)
      Parameters:
      c - campaign loaded
      Returns:
      the estimated payroll expenses for one month
    • getTotalEstimatedPayrollExpenses

      public Money getTotalEstimatedPayrollExpenses(Campaign c)
      Parameters:
      c - campaign loaded
      Returns:
      the cumulative sum of estimated payroll expenses for the duration of travel + deployment
    • getTotalTransportationFees

      public Money getTotalTransportationFees(Campaign c)
      Parameters:
      c - campaign loaded
      Returns:
      the total (2-way) estimated transportation fee from the player's current location to this contract's planet
    • getEstimatedTotalProfit

      public Money getEstimatedTotalProfit(Campaign c)
      Get the estimated total profit for this contract. The total profit is the total contract payment including fees and bonuses, minus overhead, maintenance, payroll, spare parts, and other monthly expenses. The duration used for monthly expenses is the contract duration plus the travel time from the unit's current world to the contract world and back.
      Parameters:
      c - The campaign with which this contract is associated.
      Returns:
      The estimated profit in the current default currency.
    • getMonthsLeft

      public int getMonthsLeft(LocalDate date)
      Get the number of months left in this contract after the given date. Partial months are counted as full months.
      Parameters:
      date - the date to use in the calculation
      Returns:
      the number of months left
    • acceptContract

      public void acceptContract(Campaign campaign)
      Calculations to be performed once the contract has been accepted.
    • calculateContract

      public void calculateContract(Campaign campaign)
      Only do this at the time the contract is set up, otherwise amounts may change after the ink is signed, which is a no-no.
      Parameters:
      campaign - current campaign
    • getSharesPercent

      public int getSharesPercent()
      Retrieves the percentage of shares for this contract. This currently returns a default value of 30.
      Returns:
      the percentage of shares
    • writeToXMLBegin

      protected int writeToXMLBegin(Campaign campaign, PrintWriter pw, int indent)
      Overrides:
      writeToXMLBegin in class Mission
    • loadFieldsFromXmlNode

      public void loadFieldsFromXmlNode(Campaign campaign, megamek.Version version, Node wn) throws ParseException
      Overrides:
      loadFieldsFromXmlNode in class Mission
      Throws:
      ParseException