diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index e5bfbb4aaa5a4543d9d610425c2f23b5f9190d68..b187865f2dd471fc3c70e8c0586a6377d9d96cb0 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -2209,6 +2209,111 @@ App.UI.SlaveInteract.smartSettings = function(slave) { return jQuery('#smartSettings').empty().append(el); }; +App.UI.SlaveInteract.orgasm = function(slave) { + let el = document.createElement('div'); + + const { + // eslint-disable-next-line no-unused-vars + he, + him, + his, + hers, + himself, + boy, + He, + His + } = getPronouns(slave); + const masturbation = []; + const partner = []; + const family = []; + const slaves = []; + const master = []; + + // Masturbation + masturbation.push({text: `Allow`, updateSlave: {"rules.release.masturbation": 1}}); + masturbation.push({text: `Forbid`, updateSlave: {"rules.release.masturbation": 0}}); + + // Partner + partner.push({text: `Allow`, updateSlave: {"rules.release.partner": 1}}); + partner.push({text: `Forbid`, updateSlave: {"rules.release.partner": 0}}); + + // Family + family.push({text: `Allow`, updateSlave: {"rules.release.family": 1}}); + family.push({text: `Forbid`, updateSlave: {"rules.release.family": 0}}); + + // Slaves + slaves.push({text: `Allow`, updateSlave: {"rules.release.slaves": 1}}); + slaves.push({text: `Forbid`, updateSlave: {"rules.release.slaves": 0}}); + + // Master + master.push({text: `Grant`, updateSlave: {"rules.release.master": 1}}); + master.push({text: `Deny`, updateSlave: {"rules.release.master": 0}}); + + let title = document.createElement('div'); + title.textContent = `Non-assignment orgasm rules: `; + el.append(title); + + let links; + if (masturbation.length) { + links = document.createElement('div'); + links.append(`Masturbation: `); + status(slave.rules.release.masturbation); + links.appendChild(App.UI.SlaveInteract.generateRows(masturbation, slave)); + links.className = "choices"; + el.append(links); + } + + if (partner.length) { + links = document.createElement('div'); + links.append(`Partner: `); + status(slave.rules.release.partner); + links.appendChild(App.UI.SlaveInteract.generateRows(partner, slave)); + links.className = "choices"; + el.append(links); + } + + if (family.length) { + links = document.createElement('div'); + links.append(`Family: `); + status(slave.rules.release.family); + links.appendChild(App.UI.SlaveInteract.generateRows(family, slave)); + links.className = "choices"; + el.append(links); + } + + if (slaves.length) { + links = document.createElement('div'); + links.append(`Other slaves: `); + status(slave.rules.release.slaves); + links.appendChild(App.UI.SlaveInteract.generateRows(slaves, slave)); + links.className = "choices"; + el.append(links); + } + + if (master.length) { + links = document.createElement('div'); + links.append(`Master: `); + status(slave.rules.release.master, true); + links.appendChild(App.UI.SlaveInteract.generateRows(master, slave)); + links.className = "choices"; + el.append(links); + } + + function status(setting, master) { + let selected = document.createElement('span'); + selected.style.fontWeight = "bold"; + let text; + if (master) { + text = setting ? "granted" : "denied"; + } else { + text = setting ? "allowed" : "denied"; + } + selected.textContent = `${text}. `; + links.append(selected); + } + + return jQuery('#orgasm').empty().append(el); +}; App.UI.SlaveInteract.custom = (function() { let el; @@ -3118,7 +3223,9 @@ App.UI.SlaveInteract.generateRows = function(array, slave, category, accessCheck function click(arrayOption) { if (arrayOption.updateSlave) { - Object.assign(slave, arrayOption.updateSlave); + for (const slaveProperty in arrayOption.updateSlave) { + setValue(slave, slaveProperty, arrayOption.updateSlave[slaveProperty]); + } } if (arrayOption.update) { Object.assign(V, arrayOption.update); @@ -3127,6 +3234,20 @@ App.UI.SlaveInteract.generateRows = function(array, slave, category, accessCheck App.UI.SlaveInteract.refreshAll(slave); return; } + + function setValue(obj, path, val) { + const ref = resolve(obj, path); + ref.obj[ref.prop] = val; + } + + function resolve(obj, path, separator = '.') { + const pathArray = Array.isArray(path) ? path : path.split(separator); + if (pathArray.length === 1) { + return {obj: obj, prop: pathArray[0]}; + } + const lastObj = pathArray.slice(0, pathArray.length - 1).reduce((prev, prop) => prev[prop], obj); + return {obj: lastObj, prop: pathArray.slice(pathArray.length - 1)}; + } }; App.UI.SlaveInteract.refreshAll = function(slave) { @@ -3146,4 +3267,5 @@ App.UI.SlaveInteract.refreshAll = function(slave) { App.UI.SlaveInteract.dietBase(slave); App.UI.SlaveInteract.snacks(slave); App.UI.SlaveInteract.smartSettings(slave); + App.UI.SlaveInteract.orgasm(slave); }; diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw index 7413f448cffa52bb6c598d0aee100947c9e599d4..b2842a8b890b8a72a23c5f7b2bb4af2e9a8d5ca4 100644 --- a/src/uncategorized/slaveInteract.tw +++ b/src/uncategorized/slaveInteract.tw @@ -432,37 +432,11 @@ <</if>> <</if>> - <br><br>Non-assignment orgasm rules: - <div style="text-indent:2em"> - Masturbation is <span id="relMasturbation" style="font-weight:bold"><<if getSlave($AS).rules.release.masturbation === 1>>allowed<<else>>forbidden<</if>></span>. - <<link "Allow">><<set getSlave($AS).rules.release.masturbation = 1>><<replace "#relMasturbation">>allowed<</replace>><</link>> | - <<link "Forbid">><<set getSlave($AS).rules.release.masturbation = 0>><<replace "#relMasturbation">>forbidden<</replace>><</link>> - </div> - <div style="text-indent:2em"> - Sex with romantic partner is <span id="relPartner" style="font-weight:bold"><<if getSlave($AS).rules.release.partner === 1>>allowed<<else>>forbidden<</if>></span>. - <<link "Allow">><<set getSlave($AS).rules.release.partner = 1>><<replace "#relPartner">>allowed<</replace>><</link>> | - <<link "Forbid">><<set getSlave($AS).rules.release.partner = 0>><<replace "#relPartner">>forbidden<</replace>><</link>> - </div> - <<if $seeIncest == 1>> - <div style="text-indent:2em"> - Sex with close family is <span id="relFamily" style="font-weight:bold"><<if getSlave($AS).rules.release.family === 1>>allowed<<else>>forbidden<</if>></span>. - <<link "Allow">><<set getSlave($AS).rules.release.family = 1>><<replace "#relFamily">>allowed<</replace>><</link>> | - <<link "Forbid">><<set getSlave($AS).rules.release.family = 0>><<replace "#relFamily">>forbidden<</replace>><</link>> - </div> - <</if>> - <div style="text-indent:2em"> - Sex with other slaves is <span id="relSlaves" style="font-weight:bold"><<if getSlave($AS).rules.release.slaves === 1>>allowed<<else>>forbidden<</if>></span>. - <<link "Allow">><<set getSlave($AS).rules.release.slaves = 1>><<replace "#relSlaves">>allowed<</replace>><</link>> | - <<link "Forbid">><<set getSlave($AS).rules.release.slaves = 0>><<replace "#relSlaves">>forbidden<</replace>><</link>> - </div> - <div style="text-indent:2em"> - Routine sex with <<= properMaster()>> is <span id="relMaster" style="font-weight:bold"><<if getSlave($AS).rules.release.master === 1>>granted<<else>>denied<</if>></span>. - <<link "Grant">><<set getSlave($AS).rules.release.master = 1>><<replace "#relMaster">>granted<</replace>><</link>> | - <<link "Deny">><<set getSlave($AS).rules.release.master = 0>><<replace "#relMaster">>denied<</replace>><</link>> - </div> + <span id="orgasm"></span> + <script>App.UI.SlaveInteract.orgasm(getSlave(V.activeSlave.ID))</script> <<if getSlave($AS).voice != 0>> - <br>Speech rules: <span id="speechRules" style="font-weight:bold"><<= getSlave($AS).rules.speech>></span>. + Speech rules: <span id="speechRules" style="font-weight:bold"><<= getSlave($AS).rules.speech>></span>. <<link "Restrictive">><<set getSlave($AS).rules.speech = "restrictive">><<replace "#speechRules">><<= getSlave($AS).rules.speech>><</replace>><</link>> | <<link "Permissive">><<set getSlave($AS).rules.speech = "permissive">><<replace "#speechRules">><<= getSlave($AS).rules.speech>><</replace>><</link>> <<if getSlave($AS).accent > 0 && getSlave($AS).accent < 4>>| <<link "Accent elimination">><<set getSlave($AS).rules.speech = "accent elimination">><<replace "#speechRules">><<= getSlave($AS).rules.speech>><</replace>><</link>>