Package megamek.common
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 Summary
ConstructorsConstructorDescriptionTargetRollModifier(int value, String description) Constructs aTargetRollModifierwith the specified value and description.TargetRollModifier(int value, String description, boolean cumulative) Creates an instance of aTargetRollModifierrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of thecumulativerecord component.Returns the value of thedescriptionrecord component.booleanIndicates whether some other object is "equal to" this one.getDesc()final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.intvalue()Returns the value of thevaluerecord component.
-
Constructor Details
-
TargetRollModifier
Constructs aTargetRollModifierwith 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 numberis bad and anegative numberis good.- Parameters:
value- the numeric value of the modifierdescription- a description of the modifier's purpose or source
-
TargetRollModifier
Creates an instance of aTargetRollModifierrecord class.- Parameters:
value- the value for thevaluerecord componentdescription- the value for thedescriptionrecord componentcumulative- the value for thecumulativerecord component
-
-
Method Details
-
value
public int value()Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
getDesc
- Returns:
- The modifier description (attacker jumped)
-
cumulative
public boolean cumulative()Returns the value of thecumulativerecord component.- Returns:
- the value of the
cumulativerecord component
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
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. -
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-