Compare commits

...

2 Commits

Author SHA1 Message Date
ThePendulum a0ab0302f3 1.16.2 2022-10-24 02:37:34 +02:00
ThePendulum 313b473aba Supported 1d6 dice input. 2022-10-24 02:37:32 +02:00
3 changed files with 15 additions and 3 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "schat2-clive",
"version": "1.16.1",
"version": "1.16.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "schat2-clive",
"version": "1.16.1",
"version": "1.16.2",
"license": "ISC",
"dependencies": {
"bhttp": "^1.2.8",

View File

@ -1,6 +1,6 @@
{
"name": "schat2-clive",
"version": "1.16.1",
"version": "1.16.2",
"description": "Game host for SChat 2-powered chat sites",
"main": "src/app.js",
"scripts": {

View File

@ -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;