Record Class BFSRange

java.lang.Object
java.lang.Record
megamek.common.battlefieldSupport.BFSRange
Record Components:
shortRange - the short-range band in hexes, or -1 for a keyword range
mediumRange - the medium-range band in hexes, or -1 for a keyword range
longRange - the long-range band in hexes, or -1 for a keyword range
All Implemented Interfaces:
Serializable

public record BFSRange(int shortRange, int mediumRange, int longRange) extends Record implements Serializable
The Short/Medium/Long range of a Battlefield Support Asset, in hexes. The Asset card shows this as short/medium/long (for example 3/6/9).

Assets whose single attack is not a standard ranged attack - for example Artillery or Arrow assets, or Assets with no ranged attack at all - use KEYWORD (all three values set to -1). In that case the display form is a keyword label (such as Artillery or Arrow) derived from the Asset's Specials, or an em dash when no keyword applies.

See Also:
  • Field Details

    • KEYWORD

      public static final BFSRange KEYWORD
      A non-standard range represented by a keyword (Artillery, Arrow, or none).
  • Constructor Details

    • BFSRange

      public BFSRange(int shortRange, int mediumRange, int longRange)
      Creates an instance of a BFSRange record class.
      Parameters:
      shortRange - the value for the shortRange record component
      mediumRange - the value for the mediumRange record component
      longRange - the value for the longRange record component
  • Method Details

    • isKeyword

      public boolean isKeyword()
      Returns:
      true if this is a keyword range (all three bands negative) rather than a numeric S/M/L range
    • displayString

      public String displayString(@Nullable String keywordLabel)
      Returns the card display form of this range. For a numeric range this is short/medium/long. For a keyword range (see isKeyword()) the given keywordLabel is returned, or an em dash when it is null/blank.
      Parameters:
      keywordLabel - the label to show for a keyword range (for example Artillery)
      Returns:
      the display form
    • displayString

      public String displayString()
      Returns:
      the numeric display form, or an em dash for a keyword range with no label
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • shortRange

      public int shortRange()
      Returns the value of the shortRange record component.
      Returns:
      the value of the shortRange record component
    • mediumRange

      public int mediumRange()
      Returns the value of the mediumRange record component.
      Returns:
      the value of the mediumRange record component
    • longRange

      public int longRange()
      Returns the value of the longRange record component.
      Returns:
      the value of the longRange record component