From 62deddea07302f3088d3c001acb89dd4d0434153 Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Fri, 4 Dec 2020 20:28:39 -0500 Subject: [PATCH] begin js conversion for slave on slave feeding selection --- src/interaction/slaveOnSlaveFeeding.css | 7 + .../slaveOnSlaveFeedingWorkAround.js | 166 ++++++++++++++++++ .../slaveOnSlaveFeedingWorkAround.tw | 3 + 3 files changed, 176 insertions(+) create mode 100644 src/interaction/slaveOnSlaveFeeding.css create mode 100644 src/interaction/slaveOnSlaveFeedingWorkAround.js rename src/{pregmod => interaction}/slaveOnSlaveFeedingWorkAround.tw (98%) diff --git a/src/interaction/slaveOnSlaveFeeding.css b/src/interaction/slaveOnSlaveFeeding.css new file mode 100644 index 00000000000..e4fb2cc907e --- /dev/null +++ b/src/interaction/slaveOnSlaveFeeding.css @@ -0,0 +1,7 @@ +table.slave-on-slave-feeding { + width: 90%; +} + +table.slave-on-slave-feeding tr { + vertical-align: top; +} \ No newline at end of file diff --git a/src/interaction/slaveOnSlaveFeedingWorkAround.js b/src/interaction/slaveOnSlaveFeedingWorkAround.js new file mode 100644 index 00000000000..885a9749ef0 --- /dev/null +++ b/src/interaction/slaveOnSlaveFeedingWorkAround.js @@ -0,0 +1,166 @@ +App.UI.SlaveInteract.slaveOnSlaveFeedingSelection = function(slave) { + const el = new DocumentFragment(); + let inflationLevel; + let inflationMethod; + let inflationType; + setup(); + el.append(intro()); + el.append(milkSlaves()); + + return el; + + function intro() { + const el = new DocumentFragment(); + const { his } = getPronouns(slave); + + App.UI.DOM.appendNewElement("div", el, `${slave.slaveName} is prepped to drink ${his} fill; now you must select a slave capable of producing the required amount of milk or ejaculate.`); + App.UI.DOM.appendNewElement("h2", el, "Select an eligible slave to serve as the tap"); + return el; + } + + function setup() { + for (const slave of V.slaves) { + /* milk output */ + let _milk; + let _cum; + if (slave.lactation > 0) { + slave.milkOutput = 0; + _milk = milkAmount(slave); + _milk = (_milk / 14); + _milk = Math.trunc(_milk); + slave.milkOutput = _milk; + } else { + _milk = 0; + slave.milkOutput = 0; + } + /* cum output */ + if (slave.balls > 0 && slave.dick > 0 && slave.chastityPenis !== 1) { + slave.cumOutput = 0; + _cum = cumAmount(slave); + _cum = (_cum / 7); + _cum = (_cum / 10); + _cum = Math.trunc(_cum); + slave.cumOutput = _cum; + } else { + _cum = 0; + slave.cumOutput = 0; + } + } + } + + /** + * + * @param {App.Entity.SlaveState} slave + */ + function milkSlaves(slave) { // Tabs maybe? + const el = new DocumentFragment(); + const twoLiterSlaves = []; + const fourLiterSlaves = []; + const eightLiterSlaves = []; + const {he, his} = getPronouns(slave); + + App.UI.DOM.appendNewElement("h3", el, "Milk Slaves"); + const table = document.createElement("table"); + table.classList.add("slave-on-slave-feeding"); + + const header = table.createTHead(); + table.append(header); + el.append(table); + + const columnNames = ["2 Liter", "4 Liter", "8 Liter"]; + for (const name of columnNames) { + header.append(App.UI.DOM.makeElement("th", name)); + } + + for (const tapSlave of V.slaves) { + if (tapSlave.ID !== slave.ID && tapSlave.nipples !== "fuckable") { + if (tapSlave.milkOutput >= 2) { + const tapLink = createTapLink(tapSlave); + twoLiterSlaves.push(tapLink); + if (tapSlave.milkOutput >= 4 && slave.pregKnown === 0) { + fourLiterSlaves.push(tapLink); + if (tapSlave.milkOutput >= 8) { + eightLiterSlaves.push(tapLink); + } + } + } + } + } + + if (twoLiterSlaves.length === 0) { + twoLiterSlaves.push(App.UI.DOM.makeElement("td", `Due to ${his} pregnancy, ${he} is incapable of keeping down more than two liters of milk.`)); + } + if (slave.pregKnown === 0) { + fourLiterSlaves.push(App.UI.DOM.makeElement("td", "You have no slaves capable of producing four liters of milk.")); + } else { + if (fourLiterSlaves.length === 0) { + fourLiterSlaves.push(App.UI.DOM.makeElement("td", "You have no slaves capable of producing four liters of milk.")); + } + if (eightLiterSlaves.length === 0) { + eightLiterSlaves.push(App.UI.DOM.makeElement("td", "You have no slaves capable of producing eight liters of milk.")); + } + } + + const dataRow = document.createElement("tr"); + dataRow.append(makeColumn(twoLiterSlaves, 0)); + dataRow.append(makeColumn(fourLiterSlaves, 1)); + dataRow.append(makeColumn(eightLiterSlaves, 2)); + table.append(dataRow); + + return el; + } + function createTapLink(tapSlave) { + const el = document.createElement("div"); + el.append( + App.UI.DOM.link( + tapSlave.slaveName, + () => { + V.milkTap = tapSlave; + slave.inflation = inflationLevel; + slave.inflationType = inflationType; + slave.inflationMethod = inflationMethod; + }, + [], + "FSlaveFeed" + ) + ); + const relTerm = relativeTerm(slave, tapSlave); + if (relTerm) { + el.append(` ${relTerm}`); + } + if (tapSlave.relationshipTarget === slave.ID) { + const { wife } = getPronouns(tapSlave); + switch (tapSlave.relationship) { + case 1: + el.append(` friends`); + case 2: + el.append(` best friends`); + case 3: + el.append(` friends with benefits`); + case 4: + el.append(` lover`); + case 5: + el.append(` slave${wife}`); + } + } + if (tapSlave.rivalryTarget === getSlave(V.AS).ID) { + switch (tapSlave.relationship) { + case 1: + el.append(`dislikes`); + case 2: + el.append(`rival`); + case 3: + el.append(`bitterly hates`); + } + } + return el; + } + + function makeColumn(array, index) { + const td = document.createElement("td"); + for (const cell of array) { + td.append(cell); + } + return td; + } +}; diff --git a/src/pregmod/slaveOnSlaveFeedingWorkAround.tw b/src/interaction/slaveOnSlaveFeedingWorkAround.tw similarity index 98% rename from src/pregmod/slaveOnSlaveFeedingWorkAround.tw rename to src/interaction/slaveOnSlaveFeedingWorkAround.tw index e07be1d49ed..b4fb53c1c23 100644 --- a/src/pregmod/slaveOnSlaveFeedingWorkAround.tw +++ b/src/interaction/slaveOnSlaveFeedingWorkAround.tw @@ -4,6 +4,9 @@ <<set $milkTap = 0, _descM = "milk", _descC = "cum", _eligibilityMilk2 = 0, _eligibilityMilk4 = 0, _eligibilityMilk8 = 0, _eligibilityCum2 = 0, _eligibilityCum4 = 0, _eligibilityCum8 = 0>> +<h1>DOM</h1> +<<includeDOM App.UI.SlaveInteract.slaveOnSlaveFeedingSelection(getSlave($AS))>> +<h1>SC</h1> <<for _i = 0; _i < $slaves.length; _i++>> /* milk output */ <<if $slaves[_i].lactation > 0>> <<set $slaves[_i].milkOutput = 0>> -- GitLab