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, "-") }