From e6e78b64bc4eea82396097d8f10c7d934117de6e Mon Sep 17 00:00:00 2001 From: ezsh <ezsh.junk@gmail.com> Date: Wed, 22 Apr 2020 03:13:49 +0200 Subject: [PATCH] Simplify a bit fucktoyPref and modify fragments of the SI --- src/003-assets/CSS/links.css | 14 ++ src/interaction/slaveInteract.js | 303 +++++++++++++------------------ src/js/utilsDOM.js | 6 +- 3 files changed, 142 insertions(+), 181 deletions(-) diff --git a/src/003-assets/CSS/links.css b/src/003-assets/CSS/links.css index e7f58a50fac..dec77772527 100644 --- a/src/003-assets/CSS/links.css +++ b/src/003-assets/CSS/links.css @@ -46,3 +46,17 @@ opacity: 1; transition-delay: 0.3s; } + +ul.choicesStrip { + display: inline; + list-style-type: none; + padding: 0mm; +} + +ul.choicesStrip li { + display: inline; +} + +ul.choicesStrip li + li:before { + content: " | "; +} diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index d8a3f70062e..0de96a06f41 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -21,209 +21,146 @@ App.UI.SlaveInteract.placeInLine = function(slave) { return [ slaveList[prevIndex].ID, slaveList[nextIndex].ID ]; }; +/** + * @param {App.Entity.SlaveState} slave + * @return {Node} + */ App.UI.SlaveInteract.modify = function(slave) { - /** @type {App.Entity.SlaveState} */ const {he, his} = getPronouns(slave); let el = new DocumentFragment(); let div; let note; - let sceneIntro = document.createElement('p'); - sceneIntro.className = "scene-intro"; + const isAgent = ["be your agent", "live with your agent"].includes(slave.assignment); - if (["be your agent", "live with your agent"].includes(slave.assignment)) { - sceneIntro.textContent = "Recall your agent to modify them."; - el.append(sceneIntro); - } else { - sceneIntro.textContent = "Take slave to another room."; - el.append(sceneIntro); - - // Salon - div = document.createElement('div'); - div.appendChild( - App.UI.DOM.link( - "Auto salon", - () => { - V.activeSlave = slave, - V.degradation = 0, - V.primaryHairColor = "", - V.secondaryHairColor = "", - V.primaryEarColor = "", - V.secondaryEarColor = "", - V.primaryTailColor = "", - V.secondaryTailColor = "", - V.artificialEyeColor = "", - V.artificialEyeShape = "", - V.artificialEyeFill = "", - V.tattooChoice = "", - V.piercingLevel = ""; - }, - [], - "Salon" - ) - ); - note = document.createElement('span'); - note.className="note"; - note.textContent = ` Modify hair (color, length, style), nails, and even skin color.`; - - div.append(note); - el.append(div); + App.UI.DOM.appendNewElement('p', el, isAgent ? "Recall your agent to modify them." : "Take slave to another room.", "scene-intro"); - // Body Mod - div = document.createElement('div'); - div.appendChild( - App.UI.DOM.link( - "Body mod studio", - () => { - V.activeSlave = slave, - V.degradation = 0, - V.tattooChoice = undefined; - }, - [], - "Body Modification" - ) - ); - note = document.createElement('span'); - note.className="note"; - note.textContent = ` Mark your slave with piercings, tattoos, brands or even scars.`; - - div.append(note); - el.append(div); + if (isAgent) { + return el; + } - // Surgery - div = document.createElement('div'); - div.appendChild( - App.UI.DOM.link( - "Remote surgery", - () => { - V.activeSlave = slave, - V.degradation = 0; - }, - [], - "Remote Surgery" - ) - ); - note = document.createElement('span'); - note.className="note"; - note.textContent = ` Surgically modify your slave with state of the art plastic surgery and more. Alter ${his} senses, skeletal structure, organs, and even more.`; + /** + * Create a link with a note to send a slave to a specific room + * @param {Node} c + * @param {string} caption + * @param {string} passage + * @param {string} note + * @param {function ():void} handler + */ + function makeRoomLink(c, caption, passage, note, handler) { + const res = document.createElement('div'); + c.appendChild(res); + res.appendChild(App.UI.DOM.link(caption, handler, [], passage)); + App.UI.DOM.appendNewElement('span', res, note, "note"); + return res; + } - div.append(note); - el.append(div); + makeRoomLink(el, "Auto salon", "Salon", ' Modify hair (color, length, style), nails, and even skin color.', + () => { + V.activeSlave = slave, + V.degradation = 0, + V.primaryHairColor = "", + V.secondaryHairColor = "", + V.primaryEarColor = "", + V.secondaryEarColor = "", + V.primaryTailColor = "", + V.secondaryTailColor = "", + V.artificialEyeColor = "", + V.artificialEyeShape = "", + V.artificialEyeFill = "", + V.tattooChoice = "", + V.piercingLevel = ""; + } + ); - // Prosthetics - if (V.prostheticsUpgrade > 0) { - div = document.createElement('div'); - div.appendChild( - App.UI.DOM.link( - "Configure cybernetics", - () => { - V.activeSlave = slave, - V.prostheticsConfig = "main"; - }, - [], - "Prosthetics Configuration" - ) - ); - note = document.createElement('span'); - note.className="note"; - note.textContent = ` Configure prosthetics, if ${he} has been surgically implanted with interfaces that support it.`; + makeRoomLink(el, "Body mod studio", "Body Modification", ' Mark your slave with piercings, tattoos, brands or even scars.', + () => { + V.activeSlave = slave, + V.degradation = 0, + V.tattooChoice = undefined; + }, + ); - div.append(note); - el.append(div); + makeRoomLink(el, "Remote surgery", "Remote Surgery", ` Surgically modify your slave with state of the art plastic surgery and more. Alter ${his} senses, skeletal structure, organs, and even more.`, + () => { + V.activeSlave = slave, + V.degradation = 0; } + ); + + // Prosthetics + if (V.prostheticsUpgrade > 0) { + makeRoomLink(el, "Configure cybernetics", "Prosthetics Configuration", ` Configure prosthetics, if ${he} has been surgically implanted with interfaces that support it.`, + () => { + V.activeSlave = slave, + V.prostheticsConfig = "main"; + } + ); } + return el; }; +/** + * @param {App.Entity.SlaveState} slave + */ App.UI.SlaveInteract.fucktoyPref = function(slave) { - /** @type {App.Entity.SlaveState} */ const {his} = getPronouns(slave); - let el = document.createElement('div'); + const el = document.createElement('div'); let links = []; - if ((slave.assignment === "please you") || (slave.assignment === "serve in the master suite") || (slave.assignment === "be your Concubine")) { - let storyLabel = document.createElement('span'); - storyLabel.className = "story-label"; - storyLabel.textContent = `Fucktoy use preference:`; - el.appendChild(storyLabel); + function appendLink(text, toyHole, enabled, disabledText) { + const link = {text: text}; + if (enabled) { + link.toyHole = toyHole; + } else { + link.disabled = disabledText; + } + links.push(link); + } + if ((slave.assignment === App.Data.Facilities.penthouse.jobs.fucktoy.assignment) || (slave.assignment === App.Data.Facilities.masterSuite.jobs.fucktoy.assignment) || (slave.assignment === App.Data.Facilities.masterSuite.manager.assignment)) { + App.UI.DOM.appendNewElement("span", el, "Fucktoy use preference:", "story-label"); el.append(` `); - let hole = document.createElement('span'); + const hole = App.UI.DOM.appendNewElement('span', el, `${slave.toyHole}. `); hole.style.fontWeight = "bold"; - hole.textContent = `${slave.toyHole}. `; - el.appendChild(hole); - - /** @type {object} */ - links.push({text: `Mouth`, toyHole: `mouth`}); - links.push({text: `Tits`, toyHole: `boobs`}); - if ((slave.vagina > 0) && canDoVaginal(slave)) { - links.push({text: `Pussy`, toyHole: `pussy`}); - } else if (slave.vagina === 0) { - links.push({text: `Pussy`, disabled: `Take ${his} virginity before giving ${his} pussy special attention`}); - } - if ((slave.anus > 0) && canDoAnal(slave)) { - links.push({text: `Ass`, toyHole: `ass`}); - } else { - links.push({text: `Ass`, disabled: `Take ${his} anal virginity before giving ${his} ass special attention`}); + appendLink('Mouth', 'mouth', true); + appendLink('Tits', 'boobs', true); + if (slave.vagina >= 0) { + appendLink('Pussy', 'pussy', slave.vagina > 0 && canDoVaginal(slave), `Take ${his} virginity before giving ${his} pussy special attention`); } - if ((slave.dick > 0) && canPenetrate(slave)) { - links.push({text: `Dick`, toyHole: `dick`}); + appendLink('Ass', 'ass', (slave.anus > 0) && canDoAnal(slave), `Take ${his} anal virginity before giving ${his} ass special attention`); + if (slave.dick > 0 && canPenetrate(slave)) { + appendLink('Dick', 'dick', true); } - links.push({text: `No Preference`, toyHole: `all ${his} holes`}); + appendLink('No Preference', "all her holes", true); } - el.appendChild(generateRows(links)); - function generateRows(toyHoleArray) { - let row = document.createDocumentFragment(); - for (let i = 0; i < toyHoleArray.length; i++) { - let link; - const separator = document.createTextNode(` | `); - const keys = Object.keys(toyHoleArray[i]); - - // Test to see if there was a problem with the key - for (let j = 0; j < keys.length; j++) { - if (["text", "toyHole", "disabled"].includes(keys[j])) { - continue; - } else { - toyHoleArray[i].text += " ERROR, THIS SCENE WAS NOT ENTERED CORRECTLY"; - console.log("Trash found while generateRows() was running: " + keys[j] + ": " + toyHoleArray[i][keys[j]]); - break; - } - } - // is it just text? - if (toyHoleArray[i].disabled) { - link = App.UI.DOM.disabledLink(toyHoleArray[i].text, [toyHoleArray[i].disabled]); - // Are they already on this toyHole? - } else if (toyHoleArray[i].toyHole === slave.toyHole) { - link = document.createTextNode(toyHoleArray[i].text); - // Set up the link - } else { - link = App.UI.DOM.link( - toyHoleArray[i].text, - () => { - slave.toyHole = toyHoleArray[i].toyHole, - App.UI.SlaveInteract.fucktoyPref(slave); - }, - ); + function generateLink(linkDesc) { + // is it just text? + if (linkDesc.disabled) { return App.UI.DOM.disabledLink(linkDesc.text, [linkDesc.disabled]); } + // Are they already on this toyHole? + if (linkDesc.toyHole === slave.toyHole) { return document.createTextNode(linkDesc.text); } + // Set up the link + const link = App.UI.DOM.link( + linkDesc.text, + () => { + slave.toyHole = linkDesc.toyHole; + App.UI.SlaveInteract.fucktoyPref(slave); + }, + ); - // add a note node if required - if (toyHoleArray[i].note) { - let note = document.createElement('span'); - note.textContent = `${toyHoleArray[i].note} `; - note.className = "note"; - link.appendChild(note); - } - } - row.appendChild(link); - if (i < toyHoleArray.length - 1) { - row.appendChild(separator); - } + // add a note node if required + if (linkDesc.note) { + App.UI.DOM.appendNewElement("span", link, `${linkDesc.note} `, "note"); } - - return row; + return link; } + + el.appendChild(App.UI.SlaveInteract.generateLinksStrip(links, generateLink)); + return jQuery('#fucktoypref').empty().append(el); }; @@ -269,8 +206,8 @@ App.UI.SlaveInteract.assignmentBlock = function(blockId, slave) { App.UI.DOM.link( `Stay on this assignment for another month`, () => { - slave.sentence += 4, - App.UI.SlaveInteract.assignmentBlock(blockId, slave); + slave.sentence += 4; + App.UI.SlaveInteract.assignmentBlock(blockId, slave); }, ) ); @@ -283,8 +220,8 @@ App.UI.SlaveInteract.assignmentBlock = function(blockId, slave) { App.UI.jobLinks.assignmentsFragment( V.slaveIndices[slave.ID], passage(), (slave, assignment) => { - assignJob(slave, assignment), - V.activeSlave = slave; + assignJob(slave, assignment); + V.activeSlave = slave; } ) ); @@ -1205,9 +1142,7 @@ App.UI.SlaveInteract.useSlaveDisplay = function(slave) { // Test to see if there was a problem with the key for (let j = 0; j < keys.length; j++) { - if (["text", "scene", "goto", "updateSlave", "update", "note", "disabled"].includes(keys[j])) { - continue; - } else { + if (!["text", "scene", "goto", "updateSlave", "update", "note", "disabled"].includes(keys[j])) { sexArray[i].text += " ERROR, THIS SCENE WAS NOT ENTERED CORRECTLY"; console.log("Trash found while generateRows() was running: " + keys[j] + ": " + sexArray[i][keys[j]]); break; @@ -2942,3 +2877,17 @@ App.UI.SlaveInteract.refreshAll = function(slave) { App.UI.SlaveInteract.dietBase(slave); App.UI.SlaveInteract.snacks(slave); }; + +App.UI.SlaveInteract.generateLinksStrip = function(links, mapper) { + const strip = document.createElement('ul'); + strip.className = "choicesStrip"; + + const elems = mapper ? links.map(mapper) : links; + elems.reduce((list, lnk) => { + const li = document.createElement("li"); + li.appendChild(lnk); + list.appendChild(li); + return list; + }, strip); + return strip; +}; diff --git a/src/js/utilsDOM.js b/src/js/utilsDOM.js index a88f6d5fe84..a2f71ec3b9f 100644 --- a/src/js/utilsDOM.js +++ b/src/js/utilsDOM.js @@ -169,12 +169,10 @@ App.UI.DOM.linkReplace = function(linkText, newContent) { /** * @param {string} selector for jQuery - * @param {Node} newContent + * @param {JQuery.Node} newContent */ App.UI.DOM.replace = function(selector, newContent) { - const target = $(selector); - target.empty(); - target.append(newContent); + $(selector).empty().append(newContent); }; /** -- GitLab