diff --git a/src/facilities/bodyModification/bodyModification.js b/src/facilities/bodyModification/bodyModification.js index f6dfc9e01f3198437539074db6023a42a43dacaf..7cb155dd010df61ea9ddf0dfcc040d25904b2fc9 100644 --- a/src/facilities/bodyModification/bodyModification.js +++ b/src/facilities/bodyModification/bodyModification.js @@ -856,6 +856,7 @@ App.UI.bodyModification = function(slave, cheat = false) { const el = new DocumentFragment(); App.UI.DOM.appendNewElement("h2", el, "Scars"); let r = []; + const bodyPartData = App.Data.Slave.body.get(V.scarTarget.local); for (const _scarName in slave.scar) { const scarDiv = document.createElement("div"); @@ -884,10 +885,7 @@ App.UI.bodyModification = function(slave, cheat = false) { r = []; if (["exotic", "menacing"].includes(V.scarDesign.local) && !V.scarTarget.local.endsWith("cheek")) { r.push(`"${capFirstChar(V.scarDesign.local)}" scars can only be applied to cheeks.`); - } else if ( - App.Data.Slave.body.has(V.scarTarget.local) && - App.Data.Slave.body.get(V.scarTarget.local).isPair - ) { + } else if (bodyPartData && bodyPartData.isPair) { r.push(`Choose a side to scar.`); } else { if (slave.scar.hasOwnProperty(V.scarTarget.local)) { @@ -951,6 +949,7 @@ App.UI.bodyModification = function(slave, cheat = false) { const el = new DocumentFragment(); let p = document.createElement('p'); let div = document.createElement('div'); + const bodyPartData = App.Data.Slave.body.get(V.brandTarget.local); App.UI.DOM.appendNewElement("h2", el, "Branding"); @@ -999,10 +998,7 @@ App.UI.bodyModification = function(slave, cheat = false) { if (slave.brand[V.brandTarget.local] === V.brandDesign.local) { p.append(`${He} already has ${V.brandDesign.local} on ${his} ${V.brandTarget.local}.`); - } else if ( - App.Data.Slave.body.has(V.brandTarget.local) && - App.Data.Slave.body.get(V.brandTarget.local).isPair - ) { + } else if (bodyPartData && bodyPartData.isPair) { p.append(`Choose a side to brand.`); } else { p.append( @@ -1107,11 +1103,8 @@ App.UI.brandSelect = function(category, slave, cheat = false) { App.UI.bodyPartSelector(V.brandTarget, "primary", true) ); const bodyPartRoot = App.UI.bodyPartRoot(V.brandTarget.primary); - if ( - App.Data.Slave.body.has(bodyPartRoot) && - !App.Data.Slave.body.get(bodyPartRoot).isPair && - (App.Data.Slave.body.get(bodyPartRoot)).hasOwnProperty("requirements") - ) { + const bodyPartData = App.Data.Slave.body.get(bodyPartRoot); + if (bodyPartData && (bodyPartData).hasOwnProperty("requirements")) { r.push(`It's possible that <strong>${V.brandTarget.primary}</strong> may be missing from a slave. Choose a fallback in case it is not available: Current backup is <strong>${V.brandTarget.secondary}</strong>:`); App.Events.addNode(el, r, "div"); r = []; @@ -1221,11 +1214,8 @@ App.UI.scarSelect = function(category, slave, cheat = false) { App.UI.bodyPartSelector(V.scarTarget, "primary", true) ); const bodyPartRoot = App.UI.bodyPartRoot(V.scarTarget.primary); - if ( - App.Data.Slave.body.has(bodyPartRoot) && - !App.Data.Slave.body.get(bodyPartRoot).isPair && - (App.Data.Slave.body.get(bodyPartRoot)).hasOwnProperty("requirements") - ) { + const bodyPartData = App.Data.Slave.body.get(bodyPartRoot); + if (bodyPartData && bodyPartData.hasOwnProperty("requirements")) { r.push(`It's possible that <strong>${V.scarTarget.primary}</strong> may be missing from a slave. Choose a fallback in case it is not available: Current backup is <strong>${V.scarTarget.secondary}</strong>:`); App.Events.addNode(el, r, "div"); r = []; @@ -1279,10 +1269,8 @@ App.UI.bodyPartSelector = function(variable, property, selector) { } // Choose a side - if ( - App.Data.Slave.body.has(variable[property]) && - App.Data.Slave.body.get(variable[property]).isPair - ) { + const bodyPartData = App.Data.Slave.body.get(variable[property]); + if (bodyPartData && bodyPartData.isPair) { const linkArray = []; for (const side of ["left", "right"]) { linkArray.push(App.UI.DOM.link(capFirstChar(side), () => {