diff --git a/src/interaction/siUtilities.js b/src/interaction/siUtilities.js index 789913b34c5bf9f0d0a35595a5ced81949b3baaa..b5569e4a240d44140c4a368d415f1925e08d96cc 100644 --- a/src/interaction/siUtilities.js +++ b/src/interaction/siUtilities.js @@ -145,5 +145,4 @@ App.UI.SlaveInteract.generateRows = function(array, slave, category, accessCheck App.UI.SlaveInteract.refreshAll = function(slave) { App.UI.SlaveInteract.custom(slave); - App.UI.SlaveInteract.work(slave); }; diff --git a/src/interaction/siWork.js b/src/interaction/siWork.js new file mode 100644 index 0000000000000000000000000000000000000000..cc1b55c6cb931bfb67ca0d4feebde89248d7fb0d --- /dev/null +++ b/src/interaction/siWork.js @@ -0,0 +1,296 @@ +App.UI.SlaveInteract.work = function(slave) { + const el = document.createElement("p"); + el.id = "si-work"; + el.append(description()); + return el; + + function work() { + let el = new DocumentFragment(); + let p; + let div; + let span; + const links = []; + const { + He, + him + } = getPronouns(slave); + + function appendLink(text, whoreClass, enabled, disabledText) { + const link = {text: text}; + if (enabled) { + link.whoreClass = whoreClass; + } else { + link.disabled = disabledText; + } + links.push(link); + } + + p = document.createElement('p'); + if (slave.assignment === Job.AGENT) { + const arc = V.arcologies.find((a) => a.leaderID === slave.ID); + p.className = "scene-intro"; + p.textContent = `${He} is serving as your Agent${arc ? ` leading ${arc.name}` : ` but is not currently assigned to an arcology`}. `; + p.appendChild(App.UI.DOM.link(`Recall and reenslave ${him}`, () => { removeJob(slave, slave.assignment, false); App.UI.SlaveInteract.work(slave); })); + } else if (slave.assignment === Job.AGENTPARTNER) { + const agent = getSlave(slave.relationshipTarget); + const arc = agent ? V.arcologies.find((a) => a.leaderID === agent.ID) : null; + p.className = "scene-intro"; + p.textContent = `${He} is living with your Agent ${SlaveFullName(agent)}${arc ? ` in ${arc.name}` : ``}. `; + p.appendChild(App.UI.DOM.link(`Recall ${him}`, () => { removeJob(slave, slave.assignment, false); App.UI.SlaveInteract.work(slave); })); + } else { + div = document.createElement('div'); + div.id = "mini-scene"; + p.appendChild(div); + + span = document.createElement('span'); + span.id = "useSlave"; + p.appendChild(span); + p.appendChild(App.UI.SlaveInteract.useSlaveDisplay(slave)); + } + el.append(p); + + p = document.createElement('p'); + span = document.createElement('span'); + span.className = "note"; + switch (slave.assignment) { + case Job.BODYGUARD: + span.textContent = `${He} is your Bodyguard and is not available for other work`; + break; + case Job.MADAM: + span.textContent = `${He} is the Madam and is not available for other work`; + break; + case Job.DJ: + span.textContent = `${He} is the DJ and is not available for other work`; + break; + case Job.MILKMAID: + span.textContent = `${He} is the Milkmaid and is not available for other work`; + break; + case Job.FARMER: + span.textContent = `${He} is the Farmer and is not available for other work`; + break; + case Job.STEWARD: + span.textContent = `${He} is the Stewardess and is not available for other work`; + break; + case Job.HEADGIRL: + span.textContent = `${He} is your Head Girl and is not available for other work`; + break; + case Job.RECRUITER: + span.textContent = `${He} is recruiting slaves and is not available for other work`; + break; + case Job.NURSE: + span.textContent = `${He} is the Nurse and is not available for other work`; + break; + case Job.ATTENDANT: + span.textContent = `${He} is the Attendant of the spa and is not available for other work`; + break; + case Job.MATRON: + span.textContent = `${He} is the Matron of the nursery and is not available for other work`; + break; + case Job.TEACHER: + span.textContent = `${He} is the Schoolteacher and is not available for other work`; + break; + case Job.CONCUBINE: + span.textContent = `${He} is your Concubine and is not available for other work`; + break; + case Job.WARDEN: + span.textContent = `${He} is the Wardeness and is not available for other work`; + break; + default: + // CAN BE REASSIGNED + span.classList.remove("note"); + span.id = "assignmentLinks"; + span.appendChild(assignmentBlock()); + + if ((V.brothel + V.club + V.dairy + V.farmyard + V.servantsQuarters + V.masterSuite + V.spa + V.nursery + V.clinic + V.schoolroom + V.cellblock + V.arcade + V.HGSuite) > 0) { + span.append(`Transfer to: `); + span.appendChild(App.UI.jobLinks.transfersFragment(slave.ID)); + } + + div = document.createElement('div'); + div.id = "fucktoy-pref"; + div.append(App.UI.SlaveInteract.fucktoyPref(slave)); + span.appendChild(div); + } + el.append(span); + + if (slave.assignment === Job.WHORE || slave.assignment === Job.BROTHEL) { + div = document.createElement('div'); + div.textContent = `Whoring Target: `; + span = document.createElement('span'); + span.style.fontWeight = "bold"; + + span.id = "whoreClass"; + if (!slave.whoreClass) { + span.textContent = `auto`; + } else if (slave.whoreClass === 1) { + span.textContent = `the lower class`; + } else if (slave.whoreClass === 2) { + span.textContent = `the middle class`; + } else if (slave.whoreClass === 3) { + span.textContent = `the upper class`; + } else if (slave.whoreClass === 4) { + span.textContent = `millionaires`; + } else { + span.textContent = `THERE HAS BEEN AN ERROR`; + } + div.append(span); + div.append(`. `); + + div.append(App.UI.DOM.makeElement('span', `This is the highest class they are allowed to service, when eligible `, 'note')); + + appendLink(`Auto`, 0, true); + appendLink(`Lower Class`, 1, true); + appendLink(`Middle Class`, 2, true); + appendLink(`Upper Class`, 3, true); + appendLink(`Millionaires Class`, 4, true); + div.appendChild(App.UI.DOM.generateLinksStrip(links.map(generateLink))); + + el.append(div); + } + + el.append(tutorBlock()); + + function generateLink(linkDesc) { + // is it just text? + if (linkDesc.disabled) { return App.UI.DOM.disabledLink(linkDesc.text, [linkDesc.disabled]); } + // Are they already on this whoreClass? + if (linkDesc.whoreClass === slave.whoreClass) { return document.createTextNode(linkDesc.text); } + // Set up the link + const link = App.UI.DOM.link( + linkDesc.text, + () => { + slave.whoreClass = linkDesc.whoreClass; + App.UI.SlaveInteract.work(slave); + }, + ); + + // add a note node if required + if (linkDesc.note) { + App.UI.DOM.appendNewElement("span", link, linkDesc.note, "note"); + } + return link; + } + + function assignmentBlock() { + let el = document.createElement('div'); + let title = document.createElement('div'); + let separator = document.createTextNode(` | `); + title.append(`Assignment: `); + + let assign = document.createElement('span'); + assign.style.fontWeight = "bold"; + if (slave.sentence) { + assign.textContent = `${slave.assignment} (${slave.sentence} weeks). `; + } else { + assign.textContent = `${slave.assignment}. `; + } + title.appendChild(assign); + if (V.assignmentRecords[slave.ID] && V.assignmentRecords[slave.ID] !== slave.assignment) { + title.append(`Previously: `); + assign = document.createElement('span'); + assign.style.fontWeight = "bold"; + assign.textContent = `${V.assignmentRecords[slave.ID]}. `; + title.appendChild(assign); + } + if (slave.assignment === Job.SUBORDINATE) { + const target = getSlave(slave.subTarget); + let linkText = ``; + if (target) { + title.appendChild(document.createTextNode(`Serving ${target.slaveName} exclusively. `)); + linkText = `Change`; + } else if (slave.subTarget === -1) { + title.appendChild(document.createTextNode(`Serving as a Stud. `)); + linkText = `Change role`; + } else { + title.appendChild(document.createTextNode(`Serving all your other slaves. `)); + linkText = `Choose a specific slave to submit to`; + } + title.appendChild(App.UI.DOM.passageLink(linkText, "Subordinate Targeting", () => { V.returnTo = "Slave Interact"; })); + title.append(separator); + } + if (slave.assignment !== Job.CHOICE) { + title.appendChild( + App.UI.DOM.link( + `Stay on this assignment for another month`, + () => { + slave.sentence += 4; + App.UI.SlaveInteract.work(slave); + }, + ) + ); + } + el.appendChild(title); + + let links = document.createElement('div'); + links.className = "choices"; + links.appendChild( + App.UI.jobLinks.assignmentsFragment( + slave.ID, passage(), + (slave, assignment) => { + assignJob(slave, assignment); + } + ) + ); + el.appendChild(links); + return el; + } + + function tutorBlock() { + let el = App.UI.DOM.makeElement("div"); + let title = App.UI.DOM.appendNewElement("div", el, `Private tutoring: `); + let tutor = tutorForSlave(slave); + + if (tutor === null) { + App.UI.DOM.appendNewElement("span", title, `none.`, "bold"); + } else { + App.UI.DOM.appendNewElement("span", title, tutor + `.`, "bold"); + } + + if (tutor != null) { + App.UI.DOM.appendNewElement("span", title, ` To progress slave needs to be assigned to: "` + Job.CLASSES + `" or "` + Job.SCHOOL + `".`, "note"); + } + + let list = ["None"]; + for (const keys of Object.keys(V.slaveTutor)) { + list.push(keys); + } + const array = list.map((s) => { + if (shouldBeEnabled(slave, s)) { + return App.UI.DOM.link(s, () => setTutorForSlave(slave, s)); + } else { + let reason = ["Already being taught this skill."]; + return App.UI.DOM.disabledLink(s, reason); + } + }); + App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(array)); + + function shouldBeEnabled(slave, key) { + let tutor = tutorForSlave(slave); + if (tutor === null) { + return "None"; + } + return (tutor !== key); + } + + function setTutorForSlave(slave, tutor) { + const cur = tutorForSlave(slave); + + if (tutor !== cur && cur != null) { + V.slaveTutor[cur].delete(slave.ID); + } + + if (cur !== tutor && tutor !== "None") { + V.slaveTutor[tutor].push(slave.ID); + } + App.UI.SlaveInteract.work(slave); + } + + return el; + }; + + return el; + } + function refresh() { + jQuery("#si-work").empty().append(work()); + } +}; diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index 07a3aa0a8bef8511d6c9865cfa5a1f891df0b76f..98e15986f3e0a2dd077fac3756a9dca6cb6573bb 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -126,305 +126,6 @@ App.UI.SlaveInteract.fucktoyPref = function(slave) { return el; }; -/** - * @param {App.Entity.SlaveState} slave - * @returns {JQuery<HTMLElement>} - */ -App.UI.SlaveInteract.work = function(slave) { - let el = new DocumentFragment(); - let p; - let div; - let span; - const links = []; - const { - He, - him - } = getPronouns(slave); - - function appendLink(text, whoreClass, enabled, disabledText) { - const link = {text: text}; - if (enabled) { - link.whoreClass = whoreClass; - } else { - link.disabled = disabledText; - } - links.push(link); - } - - p = document.createElement('p'); - if (slave.assignment === Job.AGENT) { - const arc = V.arcologies.find((a) => a.leaderID === slave.ID); - p.className = "scene-intro"; - p.textContent = `${He} is serving as your Agent${arc ? ` leading ${arc.name}` : ` but is not currently assigned to an arcology`}. `; - p.appendChild(App.UI.DOM.link(`Recall and reenslave ${him}`, () => { removeJob(slave, slave.assignment, false); App.UI.SlaveInteract.work(slave); })); - } else if (slave.assignment === Job.AGENTPARTNER) { - const agent = getSlave(slave.relationshipTarget); - const arc = agent ? V.arcologies.find((a) => a.leaderID === agent.ID) : null; - p.className = "scene-intro"; - p.textContent = `${He} is living with your Agent ${SlaveFullName(agent)}${arc ? ` in ${arc.name}` : ``}. `; - p.appendChild(App.UI.DOM.link(`Recall ${him}`, () => { removeJob(slave, slave.assignment, false); App.UI.SlaveInteract.work(slave); })); - } else { - div = document.createElement('div'); - div.id = "mini-scene"; - p.appendChild(div); - - span = document.createElement('span'); - span.id = "useSlave"; - p.appendChild(span); - p.appendChild(App.UI.SlaveInteract.useSlaveDisplay(slave)); - } - el.append(p); - - p = document.createElement('p'); - span = document.createElement('span'); - span.className = "note"; - switch (slave.assignment) { - case Job.BODYGUARD: - span.textContent = `${He} is your Bodyguard and is not available for other work`; - break; - case Job.MADAM: - span.textContent = `${He} is the Madam and is not available for other work`; - break; - case Job.DJ: - span.textContent = `${He} is the DJ and is not available for other work`; - break; - case Job.MILKMAID: - span.textContent = `${He} is the Milkmaid and is not available for other work`; - break; - case Job.FARMER: - span.textContent = `${He} is the Farmer and is not available for other work`; - break; - case Job.STEWARD: - span.textContent = `${He} is the Stewardess and is not available for other work`; - break; - case Job.HEADGIRL: - span.textContent = `${He} is your Head Girl and is not available for other work`; - break; - case Job.RECRUITER: - span.textContent = `${He} is recruiting slaves and is not available for other work`; - break; - case Job.NURSE: - span.textContent = `${He} is the Nurse and is not available for other work`; - break; - case Job.ATTENDANT: - span.textContent = `${He} is the Attendant of the spa and is not available for other work`; - break; - case Job.MATRON: - span.textContent = `${He} is the Matron of the nursery and is not available for other work`; - break; - case Job.TEACHER: - span.textContent = `${He} is the Schoolteacher and is not available for other work`; - break; - case Job.CONCUBINE: - span.textContent = `${He} is your Concubine and is not available for other work`; - break; - case Job.WARDEN: - span.textContent = `${He} is the Wardeness and is not available for other work`; - break; - default: - // CAN BE REASSIGNED - span.classList.remove("note"); - span.id = "assignmentLinks"; - span.appendChild(App.UI.SlaveInteract.assignmentBlock(slave)); - - if ((V.brothel + V.club + V.dairy + V.farmyard + V.servantsQuarters + V.masterSuite + V.spa + V.nursery + V.clinic + V.schoolroom + V.cellblock + V.arcade + V.HGSuite) > 0) { - span.append(`Transfer to: `); - span.appendChild(App.UI.jobLinks.transfersFragment(slave.ID)); - } - - div = document.createElement('div'); - div.id = "fucktoy-pref"; - div.append(App.UI.SlaveInteract.fucktoyPref(slave)); - span.appendChild(div); - } - el.append(span); - - if (slave.assignment === Job.WHORE || slave.assignment === Job.BROTHEL) { - div = document.createElement('div'); - div.textContent = `Whoring Target: `; - span = document.createElement('span'); - span.style.fontWeight = "bold"; - - span.id = "whoreClass"; - if (!slave.whoreClass) { - span.textContent = `auto`; - } else if (slave.whoreClass === 1) { - span.textContent = `the lower class`; - } else if (slave.whoreClass === 2) { - span.textContent = `the middle class`; - } else if (slave.whoreClass === 3) { - span.textContent = `the upper class`; - } else if (slave.whoreClass === 4) { - span.textContent = `millionaires`; - } else { - span.textContent = `THERE HAS BEEN AN ERROR`; - } - div.append(span); - div.append(`. `); - - div.append(App.UI.DOM.makeElement('span', `This is the highest class they are allowed to service, when eligible `, 'note')); - - appendLink(`Auto`, 0, true); - appendLink(`Lower Class`, 1, true); - appendLink(`Middle Class`, 2, true); - appendLink(`Upper Class`, 3, true); - appendLink(`Millionaires Class`, 4, true); - div.appendChild(App.UI.DOM.generateLinksStrip(links.map(generateLink))); - - el.append(div); - } - - el.append(App.UI.SlaveInteract.tutorBlock(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 whoreClass? - if (linkDesc.whoreClass === slave.whoreClass) { return document.createTextNode(linkDesc.text); } - // Set up the link - const link = App.UI.DOM.link( - linkDesc.text, - () => { - slave.whoreClass = linkDesc.whoreClass; - App.UI.SlaveInteract.work(slave); - }, - ); - - // add a note node if required - if (linkDesc.note) { - App.UI.DOM.appendNewElement("span", link, linkDesc.note, "note"); - } - return link; - } - - return jQuery('#work').empty().append(el); -}; - -/** - * @param {App.Entity.SlaveState} slave - * @returns {HTMLElement} - */ -App.UI.SlaveInteract.assignmentBlock = function(slave) { - let el = document.createElement('div'); - let title = document.createElement('div'); - let separator = document.createTextNode(` | `); - title.append(`Assignment: `); - - let assign = document.createElement('span'); - assign.style.fontWeight = "bold"; - if (slave.sentence) { - assign.textContent = `${slave.assignment} (${slave.sentence} weeks). `; - } else { - assign.textContent = `${slave.assignment}. `; - } - title.appendChild(assign); - if (V.assignmentRecords[slave.ID] && V.assignmentRecords[slave.ID] !== slave.assignment) { - title.append(`Previously: `); - assign = document.createElement('span'); - assign.style.fontWeight = "bold"; - assign.textContent = `${V.assignmentRecords[slave.ID]}. `; - title.appendChild(assign); - } - if (slave.assignment === Job.SUBORDINATE) { - const target = getSlave(slave.subTarget); - let linkText = ``; - if (target) { - title.appendChild(document.createTextNode(`Serving ${target.slaveName} exclusively. `)); - linkText = `Change`; - } else if (slave.subTarget === -1) { - title.appendChild(document.createTextNode(`Serving as a Stud. `)); - linkText = `Change role`; - } else { - title.appendChild(document.createTextNode(`Serving all your other slaves. `)); - linkText = `Choose a specific slave to submit to`; - } - title.appendChild(App.UI.DOM.passageLink(linkText, "Subordinate Targeting", () => { V.returnTo = "Slave Interact"; })); - title.append(separator); - } - if (slave.assignment !== Job.CHOICE) { - title.appendChild( - App.UI.DOM.link( - `Stay on this assignment for another month`, - () => { - slave.sentence += 4; - App.UI.SlaveInteract.work(slave); - }, - ) - ); - } - el.appendChild(title); - - let links = document.createElement('div'); - links.className = "choices"; - links.appendChild( - App.UI.jobLinks.assignmentsFragment( - slave.ID, passage(), - (slave, assignment) => { - assignJob(slave, assignment); - } - ) - ); - el.appendChild(links); - return el; -}; - -/** - * @param {App.Entity.SlaveState} slave - * @returns {HTMLDivElement} - */ -App.UI.SlaveInteract.tutorBlock = function(slave) { - let el = App.UI.DOM.makeElement("div"); - let title = App.UI.DOM.appendNewElement("div", el, `Private tutoring: `); - let tutor = tutorForSlave(slave); - - if (tutor === null) { - App.UI.DOM.appendNewElement("span", title, `none.`, "bold"); - } else { - App.UI.DOM.appendNewElement("span", title, tutor + `.`, "bold"); - } - - if (tutor != null) { - App.UI.DOM.appendNewElement("span", title, ` To progress slave needs to be assigned to: "` + Job.CLASSES + `" or "` + Job.SCHOOL + `".`, "note"); - } - - let list = ["None"]; - for (const keys of Object.keys(V.slaveTutor)) { - list.push(keys); - } - const array = list.map((s) => { - if (shouldBeEnabled(slave, s)) { - return App.UI.DOM.link(s, () => setTutorForSlave(slave, s)); - } else { - let reason = ["Already being taught this skill."]; - return App.UI.DOM.disabledLink(s, reason); - } - }); - App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(array)); - - function shouldBeEnabled(slave, key) { - let tutor = tutorForSlave(slave); - if (tutor === null) { - return "None"; - } - return (tutor !== key); - } - - function setTutorForSlave(slave, tutor) { - const cur = tutorForSlave(slave); - - if (tutor !== cur && cur != null) { - V.slaveTutor[cur].delete(slave.ID); - } - - if (cur !== tutor && tutor !== "None") { - V.slaveTutor[tutor].push(slave.ID); - } - App.UI.SlaveInteract.work(slave); - } - - return el; -}; - App.UI.SlaveInteract.useSlaveDisplay = function(slave) { // Goal: Be able to write the entire "use her" block with only dom fragments. let el = document.createElement('div');