slanted-gamedev-toolz
Version:
A slanted mix of tools for your brilliant ideas in game design.
41 lines • 1.84 kB
TypeScript
/**
* Rolls a fair die with a specified number of sides.
*
* @param {number} diceSides - The number of sides on the die. Must be a positive integer.
* @returns {number} A random number between 1 and diceSides (inclusive).
*/
export declare const rollDice: (diceSides: number) => number;
/**
* Rolls a die with a bias toward lower numbers.
* High rolls (above or equal to half of diceSides) have a 50% chance of being halved.
*
* @param {number} diceSides - The number of sides on the die. Must be a positive integer.
* @returns {number} A number between 1 and diceSides, more likely to be lower.
*/
export declare const rollLowWeightedDice: (diceSides: number) => number;
/**
* Rolls a die with a bias toward higher numbers.
* Low rolls (less than or equal to half of diceSides) have a 50% chance of being doubled.
*
* @param {number} diceSides - The number of sides on the die. Must be a positive integer.
* @returns {number} A number between 1 and diceSides, more likely to be higher.
*/
export declare const rollHighWeightedDice: (diceSides: number) => number;
/**
* Returns true based on a given percentage chance.
*
* @param {number} chance - An integer representing the percent chance (0–100).
* @returns {boolean} True if the random roll is below the chance threshold.
*
* @example
* percentageChance(25); // roughly 1 in 4 chance to return true
*/
export declare function percentageChance(chance: number): boolean;
/**
* Rolls a dice with a specified number of sides and checks if the result is the maximum possible value.
*
* @param diceSides - The number of sides on the die (e.g. 6 for a standard die).
* @returns `true` if the roll landed on the maximum value, otherwise `false`.
*/
export declare const rollDiceIsMaxRoll: (diceSides: number) => boolean;
//# sourceMappingURL=diceUtil.d.ts.map