From 99bbd4fe5ad8969a5f46c3216df6e74b97245866 Mon Sep 17 00:00:00 2001 From: raeleus Date: Sun, 22 Sep 2024 23:53:38 -0700 Subject: [PATCH] Fixed double punctuation in attack. Resolves #2 --- Input.js | 2 +- Library.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Input.js b/Input.js index 71b3947..b37e119 100644 --- a/Input.js +++ b/Input.js @@ -1031,7 +1031,7 @@ function doAttack(command) { var targetText = getArgumentRemainder(command, textIndex) var toMatches = targetText.match(/^to\s+/gi) if (toMatches != null) targetText = targetText.substring(toMatches[0].length) - if (!/^.*(\.|!|\?)$/gi.test(targetText)) targetText += "." + targetText = stripPunctuation(targetText) var die1 = calculateRoll("1d20") var die2 = calculateRoll("1d20") diff --git a/Library.js b/Library.js index 50377a5..be289fb 100644 --- a/Library.js +++ b/Library.js @@ -400,4 +400,8 @@ function toTitleCase(str) { /\w\S*/g, text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase() ); +} + +function stripPunctuation(str) { + return str.replaceAll(/((\.)|(!))\s*$/g, "") } \ No newline at end of file