UNPKG

@randsum/5e

Version:

A flexible, type-safe dice roller for building 5e-compatible applications

33 lines 831 B
import { roll } from '@randsum/dice'; export function roll5e({ modifier, rollingWith }) { const rollArg = { sides: 20, quantity: generateQuantity(rollingWith), modifiers: { ...generateModifiers(rollingWith), plus: modifier } }; return roll(rollArg); } function generateQuantity(rollingWith) { switch (rollingWith) { case 'Advantage': case 'Disadvantage': return 2; default: return 1; } } function generateModifiers(rollingWith) { switch (rollingWith) { case 'Advantage': return { drop: { lowest: 1 } }; case 'Disadvantage': return { drop: { highest: 1 } }; default: return {}; } } //# sourceMappingURL=roll5e.js.map