megamek.common
Class TargetRoll

java.lang.Object
  extended by megamek.common.TargetRoll
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
PilotingRollData, ToHitData

public class TargetRoll
extends java.lang.Object
implements java.io.Serializable

Keeps track of a target for a roll. Allows adding modifiers with descriptions, including appending the modifiers in another TargetRoll. Intended for rolls like a to-hit roll or a piloting skill check.

Version:
Author:
Ben
See Also:
Serialized Form

Field Summary
static int AUTOMATIC_FAIL
           
static int AUTOMATIC_SUCCESS
           
static int CHECK_FALSE
           
static int IMPOSSIBLE
           
 
Constructor Summary
TargetRoll()
          Creates new TargetRoll
TargetRoll(int value, java.lang.String desc)
          Creates a new TargetRoll with a base value & desc
TargetRoll(int value, java.lang.String desc, boolean cumulative)
          Creates a new TargetRoll with a base value & desc, which is possibly not cumulative
 
Method Summary
 void addModifier(int value, java.lang.String desc)
           
 void addModifier(int value, java.lang.String desc, boolean cumulative)
           
 void addModifier(megamek.common.TargetRoll.Modifier modifier)
           
 void append(TargetRoll other)
          Append another TargetRoll to the end of this one
 void append(TargetRoll other, boolean appendNonCumulative)
          Append another TargetRoll to the end of this one, possibly ignoring non-cumulative Modifier in the other one
 java.lang.String getCumulativePlainDesc()
          Returns the description of the first cumulative Modifier
 java.lang.String getDesc()
          Returns a description of all applicable modifiers
 java.lang.String getLastPlainDesc()
          Returns the last description found
 java.lang.String getPlainDesc()
          Returns the first description found
 int getValue()
          Returns the total value of all modifiers
 java.lang.String getValueAsString()
          Returns the total value of all modifiers
 void removeAutos()
          Remove all automatic failures or successes, but leave impossibles intact
 void removeAutos(boolean removeImpossibles)
          Remove all automatic failures or successes, and possibly also remove impossibles
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMPOSSIBLE

public static final int IMPOSSIBLE
See Also:
Constant Field Values

AUTOMATIC_FAIL

public static final int AUTOMATIC_FAIL
See Also:
Constant Field Values

AUTOMATIC_SUCCESS

public static final int AUTOMATIC_SUCCESS
See Also:
Constant Field Values

CHECK_FALSE

public static final int CHECK_FALSE
See Also:
Constant Field Values
Constructor Detail

TargetRoll

public TargetRoll()
Creates new TargetRoll


TargetRoll

public TargetRoll(int value,
                  java.lang.String desc)
Creates a new TargetRoll with a base value & desc


TargetRoll

public TargetRoll(int value,
                  java.lang.String desc,
                  boolean cumulative)
Creates a new TargetRoll with a base value & desc, which is possibly not cumulative

Parameters:
value -
desc -
cumulative -
Method Detail

getValue

public int getValue()
Returns the total value of all modifiers


getValueAsString

public java.lang.String getValueAsString()
Returns the total value of all modifiers


getDesc

public java.lang.String getDesc()
Returns a description of all applicable modifiers


getPlainDesc

public java.lang.String getPlainDesc()
Returns the first description found


getCumulativePlainDesc

public java.lang.String getCumulativePlainDesc()
Returns the description of the first cumulative Modifier

Returns:

getLastPlainDesc

public java.lang.String getLastPlainDesc()
Returns the last description found


addModifier

public void addModifier(int value,
                        java.lang.String desc)

addModifier

public void addModifier(int value,
                        java.lang.String desc,
                        boolean cumulative)

addModifier

public void addModifier(megamek.common.TargetRoll.Modifier modifier)

append

public void append(TargetRoll other)
Append another TargetRoll to the end of this one


append

public void append(TargetRoll other,
                   boolean appendNonCumulative)
Append another TargetRoll to the end of this one, possibly ignoring non-cumulative Modifier in the other one

Parameters:
other -
appendNonCumulative -

removeAutos

public void removeAutos()
Remove all automatic failures or successes, but leave impossibles intact


removeAutos

public void removeAutos(boolean removeImpossibles)
Remove all automatic failures or successes, and possibly also remove impossibles

Parameters:
removeImpossibles - boolean value wether or not impossibles should be removed