Package megamek.client.generator
Class RandomUnitGenerator
java.lang.Object
megamek.client.generator.RandomUnitGenerator
- All Implemented Interfaces:
Serializable
This class sets up a random unit generator that can then be used to read in user-created input files of random
assignment tables
Files must be located in the directory defined by Configuration.armyTablesDir(). All files should
comma-delimited text files.
The first line of the file should contain the title of the RAT The second line of the file should give the unit type number corresponding to UnitType.java The remaining lines should be comma split. The first field should give the frequency of that unit and the second line should give the name of that unit written as { Model } { Chassis }. Comment lines can also be added with "#".
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPlain old data class used to represent nodes in a Random Assignment Table tree. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidgenerate(int numRolls) Generate a list of units from the RATgenerate(int numRolls, String ratName, Predicate<MekSummary> filter) Generate a list of units from the RAT.generate(int numRolls, Predicate<MekSummary> filter) static RandomUnitGeneratorprotected MekSummarygetMekByName(String name) protected doubleprotected voidbooleanvoidNotifies all the listeners that initialization is finishedvoidvoidvoid
-
Constructor Details
-
RandomUnitGenerator
public RandomUnitGenerator()
-
-
Method Details
-
initRatTree
protected void initRatTree() -
populateUnits
public void populateUnits() -
registerListener
-
notifyListenersOfInitialization
public void notifyListenersOfInitialization()Notifies all the listeners that initialization is finished -
addRat
-
generate
Generate a list of units from the RAT- Returns:
- - a string giving the name
-
generate
Generate a list of units from the RAT.- Parameters:
numRolls- - the number of units to roll from the RATratName- - name of the RAT to roll onfilter- - entries in the RAT must pass this condition to be included. If null, no filter is applied.- Returns:
- - a list of units determined by the random rolls
-
getMekByName
-
getRandom
protected double getRandom() -
generate
-
generate
-
getRatMap
-
getChosenRAT
-
setChosenRAT
-
getRatList
-
getRatTree
-
getInstance
-
isInitialized
public boolean isInitialized()
-