roll-parser - v3.0.0-beta.0
    Preparing search index...

    Type Alias RollPart

    RollPart:
        | RollPartBase & { type: "literal"; value: number }
        | RollPartBase & { name: string; type: "variable"; value: number }
        | RollPartBase & {
            count: number;
            rolls: DieResult[];
            sides: number;
            type: "dice";
        }
        | RollPartBase & { count: number; rolls: DieResult[]; type: "fateDice" }
        | RollPartBase & { inner: RollPart; type: "grouped" }
        | RollPartBase & {
            left: RollPart;
            operator: "+" | "-" | "*" | "/" | "%" | "**";
            right: RollPart;
            type: "binaryOp";
        }
        | RollPartBase & { operand: RollPart; operator: "-"; type: "unaryOp" }
        | RollPartBase & {
            specs: ModifierSpec[];
            target: RollPart;
            type: "modifier";
        }
        | RollPartBase & {
            target: RollPart;
            threshold?: ResolvedComparePoint;
            type: "explode";
            variant: "standard"
            | "compound"
            | "penetrating";
        }
        | RollPartBase & {
            condition: ResolvedComparePoint;
            once: boolean;
            target: RollPart;
            type: "reroll";
        }
        | RollPartBase & {
            failThreshold?: ResolvedComparePoint;
            failures: number;
            successes: number;
            target: RollPart;
            threshold: ResolvedComparePoint;
            type: "successCount";
        }
        | RollPartBase & {
            dc: RollPart;
            degree: DegreeOfSuccess;
            roll: RollPart;
            type: "versus";
        }
        | RollPartBase & { args: RollPart[]; name: string; type: "functionCall" }
        | RollPartBase & {
            keptIndices?: number[];
            parts: RollPart[];
            type: "group";
        }
        | RollPartBase & {
            order: "ascending"
            | "descending";
            target: RollPart;
            type: "sort";
        }
        | RollPartBase & {
            failThresholds: ResolvedCritThreshold[];
            successThresholds: ResolvedCritThreshold[];
            target: RollPart;
            type: "critThreshold";
        }

    Structured breakdown of an evaluated expression, mirroring the AST 1:1 — every ASTNode produces exactly one RollPart. Discriminants are lowercase camelCase to distinguish evaluation-tree types from ASTNode.type (PascalCase) at a glance.

    Invariants:

    • RollResult.parts.total === RollResult.total.
    • successCount.total === successes - failures.
    • literal.total === value and variable.total === value.
    • Each part's rolls[] shares DieResult references with RollResult.rolls[]; both reflect post-evaluation state (explode accumulation, reroll flags, keep/drop flags). No deep clone.

    Meta-expression sub-trees (4d6kh(1d2), (1+1)d6 counts/sides, computed thresholds) are not surfaced as nested parts — their resolved numbers appear in the owning part, and their dice are inspectable in RollResult.rolls via the 'meta' modifier tag.