Class ContractUtilities

java.lang.Object
mekhq.campaign.mission.utilities.ContractUtilities

public class ContractUtilities extends Object
  • Constructor Details

    • ContractUtilities

      public ContractUtilities()
  • Method Details

    • calculateBaseNumberOfRequiredLances

      public static int calculateBaseNumberOfRequiredLances(Campaign campaign, boolean isCadreDuty, boolean bypassVariance, double varianceFactor)
      Calculates the number of lances used for this contract, based on [campaign].
      Parameters:
      campaign - The campaign to reference.
      isCadreDuty - true if CombatRole.CADRE should be considered a combat role
      bypassVariance - a flag indicating whether variance adjustments should be bypassed
      varianceFactor - the degree of variance to apply to required combat elements
      Returns:
      The number of lances required.
    • calculateBaseNumberOfUnitsRequiredInCombatTeams

      public static int calculateBaseNumberOfUnitsRequiredInCombatTeams(Campaign campaign)
      Calculates the number of units required for this contract, based on [campaign].
      Parameters:
      campaign - The campaign to reference.
      Returns:
      The number of combat units present.
    • getEffectiveNumUnits

      public static int getEffectiveNumUnits(Campaign campaign)
      Calculates the effective number of units available in the given campaign based on unit types and roles.

      This method iterates through all combat teams in the specified campaign, ignoring combat teams with the auxiliary role. For each valid combat team, it retrieves the associated force and evaluates all units within that force. The unit contribution to the total is determined based on its type. See CombatTeam.getSize(Campaign)

      Units that aren’t associated with a valid combat team or can’t be fetched due to missing data are ignored. The final result is returned as an integer by flooring the calculated total.

      Parameters:
      campaign - the campaign containing the combat teams and units to evaluate
      Returns:
      the effective number of units as an integer
    • calculateVarianceFactor

      public static double calculateVarianceFactor()
      Calculates the variance factor based on the given roll value and a fixed formation size divisor.

      The variance factor is determined by applying a multiplier to the fixed formation size divisor. The multiplier varies based on the roll value:

      • Roll 2: Multiplier is 0.575.
      • Roll 3: Multiplier is 0.6.
      • Roll 4: Multiplier is 0.625
      • Roll 5: Multiplier is 0.65.
      • Roll 6: Multiplier is 0.675.
      • Roll 7: Multiplier is 0.7.
      • Roll 8: Multiplier is 0.725.
      • Roll 9: Multiplier is 0.75.
      • Roll 10: Multiplier is 0.775.
      • Roll 11: Multiplier is 0.8.
      • Roll 12: Multiplier is 0.825.
      Returns:
      the calculated variance factor as a double