Added ui
This commit is contained in:
23
ui/src/js/spells.ts
Normal file
23
ui/src/js/spells.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user