Class ContractSupportPayments

java.lang.Object
mekhq.campaign.mission.contract.contractSpecialRules.ContractSupportPayments

public final class ContractSupportPayments extends Object
Renders the ongoing support an employer owes the player during a contract: the straight-support share of repair, overhead, and food and housing costs, and battle loss compensation for units lost beyond repair. Straight support does not cover maintenance (Hot Spots: Draconis Reach pg 27).

Both are paid as they are earned for an ordinary contract. Under the #NO_IN_CONTRACT_SUPPORT special rule they are instead withheld onto the contract (see AbstractContract.changeWithheldSupportPayments(Money)) and settled as a single lump sum when the contract ends through renderWithheldSupport(Campaign, AbstractContract).

Straight support is a per-contract term but the costs it covers are campaign-wide, so the share is drawn from the active contract offering the most generous support (see getStraightSupportContract(Campaign)). Battle loss compensation, by contrast, is settled against the specific contract whose scenario cost the unit.

Both payouts are doubled for a contract carrying the ChaosObjectiveSpecialRules.DOUBLE_SUPPORT_PAYOUTS special rule. The doubling is applied before the withhold check, so a contract that also carries ChaosObjectiveSpecialRules.NO_IN_CONTRACT_SUPPORT withholds - and later pays out - the already-doubled amount. The straight-support share of overhead and food and housing is capped at the whole cost, so those monthly charges can be refunded in full but never turn a profit.

Since:
0.51.01
  • Method Details

    • reimburseStraightSupport

      public static void reimburseStraightSupport(Campaign campaign, Money cost, String costDescription)
      Reimburses the straight-support share of a repair cost the player has just paid.

      The share is cost * the support multiplier of the active contract offering the most generous straight support, doubled when that contract carries ChaosObjectiveSpecialRules.DOUBLE_SUPPORT_PAYOUTS. When the contract carries the ChaosObjectiveSpecialRules.NO_IN_CONTRACT_SUPPORT special rule the share is withheld until the contract ends; otherwise it is credited immediately. Does nothing when the cost is not positive, no contract is active, or the support multiplier is zero.

      Parameters:
      campaign - the active campaign
      cost - the cost the player paid, whose support share is reimbursed
      costDescription - a short description of the cost, used in the ledger note (e.g. the repaired part or unit)
      Since:
      0.51.01
    • reimburseMonthlyStraightSupport

      public static void reimburseMonthlyStraightSupport(Campaign campaign, Money cost, String costDescription)
      Reimburses the straight-support share of a monthly overhead or food and housing charge the player has just paid, reporting the reimbursement when it is credited.

      The share is worked out as for reimburseStraightSupport(Campaign, Money, String), but capped at the whole cost (see getMonthlyStraightSupportShare(AbstractContract)).

      Parameters:
      campaign - the active campaign
      cost - the cost the player paid, whose support share is reimbursed
      costDescription - a short, lower-case description of the cost, used in the ledger note and report (e.g. "overhead costs")
      Since:
      0.51.01
    • payBattlefieldLoss

      public static void payBattlefieldLoss(Campaign campaign, AbstractContract contract, Money amount, String unitName)
      Settles battle loss compensation for a unit lost beyond repair, either crediting it immediately or, under the ChaosObjectiveSpecialRules.NO_IN_CONTRACT_SUPPORT special rule, withholding it until the contract ends.

      The amount is doubled when the contract carries ChaosObjectiveSpecialRules.DOUBLE_SUPPORT_PAYOUTS. Does nothing when the resulting amount is not positive.

      Parameters:
      campaign - the active campaign
      contract - the contract whose scenario cost the unit
      amount - the battle loss compensation owed, before the DOUBLE_SUPPORT_PAYOUTS rule is applied
      unitName - the name of the lost unit, used in the ledger note and report
      Since:
      0.51.01
    • renderWithheldSupport

      public static void renderWithheldSupport(Campaign campaign, AbstractContract contract)
      Pays out, in a single lump sum, all support withheld on the contract under the ChaosObjectiveSpecialRules.NO_IN_CONTRACT_SUPPORT special rule, then clears the withheld total.

      Does nothing when nothing has been withheld, so it is safe to call for every completed contract.

      Parameters:
      campaign - the active campaign
      contract - the contract being completed
      Since:
      0.51.01
    • getStraightSupportContract

      @Nullable public static AbstractContract getStraightSupportContract(Campaign campaign)
      Parameters:
      campaign - the active campaign
      Returns:
      the active contract offering the highest straight-support multiplier, or null when no contract is active
      Since:
      0.51.01
    • getStraightSupportShare

      public static double getStraightSupportShare(AbstractContract contract)
      The fraction of a covered cost the contract reimburses through straight support: its support multiplier, doubled when it carries ChaosObjectiveSpecialRules.DOUBLE_SUPPORT_PAYOUTS. This uncapped share applies to repairs; overhead and food and housing use getMonthlyStraightSupportShare(AbstractContract).
      Parameters:
      contract - the contract offering straight support
      Returns:
      the reimbursed fraction of each cost; zero or less when the contract offers no straight support
      Since:
      0.51.01
    • getMonthlyStraightSupportShare

      public static double getMonthlyStraightSupportShare(AbstractContract contract)
      The fraction of a monthly overhead or food and housing charge the contract reimburses through straight support: the straight-support share, capped at the whole charge so the refund never exceeds what was paid.
      Parameters:
      contract - the contract offering straight support
      Returns:
      the reimbursed fraction of each monthly charge, at most 1.0; zero or less when the contract offers no straight support
      Since:
      0.51.01