SpecialDie Enumeration

From DiceRoller Documentation

Indicates what type of special die the result is.

  • Namespace: Dice
  • Assembly: DiceRoller (in DiceRoller.dll)

Syntax

public enum SpecialDie

Members

Member name Description
Add Represents an addition operation.
Subtract Represents a subtraction operation.
Multiply Represents a multiplication operation.
Divide Represents a division operation.
OpenParen Represents the beginning of a parenthetical expression.
CloseParen Represents the end of a parenthetical expression.
Negate Represents a unary negation operation.
Comma Represents a comma.
Text Represents arbitrary text.

Remarks

Some DieResults indicate that they are special dice rather than actual rolls. This enumeration indicates what type of special die the result is. Special dice are used as guidance for display, such as open/close parenthesis when nested math expressions are rolled so that the user can see the dice displayed in the same format as they were specified.

When implementing a custom function, special dice would normally be passed as-is into the final Values of your function. Add any special dice that are needed in order to make the resulting display unambiguous and grouped according to the dice expression.

Examples

For example, if the dice expression (2d20 + 2) * 1.5 is rolled, and a 6 and 8 are rolled on the d20, the Values of the resulting roll will be the following (in order):

  1. { DieType = DieType.SpecialDie, NumSides = 0, Value = SpecialDie.OpenParen, Flags = 0 }
  2. { DieType = DieType.Normal, NumSides = 20, Value = 6, Flags = 0 }
  3. { DieType = DieType.SpecialDie, NumSides = 0, Value = SpecialDie.Add, Flags = 0 }
  4. { DieType = DieType.Normal, NumSides = 20, Value = 8, Flags = 0 }
  5. { DieType = DieType.SpecialDie, NumSides = 0, Value = SpecialDie.Add, Flags = 0 }
  6. { DieType = DieType.Literal, NumSides = 0, Value = 2, Flags = 0 }
  7. { DieType = DieType.SpecialDie, NumSides = 0, Value = SpecialDie.CloseParen, Flags = 0 }
  8. { DieType = DieType.SpecialDie, NumSides = 0, Value = SpecialDie.Multiply, Flags = 0 }
  9. { DieType = DieType.Literal, NumSides = 0, Value = 1.5, Flags = 0 }

The code snippet on RollResult.Values demonstrates how to iterate over the above result to display the string "(6 + 8 + 2) * 1.5".