From 1994ed330c04e86a4695512bf5f311279e30c859 Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Wed, 7 Oct 2020 23:03:37 -0400 Subject: [PATCH] move si custom to same format as otehrs --- src/interaction/siCustom.js | 1413 ++++++++++++++++------------------- 1 file changed, 647 insertions(+), 766 deletions(-) diff --git a/src/interaction/siCustom.js b/src/interaction/siCustom.js index 743e58b3ca7..01c0d96d845 100644 --- a/src/interaction/siCustom.js +++ b/src/interaction/siCustom.js @@ -1,871 +1,752 @@ -App.UI.SlaveInteract.custom = (function() { - let el; - let label; - let result; - let textbox; - return custom; - - function custom(slave) { - let title; - el = document.createElement('div'); - - el.appendChild(intro(slave)); - - title = document.createElement('h3'); - title.textContent = `Art`; - el.appendChild(title); - el.appendChild(customSlaveImage(slave)); - el.appendChild(customHairImage(slave)); - - title = document.createElement('h3'); - title.textContent = `Names`; - el.appendChild(title); - el.appendChild(playerTitle(slave)); - el.appendChild(slaveFullName(slave)); - - title = document.createElement('h3'); - title.textContent = `Description`; - el.appendChild(title); - el.appendChild(hair(slave)); - el.appendChild(eyeColor(slave)); - el.appendChild(customTattoo(slave)); - el.appendChild(customOriginStory(slave)); - el.appendChild(customDescription(slave)); - el.appendChild(customLabel(slave)); +App.UI.SlaveInteract.custom = function(slave) { + const el = document.createElement("p"); + el.id = "si-custom"; + el.append(custom()); + return el; + + function custom() { + const { + He, His, + he, his, him, + } = getPronouns(slave); + + const el = document.createElement('div'); + + el.appendChild(intro()); + + App.UI.DOM.appendNewElement("h3", el, `Art`); + el.appendChild(customSlaveImage()); + el.appendChild(customHairImage()); + + App.UI.DOM.appendNewElement("h3", el, `Names`); + el.appendChild(playerTitle()); + el.appendChild(slaveFullName()); + + App.UI.DOM.appendNewElement("h3", el, `Description`); + el.appendChild(hair()); + el.appendChild(eyeColor()); + el.appendChild(customTattoo()); + el.appendChild(customOriginStory()); + el.appendChild(customDescription()); + el.appendChild(customLabel()); return el; - } - function intro(slave) { - const frag = new DocumentFragment(); - let p; - p = document.createElement('p'); - p.id = "rename"; - frag.append(p); - - p = document.createElement('p'); - p.className = "scene-p"; - p.append(`You may enter custom descriptors for your slave's hair color, hair style, tattoos, or anything else here. After typing, press `); - p.appendChild(App.UI.DOM.makeElement("kbd", "enter")); - p.append(` to commit your change. These custom descriptors will appear in descriptions of your slave, but will have no gameplay effect. Changing them is free.`); - frag.append(p); - return frag; - } + function intro() { + const frag = new DocumentFragment(); + let p; + p = document.createElement('p'); + p.id = "rename"; + frag.append(p); + + p = document.createElement('p'); + p.className = "scene-p"; + p.append(`You may enter custom descriptors for your slave's hair color, hair style, tattoos, or anything else here. After typing, press `); + p.appendChild(App.UI.DOM.makeElement("kbd", "enter")); + p.append(` to commit your change. These custom descriptors will appear in descriptions of your slave, but will have no gameplay effect. Changing them is free.`); + frag.append(p); + return frag; + } - function playerTitle(slave) { - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); - let playerTitle = document.createElement('p'); - label = document.createElement('div'); - if (slave.devotion >= -50) { - if (slave.custom.title !== "") { - label.textContent = `You have instructed ${him} to always refer to you as ${slave.custom.title}, which, should ${he} lisp, comes out as ${slave.custom.titleLisp}.`; - } else { - label.textContent = `You expect ${him} to refer to you as all your other slaves do.`; - } - result = document.createElement('div'); - result.id = "result"; - result.className = "choices"; - - let hiddenTextBox = document.createElement('span'); - let shownTextBox = document.createElement('span'); - if (slave.custom.title === "") { - hiddenTextBox.appendChild( - App.UI.DOM.link( - `Set a custom title for ${him} to address you as`, - () => { - jQuery('#result').empty().append(shownTextBox); - } - ) - ); - result.appendChild(hiddenTextBox); - shownTextBox.textContent = `Custom title: `; - textbox = App.UI.DOM.makeTextBox( - "", - v => { - slave.custom.title = v; - jQuery('#result').empty().append( - document.createTextNode(`${He}'ll try ${his} best to call you ${slave.custom.title}.`) - ); - slave.custom.titleLisp = lispReplace(slave.custom.title); - }); - shownTextBox.appendChild(textbox); - } else { - result.append(`${He}'s trying ${his} best to call you `); - textbox = App.UI.DOM.makeTextBox( - slave.custom.title, - v => { - slave.custom.title = v; - jQuery('#result').empty().append( - document.createTextNode(`${He}'ll try ${his} best to call you ${slave.custom.title}.`) - ); - slave.custom.titleLisp = lispReplace(slave.custom.title); - }); - result.appendChild(textbox); - result.appendChild( - App.UI.DOM.link( - ` Stop using a custom title`, - () => { + function playerTitle() { + let playerTitle = document.createElement('p'); + const label = document.createElement('div'); + let result; + let textbox; + if (slave.devotion >= -50) { + if (slave.custom.title !== "") { + label.textContent = `You have instructed ${him} to always refer to you as ${slave.custom.title}, which, should ${he} lisp, comes out as ${slave.custom.titleLisp}.`; + } else { + label.textContent = `You expect ${him} to refer to you as all your other slaves do.`; + } + result = document.createElement('div'); + result.id = "result"; + result.className = "choices"; + + let hiddenTextBox = document.createElement('span'); + let shownTextBox = document.createElement('span'); + if (slave.custom.title === "") { + hiddenTextBox.appendChild( + App.UI.DOM.link( + `Set a custom title for ${him} to address you as`, + () => { + jQuery('#result').empty().append(shownTextBox); + } + ) + ); + result.appendChild(hiddenTextBox); + shownTextBox.textContent = `Custom title: `; + textbox = App.UI.DOM.makeTextBox( + "", + v => { + slave.custom.title = v; jQuery('#result').empty().append( - document.createTextNode(`${He} will no longer refer to you with a special title.`) + document.createTextNode(`${He}'ll try ${his} best to call you ${slave.custom.title}.`) ); - slave.custom.title = ""; - slave.custom.titleLisp = ""; - } - ) - ); - } - label.appendChild(result); - } else { - label.textContent = `You must break ${his} will further before ${he} will refer to you by a new title. `; - if (SlaveStatsChecker.checkForLisp(slave)) { - if (slave.custom.titleLisp && slave.custom.titleLisp !== "") { - label.textContent += `For now, ${he} intends to keep calling you "${slave.custom.titleLisp}."`; + slave.custom.titleLisp = lispReplace(slave.custom.title); + }); + shownTextBox.appendChild(textbox); + } else { + result.append(`${He}'s trying ${his} best to call you `); + textbox = App.UI.DOM.makeTextBox( + slave.custom.title, + v => { + slave.custom.title = v; + jQuery('#result').empty().append( + document.createTextNode(`${He}'ll try ${his} best to call you ${slave.custom.title}.`) + ); + slave.custom.titleLisp = lispReplace(slave.custom.title); + }); + result.appendChild(textbox); + result.appendChild( + App.UI.DOM.link( + ` Stop using a custom title`, + () => { + jQuery('#result').empty().append( + document.createTextNode(`${He} will no longer refer to you with a special title.`) + ); + slave.custom.title = ""; + slave.custom.titleLisp = ""; + } + ) + ); } + label.appendChild(result); } else { - if (slave.custom.title && slave.custom.title !== "") { - label.textContent += `For now, ${he} intends to keep calling you "${slave.custom.title}."`; + label.textContent = `You must break ${his} will further before ${he} will refer to you by a new title. `; + if (SlaveStatsChecker.checkForLisp(slave)) { + if (slave.custom.titleLisp && slave.custom.titleLisp !== "") { + label.textContent += `For now, ${he} intends to keep calling you "${slave.custom.titleLisp}."`; + } + } else { + if (slave.custom.title && slave.custom.title !== "") { + label.textContent += `For now, ${he} intends to keep calling you "${slave.custom.title}."`; + } } } - } - playerTitle.appendChild(label); - return playerTitle; - } - - function slaveFullName(slave) { - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); - let slaveFullNameNode = document.createElement('span'); - if ( - ((slave.devotion >= -50 || slave.trust < -20) && (slave.birthName !== slave.slaveName)) || - (slave.devotion > 20 || slave.trust < -20) - ) { - slaveFullNameNode.appendChild(slaveName()); - slaveFullNameNode.appendChild(slaveSurname()); - } else { - slaveFullNameNode.textContent = `You must break ${his} will further before you can successfully force a new name on ${him}.`; - slaveFullNameNode.className = "note"; + playerTitle.appendChild(label); + return playerTitle; } - return slaveFullNameNode; - - function slaveName() { - const oldName = slave.slaveName; - const oldSurname = slave.slaveSurname; - // Slave Name - let slaveNameNode = document.createElement('p'); - label = document.createElement('div'); - result = document.createElement('div'); - result.id = "result"; - result.className = "choices"; - const linkArray = []; - - label.append(`Change ${his} given name`); - if (slave.birthName !== slave.slaveName) { - label.append(` (${his} birth name was ${slave.birthName})`); + function slaveFullName() { + let slaveFullNameNode = document.createElement('span'); + if ( + ((slave.devotion >= -50 || slave.trust < -20) && (slave.birthName !== slave.slaveName)) || + (slave.devotion > 20 || slave.trust < -20) + ) { + slaveFullNameNode.appendChild(slaveName()); + slaveFullNameNode.appendChild(slaveSurname()); + } else { + slaveFullNameNode.textContent = `You must break ${his} will further before you can successfully force a new name on ${him}.`; + slaveFullNameNode.className = "note"; } - label.append(`: `); - - textbox = App.UI.DOM.makeTextBox( - slave.slaveName, - v => { - slave.slaveName = v; - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); - }, - false, - ); - label.appendChild(textbox); - slaveNameNode.appendChild(label); + return slaveFullNameNode; + + function slaveName() { + const oldName = slave.slaveName; + const oldSurname = slave.slaveSurname; + // Slave Name + let slaveNameNode = document.createElement('p'); + let label = document.createElement('div'); + let result = document.createElement('div'); + result.id = "result"; + result.className = "choices"; + const linkArray = []; + + label.append(`Change ${his} given name`); + if (slave.birthName !== slave.slaveName) { + label.append(` (${his} birth name was ${slave.birthName})`); + } + label.append(`: `); - if (slave.slaveName === slave.birthName) { - linkArray.push(App.UI.DOM.disabledLink(`${He} has ${his} birth name`, [`Nothing to reset`])); - } else { - linkArray.push(App.UI.DOM.link( - `Restore ${his} birth name`, - () => { - slave.slaveName = slave.birthName; + let textbox = App.UI.DOM.makeTextBox( + slave.slaveName, + v => { + slave.slaveName = v; updateName(slave, {oldName: oldName, oldSurname: oldSurname}); }, false, - )); - } + ); + label.appendChild(textbox); - if (V.arcologies[0].FSPastoralist !== "unset") { - if (slave.lactation > 0) { - linkArray.push(chooseThreeNames(`Choose a random cow name for ${him}`, setup.cowSlaveNames, "cow-names")); + slaveNameNode.appendChild(label); + + if (slave.slaveName === slave.birthName) { + linkArray.push(App.UI.DOM.disabledLink(`${He} has ${his} birth name`, [`Nothing to reset`])); + } else { + linkArray.push(App.UI.DOM.link( + `Restore ${his} birth name`, + () => { + slave.slaveName = slave.birthName; + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + }, + false, + )); } - } - if (V.arcologies[0].FSIntellectualDependency !== "unset") { - if (slave.intelligence + slave.intelligenceImplant < -10) { - linkArray.push(chooseThreeNames(`Give ${him} a random stripper given name`, setup.bimboSlaveNames, "bimbo-names")); + + if (V.arcologies[0].FSPastoralist !== "unset") { + if (slave.lactation > 0) { + linkArray.push(chooseThreeNames(`Choose a random cow name for ${him}`, setup.cowSlaveNames, "cow-names")); + } } - } - if (V.arcologies[0].FSChattelReligionist !== "unset") { - linkArray.push(chooseThreeNames(`Give ${him} a random devotional given name`, setup.chattelReligionistSlaveNames, "devotional-names")); - } - result.append(App.UI.DOM.generateLinksStrip(linkArray)); - slaveNameNode.appendChild(result); - return slaveNameNode; - - function chooseThreeNames(title, array, id) { - const el = document.createElement("span"); - el.id = id; - el.append( - App.UI.DOM.link( - title, - () => { - linkGuts(); - } - ) - ); - return el; - function linkGuts() { - // Randomize the array - const shuffled = array.sort(() => 0.5 - Math.random()); - - // Get the first three new names - const names = []; - for (let i = 0; names.length < 3; i++) { - if (i > shuffled.length) { - break; - } - if (shuffled[i] !== slave.slaveName) { - names.push(shuffled[i]); - } + if (V.arcologies[0].FSIntellectualDependency !== "unset") { + if (slave.intelligence + slave.intelligenceImplant < -10) { + linkArray.push(chooseThreeNames(`Give ${him} a random stripper given name`, setup.bimboSlaveNames, "bimbo-names")); } + } + if (V.arcologies[0].FSChattelReligionist !== "unset") { + linkArray.push(chooseThreeNames(`Give ${him} a random devotional given name`, setup.chattelReligionistSlaveNames, "devotional-names")); + } + result.append(App.UI.DOM.generateLinksStrip(linkArray)); + slaveNameNode.appendChild(result); + return slaveNameNode; + + function chooseThreeNames(title, array, id) { + const el = document.createElement("span"); + el.id = id; + el.append( + App.UI.DOM.link( + title, + () => { + linkGuts(); + } + ) + ); + return el; + function linkGuts() { + // Randomize the array + const shuffled = array.sort(() => 0.5 - Math.random()); + + // Get the first three new names + const names = []; + for (let i = 0; names.length < 3; i++) { + if (i > shuffled.length) { + break; + } + if (shuffled[i] !== slave.slaveName) { + names.push(shuffled[i]); + } + } - // return the three names as links - const nameLinks = []; - for (const name of names) { + // return the three names as links + const nameLinks = []; + for (const name of names) { + nameLinks.push( + App.UI.DOM.link( + name, + () => { + slave.slaveName = name; + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + } + ) + ); + } nameLinks.push( App.UI.DOM.link( - name, + "...", () => { - slave.slaveName = name; - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + linkGuts(); } ) ); + jQuery(`#${id}`).empty().append(App.UI.DOM.generateLinksStrip(nameLinks)); } - nameLinks.push( - App.UI.DOM.link( - "...", - () => { - linkGuts(); - } - ) - ); - jQuery(`#${id}`).empty().append(App.UI.DOM.generateLinksStrip(nameLinks)); } } - } - - function slaveSurname() { - // Slave Surname - const oldName = slave.slaveName; - const oldSurname = slave.slaveSurname; - const linkArray = []; - let slaveSurnameNode = document.createElement('p'); - label = document.createElement('div'); - result = document.createElement('div'); - result.id = "result"; - result.className = "choices"; - - label.append(`Change ${his} surname`); - if (slave.birthSurname !== slave.slaveSurname) { - label.append(` (${his} birth surname was ${slave.birthSurname})`); - } - label.append(`: `); - - textbox = App.UI.DOM.makeTextBox( - slave.slaveSurname, - v => { - slave.slaveSurname = textbox.value; - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); - }, - false, - ); - label.appendChild(textbox); - slaveSurnameNode.appendChild(label); + function slaveSurname() { + // Slave Surname + const oldName = slave.slaveName; + const oldSurname = slave.slaveSurname; + const linkArray = []; + let slaveSurnameNode = document.createElement('p'); + let label = document.createElement('div'); + let result = document.createElement('div'); + result.id = "result"; + result.className = "choices"; + + label.append(`Change ${his} surname`); + if (slave.birthSurname !== slave.slaveSurname) { + label.append(` (${his} birth surname was ${slave.birthSurname})`); + } + label.append(`: `); - if (slave.slaveSurname === slave.birthSurname) { - linkArray.push( - App.UI.DOM.disabledLink( - `Restore ${his} birth surname`, - [`${He} has ${his} birth surname`] - ) - ); - } else { - linkArray.push(App.UI.DOM.link( - ` Restore ${his} birth surname`, - () => { - slave.slaveSurname = slave.birthSurname; + let textbox = App.UI.DOM.makeTextBox( + slave.slaveSurname, + v => { + slave.slaveSurname = textbox.value; updateName(slave, {oldName: oldName, oldSurname: oldSurname}); }, false, - )); - } + ); + label.appendChild(textbox); - if (slave.slaveSurname) { - linkArray.push(App.UI.DOM.link( - `Take ${his} surname away`, - () => { - slave.slaveSurname = 0; - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); - }, - false, - )); - } - if (slave.relationship >= 5) { - const spouse = getSlave(slave.relationshipTarget); - if (spouse.slaveSurname && slave.slaveSurname !== spouse.slaveSurname) { - const wifePronouns = getPronouns(spouse); + slaveSurnameNode.appendChild(label); + + if (slave.slaveSurname === slave.birthSurname) { + linkArray.push( + App.UI.DOM.disabledLink( + `Restore ${his} birth surname`, + [`${He} has ${his} birth surname`] + ) + ); + } else { + linkArray.push(App.UI.DOM.link( + ` Restore ${his} birth surname`, + () => { + slave.slaveSurname = slave.birthSurname; + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + }, + false, + )); + } + + if (slave.slaveSurname) { + linkArray.push(App.UI.DOM.link( + `Take ${his} surname away`, + () => { + slave.slaveSurname = 0; + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + }, + false, + )); + } + if (slave.relationship >= 5) { + const spouse = getSlave(slave.relationshipTarget); + if (spouse.slaveSurname && slave.slaveSurname !== spouse.slaveSurname) { + const wifePronouns = getPronouns(spouse); + linkArray.push( + App.UI.DOM.link( + `Give ${him} ${his} ${wifePronouns.wife}'s surname`, + () => { + slave.slaveSurname = spouse.slaveSurname; + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + }, + false, + ) + ); + } + } + if (slave.relationship === -3) { + if (V.PC.slaveSurname && slave.slaveSurname !== V.PC.slaveSurname) { + linkArray.push( + App.UI.DOM.link( + `Give ${him} your surname`, + () => { + slave.slaveSurname = V.PC.slaveSurname; + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + }, + false, + ) + ); + } + } + if (V.arcologies[0].FSRomanRevivalist !== "unset") { + linkArray.push( + App.UI.DOM.link( + `Give ${him} a random full Roman name`, + () => { + slave.slaveName = setup.romanSlaveNames.random(); + slave.slaveSurname = setup.romanSlaveSurnames.random(); + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + }, + false, + ) + ); + } else if (V.arcologies[0].FSAztecRevivalist !== "unset") { + linkArray.push( + App.UI.DOM.link( + `Give ${him} a random full Aztec name`, + () => { + slave.slaveName = setup.aztecSlaveNames.random(); + slave.slaveSurname = 0; + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + }, + false, + ) + ); + } else if (V.arcologies[0].FSEgyptianRevivalist !== "unset") { + linkArray.push( + App.UI.DOM.link( + `Give ${him} a random full ancient Egyptian name`, + () => { + slave.slaveName = setup.ancientEgyptianSlaveNames.random(); + slave.slaveSurname = 0; + updateName(slave, {oldName: oldName, oldSurname: oldSurname}); + }, + false, + ) + ); + } else if (V.arcologies[0].FSEdoRevivalist !== "unset") { linkArray.push( App.UI.DOM.link( - `Give ${him} ${his} ${wifePronouns.wife}'s surname`, + `Give ${him} a random full feudal Japanese name`, () => { - slave.slaveSurname = spouse.slaveSurname; + slave.slaveName = setup.edoSlaveNames.random(); + slave.slaveSurname = setup.edoSlaveSurnames.random(); updateName(slave, {oldName: oldName, oldSurname: oldSurname}); }, false, ) ); } - } - if (slave.relationship === -3) { - if (V.PC.slaveSurname && slave.slaveSurname !== V.PC.slaveSurname) { + if (V.arcologies[0].FSDegradationist > -1) { linkArray.push( App.UI.DOM.link( - `Give ${him} your surname`, + `Give ${him} a degrading full name`, () => { - slave.slaveSurname = V.PC.slaveSurname; + DegradingName(slave); updateName(slave, {oldName: oldName, oldSurname: oldSurname}); }, false, ) ); } + result.append(App.UI.DOM.generateLinksStrip(linkArray)); + slaveSurnameNode.appendChild(result); + return slaveSurnameNode; } - if (V.arcologies[0].FSRomanRevivalist !== "unset") { - linkArray.push( - App.UI.DOM.link( - `Give ${him} a random full Roman name`, - () => { - slave.slaveName = setup.romanSlaveNames.random(); - slave.slaveSurname = setup.romanSlaveSurnames.random(); - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); - }, - false, - ) - ); - } else if (V.arcologies[0].FSAztecRevivalist !== "unset") { - linkArray.push( - App.UI.DOM.link( - `Give ${him} a random full Aztec name`, - () => { - slave.slaveName = setup.aztecSlaveNames.random(); - slave.slaveSurname = 0; - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); - }, - false, - ) - ); - } else if (V.arcologies[0].FSEgyptianRevivalist !== "unset") { - linkArray.push( - App.UI.DOM.link( - `Give ${him} a random full ancient Egyptian name`, - () => { - slave.slaveName = setup.ancientEgyptianSlaveNames.random(); - slave.slaveSurname = 0; - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); - }, - false, - ) - ); - } else if (V.arcologies[0].FSEdoRevivalist !== "unset") { - linkArray.push( - App.UI.DOM.link( - `Give ${him} a random full feudal Japanese name`, - () => { - slave.slaveName = setup.edoSlaveNames.random(); - slave.slaveSurname = setup.edoSlaveSurnames.random(); - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); - }, - false, - ) - ); - } - if (V.arcologies[0].FSDegradationist > -1) { - linkArray.push( - App.UI.DOM.link( - `Give ${him} a degrading full name`, - () => { - DegradingName(slave); - updateName(slave, {oldName: oldName, oldSurname: oldSurname}); - }, - false, - ) - ); + function updateName(slave, {oldName: oldName, oldSurname: oldSurname}) { + App.UI.SlaveInteract.rename(slave, {oldName: oldName, oldSurname: oldSurname}); + refresh(); } - result.append(App.UI.DOM.generateLinksStrip(linkArray)); - slaveSurnameNode.appendChild(result); - return slaveSurnameNode; } - function updateName(slave, {oldName: oldName, oldSurname: oldSurname}) { - App.UI.SlaveInteract.custom(slave); - App.UI.SlaveInteract.rename(slave, {oldName: oldName, oldSurname: oldSurname}); - } - } - /** - * @param {App.Entity.SlaveState} slave - */ - function hair(slave) { - let hairNode = new DocumentFragment(); - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); + function hair() { + let hairNode = new DocumentFragment(); + hairNode.appendChild(hairStyle()); + hairNode.appendChild(hairColor()); + return hairNode; - hairNode.appendChild(hairStyle()); - hairNode.appendChild(hairColor()); - return hairNode; + function hairStyle() { + let hairStyleNode = document.createElement('p'); + let label = document.createElement('div'); + label.append(`Custom hair description: `); - function hairStyle() { - let hairStyleNode = document.createElement('p'); - let label = document.createElement('div'); - label.append(`Custom hair description: `); + let textbox = App.UI.DOM.makeTextBox( + slave.hStyle, + v => { + slave.hStyle = v; + refresh(); + }); + label.appendChild(textbox); + + switch (slave.hStyle) { + case "tails": + case "dreadlocks": + case "cornrows": + label.append(` "${His} hair is in ${slave.hStyle}."`); + break; + case "ponytail": + label.append(` "${His} hair is in a ${slave.hStyle}."`); + break; + default: + label.append(` "${His} hair is ${slave.hStyle}."`); + break; + } + hairStyleNode.appendChild(label); - let textbox = App.UI.DOM.makeTextBox( - slave.hStyle, - v => { - slave.hStyle = v; - App.UI.SlaveInteract.custom(slave); - }); - label.appendChild(textbox); - - switch (slave.hStyle) { - case "tails": - case "dreadlocks": - case "cornrows": - label.append(` "${His} hair is in ${slave.hStyle}."`); - break; - case "ponytail": - label.append(` "${His} hair is in a ${slave.hStyle}."`); - break; - default: - label.append(` "${His} hair is ${slave.hStyle}."`); - break; + let choices = document.createElement('div'); + choices.className = "choices"; + choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short, uncapitalized and unpunctuated description; for example: 'back in a ponytail'`, 'note')); + hairStyleNode.appendChild(choices); + return hairStyleNode; } - hairStyleNode.appendChild(label); - let choices = document.createElement('div'); - choices.className = "choices"; - choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short, uncapitalized and unpunctuated description; for example: 'back in a ponytail'`, 'note')); - hairStyleNode.appendChild(choices); - return hairStyleNode; + function hairColor() { + let hairStyleNode = document.createElement('p'); + let label = document.createElement('div'); + label.append(`Custom hair color: `); + + let textbox = App.UI.DOM.makeTextBox( + slave.hColor, + v => { + slave.hColor = v; + refresh(); + }); + label.appendChild(textbox); + label.append(` "${His} hair is ${slave.hColor}."`); + hairStyleNode.appendChild(label); + + let choices = document.createElement('div'); + choices.className = "choices"; + choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short, uncapitalized and unpunctuated description; for example: 'black with purple highlights'`, 'note')); + hairStyleNode.appendChild(choices); + return hairStyleNode; + } } - function hairColor() { - let hairStyleNode = document.createElement('p'); + function eyeColor() { + let eyeColorNode = document.createElement('p'); let label = document.createElement('div'); - label.append(`Custom hair color: `); - - let textbox = App.UI.DOM.makeTextBox( - slave.hColor, - v => { - slave.hColor = v; - App.UI.SlaveInteract.custom(slave); - }); - label.appendChild(textbox); - label.append(` "${His} hair is ${slave.hColor}."`); - hairStyleNode.appendChild(label); + if (getLenseCount(slave) > 0) { + label.textContent = `${He} is wearing ${App.Desc.eyesColor(slave, "", "lense", "lenses")}.`; + } else { + label.textContent = `${He} has ${App.Desc.eyesColor(slave)}.`; + } + eyeColorNode.appendChild(label); let choices = document.createElement('div'); choices.className = "choices"; - choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short, uncapitalized and unpunctuated description; for example: 'black with purple highlights'`, 'note')); - hairStyleNode.appendChild(choices); - return hairStyleNode; - } - } - /** - * @param {App.Entity.SlaveState} slave - */ - function eyeColor(slave) { - let eyeColorNode = document.createElement('p'); - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); - let label = document.createElement('div'); - if (getLenseCount(slave) > 0) { - label.textContent = `${He} is wearing ${App.Desc.eyesColor(slave, "", "lense", "lenses")}.`; - } else { - label.textContent = `${He} has ${App.Desc.eyesColor(slave)}.`; + let eye; + let textbox; + + if (hasLeftEye(slave)) { + eye = document.createElement('div'); + eye.append(`Custom left eye color: `); + textbox = App.UI.DOM.makeTextBox( + slave.eye.left.iris, + v => { + slave.eye.left.iris = v; + refresh(); + }); + eye.appendChild(textbox); + choices.appendChild(eye); + } + if (hasRightEye(slave)) { + eye = document.createElement('div'); + eye.append(`Custom right eye color: `); + textbox = App.UI.DOM.makeTextBox( + slave.eye.right.iris, + v => { + slave.eye.right.iris = v; + refresh(); + }); + eye.appendChild(textbox); + choices.appendChild(eye); + } + choices.appendChild(App.UI.DOM.makeElement('span', `For best results, use a short, uncapitalized and unpunctuated description; for example: 'blue'`, 'note')); + eyeColorNode.appendChild(choices); + return eyeColorNode; } - eyeColorNode.appendChild(label); - let choices = document.createElement('div'); - choices.className = "choices"; + function customTattoo() { + let el = document.createElement('p'); + el.append(`Change ${his} custom tattoo: `); + el.appendChild(App.UI.DOM.makeTextBox( + slave.custom.tattoo, + v => { + slave.custom.tattoo = v; + refresh(); + })); - let eye; - let textbox; + let choices = document.createElement('div'); + choices.className = "choices"; + choices.appendChild(App.UI.DOM.makeElement('span', `For best results, use complete sentences; for example: '${He} has blue stars tattooed along ${his} cheekbones.'`, 'note')); + el.appendChild(choices); - if (hasLeftEye(slave)) { - eye = document.createElement('div'); - eye.append(`Custom left eye color: `); - textbox = App.UI.DOM.makeTextBox( - slave.eye.left.iris, - v => { - slave.eye.left.iris = v; - App.UI.SlaveInteract.custom(slave); - }); - eye.appendChild(textbox); - choices.appendChild(eye); + return el; } - if (hasRightEye(slave)) { - eye = document.createElement('div'); - eye.append(`Custom right eye color: `); - textbox = App.UI.DOM.makeTextBox( - slave.eye.right.iris, + + function customOriginStory() { + let el = document.createElement('p'); + el.append(`Change ${his} origin story: `); + el.appendChild(App.UI.DOM.makeTextBox( + slave.origin, v => { - slave.eye.right.iris = v; - App.UI.SlaveInteract.custom(slave); - }); - eye.appendChild(textbox); - choices.appendChild(eye); + slave.origin = v; + refresh(); + })); + + let choices = document.createElement('div'); + choices.className = "choices"; + choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use complete, capitalized and punctuated sentences; for example: '${He} followed you home from the pet store.'`, 'note')); + el.appendChild(choices); + + return el; } - choices.appendChild(App.UI.DOM.makeElement('span', `For best results, use a short, uncapitalized and unpunctuated description; for example: 'blue'`, 'note')); - eyeColorNode.appendChild(choices); - return eyeColorNode; - } - /** - * @param {App.Entity.SlaveState} slave - */ - function customTattoo(slave) { - let el = document.createElement('p'); - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); - el.append(`Change ${his} custom tattoo: `); - el.appendChild(App.UI.DOM.makeTextBox( - slave.custom.tattoo, - v => { - slave.custom.tattoo = v; - App.UI.SlaveInteract.custom(slave); - })); - - let choices = document.createElement('div'); - choices.className = "choices"; - choices.appendChild(App.UI.DOM.makeElement('span', `For best results, use complete sentences; for example: '${He} has blue stars tattooed along ${his} cheekbones.'`, 'note')); - el.appendChild(choices); + function customDescription() { + let el = document.createElement('p'); + el.append(`Change ${his} custom description: `); + el.appendChild( + App.UI.DOM.makeTextBox( + pronounsForSlaveProp(slave, slave.custom.desc), + v => { + slave.custom.desc = v; + refresh(); + } + ) + ); - return el; - } + let choices = document.createElement('div'); + choices.className = "choices"; + choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use complete, capitalized and punctuated sentences; for example: '${He} has a beauty mark above ${his} left nipple.'`, 'note')); + el.appendChild(choices); - function customOriginStory(slave) { - let el = document.createElement('p'); - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); + return el; + } - el.append(`Change ${his} origin story: `); - el.appendChild(App.UI.DOM.makeTextBox( - slave.origin, - v => { - slave.origin = v; - App.UI.SlaveInteract.custom(slave); - })); + function customLabel() { + let el = document.createElement('p'); + el.append(`Change ${his} custom label: `); + el.appendChild(App.UI.DOM.makeTextBox( + slave.custom.label, + v => { + slave.custom.label = v; + refresh(); + })); - let choices = document.createElement('div'); - choices.className = "choices"; - choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use complete, capitalized and punctuated sentences; for example: '${He} followed you home from the pet store.'`, 'note')); - el.appendChild(choices); + let choices = document.createElement('div'); + choices.className = "choices"; + choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short phrase; for example: 'Breeder.'`, 'note')); + el.appendChild(choices); - return el; - } + return el; + } - function customDescription(slave) { - let el = document.createElement('p'); - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); + function customSlaveImage() { + let el = document.createElement('p'); + el.append(`Assign ${him} a custom image: `); + + let textbox = document.createElement("INPUT"); + textbox.id = "customImageValue"; + el.appendChild(textbox); + + + let kbd = document.createElement('kbd'); + let select = document.createElement('SELECT'); + select.id = "customImageFormatSelector"; + select.style.border = "none"; + + let filetypes = [ + "png", + "jpg", + "gif", + "webm", + "webp", + "mp4" + ]; + + filetypes.forEach((fileType) => { + let el = document.createElement('OPTION'); + el.value = fileType; + el.text = fileType.toUpperCase(); + select.add(el); + }); + kbd.append(`.`); + kbd.appendChild(select); + el.appendChild(kbd); - el.append(`Change ${his} custom description: `); - el.appendChild(App.UI.DOM.makeTextBox( - pronounsForSlaveProp(slave, slave.custom.desc), - v => { - slave.custom.desc = v; - App.UI.SlaveInteract.custom(slave); - })); + el.appendChild( + App.UI.DOM.link( + ` Reset`, + () => { + slave.custom.image = null; + refresh(); + App.Art.refreshSlaveArt(slave, 3, "art-frame"); + }, + ) + ); - let choices = document.createElement('div'); - choices.className = "choices"; - choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use complete, capitalized and punctuated sentences; for example: '${He} has a beauty mark above ${his} left nipple.'`, 'note')); - el.appendChild(choices); + let choices = document.createElement('div'); + choices.className = "choices"; + let note = document.createElement('span'); + note.className = "note"; + note.append(`Place file in the `); - return el; - } + kbd = document.createElement('kbd'); + kbd.append(`resources`); + note.appendChild(kbd); - function customLabel(slave) { - let el = document.createElement('p'); - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); + note.append(` folder. Choose the extension from the menu first, then enter the filename in the space and press enter. For example, for a file with the path `); - el.append(`Change ${his} custom label: `); - el.appendChild(App.UI.DOM.makeTextBox( - slave.custom.label, - v => { - slave.custom.label = v; - App.UI.SlaveInteract.custom(slave); - })); + kbd = document.createElement('kbd'); + kbd.textContent = `\\bin\\resources\\headgirl.`; + let filetypeDesc = document.createElement('span'); + filetypeDesc.id = "customImageFormatValue"; + filetypeDesc.textContent = "png"; + kbd.appendChild(filetypeDesc); + note.appendChild(kbd); - let choices = document.createElement('div'); - choices.className = "choices"; - choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short phrase; for example: 'Breeder.'`, 'note')); - el.appendChild(choices); + note.append(`, choose `); - return el; - } + kbd = document.createElement('kbd'); + kbd.textContent = `PNG`; + note.appendChild(kbd); + note.append(` then enter `); - function customSlaveImage(slave) { - let el = document.createElement('p'); - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); - el.append(`Assign ${him} a custom image: `); - - let textbox = document.createElement("INPUT"); - textbox.id = "customImageValue"; - el.appendChild(textbox); - - - let kbd = document.createElement('kbd'); - let select = document.createElement('SELECT'); - select.id = "customImageFormatSelector"; - select.style.border = "none"; - - let filetypes = [ - "png", - "jpg", - "gif", - "webm", - "webp", - "mp4" - ]; - - filetypes.forEach((fileType) => { - let el = document.createElement('OPTION'); - el.value = fileType; - el.text = fileType.toUpperCase(); - select.add(el); - }); - kbd.append(`.`); - kbd.appendChild(select); - el.appendChild(kbd); - - el.appendChild( - App.UI.DOM.link( - ` Reset`, - () => { - slave.custom.image = null; - App.UI.SlaveInteract.custom(slave); - App.Art.refreshSlaveArt(slave, 3, "art-frame"); - }, - ) - ); - - let choices = document.createElement('div'); - choices.className = "choices"; - let note = document.createElement('span'); - note.className = "note"; - note.append(`Place file in the `); - - kbd = document.createElement('kbd'); - kbd.append(`resources`); - note.appendChild(kbd); - - note.append(` folder. Choose the extension from the menu first, then enter the filename in the space and press enter. For example, for a file with the path `); - - kbd = document.createElement('kbd'); - kbd.textContent = `\\bin\\resources\\headgirl.`; - let filetypeDesc = document.createElement('span'); - filetypeDesc.id = "customImageFormatValue"; - filetypeDesc.textContent = "png"; - kbd.appendChild(filetypeDesc); - note.appendChild(kbd); - - note.append(`, choose `); - - kbd = document.createElement('kbd'); - kbd.textContent = `PNG`; - note.appendChild(kbd); - - note.append(` then enter `); - - kbd = document.createElement('kbd'); - kbd.textContent = `headgirl`; - note.appendChild(kbd); - - note.append(`.`); - choices.appendChild(note); - el.appendChild(choices); - - jQuery(function() { - function activeSlave() { - return slave; - } + kbd = document.createElement('kbd'); + kbd.textContent = `headgirl`; + note.appendChild(kbd); - jQuery("#customImageFormatValue").text(activeSlave().custom.image === null ? "png" : activeSlave().custom.image.format); - jQuery("#customImageValue") - .val(activeSlave().custom.image === null ? - "" : activeSlave().custom.image.filename) - .on("change", function(e) { - const c = activeSlave().custom; - if (this.value.length === 0) { - c.image = null; - } else { - if (c.image === null) { - c.image = { - filename: this.value, - format: jQuery("#customImageFormatSelector").val() - }; - App.Art.refreshSlaveArt(slave, 3, "art-frame"); + note.append(`.`); + choices.appendChild(note); + el.appendChild(choices); + + jQuery(function() { + function activeSlave() { + return slave; + } + + jQuery("#customImageFormatValue").text(activeSlave().custom.image === null ? "png" : activeSlave().custom.image.format); + jQuery("#customImageValue") + .val(activeSlave().custom.image === null ? + "" : activeSlave().custom.image.filename) + .on("change", function(e) { + const c = activeSlave().custom; + if (this.value.length === 0) { + c.image = null; } else { - c.image.filename = this.value; - App.Art.refreshSlaveArt(slave, 3, "art-frame"); + if (c.image === null) { + c.image = { + filename: this.value, + format: jQuery("#customImageFormatSelector").val() + }; + App.Art.refreshSlaveArt(slave, 3, "art-frame"); + } else { + c.image.filename = this.value; + App.Art.refreshSlaveArt(slave, 3, "art-frame"); + } } - } - }); - jQuery("#customImageFormatSelector") - .val(activeSlave().custom.image ? activeSlave().custom.image.format : "png") - .on("change", function(e) { - if (activeSlave().custom.image !== null) { - activeSlave().custom.image.format = this.value; - } - jQuery("#customImageFormatValue").text(this.value); - }); - }); - return el; - } + }); + jQuery("#customImageFormatSelector") + .val(activeSlave().custom.image ? activeSlave().custom.image.format : "png") + .on("change", function(e) { + if (activeSlave().custom.image !== null) { + activeSlave().custom.image.format = this.value; + } + jQuery("#customImageFormatValue").text(this.value); + }); + }); + return el; + } - function customHairImage(slave) { - let el = document.createElement('p'); - const { - // eslint-disable-next-line no-unused-vars - he, - him, - his, - hers, - himself, - boy, - He, - His - } = getPronouns(slave); + function customHairImage() { + let el = document.createElement('p'); + if (V.seeImages === 1 && V.imageChoice === 1) { + if (!slave.custom.hairVector) { + slave.custom.hairVector = 0; + } + el.append(`Assign ${him} a custom hair SVG image: `); - if (V.seeImages === 1 && V.imageChoice === 1) { - if (!slave.custom.hairVector) { - slave.custom.hairVector = 0; - } - el.append(`Assign ${him} a custom hair SVG image: `); + el.appendChild(App.UI.DOM.makeTextBox( + slave.custom.hairVector, + v => { + slave.custom.hairVector = v; + refresh(); + })); - el.appendChild(App.UI.DOM.makeTextBox( - slave.custom.hairVector, - v => { - slave.custom.hairVector = v; - App.UI.SlaveInteract.custom(slave); - })); + el.appendChild( + App.UI.DOM.link( + ` Reset`, + () => { + slave.custom.hairVector = 0; + refresh(); + App.Art.refreshSlaveArt(slave, 3, "art-frame"); + }, + ) + ); + } - el.appendChild( - App.UI.DOM.link( - ` Reset`, - () => { - slave.custom.hairVector = 0; - App.UI.SlaveInteract.custom(slave); - App.Art.refreshSlaveArt(slave, 3, "art-frame"); - }, - ) - ); + return el; } + } - return el; + function refresh() { + jQuery("#si-custom").empty().append(custom()); } -})(); +}; -- GitLab