UNPKG

@seroh/roll

Version:

An RPG dice-rolling library with a variety of built-in roll mechanics.

17 lines 541 B
import { Mechanic } from "./Mechanic"; export class ExplodingMechanic extends Mechanic { do(min, max, randomizer) { if (min === max) return { result: min, rolls: [min] }; let result = 0; let roll; let rolls = []; do { roll = randomizer.generate(min, max); rolls.push(roll); result += roll; } while (roll === max); // Continue rolling if max value is hit return { result, rolls }; } } //# sourceMappingURL=ExplodingMechanic.js.map