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

    Variable createMockRngConst

    createMockRng: (values: number[]) => RNG = _createMockRng

    Type Declaration

      • (values: number[]): RNG
      • Creates a mock RNG that returns predefined values in sequence.

        IMPORTANT: Throws MockRNGExhaustedError when all values are consumed. This behavior catches incorrect roll counts in tests - it never wraps around.

        Parameters

        • values: number[]

          Array of values to return (dice results for nextInt, floats for next)

        Returns RNG

        RNG instance returning predefined values

        const rng = createMockRng([4, 2, 6]);
        rng.nextInt(1, 6); // Returns 4
        rng.nextInt(1, 6); // Returns 2
        rng.nextInt(1, 6); // Returns 6
        rng.nextInt(1, 6); // Throws MockRNGExhaustedError