From f7a29c57b1becd0cec8c45352b49af42da3dcf12 Mon Sep 17 00:00:00 2001 From: raeleus Date: Tue, 17 Sep 2024 18:26:12 -0700 Subject: [PATCH] Resolve issues with casted spells being repeated twice. --- Input.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Input.js b/Input.js index 0698166..dca1a9c 100644 --- a/Input.js +++ b/Input.js @@ -1481,11 +1481,15 @@ function doCastSpell(command) { if (!/^((at)|(on))\s+.*/.test(target)) target = "at " + target } } else { - var remainder = getArgumentRemainder(command, spellIndex) - spell = remainder.replace(/\s+((at)|(on)).*/i, "").trim() + if (/.*\s((at)|(on))\s.*/i.test(spell)) { + var remainder = getArgumentRemainder(command, spellIndex) + spell = remainder.replace(/\s+((at)|(on)).*/i, "").trim() + target = remainder.replace(/^.*\s+(?=(at)|(on))/i, "").trim() + } else { + spell = getArgumentRemainder(command, spellIndex).trim() + } + found = character.spells.find(x => x.toLowerCase() == spell.toLowerCase()) - - target = remainder.replace(/^.*\s+(?=(at)|(on))/i, "").trim() } if (found == null) { @@ -1622,4 +1626,4 @@ function doHelp(command) { return " " } -modifier(text) \ No newline at end of file +modifier(text)