< Dice
Revision as of 16:44, 12 April 2017 by Skizzerz (talk | contribs) (Created page with "{{APIdoc|SpecialDie Enumeration}} Indicates what type of special die the result is. {{ns}} == Syntax == <syntaxhighlight lang="C#"> public enum SpecialDie </syntaxhighlight>...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

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".