Record Class BFSDamage
java.lang.Object
java.lang.Record
megamek.common.battlefieldSupport.BFSDamage
- Record Components:
perHit- the damage value applied to each rolled locationhits- the number of separate damage groupings
- All Implemented Interfaces:
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 -
Constructor Summary
ConstructorsConstructorDescriptionBFSDamage(int perHit, int hits) Creates an instance of aBFSDamagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.booleanfinal inthashCode()Returns a hash code value for this object.inthits()Returns the value of thehitsrecord component.static BFSDamageintperHit()Returns the value of theperHitrecord component.final StringtoString()Returns a string representation of this record class.inttotal()
-
Field Details
-
NONE
An Asset with no attack damage (displayed as an em dash).
-
-
Constructor Details
-
Method Details
-
hasDamage
public boolean hasDamage()- Returns:
- true if this Asset deals any damage (both
perHitandhitsare positive)
-
total
public int total()- Returns:
- the total damage dealt across all groupings (
perHit * hits)
-
displayString
- Returns:
- the card display form: an em dash for no damage,
perHitfor a single grouping, orperHit x hitsotherwise
-
parse
Parses a card display form such as5x4,5,-or an em dash into aBFSDamage. Whitespace is ignored and thexseparator is case-insensitive. Anull, blank, malformed, out-of-range,-or em dash value yieldsNONE.- Parameters:
text- the card display form to parse- Returns:
- the parsed damage, never
null
-
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. All components in this record class are compared with '=='. -
perHit
public int perHit()Returns the value of theperHitrecord component.- Returns:
- the value of the
perHitrecord component
-
hits
public int hits()Returns the value of thehitsrecord component.- Returns:
- the value of the
hitsrecord component
-