Skip to content

Commit

Permalink
Fix validation error thrown when attempting to edit an NPC sheet with…
Browse files Browse the repository at this point in the history
… an empty CR.
  • Loading branch information
Fyorl committed Nov 12, 2024
1 parent 9d339d2 commit bcc1806
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions module/applications/actor/npc-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,14 @@ export default class ActorSheet5eNPC extends ActorSheet5e {
async _updateObject(event, formData) {

// Format NPC Challenge Rating
const crs = {"1/8": 0.125, "⅛": 0.125, "1/4": 0.25, "¼": 0.25, "1/2": 0.5, "½": 0.5};
const crs = { "1/8": 0.125, "⅛": 0.125, "1/4": 0.25, "¼": 0.25, "1/2": 0.5, "½": 0.5 };
let crv = "system.details.cr";
let cr = formData[crv];
if ( cr === "" ) formData[crv] = null;
if ( (cr === "") || (cr === "—") ) formData[crv] = null;
else {
cr = crs[cr] || parseFloat(cr);
if ( !Number.isNaN(cr) ) formData[crv] = cr < 1 ? cr : parseInt(cr);
if ( Number.isNaN(cr) ) cr = null;
else formData[crv] = cr < 1 ? cr : parseInt(cr);
}

// Parent ActorSheet update steps
Expand Down

0 comments on commit bcc1806

Please sign in to comment.