java.lang.Object
mekhq.campaign.personnel.turnoverAndRetention.Fatigue

public class Fatigue extends Object
The 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 Details

    • Fatigue

      public Fatigue()
  • Method Details

    • checkFieldKitchenCapacity

      public static int checkFieldKitchenCapacity(List<Unit> units, int fieldKitchenCapacity)
      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_KITCHEN flag 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 isUseFieldKitchenIgnoreNonCombatants parameter.

      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:
      true if the available capacity is sufficient; false otherwise.
    • processFatigueActions

      public static void processFatigueActions(Campaign campaign, Person person)
      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 ON_LEAVE.

      Parameters:
      campaign - the campaign context in which the person operates.
      person - the person whose fatigue actions are being processed.
    • getEffectiveFatigue

      public static int getEffectiveFatigue(int fatigue, boolean isClan, megamek.common.enums.SkillLevel skillLevel, boolean areFieldKitchensWithinCapacity)
      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.
      isClan - flag indicating whether the person is Clan personnel.
      skillLevel - the person's skill level.
      areFieldKitchensWithinCapacity - flag indicating if field kitchens are within capacity.
      Returns:
      the calculated effective fatigue value.
    • processFatigueRecovery

      public static void processFatigueRecovery(Campaign campaign, Person person)
      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 ACTIVE if 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.