Class StratConFacility

java.lang.Object
mekhq.campaign.digitalGM.stratCon.facility.StratConFacility

public class StratConFacility extends Object
A facility placed on a StratCon sector. It refers to its StratConFacilityDefinition by ID and keeps only its own state: who holds it, its tier, condition and garrison, how much the player knows about it, whether it has lent its modifiers this week, whether it is a strategic objective, and any scenario modifiers added when it was placed. What it does comes from the definition's profile for its current owner, so capturing it is just a change of owner.

Saves from before 0.51.01 held a full copy of the facility's old-format definition instead of an ID. Those fields are still read, and resolveLegacyData() turns them into a definition ID once loading is done.

  • Constructor Details

    • StratConFacility

      public StratConFacility()
      For loading from saves only.
    • StratConFacility

      public StratConFacility(StratConFacilityDefinition definition, ScenarioForceTemplate.ForceAlignment owner)
      Creates a facility of the given type, held by the given side.
      Parameters:
      definition - the facility's type
      owner - the side that holds it
      Since:
      0.51.01
  • Method Details

    • getDefinitionId

      public String getDefinitionId()
      Returns:
      the ID of the facility's definition
      Since:
      0.51.01
    • getDefinition

      public StratConFacilityDefinition getDefinition()
      Returns:
      the facility's definition. If no loaded definition has its ID, an empty placeholder named after the ID, so a facility whose data has gone missing does nothing rather than breaking the sector.
      Since:
      0.51.01
    • isDefinitionMissing

      public boolean isDefinitionMissing()
      Returns:
      true if no loaded definition has the facility's ID, so it stands on a placeholder. Its type is only a stand-in for drawing it: it is no source of supply and no synergy partner.
      Since:
      0.51.01
    • getProfile

      public StratConFacilityProfile getProfile()
      Returns:
      the profile that applies while the facility's current owner holds it
      Since:
      0.51.01
    • getOwner

    • setOwner

      public void setOwner(ScenarioForceTemplate.ForceAlignment owner)
    • isPlayerBuilt

      public boolean isPlayerBuilt()
      Returns:
      true if the player's side raised this facility with a Build order and still holds it. Such a facility costs upkeep each month and makes the next Build dearer.
      Since:
      0.51.01
    • setPlayerBuilt

      public void setPlayerBuilt(boolean playerBuilt)
    • getTraits

      public List<FacilityTrait> getTraits()
      Returns:
      the facility's traits, in the order they were given; the list itself, so callers may change it
      Since:
      0.51.01
    • hasTrait

      public boolean hasTrait(FacilityTrait trait)
      Parameters:
      trait - a trait
      Returns:
      true if the facility has it
      Since:
      0.51.01
    • addTrait

      public void addTrait(FacilityTrait trait)
      Gives the facility a trait, unless it already has it. A conflicting trait it has is replaced.
      Parameters:
      trait - the trait to give
      Since:
      0.51.01
    • removeTrait

      public void removeTrait(FacilityTrait trait)
      Takes a trait away from the facility, if it has it.
      Parameters:
      trait - the trait to remove
      Since:
      0.51.01
    • isReadyToSurrender

      public boolean isReadyToSurrender()
      Returns:
      true if the facility's garrison is low enough that it surrenders to a siege: none left, or one step left for a garrison with poor morale
      Since:
      0.51.01
    • isNetworked

      public boolean isNetworked()
      Returns:
      true if the facility has been linked to its holder's supply lines since it last changed sides. Only such a facility can be cut off; one that was never on them supplies itself.
      Since:
      0.51.01
    • setNetworked

      public void setNetworked(boolean networked)
    • isOwnerAlliedToPlayer

      public boolean isOwnerAlliedToPlayer()
      Returns:
      true if the facility owner is either allied to the player or is the player themselves, false otherwise.
    • getFormattedDisplayableName

      public String getFormattedDisplayableName()
    • getDisplayableName

      public String getDisplayableName()
    • getFacilityType

      public StratConFacility.FacilityType getFacilityType()
    • getUserDescription

      @Nullable public String getUserDescription()
      Returns:
      what the facility does while its current owner holds it, or null if the profile has no description
    • getTier

      Returns:
      the facility's tier; StratConFacility.FacilityTier.BASE for one saved before tiers existed
      Since:
      0.51.01
    • setTier

      public void setTier(StratConFacility.FacilityTier tier)
      Sets the facility's tier, trimming its garrison to the new tier's maximum.
      Parameters:
      tier - the new tier
      Since:
      0.51.01
    • getCondition

      public StratConFacility.FacilityCondition getCondition()
      Returns:
      the facility's condition; StratConFacility.FacilityCondition.INTACT for one saved before conditions existed
      Since:
      0.51.01
    • setCondition

      public void setCondition(StratConFacility.FacilityCondition condition)
    • getGarrison

      public int getGarrison()
      Returns:
      the facility's garrison, in steps from 0 to its tier's maximum; a full garrison for one saved before garrisons existed
      Since:
      0.51.01
    • setGarrison

      public void setGarrison(int garrison)
      Sets the facility's garrison, kept between 0 and its tier's maximum.
      Parameters:
      garrison - the new garrison, in steps
      Since:
      0.51.01
    • getGarrisonMaximum

      public int getGarrisonMaximum()
      Returns:
      the most garrison steps the facility can hold: its tier's maximum, one fewer if it is undermanned
      Since:
      0.51.01
    • getIntel

      public StratConFacility.FacilityIntel getIntel()
      Returns:
      how much the player knows about the facility. Everything, if the player's side holds it.
      Since:
      0.51.01
    • setIntel

      public void setIntel(StratConFacility.FacilityIntel intel)
      Sets how much the player knows about the facility, whether more or less than before.
      Parameters:
      intel - the new intel level
      Since:
      0.51.01
    • raiseIntel

      public void raiseIntel(StratConFacility.FacilityIntel level)
      Raises how much the player knows about the facility to at least the given level. Never lowers it.
      Parameters:
      level - the level the player now has at least
      Since:
      0.51.01
    • getVisible

      public boolean getVisible()
      Returns:
      true if the player knows at least where the facility is
    • setVisible

      public void setVisible(boolean visible)
      Shorthand for the two intel changes most callers need: true raises intel to at least StratConFacility.FacilityIntel.SCOUTED, as scouting the hex does; false hides the facility entirely.
      Parameters:
      visible - whether the player has seen the facility
    • isVisible

      public boolean isVisible()
    • getIsAvailable

      public boolean getIsAvailable()
    • setIsAvailable

      public void setIsAvailable(boolean isAvailable)
    • isAvailable

      public boolean isAvailable()
    • getSharedModifiers

      public List<String> getSharedModifiers()
      This is a list of scenario modifier IDs that affect scenarios in the same track as this facility. A damaged or crippled facility lends none.
    • getLocalModifiers

      public List<String> getLocalModifiers()
      This is a list of scenario modifier IDs that affect scenarios involving this facility directly: its garrison's, then any added when the facility was placed.

      The garrison follows a ladder. With none left, the facility has no defenders of its own. At one step it has the current profile's local modifiers; each step above that adds the next garrison modifier for the holding side that the profile doesn't already have.

    • getAdditionalLocalModifiers

      public List<String> getAdditionalLocalModifiers()
      Returns:
      the scenario modifier IDs added to this facility alone when it was placed, such as those of the objective it serves
      Since:
      0.51.01
    • addAdditionalLocalModifiers

      public void addAdditionalLocalModifiers(List<String> modifiers)
      Adds scenario modifiers to this facility alone, on top of its profile's local modifiers.
      Parameters:
      modifiers - the scenario modifier IDs to add
      Since:
      0.51.01
    • isStrategicObjective

      public boolean isStrategicObjective()
    • setStrategicObjective

      public void setStrategicObjective(boolean isStrategicObjective)
    • getBiomes

      public List<StratConBiome> getBiomes()
    • getBiomeTempMap

      public TreeMap<Integer,StratConBiome> getBiomeTempMap()
      Returns the biome temperature map (note: temperature mapping is in kelvins but stored in Celsius)
    • incrementOwnershipChangeScore

      public void incrementOwnershipChangeScore()
    • decrementOwnershipChangeScore

      public void decrementOwnershipChangeScore()
    • getOwnershipChangeScore

      public int getOwnershipChangeScore()
    • clearOwnershipChangeScore

      public void clearOwnershipChangeScore()
      Resets the ownership change score once a scenario's outcome has been settled, so it cannot carry over into the next scenario fought on this facility.
      Since:
      0.51.01
    • isRevealingTrack

      public boolean isRevealingTrack()
      Returns:
      whether the facility reveals its whole sector while its current owner holds it; never while crippled
    • getScanRangeIncrease

      public int getScanRangeIncrease()
      Returns:
      hexes the facility adds to the scan range of forces scouting its sector while its current owner holds it, adjusted for its condition
    • getScenarioOddsModifier

      public int getScenarioOddsModifier()
      Returns:
      the facility's change to its sector's scenario odds, adjusted for its condition
    • getMonthlySupportPoints

      public int getMonthlySupportPoints()
      Returns:
      the facility's monthly Employer Support change while its current owner holds it, with any extra from a well-stocked facility your side holds, adjusted for its condition
    • isPreventingAerospace

      public boolean isPreventingAerospace()
      Returns:
      whether the facility keeps air and space scenarios out of its sector; never while crippled
    • applyAttackerVictory

      public void applyAttackerVictory()
      Worsens the facility after a fight on it that its holder lost: its condition drops one step, unless it is hardened, and its garrison loses one step.
      Since:
      0.51.01
    • applyDefenderHeld

      public void applyDefenderHeld()
      Costs the facility one garrison step after a fight on it that its holder did not lose.
      Since:
      0.51.01
    • resolveLegacyData

      public void resolveLegacyData()
      Turns the old-format definition copy held by a facility from a save written before 0.51.01 into a definition ID. The facility is matched to the loaded definition of the same StratConFacility.FacilityType; any local modifiers beyond that definition's own are kept as the facility's additional ones. A facility that matches no loaded definition keeps its old data as a detached definition, so it still behaves as it did.

      Saves from before 0.51.01 also held a plain visibility flag, which becomes an intel level: seen facilities count as StratConFacility.FacilityIntel.SCOUTED. Tier, condition and garrison take their defaults for such facilities (a full StratConFacility.FacilityTier.BASE).

      Matching does nothing for a facility that already has a definition ID.

      Since:
      0.51.01