ds4/src/module/rolls/roll-provider.ts
Oliver Rümpelein c885d2d405 Implement a custom DS4 "dice" class.
Includes exploding and crit dice modifier, but not tested yet,
as some required types are still missing.
2021-01-06 19:15:56 +01:00

26 lines
711 B
TypeScript

/**
* 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 {
const rand = CONFIG.Dice.randomUniform();
return Math.ceil(rand * 20);
}
getNextRolls(amount: number): Array<number> {
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<number>;
}