/** * Runtime-implementation of the {@link RollProvider}. * * @remarks * Do not use for tests, it will inevitably fail because the `Roll` class is only provided from declarations, not as implementation! */ export class DS4RollProvider implements RollProvider { getNextRoll(): number { return new Roll("1d20").roll().total; } getNextRolls(amount: number): Array { return Array(amount) .fill(0) .map(() => this.getNextRoll()); } } /** * Provides methods to fetch one or multiple rolls. */ export interface RollProvider { getNextRoll(): number; getNextRolls(amount: number): Array; }