diff --git a/js/003-data/slaveBody.js b/js/003-data/slaveBody.js index 7410dbc3ded4878fada559bad606806505217e89..63d01f21beceace4e63d67fe788a026884c0a3df 100644 --- a/js/003-data/slaveBody.js +++ b/js/003-data/slaveBody.js @@ -1,4 +1,71 @@ App.Data.Slave.body = new Map([ - ["hasMirror", ["ankle", "breast", "buttock", "calf", "cheek", "ear", "foot", "hand", "lower arm", "shoulder", "testicle", "thigh", "upper arm", "wrist"]], - ["canAmp", ["penis", "ankle", "breast", "calf", "ear", "foot", "hand", "lower arm", "shoulder", "testicle", "thigh", "upper arm", "wrist"]], + ["head", { + "ears": { + requirements: (slave) => slave.earShape !== "none", + isPair: true + }, + "cheek": { + isPair: true + }, + "neck": {}, + }], + ["torso", { + "chest": {}, + "breast": { + isPair: true + }, + "back": {}, + "lower back": {}, + "pubic mound": {}, + "penis": { + requirements: (slave) => hasAnyNaturalArms(slave), + }, + "testicle": { + requirements: (slave) => hasAnyNaturalArms(slave), + isPair: true + }, + }], + ["arms", { + "shoulder": { + requirements: (slave) => hasAnyNaturalArms(slave), + isPair: true + }, + "upper arm": { + requirements: (slave) => hasAnyNaturalArms(slave), + isPair: true + }, + "lower arm": { + requirements: (slave) => hasAnyNaturalArms(slave), + isPair: true + }, + "wrist": { + requirements: (slave) => hasAnyNaturalArms(slave), + isPair: true + }, + "hand": { + requirements: (slave) => hasAnyNaturalArms(slave), + isPair: true + }, + }], + ["legs", { + "buttock": { + isPair: true + }, + "thigh": { + requirements: (slave) => hasAnyNaturalLegs(slave), + isPair: true + }, + "calf": { + requirements: (slave) => hasAnyNaturalLegs(slave), + isPair: true + }, + "ankle": { + requirements: (slave) => hasAnyNaturalLegs(slave), + isPair: true + }, + "foot": { + requirements: (slave) => hasAnyNaturalLegs(slave), + isPair: true + }, + }] ]); diff --git a/src/facilities/bodyModification/bodyModification.js b/src/facilities/bodyModification/bodyModification.js index 27f6f47031ca8dd1c4bac60a3aaebf2b9411b5e6..0c5a042937fa5917bbc828ab260289bd292d250a 100644 --- a/src/facilities/bodyModification/bodyModification.js +++ b/src/facilities/bodyModification/bodyModification.js @@ -884,7 +884,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.get("hasMirror").includes(V.scarTarget.local)) { + } else if (findBodyPart(V.scarTarget.local).isPair) { r.push(`Choose a side to scar.`); } else { if (slave.scar.hasOwnProperty(V.scarTarget.local)) { @@ -996,7 +996,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.get("hasMirror").includes(V.brandTarget.local)) { + } else if (findBodyPart(V.brandTarget.local).isPair) { p.append(`Choose a side to brand.`); } else { p.append( @@ -1101,9 +1101,9 @@ App.UI.brandSelect = function(category, slave, cheat = false) { App.UI.bodyPartSelector(V.brandTarget, "primary", true) ); if ( - !App.Data.Slave.body.get("hasMirror").includes(V.brandTarget.primary) && ( - App.Data.Slave.body.get("canAmp").includes(V.brandTarget.primary.replace(/left /g, "")) || - App.Data.Slave.body.get("canAmp").includes(V.brandTarget.primary.replace(/right /g, "")) + !findBodyPart(V.brandTarget.primary).isPair && ( + findBodyPart(V.brandTarget.primary.replace(/left /g, "")).canAmp || + findBodyPart(V.brandTarget.primary.replace(/right /g, "")).canAmp ) ) { 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>:`); @@ -1215,9 +1215,9 @@ App.UI.scarSelect = function(category, slave, cheat = false) { App.UI.bodyPartSelector(V.scarTarget, "primary", true) ); if ( - !App.Data.Slave.body.get("hasMirror").includes(V.scarTarget.primary) && ( - App.Data.Slave.body.get("canAmp").includes(V.scarTarget.primary.replace(/left /g, "")) || - App.Data.Slave.body.get("canAmp").includes(V.scarTarget.primary.replace(/right /g, "")) + !findBodyPart(V.scarTarget.primary).isPair && ( + findBodyPart(V.scarTarget.primary.replace(/left /g, "")).canAmp || + findBodyPart(V.scarTarget.primary.replace(/right /g, "")).canAmp ) ) { 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>:`); @@ -1239,64 +1239,36 @@ App.UI.scarSelect = function(category, slave, cheat = false) { */ App.UI.bodyPartSelector = function(variable, property, selector) { let el = document.createElement("div"); - // Sorted head to toe - // Head - const head = {}; - if (selector !== false) { - if (selector === true || selector.earShape !== "none") { - head.ears = "Ears"; - } - } - head.cheek = "Cheeks"; - head.neck = "Neck"; - el.append(partLinks(head)); - - // Torso - const torso = {}; - torso.chest = "Chest"; - torso.breast = "Breasts"; - torso.back = "Back"; - torso["lower back"] = "Lower Back"; - torso.belly = "Belly"; - torso["pubic mound"] = "Pubic Mound"; - if (selector !== false) { - if (selector === true || selector.dick > 0) { - torso.penis = "Penis"; - } - if (selector === true || selector.balls > 0 && selector.scrotum > 0) { - torso.testicle = "Testicles"; - } - } - el.append(partLinks(torso)); - - // Arms - const arms = {}; - arms.shoulder = "Shoulders"; - if (selector !== false) { - if (selector === true || hasAnyNaturalArms(selector)) { - arms["upper arm"] = "Arm, upper"; - arms["lower arm"] = "Arm, lower"; - arms.wrist = "Wrists"; - arms.hand = "Hands"; - } - } - el.append(partLinks(arms)); - - // Legs - const legs = {}; - legs.buttock = "Buttocks"; - if (selector !== false) { - if (selector === true || hasAnyNaturalLegs(selector)) { - legs.thigh = "Thighs"; - legs.calf = "Calves"; - legs.ankle = "Ankles"; - legs.foot = "Feet"; + for (const value of App.Data.Slave.body.values()) { + const linkArray = []; + const makeLink = (bp) => { + linkArray.push( + App.UI.DOM.link( + capFirstChar(bp), + () => { + variable[property] = bp; + App.UI.reload(); + } + ) + ); + }; + for (const bp in value) { + const partObj = value[bp]; + if (selector === true) { // Always show all parts + makeLink(bp); + } else if (selector === false) { // Looking for a backup slot for every slave, hide all parts that could be amputated + if (!partObj.hasOwnProperty("requirements")) { + makeLink(bp); + } + } else if (!(partObj.hasOwnProperty("requirements")) || partObj.requirements(selector)) { // We have an actual slave here, run the check on them + makeLink(bp); + } } + App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices"); } - el.append(partLinks(legs)); // Choose a side - if (App.Data.Slave.body.get("hasMirror").includes(variable[property])) { + if (findBodyPart(variable[property]).isPair) { const linkArray = []; for (const side of ["left", "right"]) { linkArray.push(App.UI.DOM.link(capFirstChar(side), () => { @@ -1322,23 +1294,4 @@ App.UI.bodyPartSelector = function(variable, property, selector) { el.append(div); return el; - - function partLinks(bodyPartObj) { - const div = document.createElement("div"); - div.classList.add("choices"); - const array = []; - for (const bp in bodyPartObj) { - array.push( - App.UI.DOM.link( - bodyPartObj[bp], - () => { - variable[property] = bp; - App.UI.reload(); - } - ) - ); - } - div.append(App.UI.DOM.generateLinksStrip(array)); - return div; - } }; diff --git a/src/js/utilsSlave.js b/src/js/utilsSlave.js index 113bb8d6663e62a2034164c30060379c970aa866..f95955f2193ba4745b685ae75e2577503c9978d8 100644 --- a/src/js/utilsSlave.js +++ b/src/js/utilsSlave.js @@ -3565,3 +3565,14 @@ globalThis.addPartner = function(slave, partner) { partnerState.partners.add(slave.ID); } }; + +globalThis.findBodyPart = function(part) { + for (const value of App.Data.Slave.body.values()) { + for (const key in value) { + if (key === part) { + return value[key]; + } + } + } + return {}; +};