diff --git a/Input.js b/Input.js index eb14d70..0dcea82 100644 --- a/Input.js +++ b/Input.js @@ -141,6 +141,18 @@ const modifier = (text) => { if (text == null) text = processCommandSynonyms(command, commandName, setAutoXpSynonyms, doSetAutoXp) if (text == null) text = processCommandSynonyms(command, commandName, showAutoXpSynonyms, doShowAutoXp) if (text == null) text = processCommandSynonyms(command, commandName, helpSynonyms, doHelp) + if (text == null) { + var character = getCharacter() + var statNames = [] + character.stats.forEach(x => { + statNames.push(x.name.toLowerCase()) + }) + character.skills.forEach(x => { + statNames.push(x.name.toLowerCase()) + }) + + text = processCommandSynonyms(command, commandName, statNames, doTest) + } return { text } } @@ -840,6 +852,18 @@ function doRest(command) { return `\n[All characters have rested and feel rejuvinated]\n` } +function doTest(command) { + var ability = getCommandName(command) + var arg0 = getArgument(command, 0) + if (arg0 == null) return; + var remainder = getArgumentRemainder(command, 1) + + command = `${arg0} ${ability} ${remainder}` + text = processCommandSynonyms(command, arg0, checkSynonyms, doCheck) + if (text == null) text = processCommandSynonyms(command, arg0, trySynonyms, doTry) + return text +} + function doCheck(command) { const advantageNames = ["normal", "advantage", "disadvantage"] const difficultyNames = ["impossible", "extreme", "hard", "medium", "easy", "effortless"] diff --git a/Library.js b/Library.js index f7fcdbc..afb4f8d 100644 --- a/Library.js +++ b/Library.js @@ -70,7 +70,9 @@ function getArgumentRemainder(command, index) { const pattern = new RegExp(argumentPattern) while ((match = pattern.exec(command)) != null) { if (counter++ == index + 1) { - return command.substring(match.index).replace(/^"/, "").replace(/"$/, "").replaceAll(/\\"/g, '"') + var result = command.substring(match.index) + if (/^".*"$/g.test(result)) result = result.replace(/^"/, "").replace(/"$/, "") + return result.replaceAll(/\\"/g, '"') } } }