RollResult.RollRoot Property

From DiceRoller Documentation

Gets the root of the dice expression's abstract syntax tree.

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

Syntax

public DiceAST RollRoot { get; private set; }

Property Value

Type: Dice.AST.DiceAST

The root of the AST for this roll. Accessing this is usually not required, but is exposed if deeper introspection into the roll is desired. This property is read-only.

Remarks

All nodes in the AST inherit from DiceAST. However, in order to gain access to child nodes these nodes must be cast into their appropriate node type. See the Dice.AST namespace reference for more information on all valid node types.

Examples

This example inspects the value of the d8 from the dice expression (1d8)d6 by using RollRoot.

using System;
using Dice;
using Dice.AST;

class Sample
{
    public static void Main()
    {
        RollResult result = Roller.Roll("(1d8)d6");
        DiceAST d8 = ((RollNode)result.RollRoot).NumDice;
        Console.WriteLine(d8.Value); // outputs the value of the d8
    }
}