Class Fatigue
Fatigue class provides utility methods for managing and processing fatigue-related mechanics in the
campaign. This includes calculating effective fatigue, processing daily and weekly fatigue recovery, handling field
kitchen requirements, and generating related reports.
Fatigue is a system that affects personnel as part of campaign management. This class ensures consistent handling of fatigue calculations, recovery, and statuses based on campaign settings and personnel conditions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareFieldKitchensWithinCapacity(int fieldKitchenCapacity, int fieldKitchenUsage) Checks if the available field kitchen capacity is sufficient to meet the requirements.static intcheckFieldKitchenCapacity(List<Unit> units, int fieldKitchenCapacity) Calculates the total field kitchen capacity for a given list of units.static intcheckFieldKitchenUsage(List<Person> activePersonnel, boolean isUseFieldKitchenIgnoreNonCombatants) Calculates the number of personnel who require field kitchen support.static intgetEffectiveFatigue(int fatigue, int permanentFatigueLoss, boolean isClan, megamek.common.enums.SkillLevel skillLevel) Calculates the effective fatigue level for a given person based on various modifiers.static voidprocessDeploymentFatigueResponses(Campaign campaign) Processes all combat teams in the campaign to evaluate deployment fatigue responses.static voidprocessFatigueActions(Campaign campaign, Person person) Processes fatigue-related actions for a given person in the campaign.static voidprocessFatigueRecovery(Campaign campaign, Person person) Deprecated, for removal: This API element is subject to removal in a future version.static voidprocessFatigueRecovery(Campaign campaign, Person person, boolean fieldKitchensAreWithinCapacity) Handles daily fatigue recovery for a specific person in the campaign.
-
Constructor Details
-
Fatigue
public Fatigue()
-
-
Method Details
-
checkFieldKitchenCapacity
Calculates the total field kitchen capacity for a given list of units.Deployed, damaged, uncrewed, or partially crewed units are excluded from the calculation. Each remaining unit contributes to the overall capacity based on the presence of the
MiscType.F_FIELD_KITCHENflag in its equipment.- Parameters:
units- the list of units to evaluate for field kitchen capacity.fieldKitchenCapacity- the capacity provided by each field kitchen.- Returns:
- the total field kitchen capacity available from all eligible units.
-
checkFieldKitchenUsage
public static int checkFieldKitchenUsage(List<Person> activePersonnel, boolean isUseFieldKitchenIgnoreNonCombatants) Calculates the number of personnel who require field kitchen support.Personnel assigned to units with sufficient onboard field kitchen facilities (e.g., small or large craft units) are excluded. Non-combatant personnel may also be excluded based on the
isUseFieldKitchenIgnoreNonCombatantsparameter.- Parameters:
activePersonnel- the list of active personnel to evaluate.isUseFieldKitchenIgnoreNonCombatants- flag to exclude non-combatants from the total.- Returns:
- the total number of personnel requiring field kitchen support.
-
areFieldKitchensWithinCapacity
public static boolean areFieldKitchensWithinCapacity(int fieldKitchenCapacity, int fieldKitchenUsage) Checks if the available field kitchen capacity is sufficient to meet the requirements.- Parameters:
fieldKitchenCapacity- the total available field kitchen capacity.fieldKitchenUsage- the total field kitchen usage based on personnel requirements.- Returns:
trueif the available capacity is sufficient;falseotherwise.
-
processFatigueActions
Processes fatigue-related actions for a given person in the campaign.This method calculates the effective fatigue of the person, determines their fatigue state (e.g., tired, fatigued, exhausted, critical), generates reports based on their fatigue level, and updates their recovery status. If the fatigue exceeds the campaign's leave threshold, the person's status is updated to
PersonnelStatus.ON_LEAVE.- Parameters:
campaign- the campaign context in which the person operates.person- the person whose fatigue actions are being processed.
-
processDeploymentFatigueResponses
Processes all combat teams in the campaign to evaluate deployment fatigue responses.For each combat team, this method checks whether the fatigue and deployment rules are enabled in the campaign options. If enabled, it iterates through each unit and crew member of the team's force, calculating effective fatigue. If a unit's crew contains at least one individual with effective fatigue above the undeployment threshold, that unit is counted as fatigued.
If at least half of the units in a force are fatigued above the threshold, a formatted warning message is created to indicate that the force has reached critical fatigue levels.
- Parameters:
campaign- the campaign containing the combat teams, options, and units to be checked- Since:
- 0.50.10
-
getEffectiveFatigue
public static int getEffectiveFatigue(int fatigue, int permanentFatigueLoss, boolean isClan, megamek.common.enums.SkillLevel skillLevel) Calculates the effective fatigue level for a given person based on various modifiers.The base fatigue level is adjusted by factors such as:
- Whether the person is classified as Clan personnel.
- The person's skill level, with higher-skilled personnel suffering less fatigue.
- Whether field kitchens are operating within their required capacity.
- Parameters:
fatigue- the base fatigue level of the person.permanentFatigueLoss- how many points of fatigue have been permanently applied to the character (usually from an EI Implant)isClan- flag indicating whether the person is Clan personnel.skillLevel- the person's skill level.- Returns:
- the calculated effective fatigue value.
-
processFatigueRecovery
@Deprecated(since="0.50.07", forRemoval=true) public static void processFatigueRecovery(Campaign campaign, Person person) Deprecated, for removal: This API element is subject to removal in a future version. -
processFatigueRecovery
public static void processFatigueRecovery(Campaign campaign, Person person, boolean fieldKitchensAreWithinCapacity) Handles daily fatigue recovery for a specific person in the campaign.If the person has fatigue, their fatigue is reduced based on a standard recovery rate, with additional adjustments if they are on leave or if the campaign has no active contracts. If fatigue becomes zero or less, the person's recovery state is cleared, and their status may be updated to
ACTIVEif they were previously on leave.- Parameters:
campaign- the campaign context in which the fatigue recovery occurs.person- the person whose fatigue recovery is being handled.fieldKitchensAreWithinCapacity- flag indicating if field kitchens are within capacity.
-