From e05c7e5900d123c379ee6dae52ee9621cb510192 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 9 Aug 2023 01:50:22 +0900 Subject: [PATCH] [feat] added roll --- src/ts/parser.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ts/parser.ts b/src/ts/parser.ts index 9e5f5525..97bd908e 100644 --- a/src/ts/parser.ts +++ b/src/ts/parser.ts @@ -599,6 +599,14 @@ const matcher = (p1:string,matcherArg:matcherArg) => { return arr[randomIndex] } } + if(p1.startsWith('roll')){ + const arr = p1.split(' ', 2) + const maxRoll = parseInt(p1[1]) + if(isNaN(maxRoll)){ + return 'NaN' + } + return Math.floor(Math.random() * maxRoll).toString() + } return null }