UNPKG

@randsum/roller

Version:

A flexible, type-safe dice roller for tabletop RPGs, game development, and probability simulations

15 lines (11 loc) 435 B
import type { ModifierOptions } from '../../../types' import { uniquePattern } from '../../patterns/modifierPatterns' export function parseUniqueModifier(notation: string): Pick<ModifierOptions, 'unique'> { const match = notation.match(uniquePattern) if (!match) return {} if (!match[2]) { return { unique: true } } const notUnique = match[2].split(',').map(s => Number(s.trim())) return { unique: { notUnique } } }