Class FactionStandingUtilities

java.lang.Object
mekhq.campaign.universe.factionStanding.FactionStandingUtilities

public class FactionStandingUtilities extends Object
  • Field Details

  • Constructor Details

    • FactionStandingUtilities

      public FactionStandingUtilities()
  • Method Details

    • calculateFactionStandingLevel

      public static FactionStandingLevel calculateFactionStandingLevel(double regard)
      Determines the FactionStandingLevel corresponding to the given regard value.

      Iterates through all defined standing levels and returns the one whose regard range (inclusive of the minimum and maximum regard) contains the provided regard value.

      If the regard value does not fall within any defined standing level range, this method logs a warning and returns FactionStandingLevel.STANDING_LEVEL_4 as a default.

      Parameters:
      regard - the regard value to evaluate
      Returns:
      the matching FactionStandingLevel for the given regard, or STANDING_LEVEL_4 if no match is found
      Since:
      0.50.07
    • getStandingLevel

      public static int getStandingLevel(double regard)
      Retrieves the current standing level based on the provided regard value.
      Parameters:
      regard - the regard value used to evaluate the faction standing level
      Returns:
      the corresponding standing level as an integer
      Since:
      0.50.07
      See Also:
    • getNegotiationModifier

      public static int getNegotiationModifier(double regard)
      Retrieves the negotiation modifier associated with the provided regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the negotiation modifier
      Since:
      0.50.07
      See Also:
    • getResupplyWeightModifier

      public static double getResupplyWeightModifier(double regard)
      Returns the resupply weight modifier for the specified regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the resupply weight modifier as a double
      Since:
      0.50.07
      See Also:
    • hasCommandCircuitAccess

      public static boolean hasCommandCircuitAccess(double regard)
      Determines if the command circuit access is available at the given regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      true if command circuit access is granted; false otherwise
      Since:
      0.50.07
      See Also:
    • isOutlawed

      public static boolean isOutlawed(double regard)
      Checks whether the specified regard value results in outlawed status.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      true if outlawed; false otherwise
      Since:
      0.50.07
      See Also:
    • isBatchallAllowed

      public static boolean isBatchallAllowed(double regard)
      Checks if Batchalls are allowed for the provided regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      true if Batchall is allowed; false otherwise
      Since:
      0.50.07
      See Also:
    • getRecruitmentTickets

      public static int getRecruitmentTickets(double regard)
      Returns the number of recruitment tickets granted for the given regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the number of recruitment tickets
      Since:
      0.50.07
      See Also:
    • getRecruitmentRollsModifier

      public static int getRecruitmentRollsModifier(double regard)
      Returns the recruitment rolls modifier based on the specified regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the recruitment rolls modifier
      Since:
      0.50.07
      See Also:
    • getBarrackCostsMultiplier

      public static double getBarrackCostsMultiplier(double regard)
      Retrieves the barrack costs multiplier for the specified regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the barrack costs multiplier as a double
      Since:
      0.50.07
      See Also:
    • getUnitMarketRarityModifier

      public static int getUnitMarketRarityModifier(double regard)
      Returns the unit market rarity modifier for the given regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the unit market rarity modifier
      Since:
      0.50.07
      See Also:
    • getContractPayMultiplier

      public static double getContractPayMultiplier(double regard)
      Retrieves the contract pay multiplier corresponding to the specified regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the contract pay multiplier as a double
      Since:
      0.50.07
      See Also:
    • getSupportPointModifierContractStart

      public static int getSupportPointModifierContractStart(double regard)
      Returns the support point modifier applied at the start of a contract for the given regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the support point modifier for contract start
      Since:
      0.50.07
      See Also:
    • getSupportPointModifierPeriodic

      public static int getSupportPointModifierPeriodic(double regard)
      Returns the periodic support point modifier for the specified regard value.
      Parameters:
      regard - the regard value to evaluate
      Returns:
      the periodic support point modifier
      Since:
      0.50.07
      See Also:
    • isUseCommandCircuit

      public static boolean isUseCommandCircuit(boolean overridingCommandCircuitRequirements, boolean isGM, boolean useFactionStandingCommandCircuit, FactionStandings factionStandings, List<AtBContract> activeContracts)
      Determines whether command circuit access should be granted based on campaign settings, GM mode, current faction standings, and a list of active contracts.

      Access is immediately granted if both command circuit requirements are overridden and GM mode is active. If not, and if faction standing is used as a criterion, the method evaluates the player's highest faction regard across all active contracts, granting access if this level meets the threshold.

      If there are no active contracts, access is denied.

      Parameters:
      overridingCommandCircuitRequirements - true if command circuit requirements are overridden
      isGM - true if GM mode is enabled
      useFactionStandingCommandCircuit - true if faction standing is used to determine access
      factionStandings - player faction standing data
      activeContracts - list of currently active contracts to evaluate for access
      Returns:
      true if command circuit access should be used; false otherwise
      Since:
      0.50.07
    • canEnterTargetSystem

      public static boolean canEnterTargetSystem(Faction campaignFaction, FactionStandings factionStandings, @Nullable PlanetarySystem currentSystem, PlanetarySystem targetSystem, LocalDate when, List<AtBContract> activeAtBContracts, FactionHints factionHints)
      Determines whether a campaign force is allowed to enter the specified target planetary system, based on population, ownership, outlaw status, contract relationships, and state of war.

      The rules for entry are as follows:

      1. If the target system is empty (population zero), entry is always permitted.
      2. If the target system is owned by any faction that is either an employer or a contract target, entry is allowed.
      3. If the player is outlawed in their current system, they may always exit to another system (unless currentSystem is null).
      4. If the player is outlawed in the target system, entry is denied.
      5. If the campaign faction is at war with all system factions, entry is denied.
      6. If none of the above conditions block entry, it is permitted.
      Parameters:
      campaignFaction - the campaign's primary faction
      factionStandings - the standings of the campaign with all factions
      currentSystem - the planetary system currently occupied
      targetSystem - the planetary system to test entry for
      when - the date of attempted entry (population/ownership may change over time)
      activeAtBContracts - list of currently active contracts
      factionHints - the details of the current factional relations
      Returns:
      true if entry to the target system is allowed; false otherwise
      Since:
      0.50.07
    • isIsOnMission

      public static boolean isIsOnMission(boolean isOnPlanet, List<AtBContract> activeAtBContracts, List<Mission> activeMissions, String factionCode, PlanetarySystem currentSystem, boolean ignoreEmployer)
      Checks whether the campaign is presently undertaking a mission for the specified faction.

      This method verifies all the following conditions to determine mission status:

      • The campaign must currently be located on a planet.
      • There must be at least one active AtB (Against the Bot) contract.
      • At least one such AtB contract must have both an employer code matching the specified faction and a system matching the current location.
      • Alternatively, the presence of any active mission also qualifies as being on a mission for the faction. This is to ensure compatibility with non-AtB campaigns.

      Returns true if these checks indicate the campaign is actively on a mission or contract corresponding to the specified faction.

      Parameters:
      isOnPlanet - whether the campaign is currently on a planet
      activeAtBContracts - list of all currently active AtB contracts
      activeMissions - list of all currently active missions
      factionCode - the code identifying the relevant faction
      currentSystem - the planetary system in which the campaign is currently located
      ignoreEmployer - whether the contract employer faction should be ignored
      Returns:
      true if the campaign is on a qualifying mission for the given faction; false otherwise
      Since:
      0.50.07
    • getFactionName

      public static String getFactionName(Faction faction, int gameYear)
      Returns the formatted full name of a Faction for the specified game year.

      If the faction's name starts with the localized "clan" prefix, the method returns the full name as-is. Otherwise, the localized "the" article is prefixed to the base name. This helps ensure proper grammatical usage for varying factions based on localization and faction naming conventions.

      Parameters:
      faction - the Faction whose name should be formatted
      gameYear - the year for which the faction's full name is relevant
      Returns:
      the formatted faction name, including the appropriate localized prefix if necessary
      Since:
      0.50.07
    • getCharacterFullName

      public static String getCharacterFullName(Person person)
      Constructs and returns the full display name for a given person.

      The name is assembled in the following order: if present: rank title, given name, bloodname (if available), or surname (if bloodname is not present). This attempts to produce a canonical or ceremonial name as used in settings with titles and bloodnames.

      Parameters:
      person - the Person whose full name should be generated
      Returns:
      the assembled full display name as a String
      Since:
      0.50.07
    • getInCharacterText

      public static String getInCharacterText(@Nullable String resourceBundle, String resourceBundleAddress, @Nullable Person commander, @Nullable Person secondCharacter, String factionName, String campaignName, String locationName, @Nullable Integer cashValue, String commanderAddress)
      Generates a localized, in-character narrative text for a faction standing event, dynamically incorporating identity and pronoun information for one or two characters, as well as campaign and faction context.

      This method prepares a set of arguments including hyperlinked titles, given names, context-aware pronouns (subject, object, possessive), and additional identifiers for the commander and (optionally) a secondary individual. It also includes campaign-specific details like the campaign and faction name. The arguments are formatted into a resource bundle string for display within campaign dialogs.

      Parameters:
      resourceBundle - the resource bundle address for localization
      resourceBundleAddress - the resource bundle reference key
      commander - the main commander or subject of the censure event; may be null if no commander is cited in the dialog.
      secondCharacter - optional secondary character affected by the event; may be null if there isn't a second character in the scene.
      factionName - the name of any relevant faction
      campaignName - the name of the current campaign
      locationName - the name of the relevant system or planet; may be null if there isn't any locational information in the scene.
      Returns:
      a formatted narrative String populated with character and context
      Since:
      0.50.07
    • getFallbackFactionKey

      public static String getFallbackFactionKey(String dialogKey, Faction judgingFaction)
      Generates a fallback dialog key by replacing the judging faction's code in the original dialog key with a suitable default affix, based on the general type of the judging faction.

      If the judging faction is a Clan, Periphery, or Inner Sphere, the corresponding constant affix is substituted. This is useful for providing default or generic dialog text when no faction-specific version is available.

      Parameters:
      dialogKey - the original dialog key, typically with a faction code suffix
      judgingFaction - the Faction being used to determine the fallback key
      Returns:
      a fallback dialog key string with the appropriate affix for the faction type
      Since:
      0.50.07