Allow passing default difficulty as "easy" for example.

This commit is contained in:
raeleus 2024-09-23 23:01:59 -07:00
parent 5b79633498
commit 37315a6858
2 changed files with 12 additions and 7 deletions

View file

@ -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`

View file

@ -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)"