Record Class TargetRollModifier

java.lang.Object
java.lang.Record
megamek.common.TargetRollModifier
All Implemented Interfaces:
Serializable

public record TargetRollModifier(int value, String description, boolean cumulative) extends Record implements Serializable
This class represents individual modifiers for a TargetRoll. Each modifier has a value, the actual modifier like +1 or -2 or one of the finalizers like TargetRoll.AUTOMATIC_FAIL, a description (attacker jumped) and indicates if it is cumulative. Note: This class is immutable.

WARNING: it is important to note that this is a modifier to the Target Number and not the roll. That means that a positive number is bad and a negative number is good.

See Also:
  • Constructor Details

    • TargetRollModifier

      public TargetRollModifier(int value, String description)
      Constructs a TargetRollModifier with the specified value and description.

      WARNING: it is important to note that this is a modifier to the Target Number and not the roll. That means that a positive number is bad and a negative number is good.

      Parameters:
      value - the numeric value of the modifier
      description - a description of the modifier's purpose or source
    • TargetRollModifier

      public TargetRollModifier(int value, String description, boolean cumulative)
      Creates an instance of a TargetRollModifier record class.
      Parameters:
      value - the value for the value record component
      description - the value for the description record component
      cumulative - the value for the cumulative record component
  • Method Details

    • value

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

      public String getDesc()
      Returns:
      The modifier description (attacker jumped)
    • cumulative

      public boolean cumulative()
      Returns the value of the cumulative record component.
      Returns:
      the value of the cumulative record component
    • equals

      public 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. Reference components are compared with Objects::equals(Object,Object); primitive components 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.
    • 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
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component