Interface IDice
Represents a collection of Die rolled together, with an optional flat modifier.
public interface IDice
- Extension Methods
Examples
IDice dice = new Dice(2, 6, 3); // 2d6+3
int total = dice.Roll(); // a value in [5, 15]
Remarks
The dice need not be homogeneous; a single Dice can contain dice with differing
side counts, for example 2d6+1d4+3.
Properties
DieCount
The number of dice in the collection.
int DieCount { get; }
Property Value
MaxValue
The maximum value that can be rolled with the dice in the collection and the modifier.
int MaxValue { get; }
Property Value
MinValue
The minimum value that can be rolled with the dice in the collection and the modifier.
int MinValue { get; }
Property Value
Modifier
An optional modifier to add to the total of the dice rolled.
int Modifier { get; }
Property Value
Remarks
The value can be positive or negative, and can be used to adjust the result of the roll.
Methods
Roll()
Rolls every die in the collection and returns the total value rolled, including any modifier.
int Roll()
Returns
- int
The sum of an independent roll of each die in the collection plus Modifier. Always between MinValue and MaxValue inclusive.
ToString()
Returns a string representation of the dice in standard dice notation, for example 2d6+1d4+3.
string ToString()
Returns
- string
The dice grouped by side count, followed by the modifier; dice order is not significant, and the modifier (omitted when zero, leading minus when negative) always comes last.