slanted-gamedev-toolz
Version:
A slanted mix of tools for your brilliant ideas in game design.
15 lines (14 loc) • 492 B
JavaScript
export const useSlantedDice = () => {
const rollDice = (diceSides) => {
if (typeof diceSides !== "number" ||
!Number.isInteger(diceSides) ||
diceSides <= 0) {
console.error("Invalid input: Please provide a positive integer for dice sides");
return 1;
}
// Perform the dice roll
const thisRollValue = Math.floor(Math.random() * diceSides + 1);
return thisRollValue;
};
return { rollDice };
};