Class DiceTerm
Represents a dice term, eg 1d4 or 2d6.
Inheritance
Implements
Inherited Members
Namespace: GoRogue.DiceNotation.Terms
Assembly: GoRogue.dll
Syntax
public class DiceTerm : ITerm
Constructors
| Improve this Doc 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. |
Properties
| Improve this Doc 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 |
---|---|
System.Collections.Generic.IEnumerable<System.Int32> |
LastMultiplicity
The result of evaluating the Multiplicity term that was used during the last call to GetResult(IGenerator).
Declaration
public int LastMultiplicity { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
LastSidedness
The result of evaluating the Sides term that was used during the last call to GetResult(IGenerator).
Declaration
public int LastSidedness { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Multiplicity
Term representing the number of dice being rolled -- 2d6 has multiplicity 2.
Declaration
public ITerm Multiplicity { get; }
Property Value
Type | Description |
---|---|
ITerm |
Sides
Term representing the number of sides the dice have -- 2d6 has 6 sides.
Declaration
public ITerm Sides { get; }
Property Value
Type | Description |
---|---|
ITerm |
Methods
| Improve this Doc View SourceGetResult(IGenerator)
Rolls the dice, returning the sum.
Declaration
public int GetResult(IGenerator rng)
Parameters
Type | Name | Description |
---|---|---|
Troschuetz.Random.IGenerator | rng | The RNG to use for rolling, |
Returns
Type | Description |
---|---|
System.Int32 | 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 |
---|---|
System.String | A parenthesized representation of the term. |