Show / Hide Table of Contents

Class DiceTerm

Represents a dice term, eg 1d4 or 2d6.

Inheritance
object
DiceTerm
Implements
ITerm
Inherited Members
object.GetType()
object.MemberwiseClone()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: GoRogue.DiceNotation.Terms
Assembly: GoRogue.dll
Syntax
[DataContract]
public class DiceTerm : ITerm

Constructors

View Source

DiceTerm(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 Source

Multiplicity

Term representing the number of dice being rolled -- 2d6 has multiplicity 2.

Declaration
[DataMember]
public readonly ITerm Multiplicity
Field Value
Type Description
ITerm
View Source

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 Source

DiceResults

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>
View Source

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
View Source

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 Source

GetResult(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.

View Source

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.

Overrides
object.ToString()

Implements

ITerm

Extension Methods

Utility.Yield<T>(T)
  • View Source
In this article
Back to top Generated by DocFX