Package megamek.client.ratgenerator
Class AvailabilityRating
java.lang.Object
megamek.client.ratgenerator.AvailabilityRating
Handles availability rating values and calculations for RAT generator. Availability is rated on a base-2 logarithmic
scale from 0 (non-existent) to 10 (ubiquitous), with 6 being a typical value when the source material does not give
an indication of frequency. The availability rating is actually twice the exponent, which allows more precision while
still storing values as integers (so it's really a base-(sqrt(2)) scale, but using 2 as the base should theoretically
be faster).
These values are stored separately for chassis and models; there is one value to indicate the likelihood that a medium Mek is a Phoenix Hawk and another set of values to indicate the likelihood that a give Phoenix Hawk is a 1D or 1K, etc.
These values are stored separately for chassis and models; there is one value to indicate the likelihood that a medium Mek is a Phoenix Hawk and another set of values to indicate the likelihood that a give Phoenix Hawk is a 1D or 1K, etc.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintadjustForRating(int equipRating, int numLevels) Adjust availability rating for the dynamic +/- value, which is based on equipment quality rating.formatAvailability(FactionRecord factionRecord) intintgetAvailability(int equipmentLevelIndex) Returns the availability value, using the provided equipment level if multiple levels are present or the raw value if notintgetAvailability(String equipmentLevel) Returns the availability value, using the provided equipment rating if multiple levels are present or the raw value if notGet the string equivalent of the ratings values.intgetEra()intDeprecated, for removal: This API element is subject to removal in a future version.intdoublebooleanIndicates this availability rating object has different ratings for multiple levels.Creates a copy of this rating for another faction.voidsetAvailability(int availability) voidsetEra(int era) voidsetFaction(String faction) voidsetRatingAdjustment(int ratingAdjustment) Deprecated, for removal: This API element is subject to removal in a future version.voidConverts letter-based equipment level to index-based for working with systems that use itvoidsetRatings(String ratings) voidsetStartYear(int year) voidsetUnitName(String unitName) toString()
-
Field Details
-
LOG_BASE
public static final double LOG_BASE
-
-
Constructor Details
-
AvailabilityRating
- Parameters:
unit- The chassis or model keyera- The era that this availability code applies to.code- A string with the format FKEY[!RATING]:AV[+/-][:YEAR]
examples: LA:7, FS:3+:3024, DC!A:8!B:7
FKEY: the faction key
!RATING: provides direct control over each equipment level. Not compatible with +/- or year values.
AV: an integer that indicates how common this unit is relative to others (chassis or model of same chassis)
+: the indicated av rating applies to the highest equipment rating for the faction (usually A or Keshik) and decreases for each step the rating is reduced.
-: as +, but applies to the lowest equipment rating (F or PGC) and decreases as rating increases.
YEAR: when the unit becomes available to the faction, if later than the beginning of the era. Any year before this within the era will be treated as having no availability.
-
-
Method Details
-
getFaction
-
setFaction
-
getAvailability
public int getAvailability() -
getAvailability
Returns the availability value, using the provided equipment rating if multiple levels are present or the raw value if not- Parameters:
equipmentLevel- name of equipment level, typically one of A/B/C/D/F- Returns:
- availability value for the specified equipment rating string
-
getAvailability
public int getAvailability(int equipmentLevelIndex) Returns the availability value, using the provided equipment level if multiple levels are present or the raw value if not- Parameters:
equipmentLevelIndex- index number of equipment level, typically 0 (F), 1 (D), 2 (C), 3 (B), 4 (A)- Returns:
- availability value for the specified equipment rating value
-
adjustForRating
public int adjustForRating(int equipRating, int numLevels) Adjust availability rating for the dynamic +/- value, which is based on equipment quality rating. The (+) will reduce availability for commands with a lower rating, while the (-) will reduce availability for commands with a higher rating.- Parameters:
equipRating- zero-based index based onnumLevelsof rating to checknumLevels- number of equipment levels available, typically 5 (A/B/C/D/F)- Returns:
- integer, may be negative
-
setAvailability
public void setAvailability(int availability) -
getRatings
-
setRatings
-
setRatingByNumericLevel
Converts letter-based equipment level to index-based for working with systems that use it- Parameters:
fRec- faction-specific record, for equipment levels (typically A/B/C/D/F)
-
getRatingAdjustment
Deprecated, for removal: This API element is subject to removal in a future version. -
setRatingAdjustment
Deprecated, for removal: This API element is subject to removal in a future version. -
hasMultipleRatings
public boolean hasMultipleRatings()Indicates this availability rating object has different ratings for multiple levels.- Returns:
- true if ratings for multiple levels are set
-
getEra
public int getEra() -
setEra
public void setEra(int era) -
getStartYear
public int getStartYear() -
setStartYear
public void setStartYear(int year) -
getUnitName
-
setUnitName
-
getFactionCode
-
getAvailabilityCode
Get the string equivalent of the ratings values. Multiple ratings requires compiling them back into a !RATING:VALUE!RATING:VALUE format- Returns:
- string with properly formatted availability values, without the leading faction code
-
formatAvailability
-
toString
-
makeCopy
Creates a copy of this rating for another faction.The copy is rebuilt from
getAvailabilityCode(), which does not carry the start year, so the year has to be reapplied by hand. Without this the copy would silently revert to the start of the era, and a unit gated to a later year would become available early.Note the copy does not carry
ratingByNumericLevel. Those indexes are resolved against a specific faction's equipment rating system, so a caller copying to a different faction must callsetRatingByNumericLevel(FactionRecord)with the new faction.- Parameters:
newFaction- the faction code the copy is for- Returns:
- the copy
-
getWeight
public double getWeight()
-