diff --git a/src/facilities/ads.js b/src/facilities/ads.js index 3bdf35f2471472058f5a769152574aec937ee927..dd94410eb6c6c1709936e232db16c30301e0f7a2 100644 --- a/src/facilities/ads.js +++ b/src/facilities/ads.js @@ -145,7 +145,6 @@ App.Ads.getAllCategories = function() { return _.values(App.Ads.Categories); }; - /** categorizes a girl in all the categories and returns the total categories in which she matches the advertisements */ App.Ads.getMatchedCategoryCount = function(slave, facility) { let matchedCategories = 0; @@ -338,6 +337,7 @@ App.Ads.report = function(building, preview = false) { } return r; } + function intro(building, preview) { let t = ``; if (adCampaign.spending !== 0) { @@ -345,10 +345,10 @@ App.Ads.report = function(building, preview = false) { t += `<div>An ad campaign is supporting business there, and `; if (building === "brothel") { t += `whores `; - } else { + } else { t += `sluts `; - } - t += `that match it make more ¤.</div>`; + } + t += `that match it make more ¤.</div>`; } else if (building === "club") { t += `<div>An ad campaign is getting citizens into the ${building} every night, and sluts that match it gratify patrons.</div>`; } @@ -359,11 +359,11 @@ App.Ads.report = function(building, preview = false) { function payBonus() { if (!preview) { if (building === "brothel") { - const adsIncome = DL*random(20, 30); + const adsIncome = DL * random(20, 30); V.facility[building].adsIncome += adsIncome; cashX(adsIncome, (building + "Ads")); } else if (building === "club") { - repX(DL*random(5, 10), (building + "Ads")); + repX(DL * random(5, 10), (building + "Ads")); } } } @@ -398,9 +398,9 @@ App.Ads.report = function(building, preview = false) { payBonus(); t += `The ${building} offers a `; if (building === "brothel") { - t+= `<span class="yellowgreen">`; + t += `<span class="yellowgreen">`; } else if (building === "club") { - t+= `<span class="green">`; + t += `<span class="green">`; } t += `wide</span> variety of slim and stacked slaves. `; } @@ -535,9 +535,9 @@ App.Ads.report = function(building, preview = false) { payBonus(); t += `The ${building} offers a `; if (building === "brothel") { - t+= `<span class="yellowgreen">`; + t += `<span class="yellowgreen">`; } else if (building === "club") { - t+= `<span class="green">`; + t += `<span class="green">`; } t += `wide</span> selection of slaves with a variety of middles. `; } @@ -673,9 +673,9 @@ App.Ads.report = function(building, preview = false) { payBonus(); t += `The ${building} offers `; if (building === "brothel") { - t+= `<span class="yellowgreen">`; + t += `<span class="yellowgreen">`; } else if (building === "club") { - t+= `<span class="green">`; + t += `<span class="green">`; } t += `both</span> a selection of heavily altered slaves and those with more natural bodies. `; } @@ -810,11 +810,11 @@ App.Ads.report = function(building, preview = false) { payBonus(); t += `The ${building} offers `; if (building === "brothel") { - t+= `<span class="yellowgreen">`; + t += `<span class="yellowgreen">`; } else if (building === "club") { - t+= `<span class="green">`; + t += `<span class="green">`; } - t+= `both</span> all-natural girls, and slaves whose beauty has been improved by surgical means. `; + t += `both</span> all-natural girls, and slaves whose beauty has been improved by surgical means. `; } t += `Most customers don't have preferences for either all-natural or surgically enhanced and implanted girls. `; } @@ -947,17 +947,17 @@ App.Ads.report = function(building, preview = false) { payBonus(); t += `The ${building} offers a `; if (building === "brothel") { - t+= `<span class="yellowgreen">`; + t += `<span class="yellowgreen">`; } else if (building === "club") { - t+= `<span class="green">`; + t += `<span class="green">`; } t += `mix</span> of `; if (building === "brothel") { t += `whores `; - } else { + } else { t += `sluts `; - } - t+= `that can appeal to varied tastes in genitalia. `; + } + t += `that can appeal to varied tastes in genitalia. `; } t += `Most customers don't have preferences for either girls with dicks or girls with pussies. `; } @@ -1095,9 +1095,9 @@ App.Ads.report = function(building, preview = false) { payBonus(); t += `The ${building} offers girls `; if (building === "brothel") { - t+= `<span class="yellowgreen">`; + t += `<span class="yellowgreen">`; } else if (building === "club") { - t+= `<span class="green">`; + t += `<span class="green">`; } t += `both</span> young and mature. `; } @@ -1147,11 +1147,11 @@ App.Ads.report = function(building, preview = false) { if (adMgr.overallVarietyBonus()) { if (!preview) { if (building === "brothel") { - const adsIncome = DL*random(40, 60); + const adsIncome = DL * random(40, 60); V.facility[building].adsIncome += adsIncome; cashX(adsIncome, (building + "Ads")); } else if (building === "club") { - repX(DL*random(10, 15), (building + "Ads")); + repX(DL * random(10, 15), (building + "Ads")); } } t += `<div>There is a `; @@ -1214,52 +1214,52 @@ App.Ads.report = function(building, preview = false) { switch (category) { case "stacked": - r+= `<div>`; - r+= radioLink("Stacked", `${building}AdsStacked`, 1, false); - r+= radioLink("Slim", `${building}AdsStacked`, -1, false); - r+= radioLink("Variety", `${building}AdsStacked`, 0, true); - r+= `</div>`; + r += `<div>`; + r += radioLink("Stacked", `${building}AdsStacked`, 1, false); + r += radioLink("Slim", `${building}AdsStacked`, -1, false); + r += radioLink("Variety", `${building}AdsStacked`, 0, true); + r += `</div>`; return r; case "preg": - r+= `<div>`; - r+= radioLink("Gravid", `${building}AdsPreg`, 1, false); - r+= radioLink("None", `${building}AdsPreg`, -1, false); - r+= radioLink("Variety", `${building}AdsPreg`, 0, true); - r+= `</div>`; + r += `<div>`; + r += radioLink("Gravid", `${building}AdsPreg`, 1, false); + r += radioLink("None", `${building}AdsPreg`, -1, false); + r += radioLink("Variety", `${building}AdsPreg`, 0, true); + r += `</div>`; return r; case "modded": - r+= `<div>`; - r+= radioLink("Modded", `${building}AdsModded`, 1, false); - r+= radioLink("Unmodded", `${building}AdsModded`, -1, false); - r+= radioLink("Variety", `${building}AdsModded`, 0, true); - r+= `</div>`; + r += `<div>`; + r += radioLink("Modded", `${building}AdsModded`, 1, false); + r += radioLink("Unmodded", `${building}AdsModded`, -1, false); + r += radioLink("Variety", `${building}AdsModded`, 0, true); + r += `</div>`; return r; case "implanted": - r+= `<div>`; - r+= radioLink("Implants", `${building}AdsImplanted`, 1, false); - r+= radioLink("All natural", `${building}AdsImplanted`, -1, false); - r+= radioLink("Variety", `${building}AdsImplanted`, 0, true); - r+= `</div>`; + r += `<div>`; + r += radioLink("Implants", `${building}AdsImplanted`, 1, false); + r += radioLink("All natural", `${building}AdsImplanted`, -1, false); + r += radioLink("Variety", `${building}AdsImplanted`, 0, true); + r += `</div>`; return r; case "XX": - r+= `<div>`; - r+= radioLink("Pussies", `${building}AdsXX`, 1, false); - r+= radioLink("Dicks", `${building}AdsXX`, -1, false); - r+= radioLink("Variety", `${building}AdsXX`, 0, true); - r+= `</div>`; + r += `<div>`; + r += radioLink("Pussies", `${building}AdsXX`, 1, false); + r += radioLink("Dicks", `${building}AdsXX`, -1, false); + r += radioLink("Variety", `${building}AdsXX`, 0, true); + r += `</div>`; return r; case "age": - r+= `<div>`; - r+= radioLink("MILF", `${building}AdsOld`, 1, false); - r+= radioLink("Young", `${building}AdsOld`, -1, false); + r += `<div>`; + r += radioLink("MILF", `${building}AdsOld`, 1, false); + r += radioLink("Young", `${building}AdsOld`, -1, false); if (V.minimumSlaveAge < 18) { - r+= radioLink("Teen", `${building}AdsOld`, -2, false); + r += radioLink("Teen", `${building}AdsOld`, -2, false); } if (V.minimumSlaveAge < 13) { - r+= radioLink("Loli", `${building}AdsOld`, -3, false); + r += radioLink("Loli", `${building}AdsOld`, -3, false); } - r+= radioLink("Variety", `${building}AdsOld`, 0, true); - r+= `</div>`; + r += radioLink("Variety", `${building}AdsOld`, 0, true); + r += `</div>`; return r; default: console.log("You done fucked up. Building: " + building + " Category: " + category); diff --git a/src/facilities/bodyModification/bodyModification.js b/src/facilities/bodyModification/bodyModification.js index 829c3121012820f769767186504400974af2e0d2..b80a11c8ed20efa396a558bd3f1a8cbad67b0742 100644 --- a/src/facilities/bodyModification/bodyModification.js +++ b/src/facilities/bodyModification/bodyModification.js @@ -1447,7 +1447,6 @@ App.UI.bodyModification = function(slave, cheat = false) { } } - function refresh() { jQuery("#body-modification").empty().append(createPage()); } diff --git a/src/facilities/dairy/dairyFramework.js b/src/facilities/dairy/dairyFramework.js index 1ff08a4391365e089fad0c391315c81c26a1f865..36515b4243a65a91a71839a295f421b29e24bb6c 100644 --- a/src/facilities/dairy/dairyFramework.js +++ b/src/facilities/dairy/dairyFramework.js @@ -29,6 +29,14 @@ App.Data.Facilities.dairy = { }; App.Entity.Facilities.DairyCowJob = class extends App.Entity.Facilities.FacilitySingleJob { + /** + * @override + * @returns {string} + */ + get assignment() { + return `be milked in ${this.facility.name}`; + } + /** * @param {App.Entity.SlaveState} slave * @returns {string[]} @@ -59,7 +67,7 @@ App.Entity.Facilities.DairyCowJob = class extends App.Entity.Facilities.Facility if ((V.dairySlimMaintainUpgrade !== 1 && V.dairySlimMaintain <= 0) && V.dairyImplantsSetting !== 1 && V.dairyImplantsSetting !== 3) { // dairy settings disallow any procedures r.push(`${slave.slaveName} is not lactating ` + ((V.seeDicks > 0) ? 'or producing semen ' : '') + `and ${this.facility.name}'s current settings forbid the automatic implantation of lactation inducing drugs or manual stimulation to induce it, and thus cannot be a cow.`); - } else if (slave.boobs <= 300){ + } else if (slave.boobs <= 300) { r.push(`${slave.slaveName} is not lactating ` + ((V.seeDicks > 0) ? 'or producing semen ' : '') + 'and have not enough breast tissue to induce lactation.'); } } @@ -72,10 +80,6 @@ App.Entity.Facilities.DairyCowJob = class extends App.Entity.Facilities.Facility return r; } - - get assignment() { - return `be milked in ${this.facility.name}`; - } }; App.Entity.Facilities.Dairy = class extends App.Entity.Facilities.SingleJobFacility { diff --git a/src/facilities/masterSuite/masterSuiteFramework.js b/src/facilities/masterSuite/masterSuiteFramework.js index 73aa85d2931ac3829205900aaf51289d6ae05333..cdcc7d5f28a3333deb02e45c2f636ded2d546429 100644 --- a/src/facilities/masterSuite/masterSuiteFramework.js +++ b/src/facilities/masterSuite/masterSuiteFramework.js @@ -30,6 +30,14 @@ App.Data.Facilities.masterSuite = { }; App.Entity.Facilities.MasterSuiteFuckToyJob = class extends App.Entity.Facilities.FacilitySingleJob { + /** + * @override + * @returns {string} + * */ + get assignment() { + return this.facility.name; + } + /** * @param {App.Entity.SlaveState} slave * @returns {string[]} @@ -42,11 +50,6 @@ App.Entity.Facilities.MasterSuiteFuckToyJob = class extends App.Entity.Facilitie return r; } - - /** @override */ - get assignment() { - return this.facility.name; - } }; App.Entity.Facilities.ConcubineJob = class extends App.Entity.Facilities.ManagingJob { diff --git a/src/facilities/penthouse/penthouseFramework.js b/src/facilities/penthouse/penthouseFramework.js index 8d9ba1d62e2ddac823ade8be12dd6dff0a5f6e8f..b7fa25023b6df5cad44b3e2a6d57d542319290f7 100644 --- a/src/facilities/penthouse/penthouseFramework.js +++ b/src/facilities/penthouse/penthouseFramework.js @@ -1,4 +1,3 @@ - App.Data.Facilities.penthouse = { baseName: "penthouse", genericName: "Penthouse", diff --git a/src/facilities/pit/pit.js b/src/facilities/pit/pit.js index af755da26c28da46baf9a07e80299fa8c20bbeb9..c8b4ed0e9b269be042b9c054bff58baf396b2da2 100644 --- a/src/facilities/pit/pit.js +++ b/src/facilities/pit/pit.js @@ -16,7 +16,10 @@ App.Facilities.Pit.pit = function() { } else { frag.append(fighters(), lethality()); - App.UI.DOM.appendNewElement("div", frag, App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.pit, passage(), false, {assign: "Select a slave to fight", remove: "Cancel a slave's fight", transfer: null}), "pit-assign"); + App.UI.DOM.appendNewElement("div", frag, + App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.pit, passage(), false, + {assign: "Select a slave to fight", remove: "Cancel a slave's fight", transfer: null}), + "pit-assign"); } frag.appendChild(App.Facilities.rename(App.Entity.facilities.pit, () => { @@ -25,8 +28,6 @@ App.Facilities.Pit.pit = function() { return frag; - - function intro() { introDiv.classList.add("pit-intro"); diff --git a/src/facilities/schoolroom/schoolroomFramework.js b/src/facilities/schoolroom/schoolroomFramework.js index dbf8428adbe66bd2a01bb4f824323881117648a8..2770017ce38892cba7f962c7c118b51b94a345cd 100644 --- a/src/facilities/schoolroom/schoolroomFramework.js +++ b/src/facilities/schoolroom/schoolroomFramework.js @@ -29,6 +29,14 @@ App.Data.Facilities.schoolroom = { }; App.Entity.Facilities.SchoolroomStudentJob = class extends App.Entity.Facilities.FacilitySingleJob { + /** + * @override + * @returns {string} + */ + get assignment() { + return `study in ${this.facility.name}`; + } + /** * @param {App.Entity.SlaveState} slave * @returns {string[]} @@ -55,13 +63,6 @@ App.Entity.Facilities.SchoolroomStudentJob = class extends App.Entity.Facilities return r; } - - /** - * @override - */ - get assignment() { - return `study in ${this.facility.name}`; - } }; App.Entity.Facilities.Schoolroom = class extends App.Entity.Facilities.SingleJobFacility { diff --git a/src/facilities/servantsQuarters/servantsQuartersFramework.js b/src/facilities/servantsQuarters/servantsQuartersFramework.js index 17c0dbd7c6e1b084141279da5ed0591132c4dbc4..e908720753a47c470b97dd722a3e1bee70473b33 100644 --- a/src/facilities/servantsQuarters/servantsQuartersFramework.js +++ b/src/facilities/servantsQuarters/servantsQuartersFramework.js @@ -29,6 +29,14 @@ App.Data.Facilities.servantsQuarters = { }; App.Entity.Facilities.ServantsQuartersServantJob = class extends App.Entity.Facilities.FacilitySingleJob { + /** + * @override + * @returns {string} + */ + get assignment() { + return `work in ${this.facility.name}`; + } + /** * @param {App.Entity.SlaveState} slave * @returns {string[]} @@ -47,13 +55,6 @@ App.Entity.Facilities.ServantsQuartersServantJob = class extends App.Entity.Faci } return r; } - - /** - * @override - */ - get assignment() { - return `work in ${this.facility.name}`; - } }; App.Entity.Facilities.ServantsQuartersStewardessJob = class extends App.Entity.Facilities.ManagingJob { diff --git a/src/facilities/surgery/surgeryPassageFaceAndHair.js b/src/facilities/surgery/surgeryPassageFaceAndHair.js index 912153d1046e572dbc52fdefb611132072553933..2d34e25b8c5127e1cd88c6ca3c00617101b85759 100644 --- a/src/facilities/surgery/surgeryPassageFaceAndHair.js +++ b/src/facilities/surgery/surgeryPassageFaceAndHair.js @@ -265,7 +265,8 @@ App.UI.surgeryPassageHairAndFace = function(slave, cheat = false) { "age", () => { applyAgeImplant(slave); - slave.faceImplant = Math.clamp(slave.faceImplant + _artificiality, 0, 100); cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave); + slave.faceImplant = Math.clamp(slave.faceImplant + _artificiality, 0, 100); + cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave); surgeryDamage(slave, 10); } ), "choices"); diff --git a/src/facilities/surgery/surgeryPassageLower.js b/src/facilities/surgery/surgeryPassageLower.js index 81cd9118743ccfacc4844f2dacaacb50aca3db77..f38be1c92fb830125e53a0998be8ae9a2d2b2001 100644 --- a/src/facilities/surgery/surgeryPassageLower.js +++ b/src/facilities/surgery/surgeryPassageLower.js @@ -337,7 +337,7 @@ App.UI.surgeryPassageLower = function(slave, cheat = false) { if (slave.eggType !== "human") { r.push(slave.eggType); } - r.push(`ovaries${(slave.mpreg) ? ` and a womb attached to ${his} rectum`:``}.`); + r.push(`ovaries${(slave.mpreg) ? ` and a womb attached to ${his} rectum` : ``}.`); } if (slave.indentureRestrictions > 0) { @@ -791,7 +791,7 @@ App.UI.surgeryPassageLower = function(slave, cheat = false) { } if (slave.vasectomy === 1) { - r.push(`${He} has had a vasectomy and shoots blanks when ${he} cums${(slave.pubertyXY === 0 || slave.ballType === "sterile") ? `, or would, if ${he} were potent`:``}.`); + r.push(`${He} has had a vasectomy and shoots blanks when ${he} cums${(slave.pubertyXY === 0 || slave.ballType === "sterile") ? `, or would, if ${he} were potent` : ``}.`); linkArray.push(makeLink( "Reverse vasectomy", "vasectomy undo", @@ -814,7 +814,7 @@ App.UI.surgeryPassageLower = function(slave, cheat = false) { )); } } else { - r.push(`${He} has working testicles${(slave.pubertyXY === 0) ? `, though ${he} isn't potent`:``}.`); + r.push(`${He} has working testicles${(slave.pubertyXY === 0) ? `, though ${he} isn't potent` : ``}.`); if (slave.indentureRestrictions < 1) { linkArray.push(makeLink( "Clamp vas deferens to cull potency", @@ -876,7 +876,7 @@ App.UI.surgeryPassageLower = function(slave, cheat = false) { "Remove drug implant", "endprecum", () => { - slave.prostate=1; + slave.prostate = 1; } )); } @@ -886,7 +886,7 @@ App.UI.surgeryPassageLower = function(slave, cheat = false) { "Remove drug implant", "endprecum", () => { - slave.prostate=1; + slave.prostate = 1; } )); } @@ -896,7 +896,7 @@ App.UI.surgeryPassageLower = function(slave, cheat = false) { "Implant slow-release productivity drugs", "precum", () => { - slave.prostate=2; + slave.prostate = 2; surgeryDamage(slave, 10); }, 1, diff --git a/src/facilities/toyShop/toyShop.js b/src/facilities/toyShop/toyShop.js index 4cd42ee8d587606d138fb80df07605e9ee76427e..f908a246c2ef377418a344cafcf010674b50680b 100644 --- a/src/facilities/toyShop/toyShop.js +++ b/src/facilities/toyShop/toyShop.js @@ -3,15 +3,25 @@ */ App.UI.toyShop = function() { const container = document.createElement("span"); - let buttPlugName; - let buttPlugData; - let selectedPlug; - let vaginalAccName; - let vaginalAccData; - let selectedVaginalAcc; - initPlug(); - initVaginalAcc(); + /** + * @typedef toyData + * @property {string} name + * @property {number} width + * @property {number} length + */ + + /** + * @typedef toy + * @property {string} name + * @property {toyData} data + * @property {string} selected + */ + + let buttPlug = {name: "", data: null, selected: ""}; + initToy(buttPlug); + let vaginalAcc = {name: "", data: null, selected: ""}; + initToy(vaginalAcc); container.append(createPage()); return container; @@ -24,22 +34,12 @@ App.UI.toyShop = function() { return el; } - function initPlug() { - buttPlugName = ""; - buttPlugData = { - name: "", - width: 1, - length: 1 - }; - } - - function initVaginalAcc() { - vaginalAccName = ""; - vaginalAccData = { - name: "", - width: 1, - length: 1 - }; + /** + * @param {toy} toy + */ + function initToy(toy) { + toy.name = ""; + toy.data = {name: "", width: 1, length: 1}; } function intro() { @@ -53,29 +53,29 @@ App.UI.toyShop = function() { const frag = new DocumentFragment(); App.UI.DOM.appendNewElement("h2", frag, "Vaginal Accessories"); const selectDiv = App.UI.DOM.appendNewElement("div", frag, App.UI.DOM.link("Start a new design", () => { - initVaginalAcc(); + initToy(vaginalAcc); refresh(); })); if (V.customItem.vaginalAccessory.size > 0) { - selectDiv.append(selectDesign()); + selectDiv.append(selectDesign(vaginalAcc, "vaginalAccessory")); } frag.append(create()); return frag; function create() { const el = new DocumentFragment(); - const existingDesign = V.customItem.vaginalAccessory.get(vaginalAccName); + const existingDesign = V.customItem.vaginalAccessory.get(vaginalAcc.name); if (existingDesign) { el.append(descLocked()); } else { el.append(desc()); } - if (vaginalAccData.name) { - el.append(title()); + if (vaginalAcc.data.name) { + el.append(title(vaginalAcc)); } el.append( - width(), - length(), + width(vaginalAcc), + length(vaginalAcc), ); if (existingDesign) { @@ -90,139 +90,39 @@ App.UI.toyShop = function() { linkArray.push( App.UI.DOM.link( - `Recall "${vaginalAccName}"`, + `Recall "${vaginalAcc.name}"`, () => { deleteVA(); } ) ); build.append(App.UI.DOM.generateLinksStrip(linkArray)); - } else if (vaginalAccName && vaginalAccData.name){ + } else if (vaginalAcc.name && vaginalAcc.data.name) { el.append(apply()); } return el; function descLocked() { - return App.UI.DOM.makeElement("div", `Description has already been selected for this model: "${vaginalAccName}"`); + return App.UI.DOM.makeElement("div", `Description has already been selected for this model: "${vaginalAcc.name}"`); } } - function selectDesign() { - const el = new DocumentFragment(); - const choice = App.UI.DOM.appendNewElement("span", el, ` or choose an existing design to edit `); - const select = App.UI.DOM.appendNewElement("select", choice); - let matchFound = false; - for (const [key, values] of V.customItem.vaginalAccessory) { - const option = App.UI.DOM.appendNewElement("option", select, values.name); - option.value = key; - if (option.value === vaginalAccName) { - option.selected = true; - matchFound = true; - } - } - if (!matchFound) { - select.selectedIndex = -1; - } - select.onchange = () => { - const O = select.options[select.selectedIndex]; - selectedVaginalAcc = O.value; - vaginalAccName = selectedVaginalAcc; - vaginalAccData = V.customItem.vaginalAccessory.get(selectedVaginalAcc); - refresh(); - }; - return el; - } function desc() { const value = App.UI.DOM.makeElement("div", `Enter shape here as it will appear in descriptions `); value.append(App.UI.DOM.makeTextBox( - vaginalAccName, + vaginalAcc.name, v => { - vaginalAccName = v; - vaginalAccData.name = capFirstChar(v); + vaginalAcc.name = v; + vaginalAcc.data.name = capFirstChar(v); refresh(); } )); - App.UI.DOM.appendNewElement("span", value, ` Your slave has a standard ${vaginalAccName ? vaginalAccName : `pink dildo`} wedged firmly in their pussy.`, "note"); + App.UI.DOM.appendNewElement("span", value, ` Your slave has a standard ${vaginalAcc.name ? vaginalAcc.name : `pink dildo`} wedged firmly in their pussy.`, "note"); return value; } - function title() { - const title = App.UI.DOM.makeElement("div", `Enter title as it will appear in lists of choices `); - title.append(App.UI.DOM.makeTextBox( - vaginalAccData.name, - v => { - vaginalAccData.name = capFirstChar(v); - refresh(); - } - )); - return title; - } - - function width() { - const widthOptions = new Map([ - ["standard", 1], - ["large", 2], - ["huge", 3], - ]); - const width = App.UI.DOM.makeElement("div", `Select width `); - const linkArray = []; - for (const [key, value] of widthOptions) { - if (vaginalAccData.width === value) { - linkArray.push( - App.UI.DOM.disabledLink( - key, - ["Currently selected"] - ) - ); - } else { - linkArray.push( - App.UI.DOM.link( - key, - () => { - vaginalAccData.width = value; - refresh(); - } - ) - ); - } - } - width.append(App.UI.DOM.generateLinksStrip(linkArray)); - return width; - } - - function length() { - const lengthOptions = new Map([ - ["standard", 1], - ["long", 2], - ]); - const length = App.UI.DOM.makeElement("div", `Select length `); - const linkArray = []; - for (const [key, value] of lengthOptions) { - if (vaginalAccData.length === value) { - linkArray.push( - App.UI.DOM.disabledLink( - key, - ["Currently selected"] - ) - ); - } else { - linkArray.push( - App.UI.DOM.link( - key, - () => { - vaginalAccData.length = value; - refresh(); - } - ) - ); - } - } - length.append(App.UI.DOM.generateLinksStrip(linkArray)); - return length; - } - function buildVA() { - V.customItem.vaginalAccessory.set(vaginalAccName, vaginalAccData); - initVaginalAcc(); + V.customItem.vaginalAccessory.set(vaginalAcc.name, vaginalAcc.data); + initToy(vaginalAcc); refresh(); } @@ -238,9 +138,9 @@ App.UI.toyShop = function() { } function deleteVA() { - V.customItem.vaginalAccessory.delete(vaginalAccName); + V.customItem.vaginalAccessory.delete(vaginalAcc.name); for (const slave of V.slaves) { - if (slave.vaginalAccessory === vaginalAccName) { + if (slave.vaginalAccessory === vaginalAcc.name) { slave.vaginalAccessory = "none"; } } @@ -250,32 +150,31 @@ App.UI.toyShop = function() { function buttPlugs() { const frag = new DocumentFragment(); - let linkArray; App.UI.DOM.appendNewElement("h2", frag, "Buttplugs"); const selectDiv = App.UI.DOM.appendNewElement("div", frag, App.UI.DOM.link("Start a new design", () => { - initPlug(); + initToy(buttPlug); refresh(); })); if (V.customItem.buttplug.size > 0) { - selectDiv.append(selectDesign()); + selectDiv.append(selectDesign(buttPlug, "buttplug")); } frag.append(create()); return frag; function create() { const el = new DocumentFragment(); - const existingDesign = V.customItem.buttplug.get(buttPlugName); + const existingDesign = V.customItem.buttplug.get(buttPlug.name); if (existingDesign) { el.append(descLocked()); } else { el.append(desc()); } - if (buttPlugData.name) { - el.append(title()); + if (buttPlug.data.name) { + el.append(title(buttPlug)); } el.append( - width(), - length(), + width(buttPlug), + length(buttPlug), ); if (existingDesign) { @@ -290,139 +189,39 @@ App.UI.toyShop = function() { linkArray.push( App.UI.DOM.link( - `Recall "${buttPlugName}"`, + `Recall "${buttPlug.name}"`, () => { deletePlug(); } ) ); build.append(App.UI.DOM.generateLinksStrip(linkArray)); - } else if (buttPlugName && buttPlugData.name){ + } else if (buttPlug.name && buttPlug.data.name) { el.append(apply()); } return el; function descLocked() { - return App.UI.DOM.makeElement("div", `Description has already been selected for this model: "${buttPlugName}"`); + return App.UI.DOM.makeElement("div", `Description has already been selected for this model: "${buttPlug.name}"`); } } - function selectDesign() { - const el = new DocumentFragment(); - const choice = App.UI.DOM.appendNewElement("span", el, ` or choose an existing design to edit `); - const select = App.UI.DOM.appendNewElement("select", choice); - let matchFound = false; - for (const [key, values] of V.customItem.buttplug) { - const option = App.UI.DOM.appendNewElement("option", select, values.name); - option.value = key; - if (option.value === buttPlugName) { - option.selected = true; - matchFound = true; - } - } - if (!matchFound) { - select.selectedIndex = -1; - } - select.onchange = () => { - const O = select.options[select.selectedIndex]; - selectedPlug = O.value; - buttPlugName = selectedPlug; - buttPlugData = V.customItem.buttplug.get(selectedPlug); - refresh(); - }; - return el; - } function desc() { const value = App.UI.DOM.makeElement("div", `Enter shape here as it will appear in descriptions `); value.append(App.UI.DOM.makeTextBox( - buttPlugName, + buttPlug.name, v => { - buttPlugName = v; - buttPlugData.name = capFirstChar(v); + buttPlug.name = v; + buttPlug.data.name = capFirstChar(v); refresh(); } )); - App.UI.DOM.appendNewElement("span", value, ` Your slave has a standard ${buttPlugName ? buttPlugName : `spade-shaped plug`} wedged firmly in their asshole.`, "note"); + App.UI.DOM.appendNewElement("span", value, ` Your slave has a standard ${buttPlug.name ? buttPlug.name : `spade-shaped plug`} wedged firmly in their asshole.`, "note"); return value; } - function title() { - const title = App.UI.DOM.makeElement("div", `Enter title as it will appear in lists of choices `); - title.append(App.UI.DOM.makeTextBox( - buttPlugData.name, - v => { - buttPlugData.name = capFirstChar(v); - refresh(); - } - )); - return title; - } - - function width() { - const widthOptions = new Map([ - ["standard", 1], - ["large", 2], - ["huge", 3], - ]); - const width = App.UI.DOM.makeElement("div", `Select width `); - linkArray = []; - for (const [key, value] of widthOptions) { - if (buttPlugData.width === value) { - linkArray.push( - App.UI.DOM.disabledLink( - key, - ["Currently selected"] - ) - ); - } else { - linkArray.push( - App.UI.DOM.link( - key, - () => { - buttPlugData.width = value; - refresh(); - } - ) - ); - } - } - width.append(App.UI.DOM.generateLinksStrip(linkArray)); - return width; - } - - function length() { - const lengthOptions = new Map([ - ["standard", 1], - ["long", 2], - ]); - const length = App.UI.DOM.makeElement("div", `Select length `); - linkArray = []; - for (const [key, value] of lengthOptions) { - if (buttPlugData.length === value) { - linkArray.push( - App.UI.DOM.disabledLink( - key, - ["Currently selected"] - ) - ); - } else { - linkArray.push( - App.UI.DOM.link( - key, - () => { - buttPlugData.length = value; - refresh(); - } - ) - ); - } - } - length.append(App.UI.DOM.generateLinksStrip(linkArray)); - return length; - } - function buildPlug() { - V.customItem.buttplug.set(buttPlugName, buttPlugData); - initPlug(); + V.customItem.buttplug.set(buttPlug.name, buttPlug.data); + initToy(buttPlug); refresh(); } @@ -438,9 +237,9 @@ App.UI.toyShop = function() { } function deletePlug() { - V.customItem.buttplug.delete(buttPlugName); + V.customItem.buttplug.delete(buttPlug.name); for (const slave of V.slaves) { - if (slave.buttplug === buttPlugName) { + if (slave.buttplug === buttPlug.name) { slave.buttplug = "none"; } } @@ -448,7 +247,115 @@ App.UI.toyShop = function() { } } + /** + * @param {toy} toy + * @returns {HTMLDivElement} + */ + function title(toy) { + const title = App.UI.DOM.makeElement("div", `Enter title as it will appear in lists of choices `); + title.append(App.UI.DOM.makeTextBox( + toy.data.name, + v => { + toy.data.name = capFirstChar(v); + refresh(); + } + )); + return title; + } + + /** + * @param {toy} toy + * @returns {HTMLDivElement} + */ + function width(toy) { + const widthOptions = new Map([ + ["standard", 1], + ["large", 2], + ["huge", 3], + ]); + const width = App.UI.DOM.makeElement("div", `Select width `); + width.append(optionsStrip(toy.data, "width", widthOptions)); + return width; + } + + /** + * @param {toy} toy + * @returns {HTMLDivElement} + */ + function length(toy) { + const lengthOptions = new Map([ + ["standard", 1], + ["long", 2], + ]); + const length = App.UI.DOM.makeElement("div", `Select length `); + length.append(optionsStrip(toy.data, "length", lengthOptions)); + return length; + } + + /** + * @param {object} obj + * @param {string} objKey + * @param {Map<string, any>} map + * @returns {HTMLUListElement} + */ + function optionsStrip(obj, objKey, map) { + const linkArray = []; + for (const [key, value] of map) { + if (obj[objKey] === value) { + linkArray.push( + App.UI.DOM.disabledLink( + key, + ["Currently selected"] + ) + ); + } else { + linkArray.push( + App.UI.DOM.link( + key, + () => { + obj[objKey] = value; + refresh(); + } + ) + ); + } + } + return App.UI.DOM.generateLinksStrip(linkArray); + } + + /** + * @param {toy} toy + * @param {string} itemKey + * @returns {DocumentFragment} + */ + function selectDesign(toy, itemKey) { + const el = new DocumentFragment(); + const choice = App.UI.DOM.appendNewElement("span", el, ` or choose an existing design to edit `); + const select = App.UI.DOM.appendNewElement("select", choice); + let matchFound = false; + for (const [key, values] of V.customItem[itemKey]) { + const option = App.UI.DOM.appendNewElement("option", select, values.name); + option.value = key; + if (option.value === toy.name) { + option.selected = true; + matchFound = true; + } + } + if (!matchFound) { + select.selectedIndex = -1; + } + select.onchange = () => { + const O = select.options[select.selectedIndex]; + toy.selected = O.value; + toy.name = toy.selected; + toy.data = V.customItem[itemKey].get(toy.selected); + refresh(); + }; + return el; + } + function refresh() { jQuery(container).empty().append(createPage()); + console.log(vaginalAcc); } }; diff --git a/src/facilities/wardrobe/wardrobeShopping.js b/src/facilities/wardrobe/wardrobeShopping.js index 06f4beb7f1f361ca747db9634745aa1aaad9ac70..d0b2c2271f4a4356245c9cd2fef26cf60cbd279a 100644 --- a/src/facilities/wardrobe/wardrobeShopping.js +++ b/src/facilities/wardrobe/wardrobeShopping.js @@ -33,7 +33,6 @@ App.UI.WardrobeShopping = function() { } App.UI.DOM.appendNewElement("p", el, r.join(" "), "scene-intro"); - App.UI.DOM.appendNewElement("h2", el, `Future Society styles`); el.append(categoryBlock("FS"));