From 37315a6858d65bb39c1d61d75b4ae112b3180374 Mon Sep 17 00:00:00 2001 From: raeleus Date: Mon, 23 Sep 2024 23:01:59 -0700 Subject: [PATCH] Allow passing default difficulty as "easy" for example. --- Input.js | 17 +++++++++++------ Output.js | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Input.js b/Input.js index b3e8739..86e4c9a 100644 --- a/Input.js +++ b/Input.js @@ -657,17 +657,22 @@ function doShowAutoXp(command) { } function doSetDefaultDifficulty(command) { - var arg0 = getArgument(command, 0) - if (arg0 == null) { + const difficultyNames = ["impossible", "extreme", "hard", "medium", "easy", "effortless"] + const difficultyScores = [30, 25, 20, 15, 10, 5] + + const difficultyPatternNames = [...new Set(difficultyNames)] + difficultyPatternNames.push("\\d+") + var difficulty = getArgument(command, 0) + if (difficulty == null) { state.show = "none" return "\n[Error: Not enough parameters. See #help]\n" } - if (isNaN(arg0)) { - state.show = "none" - return "\n[Error: Expected a number. See #help]\n" + var difficultyIndex = difficultyNames.indexOf(difficulty) + if (difficultyIndex >= 0 && difficultyIndex < difficultyNames.length) { + difficulty = difficultyScores[difficultyIndex] } - state.defaultDifficulty = Math.max(0, arg0) + state.defaultDifficulty = Math.max(0, difficulty) state.show = "none" return `\n[The default difficulty is set to ${state.defaultDifficulty}]\n` diff --git a/Output.js b/Output.js index 9c9283d..ca22b27 100644 --- a/Output.js +++ b/Output.js @@ -225,7 +225,7 @@ const modifier = (text) => { text += "\n Shows the value of the auto xp." text += "\n#levelup" text += "\n Increases the character's experience by the exact amount needed to reach the next level." - text += "\n#setdefaultdifficulty value" + text += "\n#setdefaultdifficulty (difficulty_class or effortless|easy|medium|hard|impossible)" text += "\n Sets the default difficulty for #check, #try, #attack, and #cast when a difficulty is not specified. The normal default is 10 (easy)" text += "\n#showdefaultdifficulty" text += "\n Shows the default difficulty for #check, #try, #attack, and #cast when a difficulty is not specified. The normal default is 10 (easy)"