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

    Function roll

    • Parses and evaluates a dice notation string.

      Parameters

      • notation: string

        Dice notation (e.g., "2d6+3", "4d6kh3")

      • options: RollOptions = {}

        Optional configuration (RNG or seed)

      Returns RollResult

      Complete roll result with total and metadata

      // Random roll
      const result = roll('2d6+3');
      console.log(result.total); // 5-15

      // Seeded for reproducibility
      const r1 = roll('4d6', { seed: 'test' });
      const r2 = roll('4d6', { seed: 'test' });
      r1.total === r2.total; // true

      // Custom RNG for testing
      const result = roll('1d20', { rng: createMockRng([15]) });
      result.total; // 15