Exemple #1
0
        protected override long EvaluateInternal(RollData data, DiceAST root, int depth)
        {
            long rolls = NumTimes?.Evaluate(data, root, depth + 1) ?? 0;

            rolls += Roll(data, root, depth);

            return(rolls);
        }
        // this won't appear in the overall AST, but in the course of debugging it may be worthwhile to print out a partial node
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("GPARTIAL<<");

            if (NumTimes != null)
            {
                if (NumTimes is LiteralNode || NumTimes is MacroNode)
                {
                    sb.Append(NumTimes.ToString());
                }
                else
                {
                    sb.AppendFormat("({0})", NumTimes.ToString());
                }
            }

            sb.Append("{");
            sb.Append(String.Join(", ", GroupExpressions.Select(o => o.ToString())));
            sb.Append("}");

            if (RerollNode != null)
            {
                sb.Append(RerollNode.ToString());
            }

            foreach (var k in Keep)
            {
                sb.Append(k.ToString());
            }

            if (Sort != null)
            {
                sb.Append(Sort.ToString());
            }

            if (Success != null)
            {
                sb.Append(Success.ToString());
            }

            foreach (var f in Functions)
            {
                sb.Append(f.ToString());
            }

            sb.Append(">>");

            return(sb.ToString());
        }