Fixed message for setskill and made ability optional.

This commit is contained in:
raeleus 2024-09-20 06:58:37 -07:00
parent 250173148a
commit 8e9d1f8105
2 changed files with 13 additions and 6 deletions

View file

@ -655,10 +655,11 @@ function doSetSkill(command) {
var arg2 = getArgument(command, 2)
if (arg2 == null) {
state.show = "none"
return "\n[Error: Not enough parameters. See #help]\n"
arg2 = (clamp(parseInt(arg1, 1, 100)))
arg1 = null
} else {
arg2 = clamp(parseInt(arg2), 1, 100)
}
arg2 = clamp(parseInt(arg2), 1, 100)
var possessiveName = getPossessiveName(character.name)
@ -670,14 +671,20 @@ function doSetSkill(command) {
var index = character.skills.findIndex((element) => element.name.toLowerCase() == skill.name.toLowerCase())
if (index == -1) {
if (arg1 == null) {
state.show = "none"
return "\n[Error: New skills must have an ability specified. See #help]\n"
}
character.skills.push(skill)
} else {
var existingSkill = character.skills[index]
existingSkill.modifier = parseInt(skill.modifier)
if (arg1 != null) existingSkill.stat = skill.stat
}
state.show = "none"
return `\n[${possessiveName} ${arg0} skill is now ${arg1}.]\n`
return `\n[${possessiveName} ${arg0} skill is now ${arg2 >= 0 ? "+" + arg2 : "-" + arg2} and based on ${arg1}.]\n`
}
function doSetExperience(command) {

View file

@ -247,8 +247,8 @@ const modifier = (text) => {
text += "\n Sets the character's ability modifier that affects ranged attacks."
text += "\n\n--Skills--"
text += "\n#setskill skill ability value"
text += "\n Adds the skill to the character if necessary, and associates it with the specified ability and value."
text += "\n#setskill skill (ability) value"
text += "\n Adds the skill to the character if necessary, and associates it with the specified ability and value. The ability is optional only if this is an existing skill. New skills need an ability specified."
text += "\n#showskills"
text += "\n Shows the character's list of skills"
text += "\n#removeskill"