Class DiceTerm
Represents a dice term, eg 1d4 or 2d6.
Implements
Inherited Members
Namespace: GoRogue.DiceNotation.Terms
Assembly: GoRogue.dll
Syntax
[DataContract]
public class DiceTerm : ITerm
Constructors
View SourceDiceTerm(ITerm, ITerm)
Constructor. Takes the terms representing multiplicity and number of sides.
Declaration
public DiceTerm(ITerm multiplicity, ITerm sides)
Parameters
Type | Name | Description |
---|---|---|
ITerm | multiplicity | Term representing the number of dice being rolled -- 2d6 has multiplicity 2. |
ITerm | sides | Term representing the number of sides the dice have -- 2d6 has 6 sides. |
Fields
View SourceMultiplicity
Term representing the number of dice being rolled -- 2d6 has multiplicity 2.
Declaration
[DataMember]
public readonly ITerm Multiplicity
Field Value
Type | Description |
---|---|
ITerm |
Sides
Term representing the number of sides the dice have -- 2d6 has 6 sides.
Declaration
[DataMember]
public readonly ITerm Sides
Field Value
Type | Description |
---|---|
ITerm |
Properties
View SourceDiceResults
An enumerable of integers representing the result of each dice roll. The expression 2d6 rolls 2 dice, and as such this enumerable would be of length 2 and contain the result of each individual die.
Declaration
public IEnumerable<int> DiceResults { get; }
Property Value
Type | Description |
---|---|
IEnumerable<int> |
LastMultiplicity
The result of evaluating the Multiplicity term that was used during the last call to GetResult(IEnhancedRandom).
Declaration
public int LastMultiplicity { get; }
Property Value
Type | Description |
---|---|
int |
LastSidedness
The result of evaluating the Sides term that was used during the last call to GetResult(IEnhancedRandom).
Declaration
public int LastSidedness { get; }
Property Value
Type | Description |
---|---|
int |
Methods
View SourceGetResult(IEnhancedRandom)
Rolls the dice, returning the sum.
Declaration
public int GetResult(IEnhancedRandom rng)
Parameters
Type | Name | Description |
---|---|---|
IEnhancedRandom | rng | The RNG to use for rolling, |
Returns
Type | Description |
---|---|
int | The sum of the roll. |
ToString()
Gets a parenthesized string representation of the dice term, eg (2d6).
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A parenthesized representation of the term. |