Class Roll

java.lang.Object
megamek.common.rolls.Roll
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MMRoll, MMShuffle

public abstract class Roll extends Object implements Serializable
Encapsulate all information known about a requested roll. This information can be logged for full statistical analysis and auditing, so hopefully people will finally stop questioning whether the RNG is any good.
Since:
July 20, 2004, 4:21 PM
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
    The number of faces on each virtual die.
    protected final long
    The unique identifier for this roll.
    protected final int
    The lowest value on each virtual die.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Roll(int count, int start)
    Store the configuration information for this roll.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract int
    Get the value of the roll.
    abstract int[]
    Get the individual dice values of the roll.
    int
    Returns the margin of success/failure of the roll compared to the target roll.
    abstract String
    Get a String report that can be parsed to analyse the roll.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    isTargetRollSuccess(int target)
    Simple check if the total roll of the virtual die is a success.
    boolean
    Simple check if the total roll of the virtual die is a success.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected static void
    output(Roll roll)
    Formats Roll output for test harnesses.
    abstract String
    Get a String containing the roll for each of the virtual dice.

    Methods inherited from class java.lang.Object

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

    • id

      protected final long id
      The unique identifier for this roll.
    • faces

      protected final int faces
      The number of faces on each virtual die.
    • min

      protected final int min
      The lowest value on each virtual die.
  • Constructor Details

    • Roll

      protected Roll(int count, int start)
      Store the configuration information for this roll.
      Parameters:
      count - - the int number of results possible on each virtual die.
      start - - the int value that is the start of the value set of each virtual die.
  • Method Details

    • getIntValue

      public abstract int getIntValue()
      Get the value of the roll. This is the total of each of the rolls of each virtual die.
      Returns:
      the int value of the roll.
    • toString

      public abstract String toString()
      Get a String containing the roll for each of the virtual dice.
      Overrides:
      toString in class Object
      Returns:
      the String value of the roll.
    • getReport

      public abstract String getReport()
      Get a String report that can be parsed to analyse the roll.
      Returns:
      the String details of the roll.
    • output

      protected static void output(Roll roll)
      Formats Roll output for test harnesses.
      Parameters:
      roll - - the Roll to be reported.
    • isTargetRollSuccess

      public boolean isTargetRollSuccess(int target)
      Simple check if the total roll of the virtual die is a success.
      Returns:
      the bool value of the roll, true if success.
    • isTargetRollSuccess

      public boolean isTargetRollSuccess(TargetRoll target)
      Simple check if the total roll of the virtual die is a success.
      Returns:
      the bool value of the roll, true if success.
    • isTargetRollSuccess2isFailure

      @Deprecated(since="0.51.0", forRemoval=true) public boolean isTargetRollSuccess2isFailure(int target)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Simple check if the total roll of the virtual die is a success. Automatic failure on a 2.
      Returns:
      the bool value of the roll, true if success.
    • isTargetRollSuccess2isFailure

      @Deprecated(since="0.51.0", forRemoval=true) public boolean isTargetRollSuccess2isFailure(TargetRoll target)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Simple check if the total roll of the virtual die is a success. Automatic failure on a 2.
      Returns:
      the bool value of the roll, true if success.
    • getIntValues

      public abstract int[] getIntValues()
      Get the individual dice values of the roll.
      Returns:
      the int[] array of the individual dice values.
    • getMarginOfSuccess

      public int getMarginOfSuccess(TargetRoll targetRoll)
      Returns the margin of success/failure of the roll compared to the target roll.
      Parameters:
      targetRoll - the target roll to compare against
      Returns:
      the margin of success/failure
    • isSimpleFailure

      @Deprecated(since="0.51.0", forRemoval=true) public boolean isSimpleFailure()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determines if the roll is a simple failure.
      Returns:
      true if the roll is a simple failure, false otherwise