Class Campaign

java.lang.Object
mekhq.campaign.Campaign
All Implemented Interfaces:
megamek.common.ITechManager

public class Campaign extends Object implements megamek.common.ITechManager
The main campaign class, keeps track of teams and units
  • Field Details

  • Constructor Details

    • Campaign

      public Campaign()
  • Method Details

    • getApp

      public MekHQ getApp()
      Returns:
      the app
    • setApp

      public void setApp(MekHQ app)
      Parameters:
      app - the app to set
    • setOverviewLoadingValue

      public void setOverviewLoadingValue(boolean overviewLoadingValue)
      Parameters:
      overviewLoadingValue - the overviewLoadingValue to set
    • getGame

      public megamek.common.Game getGame()
    • getPlayer

      public megamek.common.Player getPlayer()
    • setId

      public void setId(UUID id)
    • getId

      public UUID getId()
    • setVersion

      public void setVersion(megamek.Version version)
    • getVersion

      @Nullable public megamek.Version getVersion()
    • getName

      public String getName()
    • setName

      public void setName(String s)
    • getEra

      public Era getEra()
    • getTitle

      public String getTitle()
    • getLocalDate

      public LocalDate getLocalDate()
    • setLocalDate

      public void setLocalDate(LocalDate currentDay)
    • getCampaignStartDate

      public LocalDate getCampaignStartDate()
    • setCampaignStartDate

      public void setCampaignStartDate(LocalDate campaignStartDate)
    • getCurrentSystem

      public PlanetarySystem getCurrentSystem()
    • isAvoidingEmptySystems

      public boolean isAvoidingEmptySystems()
    • setIsAvoidingEmptySystems

      public void setIsAvoidingEmptySystems(boolean isAvoidingEmptySystems)
    • isOverridingCommandCircuitRequirements

      public boolean isOverridingCommandCircuitRequirements()
    • setIsOverridingCommandCircuitRequirements

      public void setIsOverridingCommandCircuitRequirements(boolean isOverridingCommandCircuitRequirements)
    • getSystemHiringHallLevel

      public HiringHallLevel getSystemHiringHallLevel()
      Returns the Hiring Hall level from the force's current system on the current date. If there is no hiring hall present, the level is HiringHallLevel.NONE.
      Returns:
      The Hiring Hall level of the current system at the present date.
    • getFunds

      public Money getFunds()
    • setForces

      public void setForces(Force f)
    • getForces

      public Force getForces()
    • getAllForces

      public List<Force> getAllForces()
    • getAllUnitsInTheTOE

      public List<UUID> getAllUnitsInTheTOE(boolean standardForcesOnly)
      Retrieves all units in the Table of Organization and Equipment (TOE).

      This method provides a list of unique identifiers for all units currently included in the force's TOE structure.

      Parameters:
      standardForcesOnly - if true, returns only units in ForceType.STANDARD forces; if false, returns all units.
      Returns:
      a List of UUID objects representing all units in the TOE according to the specified filter
      Since:
      0.50.05
    • addCombatTeam

      public void addCombatTeam(CombatTeam combatTeam)
      Adds a CombatTeam to the combatTeams Hashtable using forceId as the key.
      Parameters:
      combatTeam - the CombatTeam to be added to the Hashtable
    • removeCombatTeam

      public void removeCombatTeam(int forceId)
      Removes a CombatTeam from the combatTeams Hashtable using forceId as the key.
      Parameters:
      forceId - the key of the CombatTeam to be removed from the Hashtable
    • getCombatTeamsTable

      public Hashtable<Integer,CombatTeam> getCombatTeamsTable()
      Returns the Hashtable using the combatTeam's forceId as the key and containing all the CombatTeam objects after removing the ineligible ones. Although sanitization might not be necessary, it ensures that there is no need for isEligible() checks when fetching the Hashtable.
      Returns:
      the sanitized Hashtable of CombatTeam objects stored in the current campaign.
    • getAllCombatTeams

      public ArrayList<CombatTeam> getAllCombatTeams()
      Returns an ArrayList of all CombatTeam objects in the combatTeams Hashtable. Calls the getCombatTeamsTable() method to sanitize the Hashtable before conversion to ArrayList.
      Returns:
      an ArrayList of all the CombatTeam objects in the combatTeams Hashtable
    • setShoppingList

      public void setShoppingList(ShoppingList sl)
    • getShoppingList

      public ShoppingList getShoppingList()
    • getPersonnelMarket

      public PersonnelMarket getPersonnelMarket()
    • setPersonnelMarket

      public void setPersonnelMarket(PersonnelMarket personnelMarket)
    • getContractMarket

      public AbstractContractMarket getContractMarket()
    • setContractMarket

      public void setContractMarket(AbstractContractMarket contractMarket)
    • getUnitMarket

      public AbstractUnitMarket getUnitMarket()
    • setUnitMarket

      public void setUnitMarket(AbstractUnitMarket unitMarket)
    • getNewPersonnelMarket

      public NewPersonnelMarket getNewPersonnelMarket()
    • setNewPersonnelMarket

      public void setNewPersonnelMarket(NewPersonnelMarket newPersonnelMarket)
    • resetRandomDeath

      public void resetRandomDeath()
    • getDivorce

      public AbstractDivorce getDivorce()
    • setDivorce

      public void setDivorce(AbstractDivorce divorce)
    • getMarriage

      public AbstractMarriage getMarriage()
    • setMarriage

      public void setMarriage(AbstractMarriage marriage)
    • getProcreation

      public AbstractProcreation getProcreation()
    • setProcreation

      public void setProcreation(AbstractProcreation procreation)
    • setRetirementDefectionTracker

      public void setRetirementDefectionTracker(RetirementDefectionTracker rdt)
    • getRetirementDefectionTracker

      public RetirementDefectionTracker getRetirementDefectionTracker()
    • setPersonnelWhoAdvancedInXP

      public void setPersonnelWhoAdvancedInXP(List<Person> personnelWhoAdvancedInXP)
      Sets the list of personnel who have advanced in experience points (XP) via vocational xp.
      Parameters:
      personnelWhoAdvancedInXP - a List of Person objects representing personnel who have gained XP.
    • getPersonnelWhoAdvancedInXP

      public List<Person> getPersonnelWhoAdvancedInXP()
      Retrieves the list of personnel who have advanced in experience points (XP) via vocational xp.
      Returns:
      a List of Person objects representing personnel who have gained XP.
    • initUnitGenerator

      public void initUnitGenerator()
      Initializes the unit generator based on the method chosen in campaignOptions. Called when the unit generator is first used or when the method has been changed in campaignOptions.
    • getUnitGenerator

      public IUnitGenerator getUnitGenerator()
      Returns:
      - the class responsible for generating random units
    • setAtBEventProcessor

      public void setAtBEventProcessor(AtBEventProcessor processor)
    • setAtBConfig

      public void setAtBConfig(AtBConfiguration config)
    • getAtBConfig

      public AtBConfiguration getAtBConfig()
    • setShipSearchStart

      public void setShipSearchStart(@Nullable LocalDate shipSearchStart)
      Sets the date a ship search was started, or null if no search is in progress.
    • getShipSearchStart

      public LocalDate getShipSearchStart()
      Returns:
      The date a ship search was started, or null if none is in progress.
    • setShipSearchResult

      public void setShipSearchResult(@Nullable String result)
      Sets the lookup name of the available ship, or null if none were found.
    • getShipSearchResult

      public String getShipSearchResult()
      Returns:
      The lookup name of the available ship, or null if none is available
    • getShipSearchExpiration

      public LocalDate getShipSearchExpiration()
      Returns:
      The date the ship is no longer available, if there is one.
    • setShipSearchExpiration

      public void setShipSearchExpiration(LocalDate shipSearchExpiration)
    • setShipSearchType

      public void setShipSearchType(int unitType)
      Sets the unit type to search for.
    • startShipSearch

      public void startShipSearch(int unitType)
    • purchaseShipSearchResult

      public void purchaseShipSearchResult()
    • applyRetirement

      public boolean applyRetirement(Money totalPayout, Map<UUID,UUID> unitAssignments)
      Process retirements for retired personnel, if any.
      Parameters:
      totalPayout - The total retirement payout.
      unitAssignments - List of unit assignments.
      Returns:
      False if there were payments AND they were unable to be processed, true otherwise.
    • getCampaignSummary

      public CampaignSummary getCampaignSummary()
    • getNews

      public News getNews()
    • addForce

      public void addForce(Force force, Force superForce)
      Add force to an existing superforce. This method will also assign the force an id and place it in the forceId hash
      Parameters:
      force - - the Force to add
      superForce - - the superforce to add the new force to
    • moveForce

      public void moveForce(Force force, Force superForce)
    • importForce

      public void importForce(Force force)
      This is used by the XML loader. The id should already be set for this force so don't increment
      Parameters:
      force - Force to add
    • importScenario

      public void importScenario(Scenario scenario)
      This is used by the XML loader. The id should already be set for this scenario so don't increment
      Parameters:
      scenario - Scenario to Add.
    • addUnitToForce

      public void addUnitToForce(@Nullable Unit unit, Force force)
    • addUnitToForce

      public void addUnitToForce(@Nullable Unit unit, int id)
      Add unit to an existing force. This method will also assign that force's id to the unit.
      Parameters:
      unit - Unit to add to the existing force.
      id - Force ID to add unit to
    • addMission

      public void addMission(Mission mission)
      Add a mission to the campaign
      Parameters:
      mission - The mission to be added
    • importMission

      public void importMission(Mission mission)
      Imports a Mission into a campaign.
      Parameters:
      mission - Mission to import into the campaign.
    • getMission

      @Nullable public Mission getMission(int id)
      Parameters:
      id - the mission's id
      Returns:
      the mission in question
    • getMissions

      public Collection<Mission> getMissions()
      Returns:
      an Collection of missions in the campaign
    • getSortedMissions

      public List<Mission> getSortedMissions()
      Returns:
      missions List sorted with complete missions at the bottom
    • getActiveMissions

      public List<Mission> getActiveMissions(boolean excludeEndDateCheck)
    • getCompletedMissions

      public List<Mission> getCompletedMissions()
    • getActiveContracts

      public List<Contract> getActiveContracts()
      Retrieves a list of currently active contracts.

      This method is a shorthand for getActiveContracts(boolean) with includeFutureContracts set to false. It fetches all contracts from the list of missions and filters them for those that are currently active on the current local date.

      Returns:
      A list of Contract objects that are currently active.
    • getActiveContracts

      public List<Contract> getActiveContracts(boolean includeFutureContracts)
      Retrieves a list of active contracts, with an option to include future contracts.

      This method iterates through all missions and checks if they are instances of Contract. If so, it filters them based on their active status, as determined by the Contract.isActiveOn(LocalDate, boolean) method.

      Parameters:
      includeFutureContracts - If true, contracts that are scheduled to start in the future will also be included in the final result. If false, only contracts active on the current local date are included.
      Returns:
      A list of Contract objects that match the active criteria.
    • getFutureContracts

      public List<Contract> getFutureContracts()
      Retrieves a list of future contracts.

      This method fetches all missions and checks if they are instances of Contract. It filters the contracts where the start date is after the current day.

      Returns:
      A list of Contract objects whose start dates are in the future.
    • getAtBContracts

      public List<AtBContract> getAtBContracts()
    • hasActiveAtBContract

      public boolean hasActiveAtBContract(boolean includeFutureContracts)
      Determines whether there is an active AtB (Against the Bot) contract. This method checks if there are contracts currently active. Optionally, it can also consider future contracts that have been accepted but have not yet started.
      Parameters:
      includeFutureContracts - a boolean indicating whether contracts that have been accepted but have not yet started should also be considered as active.
      Returns:
      true if there is any currently active AtB contract, or if includeFutureContracts is true and there are future contracts starting after the current date. Otherwise, false.
      See Also:
    • hasActiveAtBContract

      public boolean hasActiveAtBContract()
      Checks if there is at least one active AtB (Against the Bot) contract, using the default search parameters.
      Returns:
      true if an active AtB contract exists; false otherwise
      Since:
      0.50.06
    • hasFutureAtBContract

      public boolean hasFutureAtBContract()
      Determines whether there are any future AtB (Against the Bot) contracts. A future contract is defined as a contract that has been accepted but has a start date later than the current day.
      Returns:
      true if there is at least one future AtB contract (accepted but starting after the current date). Otherwise, false.
    • getActiveAtBContracts

      public List<AtBContract> getActiveAtBContracts()
    • getActiveAtBContracts

      public List<AtBContract> getActiveAtBContracts(boolean excludeEndDateCheck)
    • getCompletedAtBContracts

      public List<AtBContract> getCompletedAtBContracts()
    • hasActiveContract

      public boolean hasActiveContract()
      Returns:
      whether the current campaign has an active contract for the current date
    • setHasActiveContract

      public void setHasActiveContract()
      This is used to check if the current campaign has one or more active contacts, and sets the value of hasActiveContract based on that check. This value should not be set elsewhere
    • addScenario

      public void addScenario(Scenario s, Mission m)
      Adds scenario to existing mission, generating a report.
    • addScenario

      public void addScenario(Scenario s, Mission m, boolean suppressReport)
      Add scenario to an existing mission. This method will also assign the scenario an id, provided that it is a new scenario. It then adds the scenario to the scenarioId hash.

      Scenarios with previously set ids can be sent to this mission, allowing one to remove and then re-add scenarios if needed. This functionality is used in the AtBScenarioFactory class in method createScenariosForNewWeek to ensure that scenarios are generated properly.

      Parameters:
      s - - the Scenario to add
      m - - the mission to add the new scenario to
      suppressReport - - whether to suppress the campaign report
    • getScenario

      public Scenario getScenario(int id)
    • getScenarios

      public Collection<Scenario> getScenarios()
    • setLocation

      public void setLocation(CurrentLocation l)
    • moveToPlanetarySystem

      public void moveToPlanetarySystem(PlanetarySystem s)
      Moves immediately to a PlanetarySystem.
      Parameters:
      s - The PlanetarySystem the campaign has been moved to.
    • getLocation

      public CurrentLocation getLocation()
    • importUnit

      public void importUnit(Unit unit)
      Imports a Unit into a campaign.
      Parameters:
      unit - A Unit to import into the campaign.
    • addCampaignTransport

      public void addCampaignTransport(CampaignTransportType campaignTransportType, Unit unit)
      Adds a transport (Unit) to the list specified transporters map. This transporters map is used to store transports, the kinds of transporters they have, and their remaining capacity. The transporters map is meant to be utilized by the GUI.
      Parameters:
      campaignTransportType - Transport Type (enum) we're adding to
      unit - unit with transport capabilities
      See Also:
    • updateTransportInTransports

      public void updateTransportInTransports(Unit transport)
      This will update the transport in the transports list with current capacities. When a unit is added or removed from a transport, that information needs updated in the campaign transport map. This method will update the map for every CampaignTransportType for the given transport.
      Parameters:
      transport - Unit
      See Also:
    • updateTransportInTransports

      public void updateTransportInTransports(CampaignTransportType campaignTransportType, Unit transport)
      This will update the transport in the transports list with current capacities. When a unit is added or removed from a transport, that information needs updated in the campaign transport map. This method takes the CampaignTransportType and transport as inputs and updates the map with the current capacities of the transport.
      Parameters:
      campaignTransportType - type (Enum) of TransportedUnitsSummary we're interested in
      transport - Unit
    • removeCampaignTransporter

      public void removeCampaignTransporter(CampaignTransportType campaignTransportType, Unit unit)
      Deletes an entry from the list of specified list of transports. This gets updated when the transport should no longer be in the CampaignTransporterMap, such as when Transport is mothballed or removed from the campaign.
      Parameters:
      campaignTransportType - Transport Type (enum) we're checking
      unit - - The ship we want to remove from this Set
      See Also:
    • addTestUnit

      public void addTestUnit(TestUnit testUnit)
      This is for adding a TestUnit that was previously created and had parts added to it. We need to do the normal stuff, but we also need to take the existing parts and add them to the campaign.
      Parameters:
      testUnit - TestUnit to add.
    • addNewUnit

      public Unit addNewUnit(megamek.common.Entity en, boolean allowNewPilots, int days)
      Add a new unit to the campaign and set its quality to D.
      Parameters:
      en - An Entity object that the new unit will be wrapped around
      allowNewPilots - A boolean indicating whether to add new pilots for the unit
      days - The number of days for the new unit to arrive
      Returns:
      The newly added unit
    • addNewUnit

      public Unit addNewUnit(megamek.common.Entity en, boolean allowNewPilots, int days, PartQuality quality)
      Add a new unit to the campaign and set its quality.
      Parameters:
      en - An Entity object that the new unit will be wrapped around
      allowNewPilots - A boolean indicating whether to add new pilots for the unit
      days - The number of days for the new unit to arrive
      quality - The quality of the new unit (0-5)
      Returns:
      The newly added unit
      Throws:
      IllegalArgumentException - If the quality is not within the valid range (0-5)
    • getHangar

      public Hangar getHangar()
      Returns:
      the current hangar containing the player's units.
    • getHangarStatistics

      public HangarStatistics getHangarStatistics()
      Gets statistics related to units in the hangar.
    • getCargoStatistics

      public CargoStatistics getCargoStatistics()
      Gets statistics related to cargo in the hangar.
    • getUnits

      public Collection<Unit> getUnits()
    • getActiveUnits

      public Collection<Unit> getActiveUnits()
      Retrieves a collection of units that are not mothballed or being salvaged.
      Returns:
      a collection of active units
    • getEntities

      public List<megamek.common.Entity> getEntities()
    • getUnit

      public Unit getUnit(UUID id)
    • newDependent

      public Person newDependent(megamek.common.enums.Gender gender)
      Creates a new dependent with given gender. The origin faction and planet are set to null.
      Parameters:
      gender - The Gender of the new dependent.
      Returns:
      Return a Person object representing the new dependent.
    • newDependent

      public Person newDependent(megamek.common.enums.Gender gender, @Nullable Faction originFaction, @Nullable Planet originPlanet)
      Creates a new dependent with the given gender, origin faction, and origin planet.
      Parameters:
      gender - The Gender of the new dependent.
      originFaction - The Faction that represents the origin faction for the new dependent. This can be null, suggesting the faction will be chosen based on campaign options.
      originPlanet - The Planet that represents the origin planet for the new dependent. This can be null, suggesting the planet will be chosen based on campaign options.
      Returns:
      Return a Person object representing the new dependent.
    • newPerson

      public Person newPerson(PersonnelRole role)
      Generate a new Person of the given role using whatever randomization options have been given in the CampaignOptions
      Parameters:
      role - The primary role
      Returns:
      A new Person.
    • newPerson

      public Person newPerson(PersonnelRole primaryRole, PersonnelRole secondaryRole)
      Generate a new Person of the given role using whatever randomization options have been given in the CampaignOptions
      Parameters:
      primaryRole - The primary role
      secondaryRole - A secondary role
      Returns:
      A new Person.
    • newPerson

      public Person newPerson(PersonnelRole primaryRole, String factionCode, megamek.common.enums.Gender gender)
      Generate a new Person of the given role using whatever randomization options have been given in the CampaignOptions
      Parameters:
      primaryRole - The primary role
      factionCode - The code for the faction this person is to be generated from
      gender - The gender of the person to be generated, or a randomize it value
      Returns:
      A new Person.
    • newPerson

      public Person newPerson(PersonnelRole primaryRole, PersonnelRole secondaryRole, AbstractFactionSelector factionSelector, AbstractPlanetSelector planetSelector, megamek.common.enums.Gender gender)
      Generate a new Person of the given role using whatever randomization options have been given in the CampaignOptions
      Parameters:
      primaryRole - The primary role
      secondaryRole - A secondary role
      factionSelector - The faction selector to use for the person.
      planetSelector - The planet selector for the person.
      gender - The gender of the person to be generated, or a randomize it value
      Returns:
      A new Person.
    • newPerson

      public Person newPerson(PersonnelRole primaryRole, AbstractPersonnelGenerator personnelGenerator)
      Generate a new Person of the given role, using the supplied AbstractPersonnelGenerator
      Parameters:
      primaryRole - The primary role of the Person.
      personnelGenerator - The AbstractPersonnelGenerator to use when creating the Person.
      Returns:
      A new Person configured using personnelGenerator.
    • newPerson

      public Person newPerson(PersonnelRole primaryRole, PersonnelRole secondaryRole, AbstractPersonnelGenerator personnelGenerator, megamek.common.enums.Gender gender)
      Generate a new Person of the given role, using the supplied AbstractPersonnelGenerator
      Parameters:
      primaryRole - The primary role of the Person.
      secondaryRole - The secondary role of the Person.
      personnelGenerator - The AbstractPersonnelGenerator to use when creating the Person.
      gender - The gender of the person to be generated, or a randomize it value
      Returns:
      A new Person configured using personnelGenerator.
    • getFieldKitchenWithinCapacity

      public Boolean getFieldKitchenWithinCapacity()
    • recruitPerson

      public boolean recruitPerson(Person person)
      Recruits a person into the campaign roster using their current prisoner status, assuming recruitment is not performed by a game master that recruitment actions should be logged, and the character should be employed.
      Parameters:
      person - the person to recruit; must not be null
      Returns:
      true if recruitment was successful and the person was added or employed; false otherwise
      See Also:
    • recruitPerson

      @Deprecated(since="0.50.06", forRemoval=true) public boolean recruitPerson(Person person, boolean gmAdd)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • recruitPerson

      public boolean recruitPerson(Person person, boolean gmAdd, boolean employ)
      Recruits a person into the campaign roster using their current prisoner status, allowing specification of both game master and employment flags.

      This is a convenience overload that enables logging and allows caller to choose whether the person is employed upon recruitment.

      Parameters:
      person - the person to recruit; must not be null
      gmAdd - if true, recruitment is performed by a game master (bypassing funds check)
      employ - if true, the person is marked as employed in the campaign
      Returns:
      true if recruitment was successful and personnel was added or employed; false otherwise
      See Also:
    • recruitPerson

      @Deprecated(since="0.50.06", forRemoval=true) public boolean recruitPerson(Person person, PrisonerStatus prisonerStatus)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • recruitPerson

      public boolean recruitPerson(Person person, PrisonerStatus prisonerStatus, boolean employ)
      Recruits a person into the campaign roster with default parameters for game master and logging options.

      This is a convenience overload that assumes recruitment is not performed by a game master and that recruitment actions should be logged. If successful, the person is marked as employed based on the given flag.

      Parameters:
      person - the person to recruit; must not be null
      prisonerStatus - the prison status to assign to the person
      employ - if true, the person is marked as employed in the campaign
      Returns:
      true if recruitment was successful and personnel was added or employed; false otherwise
      See Also:
    • recruitPerson

      @Deprecated(since="0.50.06", forRemoval=true) public boolean recruitPerson(Person person, PrisonerStatus prisonerStatus, boolean gmAdd, boolean log)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • recruitPerson

      public boolean recruitPerson(Person person, PrisonerStatus prisonerStatus, boolean gmAdd, boolean log, boolean employ)
      Recruits a person into the campaign roster, handling employment status, prisoner status, finances, logging, and optional relationship simulation.

      If the employ parameter is true and the person is not already employed, this method optionally deducts recruitment costs from campaign finances (unless performed by a game master). The person's status and campaign logs are updated accordingly.

      If the person is a new recruit, their joining date and personnel entry are initialized, and relationship history may be simulated based on campaign options and role.

      The method also manages staff role-specific timing pools and can log recruitment events.

      Parameters:
      person - the person to recruit; must not be null
      prisonerStatus - the prison status to assign to the person
      gmAdd - if true, indicates the recruitment is being performed by a game master (bypassing funds check)
      log - if true, a record of the recruitment will be added to campaign logs
      employ - if true, the person is marked as employed in the campaign
      Returns:
      true if recruitment was successful and personnel was added or employed; false on failure or insufficient funds
    • checkBloodnameAdd

      public void checkBloodnameAdd(Person person, boolean ignoreDice)
      If the person does not already have a bloodname, assigns a chance of having one based on skill and rank. If the roll indicates there should be a bloodname, one is assigned as appropriate to the person's phenotype and the player's faction.
      Parameters:
      person - The Bloodname candidate
      ignoreDice - If true, skips the random roll and assigns a Bloodname automatically
    • importPerson

      public void importPerson(Person person)
      Imports a Person into a campaign.
      Parameters:
      person - A Person to import into the campaign.
    • getPerson

      @Nullable public Person getPerson(UUID id)
    • getPersonnel

      public Collection<Person> getPersonnel()
    • getPersonnelFilteringOutDeparted

      public List<Person> getPersonnelFilteringOutDeparted()
      Retrieves a list of personnel, excluding those whose status indicates they have left the unit.

      This method filters the personnel collection to only include individuals who are still part of the unit, as determined by their status.

      Returns:
      a List of Person objects who have not left the unit
    • getActivePersonnel

      public List<Person> getActivePersonnel(boolean includePrisoners)
      Retrieves a list of active personnel in the campaign, optionally including prisoners.

      This method iterates through all personnel and filters out inactive members. It then further filters prisoners based on the provided parameter:

      • If includePrisoners is true, all active personnel, including prisoners, are included in the result.
      • If includePrisoners is false, only active personnel who are either free or classified as bondsmen are included.
      Parameters:
      includePrisoners - true to include all active prisoners in the result, false to exclude them unless they are free or bondsmen.
      Returns:
      A List of Person objects representing the filtered active personnel.
    • getSalaryEligiblePersonnel

      public List<Person> getSalaryEligiblePersonnel()
      Returns:
      a list of people who are currently eligible to receive a salary.
      Since:
      0.50.06
    • getActiveCombatPersonnel

      public List<Person> getActiveCombatPersonnel()
      Retrieves a filtered list of personnel who have at least one combat profession.

      This method filters the list of all personnel to include only those whose primary or secondary role is designated as a combat role.

      Returns:
      a List of Person objects representing combat-capable personnel
    • getActiveDependents

      public List<Person> getActiveDependents()
      Provides a filtered list of personnel including only active Dependents.
      Returns:
      a Person List containing all active personnel
    • getCurrentPrisoners

      public List<Person> getCurrentPrisoners()
      Provides a filtered list of personnel including only active prisoners.
      Returns:
      a Person List containing all active personnel
    • getPrisonerDefectors

      public List<Person> getPrisonerDefectors()
      Provides a filtered list of personnel including only active prisoners who are willing to defect.
      Returns:
      a Person List containing all active personnel
    • getFriendlyPrisoners

      public List<Person> getFriendlyPrisoners()
      Provides a filtered list of personnel including only friendly PoWs.
      Returns:
      a Person List containing all active personnel
    • getStudents

      public List<Person> getStudents()
      Provides a filtered list of personnel including only Persons with the Student status.
      Returns:
      a Person List containing all active personnel
    • getFactionSelector

      public AbstractFactionSelector getFactionSelector()
      Gets the AbstractFactionSelector to use with this campaign.
      Returns:
      An AbstractFactionSelector to use when selecting a Faction.
    • getFactionSelector

      public AbstractFactionSelector getFactionSelector(RandomOriginOptions options)
      Gets the AbstractFactionSelector to use
      Parameters:
      options - the random origin options to use
      Returns:
      An AbstractFactionSelector to use when selecting a Faction.
    • getPlanetSelector

      public AbstractPlanetSelector getPlanetSelector()
      Gets the AbstractPlanetSelector to use with this campaign.
      Returns:
      An AbstractPlanetSelector to use when selecting a Planet.
    • getPlanetSelector

      public AbstractPlanetSelector getPlanetSelector(RandomOriginOptions options)
      Gets the AbstractPlanetSelector to use
      Parameters:
      options - the random origin options to use
      Returns:
      An AbstractPlanetSelector to use when selecting a Planet.
    • getPersonnelGenerator

      public AbstractPersonnelGenerator getPersonnelGenerator(AbstractFactionSelector factionSelector, AbstractPlanetSelector planetSelector)
      Gets the AbstractPersonnelGenerator to use with this campaign.
      Parameters:
      factionSelector - The AbstractFactionSelector to use when choosing a Faction.
      planetSelector - The AbstractPlanetSelector to use when choosing a Planet.
      Returns:
      An AbstractPersonnelGenerator to use when creating new personnel.
    • getPatients

      public List<Person> getPatients()
    • getServiceableUnits

      public List<Unit> getServiceableUnits()
      List of all units that can show up in the repair bay.
    • importParts

      public void importParts(Collection<Part> newParts)
      Imports a collection of parts into the campaign.
      Parameters:
      newParts - The collection of Part instances to import into the campaign.
    • getWarehouse

      public Warehouse getWarehouse()
      Gets the Warehouse which stores parts.
    • setWarehouse

      public void setWarehouse(Warehouse warehouse)
      Sets the Warehouse which stores parts for the campaign.
      Parameters:
      warehouse - The warehouse in which to store parts.
    • getQuartermaster

      public Quartermaster getQuartermaster()
    • getParts

      public Collection<Part> getParts()
      Returns:
      A collection of parts in the Warehouse.
    • updatePartInUse

      public void updatePartInUse(PartInUse partInUse, boolean ignoreMothballedUnits, PartQuality ignoreSparesUnderQuality)
      Find all the parts that match this PartInUse and update their data
      Parameters:
      partInUse - part in use record to update
      ignoreMothballedUnits - don't count parts in mothballed units
      ignoreSparesUnderQuality - don't count spare parts lower than this quality
    • getPartsInUse

      public Set<PartInUse> getPartsInUse(boolean ignoreMothballedUnits, boolean isResupply, PartQuality ignoreSparesUnderQuality)
      Analyzes the warehouse inventory and returns a data set that summarizes the usage state of all parts, including their use counts, store counts, and planned counts, while filtering based on specific conditions.

      This method aggregates all parts currently in use or available as spares, while taking into account constraints like ignoring mothballed units or filtering spares below a specific quality. It uses a map structure to efficiently track and update parts during processing.

      Parameters:
      ignoreMothballedUnits - If true, parts from mothballed units will not be included in the results.
      isResupply - If true, specific units (e.g., prohibited unit types) are skipped based on the current context as defined in Resupply.isProhibitedUnitType().
      ignoreSparesUnderQuality - Spare parts of a lower quality than the specified value will be excluded from the results.
      Returns:
      A Set of PartInUse objects detailing the state of each relevant part, including:
      • Use count: How many of this part are currently in use.
      • Store count: How many of this part are available as spares in the warehouse.
      • Planned count: The quantity of this part included in acquisition orders or planned procurement.
      • Requested stock: The target or default quantity to maintain, as derived from settings or requests.
      Only parts with non-zero counts (use, store, or planned) will be included in the result.
    • getPart

      public Part getPart(int id)
    • getForce

      @Nullable public Force getForce(int id)
    • getCurrentReport

      public List<String> getCurrentReport()
    • setCurrentReportHTML

      public void setCurrentReportHTML(String html)
    • getCurrentReportHTML

      public String getCurrentReportHTML()
    • setNewReports

      public void setNewReports(List<String> reports)
    • fetchAndClearNewReports

      public List<String> fetchAndClearNewReports()
    • findBestInRole

      public Person findBestInRole(PersonnelRole role, String primary, @Nullable String secondary)
      Finds the active person in a particular role with the highest level in a given, with an optional secondary skill to break ties.
      Parameters:
      role - One of the PersonnelRole enum values
      primary - The skill to use for comparison.
      secondary - If not null and there is more than one person tied for the most the highest, preference will be given to the one with a higher level in the secondary skill.
      Returns:
      The person in the designated role with the most experience.
    • findBestInRole

      public Person findBestInRole(PersonnelRole role, String skill)
    • findBestAtSkill

      @Nullable public Person findBestAtSkill(String skillName)
      Finds and returns the Person with the highest total skill level for a specified skill.

      This method iterates over all active personnel, calculates each individual's total skill level for the given skill (taking into account campaign options, reputation modifiers, and attributes), and determines who possesses the highest skill value. If none are found, null is returned.

      Parameters:
      skillName - the name of the skill to evaluate among all active personnel
      Returns:
      the Person with the highest calculated total skill level in the specified skill, or null if no qualifying person is found
    • getTechs

      public List<Person> getTechs()
      Returns:
      The list of all active Persons who qualify as technicians (Person.isTech());
    • getTechs

      public List<Person> getTechs(boolean noZeroMinute)
    • getTechsExpanded

      public List<Person> getTechsExpanded()
    • getTechs

      public List<Person> getTechs(boolean noZeroMinute, boolean eliteFirst)
    • getTechsExpanded

      public List<Person> getTechsExpanded(boolean noZeroMinute, boolean eliteFirst, boolean expanded)
      Retrieves a list of active technicians, with options to include only those with time remaining, prioritize elite technicians, and expand the search to include technicians with additional roles.

      The resulting list includes Person objects who qualify as technicians (Person.isTech()) or, if specified, as expanded technicians (Person.isTechExpanded()). If the person is part of a self-crewed unit (e.g., an engineer on a self-crewed vessel), they are also included in the list.

      The returned list can be customized and sorted based on a variety of criteria:

      • Technicians with no remaining available time can be excluded if noZeroMinute is set to true.
      • The list can be sorted from elite (best) to least skilled if eliteFirst is set to true.
      • When expanded is set to true, technicians with expanded roles (e.g., dual skill sets) are included in addition to regular technicians.
      • The list is further sorted in the following order:
        1. By skill level (default: lowest to highest, or highest to lowest if elite-first enabled).
        2. By available daily tech time (highest to lowest).
        3. By rank (lowest to highest).
      Parameters:
      noZeroMinute - If true, excludes technicians with no remaining available minutes.
      eliteFirst - If true, sorts the list to place the most skilled technicians at the top.
      expanded - If true, includes technicians with expanded roles (e.g., those qualifying under Person.isTechExpanded()).
      Returns:
      A list of active Person objects who qualify as technicians or expanded technicians, sorted by skill, available time, and rank as specified by the input parameters.
    • getAdmins

      public List<Person> getAdmins()
    • isWorkingOnRefit

      public boolean isWorkingOnRefit(Person person)
    • getDoctors

      public List<Person> getDoctors()
    • getPatientsFor

      public int getPatientsFor(Person doctor)
    • getLogisticsPerson

      @Nullable public Person getLogisticsPerson()
      Retrieves the best logistics person based on the acquisition skill, personnel category, and maximum acquisitions allowed for the campaign.

      This method evaluates all active personnel to determine the most suitable candidate for logistics tasks, depending on the specified acquisition skill and rules. The determination is made according to the following logic:

      • If the skill is S_AUTO, the method immediately returns null.
      • If the skill is S_TECH, the method evaluates personnel based on their technical skill level, ignoring those who are ineligible for procurement or who exceed the maximum acquisition limit.
      • For all other skills, the method evaluates personnel who possess the specified skill, ensuring their eligibility for procurement and checking that they have not exceeded the maximum acquisition limit.

      The "best" logistics person is selected as the one with the highest skill level (based on the skill being evaluated). If no suitable candidate is found, the method returns null.

      Returns:
      The Person representing the best logistics character, or null if no suitable person is found.
    • getSeniorAdminPerson

      @Nullable public Person getSeniorAdminPerson(Campaign.AdministratorSpecialization type)
      Finds and returns the most senior administrator for a specific type of administrative role. Seniority is determined using the Person.outRanksUsingSkillTiebreaker(mekhq.campaign.Campaign, mekhq.campaign.personnel.Person) method when there are multiple eligible administrators for the specified role.

      The method evaluates both the primary and secondary roles of each administrator against the provided Campaign.AdministratorSpecialization type.

      The valid types of administrative roles are represented by the Campaign.AdministratorSpecialization enum:

      Parameters:
      type - the Campaign.AdministratorSpecialization representing the administrative role to check for. Passing a null type will result in an IllegalStateException.
      Returns:
      the most senior Person with the specified administrative role, or null if no eligible administrator is found.

      Behavior:

      • The method iterates through all administrators retrieved by getAdmins().
      • For each Person, it checks if their primary or secondary role matches the specified type via utility methods like AdministratorRole#isAdministratorCommand.
      • If no eligible administrators exist, the method returns null.
      • If multiple administrators are eligible, the one with the highest seniority is returned.
      • Seniority is determined by the Person.outRanksUsingSkillTiebreaker(mekhq.campaign.Campaign, mekhq.campaign.personnel.Person) method, which uses a skill-based tiebreaker when necessary.
      Throws:
      IllegalStateException - if type is null or an unsupported value.
    • getCommander

      @Nullable public Person getCommander()
      Retrieves the current campaign commander.

      If a commander is specifically flagged, that person will be returned. Otherwise, the highest-ranking member among the unit's active personnel is selected.

      Returns:
      the Person who is the commander, or null if there are no suitable candidates.
      Since:
      0.50.07
    • getSecondInCommand

      @Nullable public Person getSecondInCommand()
      Retrieves the second-in-command among the unit's active personnel.

      The second-in-command is determined as the highest-ranking active personnel member who is not the flagged commander (if one exists). If multiple candidates have the same rank, a skill-based tiebreaker is used.

      Returns:
      the Person who is considered the second-in-command, or null if there are no suitable candidates.
      Since:
      0.50.07
    • getLogisticsPersonnel

      public List<Person> getLogisticsPersonnel()
      Retrieves a list of eligible logistics personnel who can perform procurement actions based on the current campaign options. If acquisitions are set to automatically succeed, an empty list is returned.

      This method evaluates active personnel to determine who is eligible for procurement actions under the current campaign configuration. Personnel are filtered and sorted based on specific criteria:

      • Automatic Success: If the acquisition skill equals S_AUTO, an empty list is immediately returned.
      • Eligibility Filtering: The following checks are applied to filter personnel:
        • Personnel must not be ineligible based on the ProcurementPersonnelPick category.
        • Personnel must not have exceeded the maximum acquisition limit, if specified.
        • If the skill is S_TECH, the person must have a valid technical skill.
        • For other skills, the person must have the specified skill.
      • Sorting: The resulting list is sorted in descending order by skill level:
        • When the skill is S_TECH, sorting is based on the person's best technical skill level.
        • For other skills, sorting is based on the level of the specified skill.
      Returns:
      A List of Person objects who are eligible and sorted to perform logistical actions, or an empty list if acquisitions automatically succeed.
    • goShopping

      public ShoppingList goShopping(ShoppingList sList)
      This is the main function for getting stuff (parts, units, etc.) All non-GM acquisition should go through this function to ensure the campaign rules for acquisition are followed.
      Parameters:
      sList - - A ShoppingList object including items that need to be purchased
      Returns:
      A ShoppingList object that includes all items that were not successfully acquired
    • canAcquireParts

      public boolean canAcquireParts(@Nullable Person person)
      Gets a value indicating if person can acquire parts.
      Parameters:
      person - The Person to check if they have remaining time to perform acquisitions.
      Returns:
      True if person could acquire another part, otherwise false.
    • canPayFor

      public boolean canPayFor(IAcquisitionWork acquisition)
      Checks whether the campaign can pay for a given IAcquisitionWork item. This will check both whether the campaign is required to pay for a given type of acquisition by the options and if so whether it has enough money to afford it.
      Parameters:
      acquisition - - An IAcquisitionWork object
      Returns:
      true if the campaign can pay for the acquisition; false if it cannot.
    • findContactForAcquisition

      public Quartermaster.PartAcquisitionResult findContactForAcquisition(IAcquisitionWork acquisition, Person person, PlanetarySystem system)
      Make an acquisition roll for a given planet to see if you can identify a contact. Used for planetary based acquisition.
      Parameters:
      acquisition - - The IAcquisitionWork being acquired.
      person - - The Person object attempting to do the acquiring. may be null if no one on the force has the skill or the user is using automatic acquisition.
      system - - The PlanetarySystem object where the acquisition is being attempted. This may be null if the user is not using planetary acquisition.
      Returns:
      The result of the rolls.
    • acquireEquipment

      public boolean acquireEquipment(IAcquisitionWork acquisition, Person person)
      Attempt to acquire a given IAcquisitionWork object. This is the default method used by for non-planetary based acquisition.
      Parameters:
      acquisition - - The IAcquisitionWork being acquired.
      person - - The Person object attempting to do the acquiring. may be null if no one on the force has the skill or the user is using automatic acquisition.
      Returns:
      a boolean indicating whether the attempt to acquire equipment was successful.
    • workOnMothballingOrActivation

      public void workOnMothballingOrActivation(Unit unit)
      Performs work to either mothball or activate a unit.
      Parameters:
      unit - The unit to either work towards mothballing or activation.
    • mothball

      public void mothball(Unit unit)
      Performs work to mothball a unit, preparing it for long-term storage.

      Mothballing process varies based on unit type:

      • Non-Infantry Units:
        • Requires an assigned tech
        • Consumes tech work minutes
        • Requires astech support time (6 minutes per tech minute)
      • Infantry Units:
        • Uses standard work day time
        • No tech required

      The process tracks progress and can span multiple work periods until complete.

      Parameters:
      unit - The unit to mothball. Must be active (not already mothballed)
    • activate

      public void activate(Unit unit)
      Performs work to activate a unit from its mothballed state. This process requires either:
      • A tech and sufficient astech support time for non-self-crewed units
      • Only time for self-crewed units

      The activation process:

      1. Verifies the unit is mothballed
      2. For non-self-crewed units:
        • Checks for assigned tech
        • Verifies sufficient tech and astech time
        • Consumes tech and astech time
      3. For self-crewed units:
        • Uses standard work day time
      4. Updates mothball status
      5. Reports progress or completion
      Parameters:
      unit - The unit to activate. Must be mothballed for activation to proceed.
    • refit

      public void refit(Refit theRefit)
    • fixWarehousePart

      public Part fixWarehousePart(Part part, Person tech)
      Repairs a specified part from the warehouse by creating a clone of it, decrementing the quantity in stock, repairing the cloned part, and optionally adding the repaired part back to the warehouse inventory.

      If the original part's quantity drops to zero or below, no event notification is triggered. Otherwise, an event is triggered to update the system about changes in the spare part's stock.

      Parameters:
      part - The Part object to be repaired. Its quantity is decremented by one during this operation.
      tech - The Person who is performing the repair.
      Returns:
      A new repaired Part cloned from the original.
    • fixPart

      public String fixPart(IPartWork partWork, Person tech)
      Attempt to fix a part, which may have all kinds of effect depending on part type.
      Parameters:
      partWork - - the IPartWork to be fixed
      tech - - the Person who will attempt to fix the part
      Returns:
      a String of the report that summarizes the outcome of the attempt to fix the part
    • reloadNews

      public void reloadNews()
      Parses news file and loads news items for the current year.
    • readNews

      public void readNews()
      Checks for a news item for the current date. If found, adds it to the daily report.
    • getDeploymentDeficit

      public int getDeploymentDeficit(AtBContract contract)
      TODO : I should be part of AtBContract, not Campaign
      Parameters:
      contract - an active AtBContract
      Returns:
      the current deployment deficit for the contract
    • processNewDayPersonnel

      public void processNewDayPersonnel()
      Processes the daily activities and updates for all personnel that haven't already left the campaign.

      This method iterates through all personnel and performs various daily updates, including health checks, status updates, relationship events, and other daily or periodic tasks.

      The following tasks are performed for each person:

      • Death Handling: If the person has died, their processing is skipped for the day.
      • Relationship Events: Processes relationship-related events, such as marriage or divorce.
      • Reset Actions: Resets the person's minutes left for work and sets acquisitions made to 0.
      • Medical Events:
      • - If advanced medical care is available, processes the person's daily healing.
      • - If advanced medical care is unavailable, decreases the healing wait time and applies natural or doctor-assisted healing.
      • Weekly Edge Resets: Resets edge points to their purchased value weekly (applies to support personnel).
      • Vocational XP: Awards monthly vocational experience points to the person where applicable.
      • Anniversaries: Checks for birthdays or significant anniversaries and announces them as needed.
      • autoAwards: On the first day of every month, calculates and awards support points based on roles and experience levels.

      Concurrency Note: A separate filtered list of personnel is used to avoid concurrent modification issues during iteration.

      This method relies on several helper methods to perform specific tasks for each person, separating the responsibilities for modularity and readability.

      See Also:
    • processNewDayUnits

      public void processNewDayUnits()
    • newDay

      public boolean newDay()
      Returns:
      true if the new day arrived
    • checkForNewMercenaryOrganizationStartUp

      public void checkForNewMercenaryOrganizationStartUp(boolean bypassStartYear)
      Checks if a new mercenary organization is starting up in the current game year, and, if so, triggers a welcome dialog introducing the organization's representative.

      This method examines a prioritized list of known mercenary-related factions for their respective founding (start) years matching the current year. The list is evaluated in the following order: Mercenary Review Board (MRB), Mercenary Review Bonding Commission (MRBC), Mercenary Bonding Authority (MBA), and Mercenary Guild (MG), with MG as the default fallback. If a matching faction is found (and is recognized as a mercenary organization), it generates an appropriate speaker (as either a merchant or military liaison, depending on the faction) and opens a welcome dialog for the player.

      The dialog serves to introduce the player to the new mercenary organization, using an in-universe character as the spokesperson.

      Parameters:
      bypassStartYear - true if the method should be checking if the mercenary organization is currently active, rather than just checking whether it was founded in the current game year.
      Since:
      0.50.07
    • refreshPersonnelMarkets

      public void refreshPersonnelMarkets()
    • getInitiativeBonus

      public int getInitiativeBonus()
    • setInitiativeBonus

      public void setInitiativeBonus(int bonus)
    • applyInitiativeBonus

      public void applyInitiativeBonus(int bonus)
    • initiativeBonusIncrement

      public void initiativeBonusIncrement(boolean change)
    • getInitiativeMaxBonus

      public int getInitiativeMaxBonus()
    • setInitiativeMaxBonus

      public void setInitiativeMaxBonus(int bonus)
    • getFlaggedCommander

      @Nullable public Person getFlaggedCommander()
      Retrieves the flagged commander from the personnel list. If no flagged commander is found returns null.

      Usage: consider using getCommander() instead.

      Returns:
      the flagged commander if present, otherwise null
    • getSeniorCommander

      @Deprecated(since="0.50.07", forRemoval=true) public Person getSeniorCommander()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use getCommander() instead
    • removeUnit

      public void removeUnit(UUID id)
    • removePerson

      public void removePerson(@Nullable Person person)
    • removePerson

      public void removePerson(@Nullable Person person, boolean log)
    • removeAllPatientsFor

      public void removeAllPatientsFor(Person doctor)
    • removeScenario

      public void removeScenario(Scenario scenario)
    • removeMission

      public void removeMission(Mission mission)
    • removeKill

      public void removeKill(Kill k)
    • removeKillsFor

      public void removeKillsFor(UUID personID)
    • removeForce

      public void removeForce(Force force)
    • removeUnitFromForce

      public void removeUnitFromForce(Unit u)
    • getForceFor

      @Nullable public Force getForceFor(@Nullable Unit unit)
    • getForceFor

      @Nullable public Force getForceFor(Person person)
    • restore

      public void restore()
    • cleanUp

      public void cleanUp()
      Cleans incongruent data present in the campaign
    • isOvertimeAllowed

      public boolean isOvertimeAllowed()
    • setOvertime

      public void setOvertime(boolean b)
    • isGM

      public boolean isGM()
    • setGMMode

      public void setGMMode(boolean b)
    • getFaction

      public Faction getFaction()
    • isClanCampaign

      public boolean isClanCampaign()
      Determines whether the current campaign is a clan campaign.

      This method checks if the faction associated with the campaign is a clan, returning true if it is, and false otherwise.

      Returns:
      true if the campaign belongs to a clan faction, false otherwise.
      Since:
      0.50.05
    • isPirateCampaign

      public boolean isPirateCampaign()
      Determines whether the current campaign is a pirate campaign.

      This method checks if the faction associated with the campaign is Pirates, returning true if it is, and false otherwise.

      Returns:
      true if the campaign is Pirates, false otherwise.
      Since:
      0.50.07
    • isMercenaryCampaign

      public boolean isMercenaryCampaign()
      Determines whether the current campaign is a mercenary campaign.

      This method checks if the faction associated with the campaign is Mercenary, returning true if it is, and false otherwise.

      Returns:
      true if the campaign is Mercenary, false otherwise.
      Since:
      0.50.07
    • setFaction

      public void setFaction(Faction faction)
    • setFactionDirect

      public void setFactionDirect(Faction faction)
    • getRetainerEmployerCode

      public String getRetainerEmployerCode()
    • setRetainerEmployerCode

      public void setRetainerEmployerCode(String code)
    • getRetainerStartDate

      public LocalDate getRetainerStartDate()
    • setRetainerStartDate

      public void setRetainerStartDate(LocalDate retainerStartDate)
    • getRawCrimeRating

      public int getRawCrimeRating()
    • setCrimeRating

      public void setCrimeRating(int crimeRating)
    • changeCrimeRating

      public void changeCrimeRating(int change)
      Updates the crime rating by the specified change. If improving crime rating, use a positive number, otherwise negative
      Parameters:
      change - the change to be applied to the crime rating
    • getCrimePirateModifier

      public int getCrimePirateModifier()
    • setCrimePirateModifier

      public void setCrimePirateModifier(int crimePirateModifier)
    • changeCrimePirateModifier

      public void changeCrimePirateModifier(int change)
      Updates the crime pirate modifier by the specified change. If improving the modifier, use a positive number, otherwise negative
      Parameters:
      change - the change to be applied to the crime modifier
    • getAdjustedCrimeRating

      public int getAdjustedCrimeRating()
      Calculates the adjusted crime rating by adding the crime rating with the pirate modifier.
      Returns:
      The adjusted crime rating.
    • getDateOfLastCrime

      @Nullable public LocalDate getDateOfLastCrime()
    • setDateOfLastCrime

      public void setDateOfLastCrime(LocalDate dateOfLastCrime)
    • getReputation

      public ReputationController getReputation()
    • setReputation

      public void setReputation(ReputationController reputation)
    • getFactionStandings

      public FactionStandings getFactionStandings()
    • setFactionStandings

      public void setFactionStandings(FactionStandings factionStandings)
    • beginReport

      public void beginReport(String r)
      Starts a new day for the daily log
      Parameters:
      r - - the report String
    • addReport

      public void addReport(String format, Object... objects)
      Formats and then adds a report to the daily log
      Parameters:
      format - String with format markers.
      objects - Variable list of objects to format into format
    • addReport

      public void addReport(String r)
      Adds a report to the daily log
      Parameters:
      r - - the report String
    • getCamouflage

      public megamek.common.icons.Camouflage getCamouflage()
    • setCamouflage

      public void setCamouflage(megamek.common.icons.Camouflage camouflage)
    • getColour

      public megamek.client.ui.util.PlayerColour getColour()
    • setColour

      public void setColour(megamek.client.ui.util.PlayerColour colour)
    • getUnitIcon

      public StandardForceIcon getUnitIcon()
    • setUnitIcon

      public void setUnitIcon(StandardForceIcon unitIcon)
    • addFunds

      public void addFunds(TransactionType type, Money quantity, @Nullable String description)
    • removeFunds

      public void removeFunds(TransactionType type, Money quantity, @Nullable String description)
    • payPersonnel

      public void payPersonnel(TransactionType type, Money quantity, String description, Map<Person,Money> individualPayouts)
      Generic method for paying Personnel (Person) in the company. Debits money from the campaign and if the campaign tracks total earnings it will account for that.
      Parameters:
      type - TransactionType being debited
      quantity - total money - it's usually displayed outside of this method
      description - String displayed in the ledger and report
      individualPayouts - Map of Person to the Money they're owed
    • getCampaignOptions

      public CampaignOptions getCampaignOptions()
    • setCampaignOptions

      public void setCampaignOptions(CampaignOptions options)
    • getStoryArc

      public StoryArc getStoryArc()
    • useStoryArc

      public void useStoryArc(StoryArc arc, boolean initiate)
    • unloadStoryArc

      public void unloadStoryArc()
    • getCurrentObjectives

      public List<String> getCurrentObjectives()
    • getFameAndInfamy

      @Deprecated(since="0.50.07", forRemoval=true) public FameAndInfamyController getFameAndInfamy()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getAutomatedMothballUnits

      public List<UUID> getAutomatedMothballUnits()
      Retrieves the list of units that are configured for automated mothballing.

      Automated mothballing is a mechanism where certain units are automatically placed into a mothballed state, reducing their active maintenance costs and operational demands over time.

      Returns:
      A List of UUID objects that are set for automated mothballing. Returns an empty list if no units are configured.
    • setAutomatedMothballUnits

      public void setAutomatedMothballUnits(List<UUID> automatedMothballUnits)
      Sets the list of units that are configured for automated mothballing.

      Replaces the current list of units that have undergone automated mothballing.

      Parameters:
      automatedMothballUnits - A List of UUID objects to configure for automated mothballing.
    • getTemporaryPrisonerCapacity

      public int getTemporaryPrisonerCapacity()
    • setTemporaryPrisonerCapacity

      public void setTemporaryPrisonerCapacity(int temporaryPrisonerCapacity)
    • changeTemporaryPrisonerCapacity

      public void changeTemporaryPrisonerCapacity(int delta)
      Adjusts the temporary prisoner capacity by the specified delta value.

      he new capacity is constrained to be at least the minimum allowed temporary capacity, as defined by PrisonerEventManager.MINIMUM_TEMPORARY_CAPACITY.

      T
      Parameters:
      delta - the amount by which to change the temporary prisoner capacity. A positive value increases the capacity, while a negative value decreases it.
    • getRandomEventLibraries

      public RandomEventLibraries getRandomEventLibraries()
    • getFactionStandingUltimatumsLibrary

      public FactionStandingUltimatumsLibrary getFactionStandingUltimatumsLibrary()
    • writeToXML

      public void writeToXML(PrintWriter writer)
    • getSystems

      public ArrayList<PlanetarySystem> getSystems()
    • getSystemById

      public PlanetarySystem getSystemById(String id)
    • getSystemNames

      public Vector<String> getSystemNames()
    • getSystemByName

      public PlanetarySystem getSystemByName(String name)
    • getRankSystem

      public RankSystem getRankSystem()
    • setRankSystem

      public void setRankSystem(@Nullable RankSystem rankSystem)
    • setRankSystemDirect

      public void setRankSystemDirect(RankSystem rankSystem)
    • setFinances

      public void setFinances(Finances f)
    • getFinances

      public Finances getFinances()
    • getAccountant

      public Accountant getAccountant()
    • calculateJumpPath

      public JumpPath calculateJumpPath(PlanetarySystem start, PlanetarySystem end)
      Calculates and returns a JumpPath between two planetary systems, using default parameters for jump range and travel safety.

      This method provides a convenient way to compute the most likely or optimal jump path from the specified starting system to the destination system. Internal behavior and constraints are determined by the method's default parameter settings.

      Parameters:
      start - the starting PlanetarySystem
      end - the destination PlanetarySystem
      Returns:
      the calculated JumpPath between the two systems
    • calculateJumpPath

      public JumpPath calculateJumpPath(PlanetarySystem start, PlanetarySystem end, boolean skipAccessCheck, boolean skipEmptySystemCheck)
      Calculates the optimal jump path between two planetary systems using the A* algorithm.

      This implementation minimizes a combination of jump counts and recharge times to find the most efficient route between systems. The algorithm uses a heuristic based on straight-line distance combined with actual path costs from the starting system.

      The algorithm will optionally avoid systems without population when the isAvoidingEmptySystems flag equals true.

      Implementation is based on: Policy Almanac A* Tutorial

      Parameters:
      start - The starting planetary system
      end - The destination planetary system
      skipAccessCheck - true to skip checking for Outlaw status in system, false otherwise. Should be false when determining contract-related jump paths as system access is guaranteed for contract target systems.
      skipEmptySystemCheck - true to skip checking for empty system status, false otherwise. Should be false when determining contract-related jump paths.
      Returns:
      A JumpPath containing the sequence of systems to traverse, or null if no valid path exists between the systems. If start and end are the same system, returns a path containing only that system.
    • calculateCostPerJump

      public Money calculateCostPerJump(boolean excludeOwnTransports, boolean campaignOpsCosts)
      This method calculates the cost per jump for interstellar travel. It operates by fitting the part of the force not transported in owned DropShips into a number of prototypical DropShips of a few standard configurations, then adding the JumpShip charges on top. It remains fairly hacky, but improves slightly on the prior implementation as far as following the rulebooks goes.

      It can be used to calculate total travel costs in the style of FM:Mercs (excludeOwnTransports and campaignOpsCosts set to false), to calculate leased/rented travel costs only in the style of FM:Mercs (excludeOwnTransports true, campaignOpsCosts false), or to calculate travel costs for CampaignOps-style costs (excludeOwnTransports true, campaignOpsCosts true).

      Parameters:
      excludeOwnTransports - If true, do not display maintenance costs in the calculated travel cost.
      campaignOpsCosts - If true, use the Campaign Ops method for calculating travel cost. (DropShip monthly fees of 0.5% of purchase cost, 100,000 C-bills per collar.)
    • getSimplifiedTravelTime

      public int getSimplifiedTravelTime(PlanetarySystem destination)
      Calculates simplified travel time. Travel time is calculated by dividing distance (in LY) by 20 and multiplying the result by 7.
      Parameters:
      destination - the planetary system being traveled to
      Returns:
      the simplified travel time in days
    • personUpdated

      public void personUpdated(Person person)
    • getTargetFor

      public megamek.common.TargetRoll getTargetFor(IPartWork partWork, Person tech)
      Calculates the TargetRoll required for a technician to work on a specific part task.

      This method determines task difficulty and eligibility by evaluating the technician's skills, penalties due to work mode, unit and part constraints, time availability, helper modifiers, and campaign options. It produces context-specific messages when tasks are impossible due to skill, resource, or situation limitations.

      The result will reflect all applicable modifiers (such as overtime or era-based penalties) and communicates if a task is impossible, or has automatic success (e.g., for infantry refits).

      Parameters:
      partWork - the part work task to be performed
      tech - the technician assigned to the task
      Returns:
      a TargetRoll capturing the total target value and reason for success or impossibility
    • getTargetForMaintenance

      public megamek.common.TargetRoll getTargetForMaintenance(IPartWork partWork, Person tech, int asTechsUsed)
    • getTargetForAcquisition

      public megamek.common.TargetRoll getTargetForAcquisition(IAcquisitionWork acquisition)
    • getTargetForAcquisition

      public megamek.common.TargetRoll getTargetForAcquisition(IAcquisitionWork acquisition, @Nullable Person person)
    • getCurrentPlanetaryConditions

      public megamek.common.planetaryconditions.PlanetaryConditions getCurrentPlanetaryConditions(Scenario scenario)
    • getTargetForAcquisition

      public megamek.common.TargetRoll getTargetForAcquisition(IAcquisitionWork acquisition, @Nullable Person person, boolean checkDaysToWait)
      Determines the target roll required for successfully acquiring a specific part or unit based on various campaign settings, the acquisition details, and the person attempting the acquisition.

      This method evaluates multiple conditions and factors to calculate the target roll, returning one of the following outcomes:

      • TargetRoll.AUTOMATIC_SUCCESS if acquisitions are set to be automatic in the campaign options.
      • TargetRoll.IMPOSSIBLE if the acquisition is not permitted based on campaign settings, such as missing personnel, parts restrictions, or unavailable technology.
      • A calculated target roll value based on the skill of the assigned person, acquisition modifiers, and adjustments for specific campaign rules (e.g., AtB restrictions).
      Parameters:
      acquisition - the IAcquisitionWork object containing details about the requested part or supply, such as tech base, technology level, and availability.
      Returns:
      a TargetRoll object representing the roll required to successfully acquire the requested item, or an impossible/automatic result under specific circumstances.
    • findAtBPartsAvailabilityLevel

      public int findAtBPartsAvailabilityLevel()
    • resetAstechMinutes

      public void resetAstechMinutes()
    • setAstechPoolMinutes

      public void setAstechPoolMinutes(int minutes)
    • getAstechPoolMinutes

      public int getAstechPoolMinutes()
    • setAstechPoolOvertime

      public void setAstechPoolOvertime(int overtime)
    • getAstechPoolOvertime

      public int getAstechPoolOvertime()
    • getPossibleAstechPoolMinutes

      public int getPossibleAstechPoolMinutes()
    • getPossibleAstechPoolOvertime

      public int getPossibleAstechPoolOvertime()
    • setAstechPool

      public void setAstechPool(int size)
    • getAstechPool

      public int getAstechPool()
    • setMedicPool

      public void setMedicPool(int size)
    • getMedicPool

      public int getMedicPool()
    • requiresAdditionalAstechs

      public boolean requiresAdditionalAstechs()
    • getAstechNeed

      public int getAstechNeed()
    • increaseAstechPool

      public void increaseAstechPool(int i)
    • fillAstechPool

      public void fillAstechPool()
    • decreaseAstechPool

      public void decreaseAstechPool(int i)
    • getNumberAstechs

      public int getNumberAstechs()
    • getNumberPrimaryAstechs

      public int getNumberPrimaryAstechs()
      Returns the total number of primary astechs available.

      This method calculates the number of astechs by adding the base astech pool to the count of active personnel whose primary role is an astech, who are not currently deployed, and are employed.

      Returns:
      the total number of primary astechs
    • getNumberSecondaryAstechs

      public int getNumberSecondaryAstechs()
      Returns the total number of secondary astechs available.

      This method calculates the number of astechs by adding the base astech pool to the count of active personnel whose secondary role is an astech, who are not currently deployed, and are employed.

      Returns:
      the total number of secondary astechs
    • getAvailableAstechs

      public int getAvailableAstechs(int minutes, boolean alreadyOvertime)
    • getShorthandedMod

      public int getShorthandedMod(int availableHelp, boolean medicalStaff)
    • getShorthandedModForCrews

      public int getShorthandedModForCrews(@Nullable megamek.common.Crew crew)
    • getMedicsPerDoctor

      public int getMedicsPerDoctor()
    • getNumberMedics

      public int getNumberMedics()
      Returns:
      the number of medics in the campaign including any in the temporary medic pool
    • requiresAdditionalMedics

      public boolean requiresAdditionalMedics()
    • getMedicsNeed

      public int getMedicsNeed()
    • increaseMedicPool

      public void increaseMedicPool(int i)
    • fillMedicPool

      public void fillMedicPool()
    • decreaseMedicPool

      public void decreaseMedicPool(int i)
    • getGameOptions

      public megamek.common.options.GameOptions getGameOptions()
    • getGameOptionsVector

      public Vector<megamek.common.options.IBasicOption> getGameOptionsVector()
    • setGameOptions

      public void setGameOptions(megamek.common.options.GameOptions gameOptions)
    • setGameOptions

      public void setGameOptions(Vector<megamek.common.options.IBasicOption> options)
    • importKill

      public void importKill(Kill k)
      Imports a Kill into a campaign.
      Parameters:
      k - A Kill to import into the campaign.
    • addKill

      public void addKill(Kill k)
    • getKills

      public List<Kill> getKills()
    • getKillsFor

      public List<Kill> getKillsFor(UUID pid)
    • getPartsStore

      public PartsStore getPartsStore()
    • addCustom

      public void addCustom(String name)
    • isCustom

      public boolean isCustom(Unit u)
    • getUnitRatingText

      public String getUnitRatingText()
      Returns the text representation of the unit rating based on the selected unit rating method. If the unit rating method is FMMR, the unit rating value is returned. If the unit rating method is Campaign Operations, the reputation rating and unit rating modification are combined and returned. If the unit rating method is neither FMMR nor Campaign Operations, "N/A" is returned.
      Returns:
      The text representation of the unit rating
    • getAtBUnitRatingMod

      public int getAtBUnitRatingMod()
      Retrieves the unit rating modifier based on campaign options. If the unit rating method is not enabled, it returns the default value of IUnitRating.DRAGOON_C. If the unit rating method uses FMMR, it returns the unit rating as an integer. Otherwise, it calculates the modifier using the getAtBModifier method.
      Returns:
      The unit rating modifier based on the campaign options.
    • getCommanderStrategy

      public int getCommanderStrategy()
      Returns the Strategy skill of the designated commander in the campaign.
      Returns:
      The value of the commander's strategy skill if a commander exists, otherwise 0.
    • getRandomSkillPreferences

      public RandomSkillPreferences getRandomSkillPreferences()
    • setRandomSkillPreferences

      public void setRandomSkillPreferences(RandomSkillPreferences prefs)
    • setStartingSystem

      public void setStartingSystem(@Nullable Planet planet)
      Parameters:
      planet - the starting planet, or null to use the faction default
    • assignRandomPortraitFor

      public void assignRandomPortraitFor(Person person)
      Assigns a random portrait to a Person.
      Parameters:
      person - The Person who should receive a randomized portrait.
    • assignRandomOriginFor

      public void assignRandomOriginFor(Person person)
      Assigns a random origin to a Person.
      Parameters:
      person - The Person who should receive a randomized origin.
    • clearGameData

      public void clearGameData(megamek.common.Entity entity)
      Clears Transient Game Data for an Entity
      Parameters:
      entity - the entity to clear the game data for
    • refreshNetworks

      public void refreshNetworks()
    • disbandNetworkOf

      public void disbandNetworkOf(Unit u)
    • removeUnitsFromNetwork

      public void removeUnitsFromNetwork(Vector<Unit> removedUnits)
    • addUnitsToNetwork

      public void addUnitsToNetwork(Vector<Unit> addedUnits, String netid)
    • getAvailableC3iNetworks

      public Vector<String[]> getAvailableC3iNetworks()
    • getAvailableNC3Networks

      public Vector<String[]> getAvailableNC3Networks()
      Returns:
      returns a Vector of the unique name Strings of all Naval C3 networks that have at least 1 free node Adapted from getAvailableC3iNetworks() as the two technologies have very similar workings
    • getAvailableC3MastersForSlaves

      public Vector<String[]> getAvailableC3MastersForSlaves()
    • getAvailableC3MastersForMasters

      public Vector<String[]> getAvailableC3MastersForMasters()
    • removeUnitsFromC3Master

      public void removeUnitsFromC3Master(Unit master)
    • reloadGameEntities

      public void reloadGameEntities()
      This function reloads the game entities into the game at the end of scenario resolution, so that entities are properly updated and destroyed ones removed
    • completeMission

      public void completeMission(@Nullable Mission mission, MissionStatus status)
    • calculatePartTransitTime

      public int calculatePartTransitTime(PlanetarySystem system)
      Calculate transit time for supplies based on what planet they are shipping from. To prevent extra computation. This method does not calculate an exact jump path but rather determines the number of jumps crudely by dividing distance in light years by 30 and then rounding up. Total part-time is determined by several by adding the following: - (number of jumps - 1) * 7 days with a minimum value of zero. - transit times from current planet and planet of supply origins in cases where the supply planet is not the same as current planet. - a random 1d6 days for each jump plus 1d6 to simulate all the other logistics of delivery.
      Parameters:
      system - - A PlanetarySystem object where the supplies are shipping from
      Returns:
      the number of days that supplies will take to arrive.
    • calculatePartTransitTime

      public int calculatePartTransitTime(int availability)
      Calculates the transit time for the arrival of parts or supplies based on the availability of the item, a random roll, and campaign-specific transit time settings.

      The transit time is calculated using the following factors:

      • A fixed base modifier value defined by campaign rules.
      • A random roll of 1d6 to add variability to the calculation.
      • The availability value of the requested parts or supplies from the acquisition details.

      The calculated duration is applied in units (days, weeks, or months) based on the campaign's configuration for transit time.

      Parameters:
      availability - the availability code of the part or unit being acquired as an integer.
      Returns:
      the number of days required for the parts or units to arrive based on the calculated transit time.
    • calculatePartTransitTime

      public int calculatePartTransitTime(megamek.common.ITechnology.AvailabilityValue availability)
      Calculates the transit time for the arrival of parts or supplies based on the availability of the item, a random roll, and campaign-specific transit time settings.

      The transit time is calculated using the following factors:

      • A fixed base modifier value defined by campaign rules.
      • A random roll of 1d6 to add variability to the calculation.
      • The availability value of the requested parts or supplies from the acquisition details.

      The calculated duration is applied in units (days, weeks, or months) based on the campaign's configuration for transit time.

      Parameters:
      availability - the Availability of the part
      Returns:
      the number of days required for the parts or units to arrive based on the calculated transit time.
    • getPartInventory

      public PartInventory getPartInventory(Part part)
      This returns a PartInventory object detailing the current count for a part on hand, in transit, and ordered.
      Parameters:
      part - A part to look up its current inventory.
      Returns:
      A PartInventory object detailing the current counts of the part on hand, in transit, and ordered.
      See Also:
    • addLoan

      public void addLoan(Loan loan)
    • payOffLoan

      public void payOffLoan(Loan loan)
    • getTransports

      public Map<TransporterType,Map<Double,Set<UUID>>> getTransports(CampaignTransportType campaignTransportType)
      Returns a Map that maps Transporter types to another Map that maps capacity (Double) to UUID of transports for the specific TransportedUnitSummary type
      Parameters:
      campaignTransportType - type (Enum) of TransportedUnitSummary
      Returns:
      the full map for that campaign transport type
    • getTransportsByType

      public Set<Unit> getTransportsByType(CampaignTransportType campaignTransportType, TransporterType transporterType)
      Returns list of transports that have the provided TransporterType and CampaignTransportType
      Parameters:
      campaignTransportType - type of campaign transport
      transporterType - type of Transporter
      Returns:
      units that have that transport type
    • getTransportsByType

      public Set<Unit> getTransportsByType(CampaignTransportType campaignTransportType, TransporterType transporterType, double unitSize)
      Returns list of transports for the specified AbstractTransportedUnitSummary class/subclass that has transport capacity for the Transporter class/subclass For example, getTransportsByType(SHIP_TRANSPORT, MEK_BAY, 3.0) would return all transports that have 3 or more Mek Bay slots open for the SHIP_TRANSPORT type of assignment.
      Parameters:
      campaignTransportType - type (Enum) of TransportedUnitSummary
      transporterType - type (Enum) of Transporter
      unitSize - capacity that the transport must be capable of
      Returns:
      units that have that transport type
    • hasTransports

      public boolean hasTransports(CampaignTransportType campaignTransportType)
      Do we have transports for the kind of transport?
      Parameters:
      campaignTransportType - class of the TransportDetail
      Returns:
      true if it has transporters, false otherwise
    • doMaintenance

      public void doMaintenance(Unit unit)
    • initTimeInService

      @Deprecated(since="0.50.07", forRemoval=true) public void initTimeInService()
      Deprecated, for removal: This API element is subject to removal in a future version.
      No longer in use
    • initTimeInRank

      @Deprecated(since="0.50.07", forRemoval=true) public void initTimeInRank()
      Deprecated, for removal: This API element is subject to removal in a future version.
      No longer in use
    • initTurnover

      public void initTurnover()
    • initAtB

      public void initAtB(boolean newCampaign)
    • shutdownAtB

      public void shutdownAtB()
      Stop processing AtB events and release memory.
    • checkTurnoverPrompt

      public int checkTurnoverPrompt()
      Checks if an employee turnover prompt should be displayed based on campaign options, current date, and other conditions (like transit status and campaign start date).

      The turnover prompt is triggered based on the configured turnover frequency (weekly, monthly, quarterly, or annually), but only after the campaign has been running for at least 6 days and when not in transit.

      The dialog will show different messages depending on whether there are pending retirees.

      Returns:
      An integer representing the outcome: -1 if turnover prompt should not be displayed, 0 if user selected "Employee Turnover", 1 if user selected "Advance Day Regardless", 2 if user selected "Cancel Advance Day"
    • checkScenariosDue

      public boolean checkScenariosDue()
      Checks if there are any scenarios that are due based on the current date.
      Returns:
      true if there are scenarios due, false otherwise
    • setUnitRating

      public void setUnitRating(IUnitRating rating)
      Sets the type of rating method used.
    • getUnitRating

      public IUnitRating getUnitRating()
      Returns the type of rating method as selected in the Campaign Options dialog. Lazy-loaded for performance. Default is CampaignOpsReputation
    • getTechIntroYear

      public int getTechIntroYear()
      Specified by:
      getTechIntroYear in interface megamek.common.ITechManager
    • getGameYear

      public int getGameYear()
      Specified by:
      getGameYear in interface megamek.common.ITechManager
    • getTechFaction

      public megamek.common.ITechnology.Faction getTechFaction()
      Specified by:
      getTechFaction in interface megamek.common.ITechManager
    • updateTechFactionCode

      public void updateTechFactionCode()
    • useClanTechBase

      public boolean useClanTechBase()
      Specified by:
      useClanTechBase in interface megamek.common.ITechManager
    • useMixedTech

      public boolean useMixedTech()
      Specified by:
      useMixedTech in interface megamek.common.ITechManager
    • getTechLevel

      public megamek.common.SimpleTechLevel getTechLevel()
      Specified by:
      getTechLevel in interface megamek.common.ITechManager
    • unofficialNoYear

      public boolean unofficialNoYear()
      Specified by:
      unofficialNoYear in interface megamek.common.ITechManager
    • useVariableTechLevel

      public boolean useVariableTechLevel()
      Specified by:
      useVariableTechLevel in interface megamek.common.ITechManager
    • showExtinct

      public boolean showExtinct()
      Specified by:
      showExtinct in interface megamek.common.ITechManager
    • getAutoResolveBehaviorSettings

      public megamek.client.bot.princess.BehaviorSettings getAutoResolveBehaviorSettings()
    • setAutoResolveBehaviorSettings

      public void setAutoResolveBehaviorSettings(megamek.client.bot.princess.BehaviorSettings settings)
    • getCommanderAddress

      public String getCommanderAddress()
      Retrieves the address or form of address for the commander.

      This method determines the appropriate address based on whether the campaign is considered a pirate campaign. It delegates to getCommanderAddress(boolean) with the result of isPirateCampaign().

      Returns:
      the string used to address the commander
    • getCommanderAddress

      public String getCommanderAddress(boolean isInformal)
      Retrieves the address or title for the commanding officer, either in a formal or informal format.

      This method checks for the presence of a flagged commander. If no commander is found, a general fallback address is returned based on the specified formality. If a commander is present, it further tailors the address based on the gender of the commander (for informal styles) or their rank and surname (for formal styles).

      Parameters:
      isInformal - A boolean flag indicating whether the address should be informal (true for informal, false for formal).
      Returns:
      A String representing the appropriate address for the commander, either formal or informal.
    • stockUpPartsInUse

      public int stockUpPartsInUse(Set<PartInUse> partsInUse)
    • stockUpPartsInUseGM

      public void stockUpPartsInUseGM(Set<PartInUse> partsInUse)
    • isProcessProcurement

      public boolean isProcessProcurement()
    • setProcessProcurement

      public void setProcessProcurement(boolean processProcurement)
    • getPartsInUseRequestedStockMap

      public Map<String,Double> getPartsInUseRequestedStockMap()
    • setPartsInUseRequestedStockMap

      public void setPartsInUseRequestedStockMap(Map<String,Double> partsInUseRequestedStockMap)
    • getIgnoreMothballed

      public boolean getIgnoreMothballed()
    • setIgnoreMothballed

      public void setIgnoreMothballed(boolean ignoreMothballed)
    • getTopUpWeekly

      public boolean getTopUpWeekly()
    • setTopUpWeekly

      public void setTopUpWeekly(boolean topUpWeekly)
    • getIgnoreSparesUnderQuality

      public PartQuality getIgnoreSparesUnderQuality()
    • setIgnoreSparesUnderQuality

      public void setIgnoreSparesUnderQuality(PartQuality ignoreSparesUnderQuality)
    • writePartInUseToXML

      public void writePartInUseToXML(PrintWriter pw, int indent)
    • writePartInUseMapToXML

      public void writePartInUseMapToXML(PrintWriter pw, int indent)
    • wipePartsInUseMap

      public void wipePartsInUseMap()
      Wipes the Parts in use map for the purpose of resetting all values to their default
    • getCampaignFactionIcon

      public ImageIcon getCampaignFactionIcon()
      Retrieves the campaign faction icon for the specified Campaign. If a custom icon is defined in the campaign's unit icon configuration, that icon is used. Otherwise, a default faction logo is fetched based on the campaign's faction short name.
      Returns:
      An ImageIcon representing the faction icon for the given campaign.
    • checkLinkedScenario

      public boolean checkLinkedScenario(int scenarioID)
      Checks if another active scenario has this scenarioID as it's linkedScenarioID and returns true if it finds one.
    • getAllCombatEntities

      public List<megamek.common.Entity> getAllCombatEntities()
      Returns a list of entities (units) from all combat forces.
      Returns:
      a list of entities representing all combat units in the player force
    • getNewCampaignStartingPlanet

      public Planet getNewCampaignStartingPlanet()
      Determines the appropriate starting planet for a new campaign based on campaign type, faction, and various fallback scenarios.

      This method first checks if the campaign is classified as a mercenary or pirate campaign. If so, it delegates responsibility to getMercenaryOrPirateStartingPlanet(Factions, String), which implements special logic to handle those campaign types.

      For all other campaign types, it uses the current campaign's faction to attempt to retrieve that faction’s canonical starting system for the current game date. If no valid system can be found (due to, for example, the faction not having a valid capital), the logic falls back to a default faction’s starting planet, and, if necessary, ultimately falls back to the planet Terra as a default universal location.

      The method also includes special handling for Clan campaigns: if the fallback logic would result in the campaign starting on Terra but the campaign is clan-based, it attempts to relocate the starting planet to Strana Mechty.

      Returns:
      the Planet instance where the campaign should start
      Since:
      0.50.07