Record Class BFSDamage

java.lang.Object
java.lang.Record
megamek.common.battlefieldSupport.BFSDamage
Record Components:
perHit - the damage value applied to each rolled location
hits - the number of separate damage groupings
All Implemented Interfaces:
Serializable

public record BFSDamage(int perHit, int hits) extends Record implements Serializable
The damage of a Battlefield Support Asset, stored as a tuple of the damage applied per grouping (perHit) and the number of groupings (hits). The Asset card shows this as perHit x hits (for example 5x4); a single value such as 5 is 5x1, and a blank (-) is 0x0.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BFSDamage
    An Asset with no attack damage (displayed as an em dash).
  • Constructor Summary

    Constructors
    Constructor
    Description
    BFSDamage(int perHit, int hits)
    Creates an instance of a BFSDamage record class.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
     
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the hits record component.
    static BFSDamage
    parse(String text)
    Parses a card display form such as 5x4, 5, - or an em dash into a BFSDamage.
    int
    Returns the value of the perHit record component.
    final String
    Returns a string representation of this record class.
    int
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • NONE

      public static final BFSDamage NONE
      An Asset with no attack damage (displayed as an em dash).
  • Constructor Details

    • BFSDamage

      public BFSDamage(int perHit, int hits)
      Creates an instance of a BFSDamage record class.
      Parameters:
      perHit - the value for the perHit record component
      hits - the value for the hits record component
  • Method Details

    • hasDamage

      public boolean hasDamage()
      Returns:
      true if this Asset deals any damage (both perHit and hits are positive)
    • total

      public int total()
      Returns:
      the total damage dealt across all groupings (perHit * hits)
    • displayString

      public String displayString()
      Returns:
      the card display form: an em dash for no damage, perHit for a single grouping, or perHit x hits otherwise
    • parse

      public static BFSDamage parse(@Nullable String text)
      Parses a card display form such as 5x4, 5, - or an em dash into a BFSDamage. Whitespace is ignored and the x separator is case-insensitive. A null, blank, malformed, out-of-range, - or em dash value yields NONE.
      Parameters:
      text - the card display form to parse
      Returns:
      the parsed damage, never null
    • 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.
    • perHit

      public int perHit()
      Returns the value of the perHit record component.
      Returns:
      the value of the perHit record component
    • hits

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