mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-05 21:20:27 -04:00
Fixed being unable to use negative modifiers for #roll
This commit is contained in:
parent
ca76856c90
commit
ff64d9006b
2 changed files with 4 additions and 3 deletions
1
Input.js
1
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
|
||||
|
|
|
@ -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, "-")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue