Class AbstractForce
- Direct Known Subclasses:
PlayerForce
Campaign: faction identity
and appearance, finances, reputation/standing, the TO&E, and force options.
The located resources (hangar, warehouse, personnel, location) are not owned by the force — they belong
to its Detachment(s). A force is not itself a location node; getDetachments() is the
detachment-count-agnostic way to reach them, and the aggregate helpers (allUnits(), allPersonnel())
project across every detachment. Convenience accessors that assume a single detachment live on
SingleDetachmentForce; force-internal operations that still assume one go through
requireSingleDetachment().
A force holds no reference back to its Campaign. Campaign-level concerns — the
current date, and writing daily-report lines — are the campaign's responsibility: it passes values such as the date
in as method parameters and does its own reporting around the force's state changes.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractForce(ForceOptions forceOptions, megamek.common.enums.Faction techFaction, RankSystem rankSystem, Finances finances, ForceReputationController reputation, FactionStandings factionStandings) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllCombatTeams(Formation formation, Campaign campaign) Adds formation and all its sub-formations to the Combat Teams table.voidaddCombatTeam(CombatTeam combatTeam) voidaddFormation(Formation formation, Formation superFormation, Campaign campaign) Add formation to an existing superformation.voidaddFunds(TransactionType type, LocalDate date, Money quantity, String description) Creditsquantityto this force's finances.voidaddUnitsToNetwork(Vector<Unit> addedUnits, String networkID, megamek.common.game.Game game) AddsaddedUnitsto the C3i/Naval C3 network identified bynetworkID, rebuilding every member's node UUIDs, and refreshes networks against the suppliedGame.voidaddUnitToFormation(Unit unit, int id, Campaign campaign) Add unit to an existing formation.voidaddUnitToFormation(Unit unit, Formation formation, Campaign campaign) All personnel across everyDetachmentof this force.allUnits()All units across everyDetachmentof this force.voidapplyInitiativeBonus(int bonus) intcalculateMASHTheaterCapacity(Campaign campaign) voidchangeCrimePirateModifier(int change) voidchangeCrimeRating(int change) voidchangeRepairBaysRented(int delta) voidchangeTemporaryPrisonerCapacity(int delta) Adjusts the temporary prisoner capacity bydelta, clamped to at leastPrisonerEventManager.MINIMUM_TEMPORARY_CAPACITY.voiddetachUnitFromC3Networks(Unit u, megamek.common.game.Game game) Detachesufrom any C3 network it participates in (Naval C3, C3i, Nova CEWS, or a C3 master), refreshing the affected networks against the suppliedGame.voiddisbandNetworkOf(Unit u, megamek.common.game.Game game) Disbands the entire C3i/Naval C3 network thatubelongs to, clearing the stored next-node UUIDs of every unit on that network and refreshing networks against the suppliedGame.intgetAllUnitsInTheTOE(boolean standardFormationsOnly) Retrieves all units in the Table of Organization and Equipment (TOE).intmegamek.common.icons.Camouflagemegamek.client.ui.util.PlayerColourgetCombatTeamsAsList(Campaign campaign) getCombatTeamsAsMap(Campaign campaign) Returns theHashtablekeyed by the combat team'sformationId, after removing ineligible teams.The raw, unsanitized combat-team table (keyed by formation id); used for serialization and iteration.intabstract Collection<Detachment> TheDetachments this force is currently split across.booleangetFormation(int id) getFormationFor(Person person) Resolves theFormationa person belongs to: the formation of their assigned unit if they crew one, otherwise — for techs — the formation they are the assigned tech of.getFormationFor(Unit unit) getFunds()booleanintintintbooleangetMashTheatresWithinCapacity(Campaign campaign) Whether the force's MASH theatre capacity covers its patients assigned to doctors.getName()intintmegamek.common.enums.FactionintbooleanvoidimportFormation(Formation formation) This is used by the XML loader.voidinitiativeBonusIncrement(boolean change) booleanbooleanvoidmoveFormation(Formation formation, Formation superFormation, Campaign campaign) Movesformationto sit directly undersuperFormationin the TOE, detaching it from its current parent and inheriting the target's scenario assignment.voidrefreshNetworks(megamek.common.game.Game game) Rebuilds this force's C3, Naval C3, and C3i networks from the units' stored C3 UUIDs.voidremoveCombatTeam(int formationId) voidremoveFormation(Formation formation, Campaign campaign) Removesformationfrom the TOE: unassigns its units (clearing their scenario if it was deployed), removes it from any scenario it was deployed to and from its parent formation, and clears any StratCon track assignments.voidremoveFunds(TransactionType type, LocalDate date, Money quantity, String description) Debitsquantityfrom this force's finances.voidremoveUnitFromFormation(Unit unit, Campaign campaign) Removesufrom its current formation, clearing its formation and scenario assignments and detaching it from any C3 networks.voidremoveUnitsFromC3Master(Unit master, megamek.common.game.Game game) Detaches every unit slaved tomasterfrom it, clearing their C3 master reference and refreshing networks against the suppliedGame.voidremoveUnitsFromNetwork(Vector<Unit> removedUnits, megamek.common.game.Game game) RemovesremovedUnitsfrom their shared C3i/Naval C3 network and rebuilds the remaining members' node UUIDs so the network stays contiguous, refreshing networks against the suppliedGame.protected DetachmentThe soleDetachment, asserting the single-detachment assumption.voidsetAutomatedMothballUnits(List<UUID> automatedMothballUnits) voidsetCamouflage(megamek.common.icons.Camouflage camouflage) voidsetColour(megamek.client.ui.util.PlayerColour colour) voidsetCrimePirateModifier(int crimePirateModifier) voidsetCrimeRating(int crimeRating) voidsetDateOfLastCrime(LocalDate dateOfLastCrime) voidsetFaction(Faction faction) voidsetFactionDirect(Faction faction) voidsetFactionStandings(FactionStandings factionStandings) voidsetFieldKitchenWithinCapacity(boolean fieldKitchenWithinCapacity) voidsetFinances(Finances finances) voidsetFormations(Formation formations) voidsetHumanResources(ForceHumanResources humanResources) voidsetIgnoreMothballed(boolean ignoreMothballed) voidsetIgnoreSparesUnderQuality(PartQuality ignoreSparesUnderQuality) voidsetInitiativeBonus(int bonus) voidsetInitiativeMaxBonus(int bonus) voidsetIsAvoidingEmptySystems(boolean isAvoidingEmptySystems) voidsetIsOverridingCommandCircuitRequirements(boolean isOverridingCommandCircuitRequirements) voidsetMashTheatreCapacity(int mashTheatreCapacity) voidvoidsetRankSystem(RankSystem rankSystem) voidsetRankSystemDirect(RankSystem rankSystem) voidsetRepairBaysRented(int repairBaysRented) voidsetReputation(ForceReputationController reputation) voidvoidsetRetainerStartDate(LocalDate retainerStartDate) voidsetShoppingList(ForceShoppingList shoppingList) voidsetTemporaryPrisonerCapacity(int temporaryPrisonerCapacity) voidsetTopUpWeekly(boolean topUpWeekly) voidsetUnitIcon(StandardFormationIcon unitIcon) void
-
Constructor Details
-
AbstractForce
protected AbstractForce(ForceOptions forceOptions, megamek.common.enums.Faction techFaction, RankSystem rankSystem, Finances finances, ForceReputationController reputation, FactionStandings factionStandings)
-
-
Method Details
-
getDetachments
TheDetachments this force is currently split across. APlayerForcetracks exactly one; the located resources (hangar, warehouse, personnel, location) are owned by the detachment(s), not the force. -
allUnits
All units across everyDetachmentof this force. Multi-detachment-safe. -
allPersonnel
All personnel across everyDetachmentof this force. Multi-detachment-safe. -
requireSingleDetachment
The soleDetachment, asserting the single-detachment assumption. ThrowsIllegalStateExceptionif the force does not have exactly one detachment.This is the internal counterpart to
SingleDetachmentForce: greprequireSingleDetachmentto find the force-internal operations that are not yet multi-detachment-safe and must be reworked before a multi-detachment force can use them. -
getHumanResources
-
setHumanResources
-
getShoppingList
-
setShoppingList
-
getForceOptions
-
getFaction
-
setFaction
-
setFactionDirect
-
getTechFaction
public megamek.common.enums.Faction getTechFaction() -
updateTechFactionCode
public void updateTechFactionCode() -
getName
-
setName
-
getRankSystem
-
setRankSystem
-
setRankSystemDirect
-
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
-
setUnitIcon
-
getRetainerEmployerCode
-
setRetainerEmployerCode
-
getRetainerStartDate
-
setRetainerStartDate
-
getFinances
-
setFinances
-
getFunds
-
addFunds
Creditsquantityto this force's finances. The campaign is responsible for defaulting the description and writing any daily-report line. -
removeFunds
Debitsquantityfrom this force's finances. The campaign is responsible for defaulting the description and writing any daily-report line. -
getReputation
-
setReputation
-
getFactionStandings
-
setFactionStandings
-
getRawCrimeRating
public int getRawCrimeRating() -
setCrimeRating
public void setCrimeRating(int crimeRating) -
changeCrimeRating
public void changeCrimeRating(int change) -
getCrimePirateModifier
public int getCrimePirateModifier() -
setCrimePirateModifier
public void setCrimePirateModifier(int crimePirateModifier) -
changeCrimePirateModifier
public void changeCrimePirateModifier(int change) -
getAdjustedCrimeRating
public int getAdjustedCrimeRating() -
getDateOfLastCrime
-
setDateOfLastCrime
-
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) -
isAvoidingEmptySystems
public boolean isAvoidingEmptySystems() -
setIsAvoidingEmptySystems
public void setIsAvoidingEmptySystems(boolean isAvoidingEmptySystems) -
isOverridingCommandCircuitRequirements
public boolean isOverridingCommandCircuitRequirements() -
setIsOverridingCommandCircuitRequirements
public void setIsOverridingCommandCircuitRequirements(boolean isOverridingCommandCircuitRequirements) -
getIgnoreMothballed
public boolean getIgnoreMothballed() -
setIgnoreMothballed
public void setIgnoreMothballed(boolean ignoreMothballed) -
getTopUpWeekly
public boolean getTopUpWeekly() -
setTopUpWeekly
public void setTopUpWeekly(boolean topUpWeekly) -
getIgnoreSparesUnderQuality
-
setIgnoreSparesUnderQuality
-
getTemporaryPrisonerCapacity
public int getTemporaryPrisonerCapacity() -
setTemporaryPrisonerCapacity
public void setTemporaryPrisonerCapacity(int temporaryPrisonerCapacity) -
changeTemporaryPrisonerCapacity
public void changeTemporaryPrisonerCapacity(int delta) Adjusts the temporary prisoner capacity bydelta, clamped to at leastPrisonerEventManager.MINIMUM_TEMPORARY_CAPACITY. -
getCachedMashTheaterCapacity
public int getCachedMashTheaterCapacity() -
setMashTheatreCapacity
public void setMashTheatreCapacity(int mashTheatreCapacity) -
getMashTheatresWithinCapacity
Whether the force's MASH theatre capacity covers its patients assigned to doctors. Off-contract or in transit there is no cap. Takes aCampaignfor the contract/location context the force does not hold. -
calculateMASHTheaterCapacity
-
getFieldKitchenWithinCapacity
public boolean getFieldKitchenWithinCapacity() -
setFieldKitchenWithinCapacity
public void setFieldKitchenWithinCapacity(boolean fieldKitchenWithinCapacity) -
getRepairBaysRented
public int getRepairBaysRented() -
setRepairBaysRented
public void setRepairBaysRented(int repairBaysRented) -
changeRepairBaysRented
public void changeRepairBaysRented(int delta) -
getAutomatedMothballUnits
-
setAutomatedMothballUnits
-
getFormations
-
setFormations
-
getAllFormations
-
getFormationIds
-
getLastFormationId
public int getLastFormationId() -
getCombatTeamsMap
The raw, unsanitized combat-team table (keyed by formation id); used for serialization and iteration. -
getFormation
-
getAllUnitsInTheTOE
Retrieves all units in the Table of Organization and Equipment (TOE).- Parameters:
standardFormationsOnly- iftrue, returns only units inFormationType.STANDARDformations; iffalse, returns all units.- Returns:
- a List of UUID objects representing all units in the TOE according to the specified filter
-
addCombatTeam
-
removeCombatTeam
public void removeCombatTeam(int formationId) -
getCombatTeamsAsMap
Returns theHashtablekeyed by the combat team'sformationId, after removing ineligible teams. The sanitization removes the need forisEligible()checks whenever the table is fetched. -
getCombatTeamsAsList
-
addFormation
Add formation to an existing superformation. This method will also assign the formation an id and place it in the formationId hash. -
moveFormation
Movesformationto sit directly undersuperFormationin the TOE, detaching it from its current parent and inheriting the target's scenario assignment. Formation-type standardization is then applied per the moved formation'sFormationType(parents may be standardized, children may inherit), and formation levels are repopulated across the TOE. No-ops ifformationisnullor equalssuperFormation. TheCampaignis supplied as a parameter for the scenario and TOE updates this drives. -
importFormation
This is used by the XML loader. The id should already be set for this formation so don't increment. -
addUnitToFormation
-
addUnitToFormation
Add unit to an existing formation. This method will also assign that formation's id to the unit. -
addAllCombatTeams
Adds formation and all its sub-formations to the Combat Teams table. -
removeFormation
Removesformationfrom the TOE: unassigns its units (clearing their scenario if it was deployed), removes it from any scenario it was deployed to and from its parent formation, and clears any StratCon track assignments. TheCampaignis supplied as a parameter for the scenario, contract, and combat-team updates this drives. -
removeUnitFromFormation
Removesufrom its current formation, clearing its formation and scenario assignments and detaching it from any C3 networks. When StratCon is enabled and this empties the formation, the formation is dropped from the combat-teams table. TheCampaignis supplied as a parameter for the game and combat-team updates this drives. -
getFormationFor
- Returns:
- the
Formationunitis currently assigned to, ornullifunitisnullor unassigned
-
getFormationFor
Resolves theFormationa person belongs to: the formation of their assigned unit if they crew one, otherwise — for techs — the formation they are the assigned tech of.- Returns:
- the person's formation, or
nullif none applies
-
refreshNetworks
public void refreshNetworks(megamek.common.game.Game game) Rebuilds this force's C3, Naval C3, and C3i networks from the units' stored C3 UUIDs. The MegaMekGameis supplied as a parameter (the force holds no game reference) because network membership is resolved against the live game entities. -
disbandNetworkOf
Disbands the entire C3i/Naval C3 network thatubelongs to, clearing the stored next-node UUIDs of every unit on that network and refreshing networks against the suppliedGame. -
removeUnitsFromNetwork
RemovesremovedUnitsfrom their shared C3i/Naval C3 network and rebuilds the remaining members' node UUIDs so the network stays contiguous, refreshing networks against the suppliedGame. All removed units are assumed to share the first unit's network id. -
addUnitsToNetwork
public void addUnitsToNetwork(Vector<Unit> addedUnits, String networkID, megamek.common.game.Game game) AddsaddedUnitsto the C3i/Naval C3 network identified bynetworkID, rebuilding every member's node UUIDs, and refreshes networks against the suppliedGame. -
getAvailableC3iNetworks
- Returns:
- one entry per C3i network in the TOE that has at least one free node; each entry is a
{networkId, freeNodeCount}pair
-
getAvailableNC3Networks
- Returns:
- one entry per Naval C3 network in the TOE that has at least one free node; each entry is a
{networkId, freeNodeCount}pair. Naval C3 mirrors C3i, so this parallelsgetAvailableC3iNetworks().
-
getAvailableNovaCEWSNetworks
- Returns:
- one entry per Nova CEWS network in the TOE that has at least one free node; each entry is a
{networkId, freeNodeCount}pair. Nova CEWS networks hold at most three units.
-
getAvailableC3MastersForSlaves
- Returns:
- the C3 masters in the TOE that can accept a slave (have a free C3 node), excluding company-level masters
whose free-node count is unreliable; each entry is a
{c3UUID, freeNodeCount, shortName}triple
-
getAvailableC3MastersForMasters
- Returns:
- the C3 masters in the TOE that can accept another master (have a free C3-M node); each entry is a
{c3UUID, freeMasterNodeCount, shortName}triple
-
removeUnitsFromC3Master
Detaches every unit slaved tomasterfrom it, clearing their C3 master reference and refreshing networks against the suppliedGame. -
detachUnitFromC3Networks
Detachesufrom any C3 network it participates in (Naval C3, C3i, Nova CEWS, or a C3 master), refreshing the affected networks against the suppliedGame.
-