Class ForceDescriptor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final String[]static final String[]static final String[]static final String[]static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final String[]static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllEntities(List<Entity> list) voidaddAttached(ForceDescriptor forceDescriptor) voidGenerates the carried Aerospace Fighter complement of every large craft (WarShip, DropShip, JumpShip, Space Station) in this force and nests it under the carrying ship, so a generated force that includes a carrier also includes the fighters it carries.voidvoidintassignForceIds(int nextId) Assigns a uniqueforceIdto every formation node in this subtree - that is, every node from the lance/star/point level up.voidCalculates transport needs of the unit and generates enough drop-ships and jump ships to carry the indicated portion of the unit.static StringcardinalOrdinal(int n) Formats a positive integer as a numeric ordinal with the correct English suffix: 1 -> "1st", 2 -> "2nd", 3 -> "3rd", 4 -> "4th", 11/12/13 -> "th", 21 -> "21st", etc.createChild(int index) static intdecodeWeightClass(String code) generate()voidvoidgenerateLance(List<ForceDescriptor> subs) Generates a lance or other end-level unit (star, level ii) by individual units rather than as an entire formation.voidgenerateUnits(Ruleset.ProgressListener l, double progress) Goes through the force tree structure and generates units for all leaf nodes.getCamo()doublegetCargo()getCo()Builds the display label for this force, combining the formal name (e.g.doublegetFlags()intgetIndex()doublegetName()intintgetRoles()intdoublePer-cluster-type weight budget for this node, keyed by unit type, ornullif none.getXo()getYear()booleanbooleanbooleanbooleanvoidloadEntities(Ruleset.ProgressListener l, double progress) booleanmatches(ChassisRecord cRec) Checks whether the chassis matches the unit type for this node of the force tree.booleanmatches(ModelRecord mRec) If a list of acceptable chassis, models, or variants has been assigned, checks whether the model is among them.Translates between the rating codes used by the force generator and those used by the RAT Generator.doubleWeight class can differ from the target once units are generated.voidsetAttached(ArrayList<ForceDescriptor> attached) voidsetAttachments(boolean attachments) voidsetAugmented(boolean augmented) voidvoidsetCargo(double cargo) voidsetCo(CrewDescriptor co) voidvoidsetDropshipPct(double dropshipPct) voidsetEchelon(Integer echelon) voidsetElement(boolean element) voidsetExperience(Integer experience) voidsetFaction(String faction) voidsetFighterComplement(boolean fighterComplement) voidsetFluffName(String fluffName) voidvoidsetGenerationRule(String rule) voidsetIndex(int index) voidsetJumpshipPct(double jumpshipPct) voidvoidsetNameNodes(List<ValueNode> nameNodes) Because some echelon names depend on knowing the actual weight class, we save a copy of the possibilities for this node and defer selection until after the final weight class determination.voidsetParent(ForceDescriptor parent) voidsetRankSystem(Integer rankSystem) voidvoidsetSizeMod(int sizeMod) voidsetSubForces(ArrayList<ForceDescriptor> subForces) voidsetTopLevel(boolean topLevel) voidsetUnit(ModelRecord unit) Assigns a specific model to this node of the force tree.voidsetUnitType(Integer unitType) voidsetWarshipPct(double warshipPct) voidsetWeightClass(Integer weightClass) voidsetWeightTargets(Map<Integer, megamek.client.ratgenerator.WeightTarget> weightTargets) voidsetXo(CrewDescriptor xo) voidbooleanint[]Recursively counts the weight class of every BattleMek leaf element in this descriptor, its subforces, and its attachments.Tallies every generated element's weight class, grouped by unit type.boolean
-
Field Details
-
REINFORCED
public static final int REINFORCED- See Also:
-
UNDERSTRENGTH
public static final int UNDERSTRENGTH- See Also:
-
EXP_GREEN
public static final int EXP_GREEN- See Also:
-
EXP_REGULAR
public static final int EXP_REGULAR- See Also:
-
EXP_VETERAN
public static final int EXP_VETERAN- See Also:
-
RATING_0
public static final int RATING_0- See Also:
-
RATING_1
public static final int RATING_1- See Also:
-
RATING_2
public static final int RATING_2- See Also:
-
RATING_3
public static final int RATING_3- See Also:
-
RATING_4
public static final int RATING_4- See Also:
-
RATING_5
public static final int RATING_5- See Also:
-
ORDINALS
-
PHONETIC
-
GREEK
-
LATIN
-
ROMAN
-
WEIGHT_SMALL_CRAFT
public static final int WEIGHT_SMALL_CRAFT- See Also:
-
WEIGHT_SMALL_DROP
public static final int WEIGHT_SMALL_DROP- See Also:
-
WEIGHT_MEDIUM_DROP
public static final int WEIGHT_MEDIUM_DROP- See Also:
-
WEIGHT_LARGE_DROP
public static final int WEIGHT_LARGE_DROP- See Also:
-
WEIGHT_SMALL_WAR
public static final int WEIGHT_SMALL_WAR- See Also:
-
WEIGHT_LARGE_WAR
public static final int WEIGHT_LARGE_WAR- See Also:
-
WEIGHT_SMALL_SUPPORT
public static final int WEIGHT_SMALL_SUPPORT- See Also:
-
WEIGHT_MEDIUM_SUPPORT
public static final int WEIGHT_MEDIUM_SUPPORT- See Also:
-
WEIGHT_LARGE_SUPPORT
public static final int WEIGHT_LARGE_SUPPORT- See Also:
-
-
Constructor Details
-
ForceDescriptor
public ForceDescriptor()
-
-
Method Details
-
matches
Checks whether the chassis matches the unit type for this node of the force tree. If a list of acceptable chassis has been assigned, checks whether the chassis is in the list. unit type.- Parameters:
cRec- A unit chassis record- Returns:
- Whether the chassis is of the correct unit type and is on the list of acceptable chassis if it exists.
-
matches
If a list of acceptable chassis, models, or variants has been assigned, checks whether the model is among them.- Parameters:
mRec- A unit model record- Returns:
- Whether the model is on the list of acceptable chassis, variants, or models.
-
generateUnits
Goes through the force tree structure and generates units for all leaf nodes. -
generateLance
Generates a lance or other end-level unit (star, level ii) by individual units rather than as an entire formation. Some unit cohesion is attempted for certain unit types, such as building vehicle lances out of the same model or pairing fighter chassis. The equipment rating has an effect on unit cohesion, such that lower rated units are more likely to have mismatched equipment.- Parameters:
subs- The sub forces that describe the individual elements of the lance
-
setUnit
Assigns a specific model to this node of the force tree. If this is a leaf node it will be flagged as an element. If it has child nodes, they will all be made up of the same model unless changed by a rule at a lower level of organization.- Parameters:
unit- The unit to assign to this node.
-
generate
-
generate
-
loadEntities
-
getCombinedDisplayName
Builds the display label for this force, combining the formal name (e.g. "A Company") with the weight + unit-type + formation-type descriptor (e.g. "Heavy Mek Company") into a single string.Matches the layout the
ForceGeneratorViewUitree renderer shows for the same node, so what the user sees in the Force Generator preview matches what the lobby Force View shows after transfer. For lances that lack an explicit name this is the only label available — without it the lobby would render them with a blank name.- Returns:
- "Name (Descriptor)" when both sides are populated, otherwise whichever side is non-blank, or an empty string if neither is set.
-
assignForceIds
public int assignForceIds(int nextId) Assigns a uniqueforceIdto every formation node in this subtree - that is, every node from the lance/star/point level up. Leaf element nodes (the individual units) are skipped: they become entities in the game, not forces, so they need no force id. Must be run after the force tree is fully built and beforeloadEntities(megamek.client.ratgenerator.Ruleset.ProgressListener, double)so the force strings stamped onto entities are collision-free.- Parameters:
nextId- the first id to assign- Returns:
- the next unused id, so a caller can continue numbering a later subtree (e.g. transports)
-
assignCommanders
public void assignCommanders() -
assignPositions
public void assignPositions() -
assignTransport
Calculates transport needs of the unit and generates enough drop-ships and jump ships to carry the indicated portion of the unit. -
decodeWeightClass
-
getWeightClassCode
-
useWeightClass
public boolean useWeightClass() -
recalcWeightClass
public double recalcWeightClass()Weight class can differ from the target once units are generated. Weight class is recalculated based on actual units present and echelon name is set.- Returns:
- The weight class of this force node
-
getAllChildren
-
tallyMekWeightClasses
public int[] tallyMekWeightClasses()Recursively counts the weight class of every BattleMek leaf element in this descriptor, its subforces, and its attachments. Diagnostic helper for verifying that a requested force weight (e.g. an Assault regiment) actually produced the expected unit mix — compare the returned counts against the per-faction subforce tables in the ruleset XML.LandAirMeks are counted as Meks (
Entity.isMek()is true for them). Non-Mek elements (vehicles, infantry, fighters) are ignored.- Returns:
- an int array indexed by
EntityWeightClassconstant (0 = WEIGHT_ULTRA_LIGHT…5 = WEIGHT_SUPER_HEAVY); each slot holds the number of Mek elements at that weight class
-
tallyWeightClassesByType
Tallies every generated element's weight class, grouped by unit type. LiketallyMekWeightClasses()but for all of the weight-classed types the budget allocator governs (Mek, aerospace fighter, vehicle, battle armor), so each type's achieved mix can be measured and tuned independently.- Returns:
- a map from
UnitTypeconstant to a per-weight-class count array, indexed byEntityWeightClass(0 = WEIGHT_ULTRA_LIGHT...5 = WEIGHT_SUPER_HEAVY)
-
getIndex
public int getIndex() -
setIndex
public void setIndex(int index) -
getName
-
parseName
-
cardinalOrdinal
Formats a positive integer as a numeric ordinal with the correct English suffix: 1 -> "1st", 2 -> "2nd", 3 -> "3rd", 4 -> "4th", 11/12/13 -> "th", 21 -> "21st", etc. Used by the{cardinalOrdinal}name token so cluster names read like the canon Touman ("38th Assault Cluster", "202nd Battle Cluster") with no upper bound, unlike the spelled{ordinal}token which stops at "Tenth". -
getDescription
-
setName
-
getFaction
-
setFaction
-
getFactionRec
-
getYear
-
setYear
-
getEchelon
-
getEchelonCode
-
setEchelon
-
getSizeMod
public int getSizeMod() -
setSizeMod
public void setSizeMod(int sizeMod) -
isAugmented
public boolean isAugmented() -
setAugmented
public void setAugmented(boolean augmented) -
getWeightClass
-
setWeightClass
-
getWeightTargets
Per-cluster-type weight budget for this node, keyed by unit type, ornullif none. -
setWeightTargets
-
getUnitType
-
setUnitType
-
getUnitTypeName
-
getMovementModes
-
getRating
-
setRating
-
ratGeneratorRating
Translates between the rating codes used by the force generator and those used by the RAT Generator. The force generator uses abbreviations to make the formation rules more concise.- Returns:
- The RATGenerator rating code corresponding to the same index as the force generator rating code.
-
getRatingLevel
public int getRatingLevel() -
getFormation
-
setFormationType
-
getGenerationRule
-
setGenerationRule
-
getRoles
-
getModels
-
getModelName
-
getChassis
-
getVariants
-
getExperience
-
setExperience
-
getCoRank
-
setCoRank
-
getRankSystem
-
setRankSystem
-
getCo
-
setCo
-
getXo
-
setXo
-
getCamo
-
setCamo
-
setNameNodes
Because some echelon names depend on knowing the actual weight class, we save a copy of the possibilities for this node and defer selection until after the final weight class determination. -
getParent
-
setParent
-
shouldGenerateAttachments
public boolean shouldGenerateAttachments() -
setAttachments
public void setAttachments(boolean attachments) -
getSubForces
-
setSubForces
-
addSubForce
-
getAttached
-
setAttached
-
addAttached
-
isFighterComplement
public boolean isFighterComplement() -
setFighterComplement
public void setFighterComplement(boolean fighterComplement) -
addFighterComplement
public void addFighterComplement()Generates the carried Aerospace Fighter complement of every large craft (WarShip, DropShip, JumpShip, Space Station) in this force and nests it under the carrying ship, so a generated force that includes a carrier also includes the fighters it carries. Each carrier is filled to its ASF bay capacity.Run after unit generation but BEFORE commander/force-id/entity assignment, so the normal passes give the new fighters crews, ids, and entities. Fighters are added via
addAttached(ForceDescriptor)rather than as subforces so the carrier keeps its own crew (assignCommanders only reassigns from subforces), while the ToE still nests them under the ship. -
getDropshipPct
public double getDropshipPct() -
setDropshipPct
public void setDropshipPct(double dropshipPct) -
getJumpshipPct
public double getJumpshipPct() -
setJumpshipPct
public void setJumpshipPct(double jumpshipPct) -
getWarshipPct
public double getWarshipPct() -
setWarshipPct
public void setWarshipPct(double warshipPct) -
getCargo
public double getCargo() -
setCargo
public void setCargo(double cargo) -
getFlags
-
isTopLevel
public boolean isTopLevel() -
setTopLevel
public void setTopLevel(boolean topLevel) -
isElement
public boolean isElement() -
setElement
public void setElement(boolean element) -
getNameIndex
public int getNameIndex() -
getFluffName
-
setFluffName
-
getEntity
-
addAllEntities
-
createChild
-