Package megamek.utilities.ratdata
Record Class RatTableContent
java.lang.Object
java.lang.Record
megamek.utilities.ratdata.RatTableContent
- Record Components:
salvagePct- the whole-number chance, 0 to 100, that a drawn unit is replaced by salvageunits- the faction's own units, each an index into the export's unit list with its table weightsalvage- the salvage factions, each an index into the export's faction list with its share of all salvage in units of 1/10000; salvage is rolled after each unit is drawn, so these weights are not in the same pool as the unit weights
public record RatTableContent(int salvagePct, List<RatTableContent.WeightedEntry> units, List<RatTableContent.WeightedEntry> salvage)
extends Record
One random assignment table as the RAT data export stores it: the faction's own units with their weights, the
salvage factions with their weights, and the chance a roll goes to salvage.
The encoding is canonical: entries are sorted by index, so two tables with the same contents always encode to the
same bytes. That is what lets RatDataShard store each distinct table once.
Encoded layout, little-endian:
uint8 salvagePct uint16 unitCount uint16 salvageCount unitCount x (uint16 unitIndex, uint16 weight) salvageCount x (uint16 factionIndex, uint16 weight)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn index into one of the export's lists, with its weight in the table. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA salvage faction's weight is its share of all salvage, out of this total. -
Constructor Summary
ConstructorsConstructorDescriptionRatTableContent(int salvagePct, List<RatTableContent.WeightedEntry> units, List<RatTableContent.WeightedEntry> salvage) Creates an instance of aRatTableContentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]encode()final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.salvage()Returns the value of thesalvagerecord component.intReturns the value of thesalvagePctrecord component.static intsalvagePct(SalvageChance salvageChance) static intsalvageWeight(SalvageChance salvageChance, FactionRecord faction) final StringtoString()Returns a string representation of this record class.units()Returns the value of theunitsrecord component.
-
Field Details
-
SALVAGE_WEIGHT_SCALE
public static final int SALVAGE_WEIGHT_SCALEA salvage faction's weight is its share of all salvage, out of this total.- See Also:
-
-
Constructor Details
-
RatTableContent
public RatTableContent(int salvagePct, List<RatTableContent.WeightedEntry> units, List<RatTableContent.WeightedEntry> salvage) Creates an instance of aRatTableContentrecord class.- Parameters:
salvagePct- the value for thesalvagePctrecord componentunits- the value for theunitsrecord componentsalvage- the value for thesalvagerecord component
-
-
Method Details
-
salvagePct
- Parameters:
salvageChance- the table's salvage chance- Returns:
- the chance that a drawn unit is salvage, rounded to a whole percentage; 0 when there are no salvage sources
-
salvageWeight
- Parameters:
salvageChance- the table's salvage chancefaction- one of its salvage sources- Returns:
- the faction's share of all salvage, in units of 1/10000
-
encode
public byte[] encode()- Returns:
- the canonical byte encoding of this table
-
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 '=='. -
salvagePct
public int salvagePct()Returns the value of thesalvagePctrecord component.- Returns:
- the value of the
salvagePctrecord component
-
units
Returns the value of theunitsrecord component.- Returns:
- the value of the
unitsrecord component
-
salvage
Returns the value of thesalvagerecord component.- Returns:
- the value of the
salvagerecord component
-