Package megamek.client.ratgenerator
Class UnitTable
java.lang.Object
megamek.client.ratgenerator.UnitTable
Manages random assignment table generated by RATGenerator.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUnitTable(Parameters key) Initializes table based on restrictions provided by a Parameters object -
Method Summary
Modifier and TypeMethodDescriptionstatic UnitTablefindTable(FactionRecord faction, int unitType, int year, String rating, Collection<Integer> weightClasses, int networkMask, Collection<EntityMovementMode> movementModes, Collection<MissionRole> roles, int roleStrictness) Provided as a convenience to call findTable while using the faction parameter as the deploying factionstatic UnitTablefindTable(FactionRecord faction, int unitType, int year, String rating, Collection<Integer> weightClasses, int networkMask, Collection<EntityMovementMode> movementModes, Collection<MissionRole> roles, int roleStrictness, FactionRecord deployingFaction) Checks the cache for a previously generated table meeting the criteria.static UnitTablefindTable(FactionRecord faction, int unitType, int year, String rating, Collection<Integer> weightClasses, int networkMask, Collection<EntityMovementMode> movementModes, Collection<MissionRole> roles, Collection<MissionRole> rolesExcluded, int roleStrictness, FactionRecord deployingFaction) Overloaded method, with additional argument for excluded rolesstatic UnitTablefindTable(Parameters params) Checks cache for a unit table with the given parameters.Selects a unit from the full table.generateUnit(UnitTable.UnitFilter filter) Selects a unit from the entries in the table that pass the filtergenerateUnits(int num) Selects a number of units from the table.generateUnits(int num, UnitTable.UnitFilter filter) Selects a number of units from the table with a filter.intgetBV(int index) getEntryText(int index) intgetEntryWeight(int index) getMekSummary(int index) intgetTechBase(int index) getUnitRole(int index) booleanhasUnits()
-
Constructor Details
-
UnitTable
Initializes table based on restrictions provided by a Parameters object- Parameters:
key- aParametersstructure providing the parameters for generating the table
-
-
Method Details
-
findTable
public static UnitTable findTable(FactionRecord faction, int unitType, int year, String rating, Collection<Integer> weightClasses, int networkMask, Collection<EntityMovementMode> movementModes, Collection<MissionRole> roles, int roleStrictness, FactionRecord deployingFaction) Checks the cache for a previously generated table meeting the criteria. If none is found, generates it and adds it to the cache. This method is provided as a convenience for when there are no excluded roles.- Parameters:
faction- The faction the table filters forunitType-UnitTypeconstant with the type of unityear- the game yearrating- the unit's equipment rating; if null, the table is not adjusted for unit rating.weightClasses- a collection ofEntityWeightClassconstants to include in the table; if null or empty all weight classes are includednetworkMask- One of theModelRecordNETWORK constants, for filtering various C3 systemsmovementModes- the movement modes covered by the table, null/empty for all modesroles-MissionRoletypes the units should qualify for, null/empty for no role filteringroleStrictness- how strongly to apply roles, zero for none/minimal with higher being more restrictive; typically no higher than 5deployingFaction- when using the salvage/isorla mechanism, any omni unit will select the configuration based on the faction actually deploying- Returns:
- table containing units which fit all parameters and their relative weights
-
findTable
public static UnitTable findTable(FactionRecord faction, int unitType, int year, String rating, Collection<Integer> weightClasses, int networkMask, Collection<EntityMovementMode> movementModes, Collection<MissionRole> roles, Collection<MissionRole> rolesExcluded, int roleStrictness, FactionRecord deployingFaction) Overloaded method, with additional argument for excluded roles- Parameters:
faction- The faction the table filters forunitType-UnitTypeconstant with the type of unityear- the game yearrating- the unit's equipment rating; if null, the table is not adjusted for unit rating.weightClasses- collection ofEntityWeightClassconstants to include in the table; if null or empty all weight classes are includednetworkMask- One of theModelRecordNETWORK constants, for filtering various C3 systemsmovementModes- the movement modes covered by the table, null/empty for all modesroles-MissionRoletypes the units should qualify for, null/empty for no role filteringrolesExcluded-MissionRoletypes the units should not contain, null empty to allow all rolesroleStrictness- how strongly to apply roles, zero for none/minimal with higher being more restrictive; typically no higher than 5deployingFaction- when using the salvage/isorla mechanism, any omni unit will select the configuration based on the faction actually deploying- Returns:
- table containing units which fit all parameters and their relative weights
-
findTable
public static UnitTable findTable(FactionRecord faction, int unitType, int year, String rating, Collection<Integer> weightClasses, int networkMask, Collection<EntityMovementMode> movementModes, Collection<MissionRole> roles, int roleStrictness) Provided as a convenience to call findTable while using the faction parameter as the deploying faction -
findTable
Checks cache for a unit table with the given parameters. If none is found, generates one and adds to the cache using a copy of the Parameters object as a key.- Parameters:
params- - the parameters to use in generating the table.- Returns:
- a generated table matching the parameters
-
getNumEntries
public int getNumEntries()- Returns:
- - number of entries in the table
-
getEntryWeight
public int getEntryWeight(int index) - Parameters:
index- index of the Weight- Returns:
- - the weight value for the entry at the indicated index
-
getEntryText
- Parameters:
index- index of the Text- Returns:
- - a string representing the entry at the indicated index for use in the table
-
getTechBase
- Parameters:
index- index of the Tech Base- Returns:
- - a string representing the entry at the indicated index for use in the table
-
getUnitRole
- Parameters:
index- index of the Unit Role- Returns:
- - a string representing the entry at the indicated index for use in the table
-
getMekSummary
- Parameters:
index- of theMekSummary- Returns:
- - the MekSummary entry for the indicated index, or null if this is a salvage entry
-
getBV
public int getBV(int index) - Parameters:
index- of the BV- Returns:
- - the BV of the unit at the indicated index, or 0 if this is a salvage entry
-
hasUnits
public boolean hasUnits()- Returns:
- true if the generated table has any unit entries
-
generateUnit
Selects a unit from the full table.- Returns:
- the selected unit
-
generateUnit
Selects a unit from the entries in the table that pass the filter- Parameters:
filter- - the function that determines which units are permitted; if null, no filter is applied.- Returns:
- - the selected unit, or null if no units pass the filter.
-
generateUnits
Selects a number of units from the table.- Parameters:
num- - the number of units to be generated.- Returns:
- - a list of randomly generated units
-
generateUnits
Selects a number of units from the table with a filter.- Parameters:
num- - the number of units to be generated.filter- - the function that determines which units are permitted; if null, no filter is applied.- Returns:
- - a list of randomly generated units
-