Class RandomOperationNameGenerator
java.lang.Object
mekhq.campaign.mission.contract.contractGeneration.RandomOperationNameGenerator
Supplies the two word pools used to build a contract's operation codename (for example,
RED and EAGLE
in "Operation RED EAGLE"). One shared, objective-agnostic descriptor pool provides the leading modifier; a
per-ContractObjectiveType noun pool provides the head word, which is where the objective flavor
lives. A name is one weighted draw from the descriptor pool combined with one weighted draw from the objective's noun
pool, so a pool of D descriptors and N nouns yields D * N distinct names per objective.
Structured after RandomCompanyNameGenerator: a lazily created,
double-checked singleton whose pools are populated on background threads from word,weight CSV files (a base
file plus an optional userdata/ override merged on top). The file paths are the explicit per-pool constants
in MHQConstants.
Save File Formatting: word,weight. The word is a String that does not include a ',';
weight is an integer weight used during generation. The first line of each file is a header and is skipped.
-
Method Summary
Modifier and TypeMethodDescriptionDraws a random descriptor (the leading modifier word).generateNoun(ContractObjectiveType objectiveType) Draws a random noun (the head word) themed to the given objective.static RandomOperationNameGeneratorReturns the singleton instance, creating and kicking off initialization of every word pool on first use.static megamek.common.util.weightedMaps.WeightedIntMap<String> static megamek.common.util.weightedMaps.WeightedIntMap<String> getWeightedNoun(ContractObjectiveType objectiveType) static voidsetWeightedDescriptor(megamek.common.util.weightedMaps.WeightedIntMap<String> weightedDescriptor)
-
Method Details
-
getWeightedDescriptor
-
setWeightedDescriptor
public static void setWeightedDescriptor(megamek.common.util.weightedMaps.WeightedIntMap<String> weightedDescriptor) -
getWeightedNoun
public static megamek.common.util.weightedMaps.WeightedIntMap<String> getWeightedNoun(ContractObjectiveType objectiveType) -
getInstance
Returns the singleton instance, creating and kicking off initialization of every word pool on first use. Applies the double-checked locking pattern so only one instance is ever created.- Returns:
- the
RandomOperationNameGeneratorinstance
-
generateDescriptor
Draws a random descriptor (the leading modifier word).- Returns:
- a weighted-random descriptor, or
nullif the pool is not yet initialized or is empty
-
generateNoun
Draws a random noun (the head word) themed to the given objective. Falls back to theContractObjectiveType.UNDEFINEDpool when the objective's own pool is empty (for example, when its data file is missing).- Parameters:
objectiveType- the contract's objective, selecting the noun pool- Returns:
- a weighted-random noun, or
nullif no pool is available or initialized
-