Package megamek.client.generator
Class TeamLoadOutGenerator
java.lang.Object
megamek.client.generator.TeamLoadOutGenerator
Notes: check out - RATGenerator.java - ForceDescriptor.java for era-based search examples
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected int
protected String
protected boolean
protected GameOptions
protected int
protected SimpleTechLevel
static final String
protected boolean
protected boolean
static float
static Properties
-
Constructor Summary
ConstructorsConstructorDescriptionTeamLoadOutGenerator
(Game ownerGame) TeamLoadOutGenerator
(Game ownerGame, String defaultSettings) Deprecated, for removal: This API element is subject to removal in a future version.No indicated uses. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
applyWeightsToMunitionTree
(megamek.client.generator.MunitionWeightCollection mwc, MunitionTree mt) Turn a selection of the computed munition weights into imperatives to load in the MunitionTreestatic Double
castPropertyDouble
(String field, Double defValue) Use values from the Properties file defined in TeamLoadOutGenerator class if available; else use provided defaultstatic int
castPropertyInt
(String field, int defValue) boolean
checkLegality
(AmmoType aType, String faction, String techBase, boolean mixedTech) Calculates legality of ammo types given a faction, tech base (IS/CL), mixed tech, and the instance's already-set year, tech level, and option for showing extinct equipment.protected void
clampAmmoShots
(Entity entity, float binFillRatio) Applies specified ammo fill ratio to all binsint[]
generateExternalOrdnance
(int bombUnits, boolean airOnly, boolean isPirate, int quality, int year, String faction, String techBase, boolean mixedTech) Randomly generate a set of external ordnance up to the number of indicated bomb units.static MunitionTree
generateMunitionTree
(ReconfigurationParameters rp, ArrayList<Entity> entities, String defaultSettingsFile) static MunitionTree
generateMunitionTree
(ReconfigurationParameters reconfigurationParameters, ArrayList<Entity> ownTeamEntities, String defaultSettingsFile, megamek.client.generator.MunitionWeightCollection mwc) Generate the list of desired ammo load-outs for this team.Deprecated, for removal: This API element is subject to removal in a future version.Not inidicated uses.generateParameters
(ArrayList<Entity> ownEntities, String ownFaction, Team t) static ReconfigurationParameters
generateParameters
(ArrayList<Entity> ownTeamEntities, ArrayList<Entity> etEntities, String friendlyFaction, ArrayList<String> enemyFactions, boolean blind, boolean darkEnvironment, boolean groundMap, boolean spaceEnvironment, int rating, float fillRatio) static ReconfigurationParameters
generateParameters
(Game g, GameOptions gOpts, ArrayList<Entity> ownEntities, String friendlyFaction, ArrayList<Entity> enemyEntities, ArrayList<String> enemyFactions, int rating, float fillRatio) static ReconfigurationParameters
generateParameters
(Game g, GameOptions gOpts, ArrayList<Entity> ownEntities, String friendlyFaction, Team team) Create the parameters that will determine how to configure ammo loadouts for this teamgenerateParameters
(Team team) static MunitionTree
boolean
Deprecated, for removal: This API element is subject to removal in a future version.not in use.void
populateAeroBombs
(List<Entity> entityList, int year, boolean hasGroundTargets, int quality, boolean isPirate, String faction) Helper function to load bombs onto a random portion of units that can carry themvoid
randomizeBotTeamConfiguration
(Team team, String faction) Configure Bot Team with all munitions randomizedvoid
reconfigureAero
(Entity e, MunitionTree mt, String faction) TODO: implement in 0.50.1 with other new errata changes This method should mirror reconfigureEntity but with more restrictions based on the types of alternate munitions allowed by Aerospace rules.void
reconfigureBotTeamWithDefaults
(Team team, String faction) Deprecated, for removal: This API element is subject to removal in a future version.- no indicated uses.void
reconfigureEntities
(ArrayList<Entity> entities, String faction, MunitionTree mt, ReconfigurationParameters reconfigurationParameters) More generic reconfiguration function that acts on sets of units, not teamsvoid
reconfigureEntity
(Entity e, MunitionTree mt, String faction) Wrapper that assumes full bins, mostly for testingvoid
reconfigureEntity
(Entity entity, MunitionTree mt, String faction, float binFillRatio) Method to apply a MunitionTree to a specific unit.void
reconfigureTeam
(Team team, String faction, String adfFile) Wrapper to load a file of preset munition imperativesvoid
setTrueRandom
(boolean value) void
void
updateOptionValues
(GameOptions gameOpts)
-
Field Details
-
LOAD_OUT_SETTINGS_PATH
-
weightProperties
-
UNSET_FILL_RATIO
public static float UNSET_FILL_RATIO -
AP_MUNITIONS
-
FLAK_MUNITIONS
-
ACCURATE_MUNITIONS
-
HIGH_POWER_MUNITIONS
-
ANTI_INF_MUNITIONS
-
ANTI_BA_MUNITIONS
-
HEAT_MUNITIONS
-
ILLUMINATION_MUNITIONS
-
UTILITY_MUNITIONS
-
GUIDED_MUNITIONS
-
TAG_GUIDED_MUNITIONS
-
NARC_GUIDED_MUNITIONS
-
SEEKING_MUNITIONS
-
AMMO_REDUCING_MUNITIONS
-
TYPE_LIST
-
TYPE_MAP
-
gameOptions
-
allowedYear
protected int allowedYear -
gameTechLevel
protected int gameTechLevel -
legalLevel
-
eraBasedTechLevel
protected boolean eraBasedTechLevel -
advAeroRules
protected boolean advAeroRules -
showExtinct
protected boolean showExtinct -
trueRandom
protected boolean trueRandom -
defaultBotMunitionsFile
-
-
Constructor Details
-
TeamLoadOutGenerator
-
TeamLoadOutGenerator
@Deprecated(since="0.50.05", forRemoval=true) public TeamLoadOutGenerator(Game ownerGame, String defaultSettings) Deprecated, for removal: This API element is subject to removal in a future version.No indicated uses.- Since:
- 0.50.05
-
-
Method Details
-
updateOptionValues
public void updateOptionValues() -
updateOptionValues
-
checkLegality
Calculates legality of ammo types given a faction, tech base (IS/CL), mixed tech, and the instance's already-set year, tech level, and option for showing extinct equipment.- Parameters:
aType
- the AmmoType of the munition under consideration. q.v.faction
- MM-style faction code, per factions.xml and FactionRecord keystechBase
- either 'IS' or 'CL', used for clan boolean check.mixedTech
- makes munitions checks more lenient by allowing faction to access both IS and CL tech bases.- Returns:
- boolean true if legal for combination of inputs, false otherwise. Determines if an AmmoType is loaded.
-
castPropertyDouble
Use values from the Properties file defined in TeamLoadOutGenerator class if available; else use provided default- Parameters:
field
- Field name in property filedefValue
- Default value to use- Returns:
- Double read value or default
-
castPropertyInt
-
setTrueRandom
public void setTrueRandom(boolean value) -
getTrueRandom
Deprecated, for removal: This API element is subject to removal in a future version.not in use. -
generateParameters
-
generateParameters
public ReconfigurationParameters generateParameters(ArrayList<Entity> ownEntities, String ownFaction, Team t) -
generateParameters
public static ReconfigurationParameters generateParameters(Game g, GameOptions gOpts, ArrayList<Entity> ownEntities, String friendlyFaction, Team team) Create the parameters that will determine how to configure ammo loadouts for this team- Parameters:
g
-Game
ObjectgOpts
-GameOptions
ObjectownEntities
-Entity
List of own entitiesfriendlyFaction
- Friendly Faction Nameteam
-Team
Object- Returns:
- ReconfigurationParameters with information about enemy and friendly forces
-
generateParameters
public static ReconfigurationParameters generateParameters(Game g, GameOptions gOpts, ArrayList<Entity> ownEntities, String friendlyFaction, ArrayList<Entity> enemyEntities, ArrayList<String> enemyFactions, int rating, float fillRatio) -
generateParameters
-
generateMunitionTree
@Deprecated(since="0.50.05", forRemoval=true) public MunitionTree generateMunitionTree(ReconfigurationParameters rp, Team team) Deprecated, for removal: This API element is subject to removal in a future version.Not inidicated uses. -
generateMunitionTree
public static MunitionTree generateMunitionTree(ReconfigurationParameters rp, ArrayList<Entity> entities, String defaultSettingsFile) -
generateMunitionTree
public static MunitionTree generateMunitionTree(ReconfigurationParameters reconfigurationParameters, ArrayList<Entity> ownTeamEntities, String defaultSettingsFile, megamek.client.generator.MunitionWeightCollection mwc) Generate the list of desired ammo load-outs for this team. TODO: implement generateDetailedMunitionTree with more complex breakdowns per unit type NOTE: if sub-classing this generator, should only need to override this method.- Parameters:
reconfigurationParameters
-ReconfigurationParameters
ObjectdefaultSettingsFile
- File name to settings file.- Returns:
- generated MunitionTree with imperatives for each weapon type
-
applyWeightsToMunitionTree
public static void applyWeightsToMunitionTree(megamek.client.generator.MunitionWeightCollection mwc, MunitionTree mt) Turn a selection of the computed munition weights into imperatives to load in the MunitionTree- Parameters:
mt
-MunitionTree
Objectmwc
-MunitionWeightCollection
Object
-
reconfigureBotTeamWithDefaults
@Deprecated(since="0.50.05", forRemoval=true) public void reconfigureBotTeamWithDefaults(Team team, String faction) Deprecated, for removal: This API element is subject to removal in a future version.- no indicated uses.Wrapper to streamline bot team configuration using standardized defaults -
reconfigureTeam
Wrapper to load a file of preset munition imperatives- Parameters:
team
-Team
Objectfaction
- Related FactionadfFile
- Munitions File.
-
reconfigureEntities
public void reconfigureEntities(ArrayList<Entity> entities, String faction, MunitionTree mt, ReconfigurationParameters reconfigurationParameters) More generic reconfiguration function that acts on sets of units, not teams- Parameters:
entities
- ArrayList of entities, including ground and air unitsfaction
- String code for entities' main factionmt
- MunitionTree defining all applicable load out imperatives
-
randomizeBotTeamConfiguration
Configure Bot Team with all munitions randomized- Parameters:
team
-Team
Objectfaction
- Related Faction to team
-
generateRandomizedMT
-
reconfigureEntity
Wrapper that assumes full bins, mostly for testing- Parameters:
e
-Entity
with Ammo Binsmt
-MunitionTree
Ammo usedfaction
- Related Faction
-
reconfigureEntity
Method to apply a MunitionTree to a specific unit. Main application logic- Parameters:
entity
-Entity
with Ammo Binsmt
-MunitionTree
Ammo usedfaction
- Related FactionbinFillRatio
- float setting the max fill rate for all bins in this entity (mostly for Pirates)
-
clampAmmoShots
Applies specified ammo fill ratio to all bins- Parameters:
entity
-Entity
Unit tow work with.binFillRatio
- How full to make bins.
-
reconfigureAero
TODO: implement in 0.50.1 with other new errata changes This method should mirror reconfigureEntity but with more restrictions based on the types of alternate munitions allowed by Aerospace rules.- Parameters:
e
-Entity
Unit to work with.mt
-MunitionTree
Ammo Treefaction
- Related Faction
-
populateAeroBombs
public void populateAeroBombs(List<Entity> entityList, int year, boolean hasGroundTargets, int quality, boolean isPirate, String faction) Helper function to load bombs onto a random portion of units that can carry them- Parameters:
entityList
- The list of entities to processhasGroundTargets
- true to select air-to-ground ordnance, false for air-to-air onlyquality
- IUnitRating enum for force quality (A/A* through F)isPirate
- true to use specific pirate ordnance loadouts
-
generateExternalOrdnance
public int[] generateExternalOrdnance(int bombUnits, boolean airOnly, boolean isPirate, int quality, int year, String faction, String techBase, boolean mixedTech) Randomly generate a set of external ordnance up to the number of indicated bomb units. Lower rated forces are more likely to get simpler types (HE and rockets). Because TAG is only useful as one-per-fighter, it should be handled elsewhere.- Parameters:
bombUnits
- how many bomb units to generate, some types count as more than one unit so returned counts may be lower than this but never higherairOnly
- true to only select air-to-air ordnanceisPirate
- true if force is pirate, specific low-tech/high chaos selectionsquality
- force rating to work withyear
- current year, for tech filter- Returns:
- array of integers, with each element being a bomb count using BombUnit enums as the lookup e.g. [BombUnit.HE] will get the number of HE bombs.
-