Package megamek.client.ratgenerator
Record Class GenerationContext
java.lang.Object
java.lang.Record
megamek.client.ratgenerator.GenerationContext
- Record Components:
faction- theFactionRecordkey, dotted for a sub-command; never blankyear- the year the units were rolled forrating- the equipment rating ("A" to "F", "Keshik", "SL"), ornullwhen none chosensource- which generator produced the units, so a report can say where this came from
public record GenerationContext(String faction, int year, String rating, GenerationContext.Source source)
extends Record
What a player chose when they generated a force: the faction and command it was rolled for, the
year, and the equipment rating. The army generators put all of this on screen and then drop it the
moment the units are added, which leaves the lobby holding a pile of units with no idea what they
were meant to be. Capturing it lets later work organize those units the way the faction actually
organizes its units.
The faction key carries the command as well: a sub-command is written as a dotted key -
"FS.CH" is the Ceti Hussars of the Federated Suns, "CC.SIJ" the St. Ives Janissaries
- so one string answers both "which faction" and "which command". The plain key ("FS") is
the faction at large.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhich generator a force came from. -
Constructor Summary
ConstructorsConstructorDescriptionGenerationContext(String faction, int year, String rating, GenerationContext.Source source) Creates an instance of aGenerationContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic GenerationContextdefaultFor(int year) The fallback when a player generated units without choosing a faction: the Inner Sphere at large, which is what every faction lookup in this package already falls back to.describe()A one-line summary for logs and diagnostics, e.g.final booleanIndicates whether some other object is "equal to" this one.faction()Returns the value of thefactionrecord component.final inthashCode()Returns a hash code value for this object.booleanstatic GenerationContextof(FactionRecord factionRecord, int year, String rating, GenerationContext.Source source) Builds a context from what a generator tab holds, falling back to the Inner Sphere when the tab has no faction selected.rating()Returns the value of theratingrecord component.source()Returns the value of thesourcerecord component.final StringtoString()Returns a string representation of this record class.intyear()Returns the value of theyearrecord component.
-
Constructor Details
-
GenerationContext
public GenerationContext(String faction, int year, @Nullable String rating, GenerationContext.Source source) Creates an instance of aGenerationContextrecord class.
-
-
Method Details
-
defaultFor
The fallback when a player generated units without choosing a faction: the Inner Sphere at large, which is what every faction lookup in this package already falls back to.- Parameters:
year- the year to record- Returns:
- a context naming no particular command
-
of
public static GenerationContext of(@Nullable FactionRecord factionRecord, int year, @Nullable String rating, GenerationContext.Source source) Builds a context from what a generator tab holds, falling back to the Inner Sphere when the tab has no faction selected.- Parameters:
factionRecord- the chosen faction, may benullyear- the chosen yearrating- the chosen equipment rating, may benullor blanksource- which generator this is- Returns:
- the context, never
null
-
hasSubCommand
public boolean hasSubCommand()- Returns:
truewhen the faction key names a command rather than a faction at large
-
parentFaction
- Returns:
- the parent faction key:
"FS"for"FS.CH", unchanged when there is none
-
factionDisplayName
- Returns:
- the faction's display name for the recorded year, falling back to the raw key when the generator data does not know it
-
describe
A one-line summary for logs and diagnostics, e.g."Ceti Hussars, 3067, rating A". Not for display: anything a player reads is built from the parts throughMessagesso it can be translated.- Returns:
- the summary
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
faction
Returns the value of thefactionrecord component.- Returns:
- the value of the
factionrecord component
-
year
public int year()Returns the value of theyearrecord component.- Returns:
- the value of the
yearrecord component
-
rating
Returns the value of theratingrecord component.- Returns:
- the value of the
ratingrecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-