Class ContractUtilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalculateBaseNumberOfRequiredLances(Campaign campaign, boolean bypassVariance, double varianceFactor) Calculates the number of lances used for this contract, based on [campaign].static intCalculates the number of units required for this contract, based on [campaign].static intgetEffectiveNumUnits(Campaign campaign) Calculates the effective number of units available in the given campaign based on unit types and roles.static StringgetEnemyDisplayNameIncludingFaction(Faction enemyFaction, String enemyDisplayName, int gameYear) static JumpPathgetJumpPath(Campaign campaign, AbstractContract abstractContract, AbstractLocation currentLocation) static intgetTravelDays(Campaign campaign, LocalDate currentDate, AbstractContract abstractContract, AbstractLocation currentLocation, boolean isOverridingCommandCircuitRequirements, boolean isGM, FactionStandings factionStandings) Estimates, in whole days, how long the force atcurrentLocationneeds to reach the contract's target world, caching the jump path on the contract asgetJumpPath(mekhq.campaign.Campaign, mekhq.campaign.mission.contract.AbstractContract, mekhq.campaign.AbstractLocation)does.static intgetTravelDays(Campaign campaign, AbstractContract abstractContract, AbstractLocation currentLocation, boolean isOverridingCommandCircuitRequirements, FactionStandings factionStandings) static booleanhasArrivedAtContractLocation(AbstractLocation location, AbstractContract contract) Whether a force atlocationhas arrived at wherecontractis fought.
-
Constructor Details
-
ContractUtilities
public ContractUtilities()
-
-
Method Details
-
calculateBaseNumberOfRequiredLances
public static int calculateBaseNumberOfRequiredLances(Campaign campaign, boolean bypassVariance, double varianceFactor) Calculates the number of lances used for this contract, based on [campaign].- Parameters:
campaign- The campaign to reference.bypassVariance- a flag indicating whether variance adjustments should be bypassedvarianceFactor- the degree of variance to apply to required combat elements- Returns:
- The number of lances required.
-
calculateBaseNumberOfUnitsRequiredInCombatTeams
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
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
-
hasArrivedAtContractLocation
public static boolean hasArrivedAtContractLocation(AbstractLocation location, AbstractContract contract) Whether a force atlocationhas arrived at wherecontractis fought.Arrival is judged on the system first, since that is what the location model has always tracked, and then on the world - but only when both worlds are known. A location from a save predating planet tracking knows only its system, and
AbstractLocation.getPlanet()would report the system's primary world; comparing that against a contract targeting some other world would say "not arrived" forever.- Parameters:
location- the force's locationcontract- the contract whose target is being tested against- Returns:
truewhen the force is in the contract's target system, out of transit, and - where known - at its target world
-
getTravelDays
public static int getTravelDays(Campaign campaign, AbstractContract abstractContract, AbstractLocation currentLocation, boolean isOverridingCommandCircuitRequirements, FactionStandings factionStandings) -
getTravelDays
public static int getTravelDays(Campaign campaign, LocalDate currentDate, AbstractContract abstractContract, AbstractLocation currentLocation, boolean isOverridingCommandCircuitRequirements, boolean isGM, FactionStandings factionStandings) Estimates, in whole days, how long the force atcurrentLocationneeds to reach the contract's target world, caching the jump path on the contract asgetJumpPath(mekhq.campaign.Campaign, mekhq.campaign.mission.contract.AbstractContract, mekhq.campaign.AbstractLocation)does.Command Circuit access is judged exactly as it is for the journey itself: by the regard of the faction whose standing the contract answers to (
AbstractContract.getStandingEmployerFactionCode()), and only when the campaign uses Faction Standing for Command Circuits. Otherwise a contract's start date and the fleet's actual arrival would disagree.- Parameters:
campaign- the campaigncurrentDate- the date the journey startsabstractContract- the contract being travelled tocurrentLocation- the force's locationisOverridingCommandCircuitRequirements- whether the GM is overriding Command Circuit requirementsisGM- whether GM mode is enabledfactionStandings- the player's faction standings- Returns:
- the travel time in days, rounded up;
0when no route can be measured - Since:
- 0.51.01
-
getJumpPath
@Nullable public static JumpPath getJumpPath(Campaign campaign, AbstractContract abstractContract, AbstractLocation currentLocation) -
getEnemyDisplayNameIncludingFaction
-