import { Spell } from '@/api/spells.types'; export function levelText(spell: Spell) { if (spell.level === 0) { return 'Cantrip'; } else { return `Level ${spell.level}`; } } export function rollDice(dice: string): number[] { // eslint-disable-next-line prefer-const let [count, sides] = dice.split('d'); const rolls = []; if (isNaN(parseInt(count))) { count = '1'; } for (let i = 0; i < parseInt(count); i++) { rolls.push(Math.floor(Math.random() * parseInt(sides)) + 1); } console.log(rolls); return rolls; }