ttrpg-lib-dice
Version:
A small library for rolling dice in tabletop games
22 lines (21 loc) • 943 B
TypeScript
import { Dice } from './domain/Dice';
/**
* Generates a cryptographically secure random integer between min (inclusive) and max (inclusive)
*/
export declare const secureRandomInteger: (min: number, max: number) => number;
export declare const getRandomArrayItem: <T = unknown>(arr: Array<T>) => T;
export declare const getRandomArrayItems: <T = unknown>(arr: Array<T>, count: number) => Array<T>;
export declare const roll: (dice?: Dice) => number;
export declare const isValidDiceFormula: (formula: string) => boolean;
export declare const rollDiceFormula: (formula: string) => number;
type DiceRollResult = [string, number, number[]];
type DiceRollResultsList = DiceRollResult[];
/**
* TODO fix issues, publish
*/
export declare const rollDiceFormulaDetailed: (formula: string) => DiceRollResultsList;
/**
* O(n) Fisher–Yates shuffle (crypto‐secure)
*/
export declare const shuffleArray: <T>(arr: readonly T[]) => T[];
export {};