diff --git a/src/js/slaveInteract.js b/src/js/slaveInteract.js index fbc7b3542d8c28adad29e23aad52a3f4daa3100b..e1fb1b99c4f056ffa2283d612eb45f33c3c817dd 100644 --- a/src/js/slaveInteract.js +++ b/src/js/slaveInteract.js @@ -1,114 +1,105 @@ -App.UI.SlaveInteract = { - fucktoyPref: function() { - let res = ""; - /** @type {App.Entity.SlaveState} */ - const slave = State.variables.activeSlave; - const {his} = getPronouns(slave); - el = document.createElement('div'); +App.UI.SlaveInteract = {}; - if ((slave.assignment === "please you") || (slave.assignment === "serve in the master suite") || (slave.assignment === "be your Concubine")) { - let storyLabel = document.createElement('span'); - storyLabel.className = "story-label"; - storyLabel.textContent = `Fucktoy use preference: `; - el.appendChild(storyLabel); +App.UI.SlaveInteract.fucktoyPref = function() { + /** @type {App.Entity.SlaveState} */ + const slave = State.variables.activeSlave; + const {his} = getPronouns(slave); + let el = document.createElement('div'); + let links = []; - let hole = document.createElement('span'); - hole.style.fontWeight = "bold"; - hole.textContent = `${slave.toyHole}. `; - el.appendChild(hole); + if ((slave.assignment === "please you") || (slave.assignment === "serve in the master suite") || (slave.assignment === "be your Concubine")) { + let storyLabel = document.createElement('span'); + storyLabel.className = "story-label"; + storyLabel.textContent = `Fucktoy use preference:`; + el.appendChild(storyLabel); - /** @type {string[]} */ - let links = []; - links.push('<<link "Mouth">><<set $activeSlave.toyHole = "mouth">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>>'); - links.push('<<link "Tits">><<set $activeSlave.toyHole = "boobs">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>>'); - if ((slave.vagina > 0) && canDoVaginal(slave)) { - links.push('<<link "Pussy">><<set $activeSlave.toyHole = "pussy">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>>'); - links.push({text: ``, toyHole: ``}); - } else if (slave.vagina === 0) { - links.push(App.UI.disabledLink("Pussy", - [`Take ${his} virginity before giving ${his} pussy special attention`])); - links.push({text: ``, toyHole: ``}); - } - if ((slave.anus > 0) && canDoAnal(slave)) { - links.push('<<link "Ass">><<set $activeSlave.toyHole = "ass">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>>'); - links.push({text: ``, toyHole: ``}); - } else { - links.push(App.UI.disabledLink("Ass", - links.push({text: `Take ${his} anal virginity before giving ${his} ass special attention`}); - } - if ((slave.dick > 0) && canPenetrate(slave)) { - links.push({text: `Dick`, toyHole: `dick`}); - } - links.push({text: `No Preference`, toyHole: `all ${his} holes`}); + el.append(` `); + + let hole = document.createElement('span'); + hole.style.fontWeight = "bold"; + hole.textContent = `${slave.toyHole}. `; + el.appendChild(hole); + + /** @type {string[]} */ + + links.push({text: `Mouth`, toyHole: `mouth`}); + links.push({text: `Tits`, toyHole: `boobs`}); + if ((slave.vagina > 0) && canDoVaginal(slave)) { + links.push({text: `Pussy`, toyHole: `pussy`}); + } else if (slave.vagina === 0) { + links.push({text: `Pussy`, disabled: `Take ${his} virginity before giving ${his} pussy special attention`}); + } + if ((slave.anus > 0) && canDoAnal(slave)) { + links.push({text: `Ass`, toyHole: `ass`}); + } else { + links.push({text: `Ass`, disabled: `Take ${his} anal virginity before giving ${his} ass special attention`}); } - el.appendChild(generateRows(links)); + if ((slave.dick > 0) && canPenetrate(slave)) { + links.push({text: `Dick`, toyHole: `dick`}); + } + links.push({text: `No Preference`, toyHole: `all ${his} holes`}); + } + el.appendChild(generateRows(links)); - function generateRows(toyHoleArray) { - let row = document.createDocumentFragment(); - for (let i = 0; i < toyHoleArray.length; i++) { - let link; - const separator = document.createTextNode(` | `); - const keys = Object.keys(toyHoleArray[i]); - - // Test to see if there was a problem with the key - for (let j = 0; j < keys.length; j++) { - if (["text", "toyHole"].includes(keys[j])) { - continue; - } else { - toyHoleArray[i].text += " ERROR, THIS SCENE WAS NOT ENTERED CORRECTLY"; - console.log("Trash found while generateRows() was running: " + keys[j] + ": " + toyHoleArray[i][keys[j]]); - break; - } - } - - // is it just text? - if (keys.length === 1) { - if (toyHoleArray[i].text) { - link = document.createTextNode(toyHoleArray[i].text); - } else { - console.log(`expected 'text' only, got: ${toyHoleArray[i]}`); - link = document.createTextNode("error, text not found"); - } - // Are they already on this toyHole? - } else if (toyHoleArray[i].toyHole === slave.toyHole) { - link = document.createTextNode(toyHoleArray[i].text); - // Set up the link + function generateRows(toyHoleArray) { + let row = document.createDocumentFragment(); + for (let i = 0; i < toyHoleArray.length; i++) { + let link; + const separator = document.createTextNode(` | `); + const keys = Object.keys(toyHoleArray[i]); + + // Test to see if there was a problem with the key + for (let j = 0; j < keys.length; j++) { + if (["text", "toyHole", "disabled"].includes(keys[j])) { + continue; } else { - link = App.UI.DOM.link( - toyHoleArray[i].text, - () => { - slave.toyHole = toyHoleArray[i].toyHole, - App.UI.SlaveInteract.fucktoyPref(slave); - }, - ); - - // add a note node if required - if (toyHoleArray[i].note) { - let note = document.createTextNode(toyHoleArray[i].note); - note.className = "note"; - link.appendChild(note); - } + toyHoleArray[i].text += " ERROR, THIS SCENE WAS NOT ENTERED CORRECTLY"; + console.log("Trash found while generateRows() was running: " + keys[j] + ": " + toyHoleArray[i][keys[j]]); + break; } - row.appendChild(link); - if (i < toyHoleArray.length-1) { - row.appendChild(separator); + } + // is it just text? + if (toyHoleArray[i].disabled) { + link = App.UI.DOM.disabledLink(toyHoleArray[i].text, [toyHoleArray[i].disabled]); + // Are they already on this toyHole? + } else if (toyHoleArray[i].toyHole === slave.toyHole) { + link = document.createTextNode(toyHoleArray[i].text); + // Set up the link + } else { + link = App.UI.DOM.link( + toyHoleArray[i].text, + () => { + slave.toyHole = toyHoleArray[i].toyHole, + App.UI.SlaveInteract.fucktoyPref(slave); + }, + ); + + // add a note node if required + if (toyHoleArray[i].note) { + let note = document.createTextNode(toyHoleArray[i].note); + note.className = "note"; + link.appendChild(note); } } - - return row; + row.appendChild(link); + if (i < toyHoleArray.length-1) { + row.appendChild(separator); + } } - return jQuery('#hole').empty().append(el); - }, - assignmentBlock: function(blockId) { - let res = App.UI.jobLinks.assignments(-1, undefined, () => { - return `<<replace "#assign">>$activeSlave.assignment<</replace>><<replace "#${blockId}">><<= App.UI.SlaveInteract.assignmentBlock("${blockId}")>><<= App.UI.SlaveInteract.fucktoyPref()>><</replace>>`; - }); - if (State.variables.activeSlave.assignment !== "choose her own job") { - res += ' |  <<link "Stay on this assignment for another month">><<set $activeSlave.sentence += 4>><<replace "#assign">>$activeSlave.assignment($activeSlave.sentence weeks)<</replace>><</link>>'; - } - return res; + return row; + } + return jQuery('#fucktoypref').empty().append(el); +}; + +App.UI.SlaveInteract.assignmentBlock = function(blockId) { + let res = App.UI.jobLinks.assignments(-1, undefined, () => { + return `<<replace "#assign">>$activeSlave.assignment<</replace>><<replace "#${blockId}">><<= App.UI.SlaveInteract.assignmentBlock("${blockId}")>><</replace>>`; + }); + if (State.variables.activeSlave.assignment !== "choose her own job") { + res += ' |  <<link "Stay on this assignment for another month">><<set $activeSlave.sentence += 4>><<replace "#assign">>$activeSlave.assignment($activeSlave.sentence weeks)<</replace>><</link>>'; } + return res; }; App.UI.SlaveInteract.drugs = function(slave) { diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw index a2b752cad57cf11e1b8b49ec73588e9eb88483c5..dae1caf6d5d5fcbc1126156a8823a2d255cd024d 100644 --- a/src/uncategorized/slaveInteract.tw +++ b/src/uncategorized/slaveInteract.tw @@ -120,34 +120,6 @@ <br> -<span id="fucktoypref"> - <<if ($activeSlave.assignment == "please you") || ($activeSlave.assignment == "serve in the master suite") || ($activeSlave.assignment == "be your Concubine")>> - Fucktoy use preference: <span id="hole" style="font-weight:bold">$activeSlave.toyHole.</span> - <<link "Mouth">><<set $activeSlave.toyHole = "mouth">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>> - | <<link "Tits">><<set $activeSlave.toyHole = "boobs">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>> - <<if ($activeSlave.vagina > 0) && canDoVaginal($activeSlave)>> - | <<link "Pussy">><<set $activeSlave.toyHole = "pussy">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>> - <<elseif ($activeSlave.vagina > 0)>> - | //$His pussy is not available while in chastity// - <<elseif ($activeSlave.vagina == 0)>> - | //Take $his virginity before giving $his pussy special attention// - <</if>> - <<if ($activeSlave.anus > 0) && canDoAnal($activeSlave)>> - | <<link "Ass">><<set $activeSlave.toyHole = "ass">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>> - <<elseif ($activeSlave.anus > 0)>> - | //$His ass is not available while in chastity// - <<elseif ($activeSlave.anus == 0)>> - | //Take $his anal virginity before giving $his ass special attention// - <</if>> - /*check*/ - <<if ($activeSlave.dick > 0) && canPenetrate($activeSlave)>> - | <<link "Dick">><<set $activeSlave.toyHole = "dick">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>> - <</if>> - | <<link "No Preference">><<set $activeSlave.toyHole = "all her holes">><<replace "#hole">>$activeSlave.toyHole<</replace>><</link>> - <br> - <</if>> -</span> - <<switch $activeSlave.assignment>> <<case "recover from surgery">> //$He is recovering from surgery this week// @@ -183,6 +155,9 @@ /* CAN BE REASSIGNED */ + <div id="fucktoypref"></div> + <script>App.UI.SlaveInteract.fucktoyPref(V.activeSlave)</script> + Assignment: <span id="assign" font-weight="bold"> <<if $activeSlave.sentence>> @@ -194,8 +169,7 @@ <<if $assignmentRecords[$activeSlave.ID] && $assignmentRecords[$activeSlave.ID] != $activeSlave.assignment>> Previously: <<print $assignmentRecords[$activeSlave.ID]>> <</if>> - <div id="hole"></div> - <script>App.UI.SlaveInteract.fucktoyPref(V.activeSlave)</script> + <span id="assignmentLinks"><<= App.UI.SlaveInteract.assignmentBlock("assignmentLinks")>></span> <<set _numFacilities = $brothel+$club+$dairy+$farmyard+$servantsQuarters+$masterSuite+$spa+$nursery+$clinic+$schoolroom+$cellblock+$arcade+$HGSuite>>