Interface Dice

All Known Implementing Classes:
CampaignDice

public interface Dice
The source of random rolls for part destruction checks.

Parts reach it through Campaign.getDice() rather than calling MegaMek's Compute directly, so that a test can supply a fixed sequence of rolls and pin down which parts survive. The default implementation, CampaignDice, delegates to Compute exactly as the parts did before.

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    d6(int numberOfDice)
    Rolls a number of six-sided dice and returns their total.
    int
    randomInt(int maximumValue)
    Returns a random integer from 0 (inclusive) to maximumValue (exclusive).
  • Method Details

    • d6

      int d6(int numberOfDice)
      Rolls a number of six-sided dice and returns their total.
      Parameters:
      numberOfDice - how many six-sided dice to roll
      Returns:
      the sum of the dice
    • randomInt

      int randomInt(int maximumValue)
      Returns a random integer from 0 (inclusive) to maximumValue (exclusive).
      Parameters:
      maximumValue - the exclusive upper bound
      Returns:
      a random integer between 0 and maximumValue - 1