Class DiceExpression
The default class for representing a parsed dice expression.
Inherited Members
Namespace: GoRogue.DiceNotation
Assembly: GoRogue.dll
Syntax
[DataContract]
public class DiceExpression
Constructors
View SourceDiceExpression(ITerm)
Constructor. Takes the last term in the dice expression (the root of the expression tree).
Declaration
public DiceExpression(ITerm rootTerm)
Parameters
Type | Name | Description |
---|---|---|
ITerm | rootTerm | The root of the expression tree -- by evaluating this term, all others will be evaluated recursively. |
Fields
View SourceRootTerm
The root term in this expression tree.
Declaration
[DataMember]
public readonly ITerm RootTerm
Field Value
Type | Description |
---|---|
ITerm |
Methods
View SourceMaxRoll()
Returns the maximum possible result of the dice expression.
Declaration
public int MaxRoll()
Returns
Type | Description |
---|---|
int | The maximum possible result of the dice expression. |
MinRoll()
Returns the minimum possible result of the dice expression.
Declaration
public int MinRoll()
Returns
Type | Description |
---|---|
int | The minimum possible result of the dice expression. |
Roll(IEnhancedRandom?)
Rolls the expression using the RNG given, returning the result.
Declaration
public int Roll(IEnhancedRandom? rng = null)
Parameters
Type | Name | Description |
---|---|---|
IEnhancedRandom | rng | The RNG to use. If null is specified, the default RNG is used. |
Returns
Type | Description |
---|---|
int | The result obtained by rolling the dice expression. |
ToString()
Returns a parenthesized string representing the dice expression in dice notation
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A parenthesized string representing the expression. |