From ff64d9006b6a7ecf2d1da3ae7a4e82100518f467 Mon Sep 17 00:00:00 2001 From: raeleus Date: Sun, 6 Oct 2024 10:22:49 -0700 Subject: [PATCH] Fixed being unable to use negative modifiers for #roll --- Input.js | 1 + Library.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Input.js b/Input.js index 480478c..d0e0359 100644 --- a/Input.js +++ b/Input.js @@ -605,6 +605,7 @@ function doRoll(command) { if (roll == 20) text += " Critical Success!" else if (roll == 1) text += " Critical Failure!" else if (addition > 0) text += ` + ${addition} = ${roll + addition}` + else if (addition < 0) text += ` - ${Math.abs(addition)} = ${roll + addition}` text += "]\n" return text diff --git a/Library.js b/Library.js index 1aefc19..1db6ff3 100644 --- a/Library.js +++ b/Library.js @@ -200,16 +200,16 @@ function getSides(rolltext) { } function getAddition(rolltext) { - var matches = rolltext.match(/(?<=(\+|-)\s*)\d+/) + var matches = rolltext.match(/(\+|-)\s*\d+/) if (matches != null) { - return parseInt(matches[0]) + return parseInt(matches[0].replaceAll(/\s*/g, "")) } return 0 } function formatRoll(text) { - var matches = text.match(/(?<=.*)\d*d\d+(?=.*)(\s*\+\s*\d+)?/) + var matches = text.match(/(?<=.*)\d*d\d+(?=.*)(\s*(\+|-)\s*\d+)?/) if (matches != null) { return matches[0].replaceAll(/\s*\+\s*/g, "+").replaceAll(/\s*-\s*/g, "-") }