diff --git a/src/games/dice.js b/src/games/dice.js index 33ce346..3383bc0 100644 --- a/src/games/dice.js +++ b/src/games/dice.js @@ -8,9 +8,21 @@ const style = require('../utils/style'); const dieFaces = ['⚀', '⚁', '⚂', '⚃', '⚄', '⚅']; function onCommand(args, context) { + const pattern = args[0]?.match(/(\d+)?d(\d+)?/i); + + if (pattern) { + onCommand(pattern.slice(1), context); + return; + } + const rolls = Number(args[0]) || 1; const faces = Number(args[1]) || 6; + if (rolls < 1 || faces < 1) { + context.sendMessage('The dice must exist in the physical universe.', context.room.id); + return; + } + if (rolls > config.dice.maxRolls) { context.sendMessage(`You can only roll ${config.dice.maxRolls} dice at one time`, context.room.id); return;