From 023bf294e349c8d2f5549798cac31d74b6651252 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Wed, 29 Jul 2020 17:37:32 -0700 Subject: [PATCH] Move all slave lists to pure DOM output, and use <<includeDOM>> to include them in their host passages. Simplify NGP slave selection a bit and remove the $slavesToImport global. Split JS portions of underperformingSlaves.tw into underperformingSlaves.js. --- .../DinnerParty/dinnerPartyPreparations.tw | 2 +- src/facilities/farmyard/farmerSelect.tw | 2 +- src/facilities/farmyard/farmyard.tw | 2 +- src/facilities/nursery/matronSelect.tw | 2 +- src/facilities/nursery/nursery.tw | 2 +- src/gui/options/summaryOptions.tw | 6 +- src/js/findSlave.js | 2 +- src/js/slaveListing.js | 263 +++++++----------- src/js/underperformingSlaves.js | 57 ++++ src/neighbor/neighborInteract.js | 2 +- src/npc/agent/agentSelect.tw | 2 +- src/npc/interaction/passage/matchmaking.tw | 2 +- src/uncategorized/arcade.tw | 2 +- src/uncategorized/attendantSelect.tw | 2 +- src/uncategorized/bgSelect.tw | 2 +- src/uncategorized/brothel.tw | 2 +- src/uncategorized/cellblock.tw | 2 +- src/uncategorized/clinic.tw | 2 +- src/uncategorized/club.tw | 2 +- src/uncategorized/concubineSelect.tw | 2 +- src/uncategorized/coursingAssociation.tw | 4 +- src/uncategorized/dairy.tw | 4 +- src/uncategorized/djSelect.tw | 2 +- src/uncategorized/headGirlSuite.tw | 2 +- src/uncategorized/hgSelect.tw | 2 +- src/uncategorized/madamSelect.tw | 2 +- src/uncategorized/masterSuite.tw | 2 +- src/uncategorized/milkmaidSelect.tw | 2 +- src/uncategorized/newGamePlus.tw | 8 +- src/uncategorized/nurseSelect.tw | 2 +- src/uncategorized/personalAttentionSelect.tw | 2 +- src/uncategorized/pit.tw | 2 +- src/uncategorized/recruiterSelect.tw | 2 +- src/uncategorized/schoolroom.tw | 2 +- src/uncategorized/schoolteacherSelect.tw | 2 +- src/uncategorized/servantsQuarters.tw | 4 +- src/uncategorized/spa.tw | 2 +- src/uncategorized/stewardessSelect.tw | 2 +- src/uncategorized/subordinateTargeting.tw | 2 +- src/uncategorized/underperformingSlaves.tw | 49 +--- src/uncategorized/wardenessSelect.tw | 2 +- 41 files changed, 200 insertions(+), 261 deletions(-) create mode 100644 src/js/underperformingSlaves.js diff --git a/src/Mods/DinnerParty/dinnerPartyPreparations.tw b/src/Mods/DinnerParty/dinnerPartyPreparations.tw index 777778de6c0..21d00fcdb15 100644 --- a/src/Mods/DinnerParty/dinnerPartyPreparations.tw +++ b/src/Mods/DinnerParty/dinnerPartyPreparations.tw @@ -29,7 +29,7 @@ Your assistant will take care of the invitations and all the arrangements; all y __Select Your Meat:__ <br><br> -<<= App.UI.SlaveList.slaveSelectionList( +<<includeDOM App.UI.SlaveList.slaveSelectionList( s => assignmentVisible(s) && s.fuckdoll === 0, App.UI.SlaveList.SlaveInteract.stdInteract, null, diff --git a/src/facilities/farmyard/farmerSelect.tw b/src/facilities/farmyard/farmerSelect.tw index 8ea91518783..2c66982b707 100644 --- a/src/facilities/farmyard/farmerSelect.tw +++ b/src/facilities/farmyard/farmerSelect.tw @@ -12,4 +12,4 @@ <br><br>''Appoint a Farmer from your obedient slaves:'' <br><br>[[None|Farmyard][removeJob($Farmer, "be the Farmer")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.farmyard, "Farmyard")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.farmyard, "Farmyard")>> diff --git a/src/facilities/farmyard/farmyard.tw b/src/facilities/farmyard/farmyard.tw index b05f981da85..f86e94f1732 100644 --- a/src/facilities/farmyard/farmyard.tw +++ b/src/facilities/farmyard/farmyard.tw @@ -237,7 +237,7 @@ <br><hr><br> -<<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.farmyard)>> +<<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.farmyard)>> <br><br>Rename $farmyardName: <<textbox "$farmyardName" $farmyardName "Farmyard">> //Use a noun or similar short phrase// diff --git a/src/facilities/nursery/matronSelect.tw b/src/facilities/nursery/matronSelect.tw index 0b52309d0ff..70531aff189 100644 --- a/src/facilities/nursery/matronSelect.tw +++ b/src/facilities/nursery/matronSelect.tw @@ -12,4 +12,4 @@ <br><br>''Appoint a Matron from your devoted slaves:'' <br><br>[[None|Nursery][removeJob($Matron, "be the Matron")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.nursery, "Nursery")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.nursery, "Nursery")>> diff --git a/src/facilities/nursery/nursery.tw b/src/facilities/nursery/nursery.tw index 86e754f2f8c..00445ff9cbd 100644 --- a/src/facilities/nursery/nursery.tw +++ b/src/facilities/nursery/nursery.tw @@ -151,7 +151,7 @@ </div> <p> - <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.nursery)>> + <<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.nursery)>> </p> /* </div> diff --git a/src/gui/options/summaryOptions.tw b/src/gui/options/summaryOptions.tw index bb269e7d04b..9c079d55801 100644 --- a/src/gui/options/summaryOptions.tw +++ b/src/gui/options/summaryOptions.tw @@ -43,11 +43,7 @@ <h2>Individual panels</h2> Sample summary: -<<= App.UI.SlaveList.render.listMarkup( - [$activeSlave.ID], - [], - App.UI.SlaveList.SlaveInteract.stdInteract -)>> +<<includeDOM App.UI.SlaveList.render([$activeSlave.ID], new Array(), App.UI.SlaveList.SlaveInteract.stdInteract)>> <<set _options = (new App.UI.OptionsGroup()).enableDoubleColumn()>> diff --git a/src/js/findSlave.js b/src/js/findSlave.js index 6587925d17b..bd138ce9bdc 100644 --- a/src/js/findSlave.js +++ b/src/js/findSlave.js @@ -34,7 +34,7 @@ App.FindSlave._appendResultList = function(ids, frag) { if (ids.length === 0) { App.UI.DOM.appendNewElement("p", frag, "No matching slaves."); } else { - frag.appendChild(App.UI.SlaveList.render.listDOM(ids, [], App.UI.SlaveList.SlaveInteract.stdInteract)); + frag.appendChild(App.UI.SlaveList.render(ids, [], App.UI.SlaveList.SlaveInteract.stdInteract)); } }; diff --git a/src/js/slaveListing.js b/src/js/slaveListing.js index dec49159585..f94b41f25ed 100644 --- a/src/js/slaveListing.js +++ b/src/js/slaveListing.js @@ -29,18 +29,10 @@ App.UI.SlaveList.render = function() { // potentially can be a problem if played long enough to reach Number.MAX_SAFE_INTEGER let listID = Number.MIN_SAFE_INTEGER; - /** @type {Object.<number, Node>}*/ - const readyResults = { - - }; - /** @type {App.Art.SlaveArtBatch?} */ let batchRenderer = null; - return { - listMarkup: listMarkup, - listDOM: listDOM - }; + return listDOM; /** * @param {number[]} IDs @@ -122,37 +114,6 @@ App.UI.SlaveList.render = function() { return res; } - /** - * @param {number[]} IDs - * @param {Array.<{id: number, rejects: string[]}>} rejectedSlaves - * @param {slaveToElement} interactionLink - * @param {slaveToElement} [postNote] - * @returns {string} - */ - function listMarkup(IDs, rejectedSlaves, interactionLink, postNote) { - const listIDStr = `slave-list-${listID}`; - readyResults[listID] = listDOM(IDs, rejectedSlaves, interactionLink, postNote); - - $(document).one(':passagedisplay', function() { - for (const e of document.querySelectorAll('[id^=slave-list]')) { - const id = e.getAttribute("data-listId"); - if (readyResults.hasOwnProperty(id)) { - if (e.childNodes.length > 0) { - e.innerHTML = ''; - } - e.appendChild(readyResults[id]); - delete readyResults[id]; - } - } - }); - - let resMarkup = `<div id="${listIDStr}" data-listId="${listID}"></div>`; - ++listID; - - return resMarkup; - } - - /** * @param {number} id * @param {slaveToElement} interactionLink @@ -615,31 +576,11 @@ App.UI.selectSlaveForPersonalAttention = function(id) { SugarCube.Engine.play("Personal Attention Select"); }; -/** - * Generates fragment with sorting options, that link to the given passage - * @param {string} passage The passage to link to - * @returns {string} - */ -App.UI.SlaveList.sortingLinks = function(passage) { - let r = ' Sort by: '; - let textify = (cc) => capFirstChar(cc.replace(/([A-Z])/g, " $1")); - r += ["devotion", "name", "assignment", "seniority", "actualAge", "visualAge", "physicalAge", "weeklyIncome"] - .map(so => V.sortSlavesBy !== so ? - App.UI.passageLink(textify(so), passage, `$sortSlavesBy = "${so}"`) : textify(so)) - .join(" | "); - - r += ' Sort: '; - r += ["descending", "ascending"].map(so => V.sortSlavesOrder !== so ? - App.UI.passageLink(capFirstChar(so), passage, `$sortSlavesOrder = "${so}"`) : capFirstChar(so)) - .join(" | "); - return r; -}; - /** * @param {string} passage - * @returns {*} + * @returns {HTMLElement} */ -App.UI.SlaveList.sortingLinksDOM = function(passage) { +App.UI.SlaveList.sortingLinks = function(passage) { const outerDiv = document.createElement("div"); outerDiv.classList.add("flex-container"); const textify = string => capFirstChar(string.replace(/([A-Z])/g, " $1")); @@ -666,7 +607,7 @@ App.UI.SlaveList.sortingLinksDOM = function(passage) { * @param {string} [facilityPassage] * @param {boolean} [showTransfersTab=false] * @param {{assign: string, remove: string, transfer: (string| undefined)}} [tabCaptions] - * @returns {string} + * @returns {DocumentFragment} */ App.UI.SlaveList.listSJFacilitySlaves = function(facility, facilityPassage, showTransfersTab = false, tabCaptions = undefined) { const job = facility.job(); @@ -677,30 +618,31 @@ App.UI.SlaveList.listSJFacilitySlaves = function(facility, facilityPassage, show remove: 'Remove a slave', transfer: 'Transfer from Facility' }; - let r = ''; + const frag = document.createDocumentFragment(); if (V.sortSlavesMain) { - r += this.sortingLinks(facilityPassage) + '<br>'; + frag.append(this.sortingLinks(facilityPassage)); } - r += '<div class="tabbar">' + - App.UI.tabbar.tabButton('assign', tabCaptions.assign) + - App.UI.tabbar.tabButton('remove', tabCaptions.remove) + - (showTransfersTab ? App.UI.tabbar.tabButton('transfer', tabCaptions.transfer) : '') + - '</div>'; + const tabbar = App.UI.DOM.appendNewElement("div", frag, '', "tabbar"); + tabbar.append( + App.UI.tabbar.tabButtonDOM('assign', tabCaptions.assign), + App.UI.tabbar.tabButtonDOM('remove', tabCaptions.remove), + (showTransfersTab ? App.UI.tabbar.tabButtonDOM('transfer', tabCaptions.transfer) : '') + ); const facilitySlaves = [...job.employeesIDs()]; if (facilitySlaves.length > 0) { SlaveSort.IDs(facilitySlaves); - r += App.UI.tabbar.makeTab("remove", App.UI.SlaveList.render.listMarkup(facilitySlaves, [], + frag.append(App.UI.tabbar.makeTabDOM("remove", App.UI.SlaveList.render(facilitySlaves, [], App.UI.SlaveList.SlaveInteract.stdInteract, (slave) => App.UI.DOM.link(`Retrieve ${getPronouns(slave).object} from ${facility.name}`, () => removeJob(slave, job.desc.assignment), [], facilityPassage) - )); + ))); } else { - r += App.UI.tabbar.makeTab("remove", `<em>${capFirstChar(facility.name)} is empty for the moment</em>`); + frag.append(App.UI.tabbar.makeTabDOM("remove", App.UI.DOM.makeElement("em", `${capFirstChar(facility.name)} is empty for the moment`))); } /** * @param {number[]} slaveIDs - * @returns {string} + * @returns {DocumentFragment} */ function assignableTabContent(slaveIDs) { SlaveSort.IDs(slaveIDs); @@ -714,7 +656,7 @@ App.UI.SlaveList.listSJFacilitySlaves = function(facility, facilityPassage, show passedSlaves.push(id); } }, []); - return App.UI.SlaveList.render.listMarkup(passedSlaves, rejectedSlaves, + return App.UI.SlaveList.render(passedSlaves, rejectedSlaves, App.UI.SlaveList.SlaveInteract.stdInteract, (slave) => App.UI.DOM.link(`Send ${getPronouns(slave).object} to ${facility.name}`, () => { assignmentTransition(slave, job.desc.assignment, facilityPassage); })); } @@ -722,9 +664,9 @@ App.UI.SlaveList.listSJFacilitySlaves = function(facility, facilityPassage, show const assignableSlaveIDs = job.desc.partTime ? V.slaves.map(slave => slave.ID) : // all slaves can work here [...App.Entity.facilities.penthouse.employeesIDs()]; // only slaves from the penthouse can be transferred here - r += App.UI.tabbar.makeTab("assign", assignableTabContent(assignableSlaveIDs)); + frag.append(App.UI.tabbar.makeTabDOM("assign", assignableTabContent(assignableSlaveIDs))); } else { - r += App.UI.tabbar.makeTab("assign", `<strong>${capFirstChar(facility.name)} is full and cannot hold any more slaves</strong>`); + frag.append(App.UI.tabbar.makeTabDOM("assign", App.UI.DOM.makeElement("strong", `${capFirstChar(facility.name)} is full and cannot hold any more slaves`))); } if (showTransfersTab) { @@ -736,14 +678,14 @@ App.UI.SlaveList.listSJFacilitySlaves = function(facility, facilityPassage, show } return acc; }, []); - r += App.UI.tabbar.makeTab("transfer", assignableTabContent(transferableIDs)); + frag.append(App.UI.tabbar.makeTabDOM("transfer", assignableTabContent(transferableIDs))); } else { - r += App.UI.tabbar.makeTab("transfer", `<strong>${capFirstChar(facility.name)} is full and cannot hold any more slaves</strong>`); + frag.append(App.UI.tabbar.makeTabDOM("transfer", App.UI.DOM.makeElement("strong", `${capFirstChar(facility.name)} is full and cannot hold any more slaves`))); } } App.UI.tabbar.handlePreSelectedTab(); - return r; + return frag; }; /** @@ -761,77 +703,76 @@ App.UI.SlaveList.makeNameDecorator = function(classNames) { }; /** - * @returns {string} + * @returns {DocumentFragment} */ App.UI.SlaveList.listNGPSlaves = function() { const thisPassage = 'New Game Plus'; - let r = this.sortingLinks(thisPassage) + '<br>'; - r += '<div class="tabbar">' + - App.UI.tabbar.tabButton('assign', 'Import a slave') + - App.UI.tabbar.tabButton('remove', 'Remove from import') + - '</div>'; + const frag = document.createDocumentFragment(); + frag.append(this.sortingLinks(thisPassage)); + const tabbar = App.UI.DOM.appendNewElement("div", frag, '', "tabbar"); + tabbar.append( + App.UI.tabbar.tabButtonDOM('assign', "Import a slave"), + App.UI.tabbar.tabButtonDOM('remove', "Remove from import") + ); const NGPassignment = Job.IMPORTED; - /** @type {App.Entity.SlaveState[]} */ - const slaves = V.slaves; - - /* handle the legacy assignment string */ - for (const slave of slaves) { + let imported = []; + let nonImported = []; + for (const slave of V.slaves) { + /* handle the legacy assignment string */ if (slave.assignment === "be imported") { - slave.assignment = Job.IMPORTED; + slave.assignment = NGPassignment; + } + if (slave.assignment === NGPassignment) { + imported.push(slave.ID); + } else { + nonImported.push(slave.ID); } } - if (V.slavesToImport > 0) { - const importedSlavesIDs = slaves.reduce((acc, s) => { - if (s.assignment === NGPassignment) { - acc.push(s.ID); - } - return acc; - }, []); - SlaveSort.IDs(importedSlavesIDs); - r += App.UI.tabbar.makeTab("remove", App.UI.SlaveList.render.listMarkup(importedSlavesIDs, [], + if (imported.length > 0) { + SlaveSort.IDs(imported); + frag.append(App.UI.tabbar.makeTabDOM("remove", App.UI.SlaveList.render(imported, [], App.UI.SlaveList.makeNameDecorator(["emphasizedSlave", "pink"]), - (s) => App.UI.DOM.passageLink('Remove from import list', thisPassage, - () => { V.slavesToImport -= 1; removeJob(s, NGPassignment); } - ))); + (s) => App.UI.DOM.passageLink('Remove from import list', thisPassage, () => removeJob(s, NGPassignment)) + ))); } else { - r += App.UI.tabbar.makeTab("remove", `<em>No slaves will go with you to the new game</em>`); + frag.append(App.UI.tabbar.makeTabDOM("remove", App.UI.DOM.makeElement('em', "No slaves will go with you to the new game"))); } - if (V.slavesToImport < V.slavesToImportMax) { - const slavesToImportIDs = slaves.reduce((acc, s) => { if (s.assignment !== NGPassignment) { acc.push(s.ID); } return acc; }, []); - SlaveSort.IDs(slavesToImportIDs); - r += App.UI.tabbar.makeTab("assign", App.UI.SlaveList.render.listMarkup(slavesToImportIDs, [], + if (imported.length < V.slavesToImportMax) { + SlaveSort.IDs(nonImported); + frag.append(App.UI.tabbar.makeTabDOM("assign", App.UI.SlaveList.render(nonImported, [], App.UI.SlaveList.makeNameDecorator(["emphasizedSlave", "pink"]), - (s) => App.UI.DOM.passageLink('Add to import list', thisPassage, - () => { V.slavesToImport += 1; assignJob(s, NGPassignment); } - ))); + (s) => App.UI.DOM.passageLink('Add to import list', thisPassage, () => assignJob(s, NGPassignment)) + ))); } else { - r += App.UI.tabbar.makeTab("assign", `<strong>Slave import limit reached</strong>`); + frag.append(App.UI.tabbar.makeTabDOM("assign", App.UI.DOM.makeElement('strong', `Slave import limit reached`))); } App.UI.tabbar.handlePreSelectedTab(); - return r; + return frag; }; /** * Renders facility manager summary or a note with a link to select one * @param {App.Entity.Facilities.Facility} facility * @param {string} [selectionPassage] passage name for manager selection. "${Manager} Select" if omitted - * @returns {string} + * @returns {DocumentFragment} */ App.UI.SlaveList.displayManager = function(facility, selectionPassage) { const managerCapName = capFirstChar(facility.desc.manager.position); selectionPassage = selectionPassage || `${managerCapName} Select`; const manager = facility.manager.currentEmployee; if (manager) { - return this.render.listMarkup([manager.ID], [], + return this.render([manager.ID], [], App.UI.SlaveList.SlaveInteract.stdInteract, () => App.UI.DOM.passageLink(`Change or remove ${managerCapName}`, selectionPassage)); } else { - return `You do not have a slave serving as a ${managerCapName}. ${App.UI.passageLink(`Appoint one`, selectionPassage, "")}`; + const frag = document.createDocumentFragment(); + frag.append(`You do not have a slave serving as a ${managerCapName}. `, App.UI.DOM.passageLink(`Appoint one`, selectionPassage)); + return frag; } }; @@ -839,10 +780,13 @@ App.UI.SlaveList.displayManager = function(facility, selectionPassage) { * Displays standard facility page with manager and list of workers * @param {App.Entity.Facilities.Facility} facility * @param {boolean} [showTransfersPage] - * @returns {string} + * @returns {DocumentFragment} */ App.UI.SlaveList.stdFacilityPage = function(facility, showTransfersPage) { - return this.displayManager(facility) + '<br><br>' + this.listSJFacilitySlaves(facility, passage(), showTransfersPage); + const frag = this.displayManager(facility); + frag.append(document.createElement('br')); // TODO: replace with margin on one of the divs? + frag.append(this.listSJFacilitySlaves(facility, passage(), showTransfersPage)); + return frag; }; App.UI.SlaveList.penthousePage = function() { @@ -865,7 +809,7 @@ App.UI.SlaveList.penthousePage = function() { const link = App.UI.DOM.makeElement("span", App.UI.DOM.passageLink("Manage Head Girl", "HG Select"), "major-link"); link.id = "manageHG"; slaveWrapper.append(link, " ", App.UI.DOM.makeElement("span", App.UI.Hotkeys.hotkeys("HG Select"), "hotkey")); - slaveWrapper.append(App.UI.SlaveList.render.listDOM([HG.ID], [], + slaveWrapper.append(App.UI.SlaveList.render([HG.ID], [], App.UI.SlaveList.SlaveInteract.penthouseInteract)); } else { if (V.slaves.length > 1) { @@ -908,7 +852,7 @@ App.UI.SlaveList.penthousePage = function() { const link = App.UI.DOM.makeElement("span", App.UI.DOM.passageLink("Manage Recruiter", "Recruiter Select"), "major-link"); link.id = "manageRecruiter"; slaveWrapper.append(link, " ", App.UI.DOM.makeElement("span", App.UI.Hotkeys.hotkeys("Recruiter Select"), "hotkey")); - slaveWrapper.append(App.UI.SlaveList.render.listDOM([RC.ID], [], + slaveWrapper.append(App.UI.SlaveList.render([RC.ID], [], App.UI.SlaveList.SlaveInteract.penthouseInteract)); } else { slaveWrapper.append("You have ", App.UI.DOM.makeElement("span", "not", "warning"), " selected a Recruiter. ", @@ -931,7 +875,7 @@ App.UI.SlaveList.penthousePage = function() { const link = App.UI.DOM.makeElement("span", App.UI.DOM.passageLink("Manage Bodyguard", "BG Select"), "major-link"); link.id = "manageBG"; slaveWrapper.append(link, " ", App.UI.DOM.makeElement("span", App.UI.Hotkeys.hotkeys("BG Select"), "hotkey")); - slaveWrapper.append(App.UI.SlaveList.render.listDOM([BG.ID], [], + slaveWrapper.append(App.UI.SlaveList.render([BG.ID], [], App.UI.SlaveList.SlaveInteract.penthouseInteract)); slaveWrapper.append(App.MainView.useGuard()); } else { @@ -962,7 +906,7 @@ App.UI.SlaveList.penthousePage = function() { SlaveSort.IDs(employeesIDs); return { n: employeesIDs.length, - dom: App.UI.SlaveList.render.listDOM(employeesIDs, [], App.UI.SlaveList.SlaveInteract.penthouseInteract, + dom: App.UI.SlaveList.render(employeesIDs, [], App.UI.SlaveList.SlaveInteract.penthouseInteract, V.fucktoyInteractionsPosition === 1 && job === "fucktoy" ? App.MainView.useFucktoy : null) }; } @@ -1051,7 +995,7 @@ App.UI.SlaveList.penthousePage = function() { } SlaveSort.IDs(penthouseSlavesIDs); return makeTabDesc('all', `All${V.useSlaveSummaryTabs > 0 ? ` (${penthouseSlavesIDs.length})` : ""}`, - App.UI.SlaveList.render.listDOM(penthouseSlavesIDs, [], App.UI.SlaveList.SlaveInteract.penthouseInteract)); + App.UI.SlaveList.render(penthouseSlavesIDs, [], App.UI.SlaveList.SlaveInteract.penthouseInteract)); } let fragment = document.createDocumentFragment(); @@ -1061,7 +1005,7 @@ App.UI.SlaveList.penthousePage = function() { } if (V.sortSlavesMain) { - fragment.append(App.UI.SlaveList.sortingLinksDOM("Main")); + fragment.append(App.UI.SlaveList.sortingLinks("Main")); } /** @type {tabDesc[]} */ @@ -1127,12 +1071,6 @@ App.UI.SlaveList.penthousePage = function() { return fragment; }; -/** - * @callback assignmentFilterGenerateCallback - * @param {string} value - * @returns {string} - */ - /** * @callback slaveFilterCallbackReasoned * @param {App.Entity.SlaveState} slave @@ -1148,49 +1086,53 @@ App.UI.SlaveList.penthousePage = function() { App.UI.SlaveList.slaveSelectionList = function() { const selectionElementId = "slaveSelectionList"; - return selection; - /** - * @typedef ListOptions * @property {slaveFilterCallbackReasoned|slaveFilterCallbackSimple} filter - * @property {slaveTestCallback} [expCheck] * @property {slaveToElement} interactionLink + * @property {slaveTestCallback} [expCheck] * @property {slaveToElement} [postNote] */ + let options = null; + + return selection; /** * @param {slaveFilterCallbackReasoned|slaveFilterCallbackSimple} filter * @param {slaveToElement} interactionLink - * @param {slaveTestCallback} [experianceChecker] + * @param {slaveTestCallback} [experienceChecker] * @param {slaveToElement} [postNote] - * @returns {string} + * @returns {HTMLElement} */ - function selection(filter, interactionLink, experianceChecker, postNote) { - if (experianceChecker === null) { experianceChecker = undefined; } - State.temporary.slaveSelection = { + function selection(filter, interactionLink, experienceChecker, postNote) { + if (experienceChecker === null) { experienceChecker = undefined; } + options = { filter: filter, - expCheck: experianceChecker, interactionLink: interactionLink, - postNote: postNote, - update: _updateList + expCheck: experienceChecker, + postNote: postNote }; $(document).one(':passagedisplay', () => { _updateList('all'); }); - return `<div>${_assignmentFilter(s => `<<run _slaveSelection.update('${s}')>>`, experianceChecker !== undefined)} <div id=${selectionElementId}></div></div>`; + + const div = document.createElement("div"); + div.append(_assignmentFilter(experienceChecker !== undefined)); + const selectionElement = App.UI.DOM.appendNewElement("div", div); + selectionElement.id = selectionElementId; + return div; } function _updateList(assignment) { const e = document.getElementById(selectionElementId); e.innerHTML = ''; - e.appendChild(_listSlaves(assignment, State.temporary.slaveSelection)); + e.appendChild(_listSlaves(assignment)); } + /** - * Displays assignment filter links, whose action are generated by the callback - * @param {assignmentFilterGenerateCallback} callback + * Displays assignment filter links * @param {boolean} includeExperienced - * @returns {string} + * @returns {HTMLElement} */ - function _assignmentFilter(callback, includeExperienced) { + function _assignmentFilter(includeExperienced) { let filters = { all: "All" }; @@ -1204,30 +1146,21 @@ App.UI.SlaveList.slaveSelectionList = function() { } } let links = []; - /* seems like SC2 does not process data-setter when data-passage is not set for (const f in filters) { - links.push(App.UI.passageLink(filters[f], passage, callback(f))); + links.push(App.UI.DOM.link(filters[f], () => _updateList(f))); } if (includeExperienced) { - links.push(`<span class="lime">${App.UI.passageLink('Experienced', passage, callback('experienced'))}</span>`); - }*/ - for (const f in filters) { - links.push(`<<link "${filters[f]}">>${callback(f)}<</link>>`); - } - if (includeExperienced) { - links.push(`<span class="lime"><<link "Experienced">>${callback('experienced')}<</link>></span>`); + links.push(App.UI.DOM.makeElement("span", App.UI.DOM.link('Experienced', () => _updateList('experienced')), "lime")); } - return links.join(' | '); + return App.UI.DOM.generateLinksStrip(links); } /** - * * @param {string} assignmentStr - * @param {ListOptions} options * @returns {DocumentFragment} */ - function _listSlaves(assignmentStr, options) { + function _listSlaves(assignmentStr) { const slaves = V.slaves; let unfilteredIDs = []; switch (assignmentStr) { @@ -1235,7 +1168,7 @@ App.UI.SlaveList.slaveSelectionList = function() { unfilteredIDs = slaves.map(s => s.ID); break; case 'experienced': - unfilteredIDs = slaves.reduce((acc, s, idx) => { + unfilteredIDs = slaves.reduce((acc, s) => { if (options.expCheck(s)) { acc.push(s.ID); } @@ -1273,14 +1206,14 @@ App.UI.SlaveList.slaveSelectionList = function() { s => options.postNote(s) : () => null; - return App.UI.SlaveList.render.listDOM(passingIDs, rejects, options.interactionLink, listPostNote); + return App.UI.SlaveList.render(passingIDs, rejects, options.interactionLink, listPostNote); } }(); /** * @param {App.Entity.Facilities.Facility} facility * @param {string} passage go here after the new facility manager is selected - * @returns {string} + * @returns {HTMLElement} */ App.UI.SlaveList.facilityManagerSelection = function(facility, passage) { return this.slaveSelectionList(slave => facility.manager.canEmploy(slave), diff --git a/src/js/underperformingSlaves.js b/src/js/underperformingSlaves.js new file mode 100644 index 00000000000..635485ae599 --- /dev/null +++ b/src/js/underperformingSlaves.js @@ -0,0 +1,57 @@ +App.Underperformers = {}; + +App.Underperformers.highSale = function() { + const description = App.UI.DOM.makeElement("div", "Take the rough value of a slave and divide it by how much they made overall last week. This will tell you how many weeks it might take them to earn the same amount you'd get for selling them right now.", "note"); + + const frag = App.UI.SlaveList.render( + getBestSlavesIDs( + { + part:(slave) => { + const ratio = slaveCost(slave) / (slave.lastWeeksCashIncome - getSlaveCost(slave)); + return ratio > 0 ? ratio : 100000000 + ratio; + }, + count: 7, + filter:(slave) => ( + ["be confined in the arcade", "get milked", "whore", "work a glory hole", "work in the brothel", "work in the dairy"].includes(slave.assignment) + && ((slave.weekAcquired + 1) < V.week) + && slave.lastWeeksCashIncome + ) + } + ), + [], + App.UI.SlaveList.SlaveInteract.stdInteract, + (slave) => $(document.createDocumentFragment()).append( + `Worth ${cashFormatColor(slaveCost(slave))} / Nets ${cashFormatColor(slave.lastWeeksCashIncome - getSlaveCost(slave))} a week = ${(Math.trunc(slaveCost(slave) / (slave.lastWeeksCashIncome - getSlaveCost(slave)))) > 0 ? (Math.trunc(slaveCost(slave) / (slave.lastWeeksCashIncome - getSlaveCost(slave)))) : "infinite"} weeks` + ).get(0) + ); + + frag.prepend(description); + return frag; +}; + +App.Underperformers.expensive = function() { + const description = App.UI.DOM.makeElement("div", "This list looks for moochers by weighing their weekly income against the weekly cost of providing for them.", "note"); + + const frag = App.UI.SlaveList.render( + getBestSlavesIDs( + { + part:(slave) => (slave.lastWeeksCashIncome - getSlaveCost(slave)), + largest: false, + count: 7, + filter:(slave) => ( + ["be confined in the arcade", "get milked", "whore", "work a glory hole", "work in the brothel", "work in the dairy"].includes(slave.assignment) + && ((slave.weekAcquired + 1) < V.week) + && slave.lastWeeksCashIncome + ) + } + ), + [], + App.UI.SlaveList.SlaveInteract.stdInteract, + (slave) => $(document.createDocumentFragment()).append( + `${cashFormatColor(Math.trunc(slave.lastWeeksCashIncome - getSlaveCost(slave)))} net last week` + ).get(0) + ); + + frag.prepend(description); + return frag; +}; diff --git a/src/neighbor/neighborInteract.js b/src/neighbor/neighborInteract.js index 92701210edd..3abdab94c9f 100644 --- a/src/neighbor/neighborInteract.js +++ b/src/neighbor/neighborInteract.js @@ -181,7 +181,7 @@ App.Neighbor.Interact = (function() { linkText = `Recall them and reenslave your agent`; residentList.push(agentPartner.ID); } - container.append(App.UI.SlaveList.render.listDOM(residentList, [], App.UI.SlaveList.SlaveInteract.stdInteract)); + container.append(App.UI.SlaveList.render(residentList, [], App.UI.SlaveList.SlaveInteract.stdInteract)); container.append(App.UI.DOM.link(linkText, (f) => { removeJob(agent, "be your agent"); arcChanged(arcID); })); } container.append(" | "); diff --git a/src/npc/agent/agentSelect.tw b/src/npc/agent/agentSelect.tw index 147416474db..e337c0d0ba6 100644 --- a/src/npc/agent/agentSelect.tw +++ b/src/npc/agent/agentSelect.tw @@ -3,7 +3,7 @@ <<set $nextButton = "Back", $nextLink = "Neighbor Interact", $encyclopedia = "Agents">> ''Appoint an Agent from your devoted slaves:'' -<<= App.UI.SlaveList.slaveSelectionList( +<<includeDOM App.UI.SlaveList.slaveSelectionList( s => (s.fuckdoll === 0 && s.devotion > 20 && s.intelligence + s.intelligenceImplant > 15 && s.intelligenceImplant >= 15 && canWalk(s) && canSee(s) && canHear(s) && canTalk(s) && s.broodmother < 2 && (s.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")), (slave) => App.UI.DOM.passageLink(SlaveFullName(slave), 'Agent Workaround', () => { V.i = V.slaves.findIndex((s) => s.ID === slave.ID); }), diff --git a/src/npc/interaction/passage/matchmaking.tw b/src/npc/interaction/passage/matchmaking.tw index aa3ddabef18..1bec089c484 100644 --- a/src/npc/interaction/passage/matchmaking.tw +++ b/src/npc/interaction/passage/matchmaking.tw @@ -37,7 +37,7 @@ Their relationship would probably be somewhat artificial at first, and they'd ha <<if $seeImages == 1>><br style="clear:both"><</if>> <br><br>__Put $him with another worshipful <<if getSlave($activeSlave.ID).relationship == -2>>emotionally bonded slave<<else>>emotional slut<</if>>:__ -<<print App.UI.SlaveList.slaveSelectionList( +<<includeDOM App.UI.SlaveList.slaveSelectionList( s => s.devotion >= 100 && s.relationship === $activeSlave.relationship && s.ID !== $activeSlave.ID, App.UI.SlaveList.SlaveInteract.stdInteract, null, diff --git a/src/uncategorized/arcade.tw b/src/uncategorized/arcade.tw index 1bd7640f370..7d6d6beb788 100644 --- a/src/uncategorized/arcade.tw +++ b/src/uncategorized/arcade.tw @@ -179,7 +179,7 @@ <<includeDOM App.Facilities.Arcade.Stats(true)>> <p> - <<print App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.arcade)>> + <<includeDOM App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.arcade)>> </p> <p> diff --git a/src/uncategorized/attendantSelect.tw b/src/uncategorized/attendantSelect.tw index 9145c5cb49f..f563ca18ad9 100644 --- a/src/uncategorized/attendantSelect.tw +++ b/src/uncategorized/attendantSelect.tw @@ -11,4 +11,4 @@ <br><br>''Appoint an Attendant from your devoted slaves:'' <br><br>[[None|Spa][removeJob(_S.Attendant, Job.ATTENDANT)]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.spa, "Spa")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.spa, "Spa")>> diff --git a/src/uncategorized/bgSelect.tw b/src/uncategorized/bgSelect.tw index b888caa6e8f..9bf57513c0e 100644 --- a/src/uncategorized/bgSelect.tw +++ b/src/uncategorized/bgSelect.tw @@ -37,5 +37,5 @@ [[None|Main][removeJob($Bodyguard, "guard you")]] </div> <p> - <<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.armory, "Main")>> + <<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.armory, "Main")>> </p> diff --git a/src/uncategorized/brothel.tw b/src/uncategorized/brothel.tw index e638724aa40..f9fa7e5d799 100644 --- a/src/uncategorized/brothel.tw +++ b/src/uncategorized/brothel.tw @@ -253,7 +253,7 @@ <<includeDOM App.Facilities.Brothel.Stats(true)>> <p> - <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.brothel)>> + <<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.brothel)>> </p> <p> diff --git a/src/uncategorized/cellblock.tw b/src/uncategorized/cellblock.tw index 33ebb3147d7..90b64622ccf 100644 --- a/src/uncategorized/cellblock.tw +++ b/src/uncategorized/cellblock.tw @@ -138,7 +138,7 @@ </p> <p> - <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.cellblock)>> + <<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.cellblock)>> </p> <p> diff --git a/src/uncategorized/clinic.tw b/src/uncategorized/clinic.tw index f29386e96ab..7e88681d257 100644 --- a/src/uncategorized/clinic.tw +++ b/src/uncategorized/clinic.tw @@ -207,7 +207,7 @@ </div> <p> - <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.clinic, true)>> + <<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.clinic, true)>> </p> <p> diff --git a/src/uncategorized/club.tw b/src/uncategorized/club.tw index 2595248737f..e9c220d61ec 100644 --- a/src/uncategorized/club.tw +++ b/src/uncategorized/club.tw @@ -285,7 +285,7 @@ <<includeDOM App.Facilities.Club.Stats(true)>> <p> - <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.club)>> + <<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.club)>> </p> <p> diff --git a/src/uncategorized/concubineSelect.tw b/src/uncategorized/concubineSelect.tw index 9f153e75443..f41a0edbcfa 100644 --- a/src/uncategorized/concubineSelect.tw +++ b/src/uncategorized/concubineSelect.tw @@ -12,4 +12,4 @@ <br><br>''Appoint a Concubine from your devoted slaves:'' <br><br>[[None|Master Suite][removeJob($Concubine, "be your Concubine")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.masterSuite, "Master Suite")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.masterSuite, "Master Suite")>> diff --git a/src/uncategorized/coursingAssociation.tw b/src/uncategorized/coursingAssociation.tw index a1d356c18ad..1e681968337 100644 --- a/src/uncategorized/coursingAssociation.tw +++ b/src/uncategorized/coursingAssociation.tw @@ -16,13 +16,13 @@ The chasing slaves are known as lurchers, the term once used for the sighthounds <<if $LurcherID != 0>> <br><br>''Fire your Lurcher:'' - <<= App.UI.SlaveList.render.listMarkup([$LurcherID], [], + <<includeDOM App.UI.SlaveList.render([$LurcherID], new Array(), (slave) => App.UI.DOM.passageLink(SlaveFullName(slave), 'Coursing Association', () => removeJob(slave, Job.LURCHER)))>> <</if>> <br><br>''Select a slave to course as a Lurcher:'' <br><br> -<<= App.UI.SlaveList.slaveSelectionList( +<<includeDOM App.UI.SlaveList.slaveSelectionList( s => $LurcherID !== s.ID && canWalk(s) && canHold(s) && (canSee(s) || canHear(s)) && s.fuckdoll === 0 && isSlaveAvailable(s), (slave) => App.UI.DOM.link(SlaveFullName(slave), () => assignmentTransition(slave, Job.LURCHER, "Coursing Association")) )>> diff --git a/src/uncategorized/dairy.tw b/src/uncategorized/dairy.tw index 396eb889711..8000aeccd8b 100644 --- a/src/uncategorized/dairy.tw +++ b/src/uncategorized/dairy.tw @@ -720,7 +720,7 @@ <p> <<set _facility = App.Entity.facilities.dairy>> <<if ($Milkmaid != 0)>> - <<print App.UI.SlaveList.displayManager(_facility)>> + <<includeDOM App.UI.SlaveList.displayManager(_facility)>> <<if canAchieveErection($Milkmaid) && $Milkmaid.pubertyXY == 1>> <<setLocalPronouns $Milkmaid>> <<if $milkmaidImpregnates == 1>> @@ -762,7 +762,7 @@ <p> - <<print App.UI.SlaveList.listSJFacilitySlaves(_facility)>> + <<includeDOM App.UI.SlaveList.listSJFacilitySlaves(_facility)>> </p> <p> diff --git a/src/uncategorized/djSelect.tw b/src/uncategorized/djSelect.tw index 721284c8b0b..7a962c67acb 100644 --- a/src/uncategorized/djSelect.tw +++ b/src/uncategorized/djSelect.tw @@ -11,4 +11,4 @@ <br><br>''Appoint a DJ from your devoted slaves:'' <br><br>[[None|Club][removeJob(_S.DJ, "be the DJ")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.club, "Club")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.club, "Club")>> diff --git a/src/uncategorized/headGirlSuite.tw b/src/uncategorized/headGirlSuite.tw index af33f033102..3e1d5f0c885 100644 --- a/src/uncategorized/headGirlSuite.tw +++ b/src/uncategorized/headGirlSuite.tw @@ -58,7 +58,7 @@ </div> <</if>> <p> - <<print App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.headGirlSuite)>> + <<includeDOM App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.headGirlSuite)>> </p> <</if>> <p> diff --git a/src/uncategorized/hgSelect.tw b/src/uncategorized/hgSelect.tw index f729326e0e5..9b595199430 100644 --- a/src/uncategorized/hgSelect.tw +++ b/src/uncategorized/hgSelect.tw @@ -91,4 +91,4 @@ _HGName <br><br>''Appoint a Head Girl from among your devoted slaves:'' <br><br>[[None|Main][removeJob($HeadGirl, "be your Head Girl")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.headGirlSuite, "Main")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.headGirlSuite, "Main")>> diff --git a/src/uncategorized/madamSelect.tw b/src/uncategorized/madamSelect.tw index e72ea4a1018..ef9dd5cba03 100644 --- a/src/uncategorized/madamSelect.tw +++ b/src/uncategorized/madamSelect.tw @@ -12,4 +12,4 @@ <br><br>''Appoint a Madam from your devoted slaves:'' <br><br>[[None|Brothel][removeJob($Madam, "be the Madam")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.brothel, "Brothel")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.brothel, "Brothel")>> diff --git a/src/uncategorized/masterSuite.tw b/src/uncategorized/masterSuite.tw index efa64270a4d..c7d5fc3a683 100644 --- a/src/uncategorized/masterSuite.tw +++ b/src/uncategorized/masterSuite.tw @@ -360,7 +360,7 @@ $masterSuiteNameCaps is furnished <</if>> <br><br> -<<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.masterSuite)>> +<<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.masterSuite)>> <br><br>Rename $masterSuiteName: <<textbox "$masterSuiteName" $masterSuiteName "Master Suite">> //Use a noun or similar short phrase// diff --git a/src/uncategorized/milkmaidSelect.tw b/src/uncategorized/milkmaidSelect.tw index 1123fb3d527..36069c2e9c0 100644 --- a/src/uncategorized/milkmaidSelect.tw +++ b/src/uncategorized/milkmaidSelect.tw @@ -12,4 +12,4 @@ <br><br>''Appoint a Milkmaid from your obedient slaves:'' <br><br>[[None|Dairy][removeJob($Milkmaid, "be the Milkmaid")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.dairy, "Dairy")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.dairy, "Dairy")>> diff --git a/src/uncategorized/newGamePlus.tw b/src/uncategorized/newGamePlus.tw index ed8e42b62e0..f582693fbfd 100644 --- a/src/uncategorized/newGamePlus.tw +++ b/src/uncategorized/newGamePlus.tw @@ -1,10 +1,6 @@ :: New Game Plus [nobr] <<set $ui = "start">> <<unset $SlaveSummaryFiler>> -<<if ndef $slavesToImport>> - <<silently>><<include "Backwards Compatibility">><</silently>> -<</if>> -<<if ndef $slavesToImport>><<set $slavesToImport = 0>><</if>> <<if ndef $slavesToImportMax>><<set $slavesToImportMax = 5>><</if>> <<set _fee = 50000+($slavesToImportMax*10000)>> @@ -54,7 +50,7 @@ You <<if $cash >= _fee>>have<<else>>lack<</if>> the funds to bring more than $sl <<if $cheatMode == 1>> <<link "DEBUG: Add all slaves to import list" "New Game Plus">> <<for _ngi = 0; _ngi < $slaves.length; _ngi++>> <<= assignJob($slaves[_ngi], Job.IMPORTED)>> <</for>> <</link>> <br> <</if>> -Select up to $slavesToImportMax slaves to be imported into a new game and then click [[here.|init][$saveImported = 1,$oldCareer = "undefined",$slavesToImport = 0]] +Select up to $slavesToImportMax slaves to be imported into a new game and then click [[here.|init][$saveImported = 1,$oldCareer = "undefined"]] <br> -<<print App.UI.SlaveList.listNGPSlaves()>> +<<includeDOM App.UI.SlaveList.listNGPSlaves()>> diff --git a/src/uncategorized/nurseSelect.tw b/src/uncategorized/nurseSelect.tw index f6ad039bf40..84211a0e169 100644 --- a/src/uncategorized/nurseSelect.tw +++ b/src/uncategorized/nurseSelect.tw @@ -12,4 +12,4 @@ <br><br>[[None|Clinic][removeJob(_S.Nurse, "be the Nurse")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.clinic, "Clinic")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.clinic, "Clinic")>> diff --git a/src/uncategorized/personalAttentionSelect.tw b/src/uncategorized/personalAttentionSelect.tw index 74c8f24c04d..c4516490fe4 100644 --- a/src/uncategorized/personalAttentionSelect.tw +++ b/src/uncategorized/personalAttentionSelect.tw @@ -359,7 +359,7 @@ <</if>> /* CLOSES NO SLAVE SELECTED */ <br><br>__Select a slave to train:__ <<if $PC.skill.slaving >= 100>>//Your @@.springgreen;slaving experience@@ allows you to divide your attention between more than one slave each week, with slightly reduced efficiency//<</if>> -<<= App.UI.SlaveList.slaveSelectionList( +<<includeDOM App.UI.SlaveList.slaveSelectionList( s => assignmentVisible(s) && s.fuckdoll === 0, s => App.UI.DOM.link(SlaveFullName(s), (id) => {App.UI.selectSlaveForPersonalAttention(id); }, s.ID) )>> diff --git a/src/uncategorized/pit.tw b/src/uncategorized/pit.tw index 8379add2ba0..23b9f4956ec 100644 --- a/src/uncategorized/pit.tw +++ b/src/uncategorized/pit.tw @@ -331,7 +331,7 @@ $pitNameCaps is clean and ready, <</if>> <br><br> -<<print App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.pit, passage(), false, +<<includeDOM App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.pit, passage(), false, {assign: "Select a slave to fight", remove: "Cancel a slave's fight"})>> <br><br>Rename $pitName: <<textbox "$pitName" $pitName "Pit">> //Use a noun or similar short phrase// diff --git a/src/uncategorized/recruiterSelect.tw b/src/uncategorized/recruiterSelect.tw index 49ad10e6d6d..91f29f6dcde 100644 --- a/src/uncategorized/recruiterSelect.tw +++ b/src/uncategorized/recruiterSelect.tw @@ -65,4 +65,4 @@ <br><br>''Appoint a recruiter from among your devoted slaves:'' <br>[[None|Main][removeJob($Recruiter, "recruit girls")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.penthouse, "Main")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.penthouse, "Main")>> diff --git a/src/uncategorized/schoolroom.tw b/src/uncategorized/schoolroom.tw index 57698e3065d..4e0ea70ca30 100644 --- a/src/uncategorized/schoolroom.tw +++ b/src/uncategorized/schoolroom.tw @@ -179,7 +179,7 @@ </div> <p> - <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.schoolroom, true)>> + <<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.schoolroom, true)>> </p> <p> diff --git a/src/uncategorized/schoolteacherSelect.tw b/src/uncategorized/schoolteacherSelect.tw index e7fa4148322..7572a3d974d 100644 --- a/src/uncategorized/schoolteacherSelect.tw +++ b/src/uncategorized/schoolteacherSelect.tw @@ -11,4 +11,4 @@ <br><br>''Appoint a Schoolteacher from your devoted slaves:'' <br><br>[[None|Schoolroom][removeJob(_S.Schoolteacher, "be the Schoolteacher")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.schoolroom, "Schoolroom")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.schoolroom, "Schoolroom")>> diff --git a/src/uncategorized/servantsQuarters.tw b/src/uncategorized/servantsQuarters.tw index 1c1d71e93e4..ffd1cec37fd 100644 --- a/src/uncategorized/servantsQuarters.tw +++ b/src/uncategorized/servantsQuarters.tw @@ -126,7 +126,7 @@ <<set _facility = App.Entity.facilities.servantsQuarters>> <<if _S.Stewardess>> <<setLocalPronouns _S.Stewardess>> - <<print App.UI.SlaveList.displayManager(_facility)>> + <<includeDOM App.UI.SlaveList.displayManager(_facility)>> <<if canAchieveErection(_S.Stewardess) && _S.Stewardess.pubertyXY == 1>> <<if $stewardessImpregnates == 1>> Keeping the maids pregnant is part of $his job. @@ -146,7 +146,7 @@ </p> <p> - <<print App.UI.SlaveList.listSJFacilitySlaves(_facility)>> + <<includeDOM App.UI.SlaveList.listSJFacilitySlaves(_facility)>> </p> <p> diff --git a/src/uncategorized/spa.tw b/src/uncategorized/spa.tw index 696db7c3bcd..a3ef5999615 100644 --- a/src/uncategorized/spa.tw +++ b/src/uncategorized/spa.tw @@ -148,7 +148,7 @@ </div> <p> - <<print App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.spa, true)>> + <<includeDOM App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.spa, true)>> </p> <p> diff --git a/src/uncategorized/stewardessSelect.tw b/src/uncategorized/stewardessSelect.tw index dfac601f9c9..a9dc36cfaa2 100644 --- a/src/uncategorized/stewardessSelect.tw +++ b/src/uncategorized/stewardessSelect.tw @@ -11,4 +11,4 @@ <br><br>''Appoint a Stewardess from your devoted slaves:'' <br><br>[[None|Servants' Quarters][removeJob(_S.Stewardess, Job.STEWARD)]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.servantsQuarters, "Servants' Quarters")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.servantsQuarters, "Servants' Quarters")>> diff --git a/src/uncategorized/subordinateTargeting.tw b/src/uncategorized/subordinateTargeting.tw index 8f357c01528..7f9a8f115e9 100644 --- a/src/uncategorized/subordinateTargeting.tw +++ b/src/uncategorized/subordinateTargeting.tw @@ -32,7 +32,7 @@ <</if>> <br><br>[[None|Subordinate Targeting][$activeSlave.subTarget = 0]] <br><br>__Select a slave for $him to submit to, sexually:__ - <<= App.UI.SlaveList.slaveSelectionList( + <<includeDOM App.UI.SlaveList.slaveSelectionList( s => s.devotion >= -20 && s.fuckdoll === 0 && State.variables.activeSlave.ID !== s.ID && (!isAmputee(State.variables.activeSlave) || !isAmputee(s)), (s) => App.UI.DOM.passageLink(SlaveFullName(s), 'Subordinate Targeting', () => { V.activeSlave.subTarget = s.ID; }), diff --git a/src/uncategorized/underperformingSlaves.tw b/src/uncategorized/underperformingSlaves.tw index 2b874d72445..5fc39bb79b8 100644 --- a/src/uncategorized/underperformingSlaves.tw +++ b/src/uncategorized/underperformingSlaves.tw @@ -24,58 +24,15 @@ <button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'highSale')" id="tab highSale">Worth much but earning little</button> <button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'expensive')" id="tab expensive">Costing vs earning</button> </div> + <div id="highSale" class="tabcontent"> <div class="content"> - <div style="font-style:italic"> - Take the rough value of a slave and divide it by how much they made overall last week. This will tell you how many weeks it might take them to earn the same amount you'd get for selling them right now. - </div> - <<print App.UI.SlaveList.render.listMarkup( - getBestSlavesIDs( - { - part:(slave) => { - const ratio = slaveCost(slave) / (slave.lastWeeksCashIncome - getSlaveCost(slave)); - return ratio > 0 ? ratio : 100000000 + ratio; - }, - count: 7, - filter:(slave) => ( - ["be confined in the arcade", "get milked", "whore", "work a glory hole", "work in the brothel", "work in the dairy"].includes(slave.assignment) - && ((slave.weekAcquired + 1) < V.week) - && slave.lastWeeksCashIncome - ) - } - ), - [], - App.UI.SlaveList.SlaveInteract.stdInteract, - (slave) => $(document.createDocumentFragment()).append( - `Worth ${cashFormatColor(slaveCost(slave))} / Nets ${cashFormatColor(slave.lastWeeksCashIncome - getSlaveCost(slave))} a week = ${(Math.trunc(slaveCost(slave) / (slave.lastWeeksCashIncome - getSlaveCost(slave)))) > 0 ? (Math.trunc(slaveCost(slave) / (slave.lastWeeksCashIncome - getSlaveCost(slave)))) : "infinite"} weeks` - ).get(0) - )>> + <<includeDOM App.Underperformers.highSale()>> </div> </div> <div id="expensive" class="tabcontent"> <div class="content"> - <div style="font-style:italic"> - This list looks for moochers by weighing their weekly income against the weekly cost of providing for them. - </div> - <<print App.UI.SlaveList.render.listMarkup( - getBestSlavesIDs( - { - part:(slave) => (slave.lastWeeksCashIncome - getSlaveCost(slave)), - largest: false, - count: 7, - filter:(slave) => ( - ["be confined in the arcade", "get milked", "whore", "work a glory hole", "work in the brothel", "work in the dairy"].includes(slave.assignment) - && ((slave.weekAcquired + 1) < V.week) - && slave.lastWeeksCashIncome - ) - } - ), - [], - App.UI.SlaveList.SlaveInteract.stdInteract, - (slave) => $(document.createDocumentFragment()).append( - `${cashFormatColor(Math.trunc(slave.lastWeeksCashIncome - getSlaveCost(slave)))} net last week` - ).get(0) - )>> + <<includeDOM App.Underperformers.expensive()>> </div> </div> diff --git a/src/uncategorized/wardenessSelect.tw b/src/uncategorized/wardenessSelect.tw index d64de5bdce2..6ae7bf5aed1 100644 --- a/src/uncategorized/wardenessSelect.tw +++ b/src/uncategorized/wardenessSelect.tw @@ -11,4 +11,4 @@ <br><br>''Appoint a Wardeness from your devoted slaves:'' <br><br>[[None|Cellblock][removeJob(_S.Wardeness, "be the Wardeness")]] <br><br> -<<print App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.cellblock, "Cellblock")>> +<<includeDOM App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.cellblock, "Cellblock")>> -- GitLab