diff --git a/src/interaction/main/mainLinks.js b/src/interaction/main/mainLinks.js index beb5e84d1faa78f240aa3ebacedc528a6a040172..c2e7c0e9e0d51d1400c799a8c3e63d6ee4b688d0 100644 --- a/src/interaction/main/mainLinks.js +++ b/src/interaction/main/mainLinks.js @@ -8,19 +8,17 @@ App.UI.View.MainLinks = function() { "use strict"; const V = State.variables; const PA = Array.isArray(V.personalAttention) ? V.personalAttention.map(function(x) { return getSlave(x.ID); }) : []; - var r = ``; + let r = ``; if (V.HeadGirl) { - var pronouns = getPronouns(V.HeadGirl); - var he = pronouns.pronoun; - var him = pronouns.object; - var his = pronouns.possessive; - var hers = pronouns.possessivePronoun; - var himself = pronouns.objectReflexive; - var boy = pronouns.noun; - var He = capFirstChar(he); - var His = capFirstChar(his); - var sl = V.slaves.length; - var cl = V.completedOrgans.length; + var pronouns = getPronouns(V.HeadGirl), + he = pronouns.pronoun, + him = pronouns.object, + his = pronouns.possessive, + hers = pronouns.possessivePronoun, + himself = pronouns.objectReflexive, + boy = pronouns.noun, + He = capFirstChar(he), + His = capFirstChar(his); } if (V.PCWounded === 1) { @@ -64,7 +62,7 @@ App.UI.View.MainLinks = function() { r += `This week you will learn hacking.`; break; case "proclamation": - r += `This week you plan to issue a proclamation about ${proclamationType}.`; + r += `This week you plan to issue a proclamation about ${V.proclamationType}.`; break; case "technical accidents": r += `This week you plan to sell your technical skills to the highest bidder.`; @@ -126,85 +124,58 @@ App.UI.View.MainLinks = function() { } } - - /* cycle through slaves, for each slave cycle through completed organs and track how many are of the interrogated slave (and if organs have a slaves to be implanted on) if (V.completedOrgans.length > 0) { - let validOrgans = 0; - for (let dwj = 0; dwj < sl; dwj++) { - /* the original code has a <<capture>>, not sure if we need one here + /* first remove any organs with no corresponding slave */ + V.completedOrgans = V.completedOrgans.filter(organ => { + return (typeof organ === 'object' && getSlave(organ.ID) !== undefined); + }); + /* cycle through slaves, for each slave cycle through completed organs and track how many are of the interrogated slave (and if organs have a slaves to be implanted on) */ + for (let i = 0; i < V.slaves.length; i++) { let slaveOrgans = 0; - for (let dwk = 0; dwk < cl; dwk++) { - if ((V.completedOrgans[dwk] !== 0) && (V.completedOrgans[dwk].ID === V.slaves[dwk].ID)) { + V.completedOrgans.forEach(organ => { + if (organ.ID === V.slaves[i].ID) slaveOrgans++; - validOrgans++; - } - } - /* if the interrogated slave has one or more organs ready: + }); + /* if the interrogated slave has one or more organs ready: */ if (slaveOrgans > 0) { - r += `<br><span class=yellow>The fabricator has completed `; + r += '<br><span class=yellow>The fabricator has completed '; if (slaveOrgans > 1) { - r += slaveOrgans + ` organs`; + r += `${slaveOrgans} organs`; } else { - r += `an organ`; + r += 'an organ'; } - r += ` for </span><<link "<<print $slaves[_dwi].slaveName>>">><<set $activeSlave = $slaves[_dwi]>><<goto "Slave Interact">> - <</link>> - , <span class=yellow> which `; + r += ` for </span><<link "<<print $slaves[${i}].slaveName>>">><<set $activeSlave = $slaves[${i}]>><<goto "Slave Interact">><</link>>, <span class=yellow> which `; if (slaveOrgans > 1) { - r += `are`; + r += 'are'; } else { - r += `is`; + r += 'is'; } - r += ` ready to be implanted.</span>`; - } - } - - /* if the check returns true it means there are organs without slaves associated to. I think this was the purpose of the _validHost check in the original code - if (validOrgans < cl) { - let sl; - for (let dwl = 0; dwl < cl; dwl++) { - let isValid = 0; - for (let dwm = 0; dwm < sl; dwm++) { - if ((V.completedOrgans[dwm] !== 0) && (V.completedOrgans[dwm].ID === V.slaves[dwm].ID)) { - isValid = 1; - } - } - if (isValid === 0) { - V.completedOrgans.deleteAt(dwm); - } + r += ' ready to be implanted.</span>'; } } } if (V.limbsCompleted > 0) { - let ll = V.limbs.length; - for (let dwn = 0; dwn < ll; dwn++) { - let validHost = 0; - for (let dwo = 0; dwo < sl; dwo++) { - let slave = V.slaves[dwn]; - if ((V.limbs[dwn] !== 0) && (V.limbs[dwn].ID === slave.ID)) { - validHost = 1; - if (limbs[dwn].weeksToCompletion <= 0) { - r += `<br><span class=yellow>The facility has completed a set of limbs for</span> <span id="name"><<print "[[SlaveFullName(_Slave)|Slave Interact][$activeSlave = $slaves[" + _dwi + "]]]">></span>, <span class=yellow> which is ready to be attached.</span>`; - } + for (let j = 0; j < V.limbs.length; j++) { + if (typeof V.limbs[j] === 'object' || getSlave(V.limbs[j].ID) !== undefined) { + let i = V.slaveIndices[V.limbs[j].ID]; + if (V.limbs[j].weeksToCompletion <= 0) { + r += `<br><span class=yellow>The facility has completed a set of limbs for</span> <span id="name"><<print "[[SlaveFullName($slaves[${i}])|Slave Interact][$activeSlave = $slaves[${i}]]]">></span>, <span class=yellow> which is ready to be attached.</span>`; } - } - if (validHost === 0) { - let dump = V.limbs.deleteAt(dwn); - dwn--; + } else { + V.limbs.splice(j, 1); + j--; } } } - if (cl > 0 && V.limbsCompleted > 0) { - r += `<br>[[Implant and Attach|Multiple Organ Implant]] <span class=yellow>all organs and limbs that are ready.</span>`; - } else if (cl > 0) { - r += `<br>[[Implant|Multiple Organ Implant]] <span class=yellow>all organs that are ready for implantation.</span>`; + if (V.completedOrgans.length > 0 && V.limbsCompleted > 0) { + r += `<br>[[Implant and Attach|Multiple Organ Implant]] <span class=yellow>all organs and limbs that are ready.</span><br>`; + } else if (V.completedOrgans.length > 0) { + r += `<br>[[Implant|Multiple Organ Implant]] <span class=yellow>all organs that are ready for implantation.</span><br>`; } else if (V.limbsCompleted > 0) { - r += `<br>[[Attach|Multiple Organ Implant]] <span class=yellow>all sets of limbs that are ready to be attached.</span>`; + r += `<br>[[Attach|Multiple Organ Implant]] <span class=yellow>all sets of limbs that are ready to be attached.</span><br>`; } - */ - r += `<<MainLinks>><br>`; if (V.slaveCostFactor > 1.05) { r += `<span class=yellow>There is a bull market for slaves; the price of slaves is very high.</span>`; @@ -247,5 +218,5 @@ App.UI.View.MainLinks = function() { } } return r; -} -/* CLOSE MAIN */ \ No newline at end of file +}; +/* CLOSE MAIN */ diff --git a/src/utility/descriptionWidgets.tw b/src/utility/descriptionWidgets.tw index 33cd90b3cc57ab20d34f47c3791ecec64802f7ce..bb34bda797a64c05b44a754d1f022939d16b1452 100644 --- a/src/utility/descriptionWidgets.tw +++ b/src/utility/descriptionWidgets.tw @@ -1,75 +1,5 @@ :: description widgets [widget nobr] -<<widget "MainLinks">> - -/* cycle through slaves, for each slave cycle through completed organs and track how many are of the interrogated slave (and if organs have a slaves to be implanted on) */ -<<if $completedOrgans.length > 0>> - <<set _validOrgans = 0>> - <<for _dwi = 0; _dwi < $slaves.length; _dwi++>> - <<capture _dwi>> - <<set _slaveOrgans = 0>> - <<for _dwj = 0; _dwj < $completedOrgans.length; _dwj++>> - <<if ($completedOrgans[_dwj] != 0) && ($completedOrgans[_dwj].ID == $slaves[_dwi].ID)>> - <<set _slaveOrgans++>> - <<set _validOrgans++>> - <</if>> - <</for>> - /* if the interrogated slave has one or more organs ready: */ - <<if _slaveOrgans > 0>> - <br>@@.yellow;The fabricator has completed <<if _slaveOrgans > 1>><<print _slaveOrgans>> organs<<else>>an organ<</if>> for@@ - <<link "<<print $slaves[_dwi].slaveName>>">> - <<set $activeSlave = $slaves[_dwi]>> - <<goto "Slave Interact">> - <</link>> - , @@.yellow; which <<if _slaveOrgans > 1>>are<<else>>is<</if>> ready to be implanted.@@ - <</if>> - <</capture>> - <</for>> - /* if the check returns true it means there are organs without slaves associated to. I think this was the purpose of the _validHost check in the original code */ - <<if _validOrgans < $completedOrgans.length>> - <<for _dwj = 0; _dwj < $completedOrgans.length; _dwj++>> - <<set _isValid = 0>> - <<for _dwi = 0; _dwi < $slaves.length; _dwi++>> - <<if ($completedOrgans[_dwj] != 0) && ($completedOrgans[_dwj].ID == $slaves[_dwi].ID)>> - <<set _isValid = 1>> - <</if>> - <</for>> - /* if there is no associated slave delete the organ, should there be a notification for the player, here? */ - <<if _isValid == 0>> - <<set $completedOrgans.deleteAt(_dwj)>> - <</if>> - <</for>> - <</if>> -<</if>> - -<<if $limbsCompleted > 0>> -<<for _dwj = 0; _dwj < $limbs.length; _dwj++>> - <<set _validHost = 0>> - <<for _dwi = 0; _dwi < $slaves.length; _dwi++>> - <<set _Slave = $slaves[_dwi]>> - <<if ($limbs[_dwj] != 0) && ($limbs[_dwj].ID == _Slave.ID)>> - <<set _validHost = 1>> - <<if ($limbs[_dwj].weeksToCompletion <= 0)>> - <br>@@.yellow;The facility has completed a set of limbs for@@ <span id="name"><<print "[[SlaveFullName(_Slave)|Slave Interact][$activeSlave = $slaves[" + _dwi + "]]]">></span>, @@.yellow; which is ready to be attached.@@ - <</if>> - <</if>> - <</for>> - <<if _validHost == 0>> - <<set _dump = $limbs.deleteAt(_dwj), _dwj-->> - <</if>> -<</for>> -<</if>> - -<<if ($completedOrgans.length > 0) && ($limbsCompleted > 0)>> - <br>[[Implant and Attach|Multiple Organ Implant]] @@.yellow;all organs and limbs that are ready.@@ -<<elseif ($completedOrgans.length > 0)>> - <br>[[Implant|Multiple Organ Implant]] @@.yellow;all organs that are ready for implantation.@@ -<<elseif ($limbsCompleted > 0)>> - <br>[[Attach|Multiple Organ Implant]] @@.yellow;all sets of limbs that are ready to be attached.@@ -<</if>> - -<</widget>> - <<widget "FlowerDesc">> <<if $activeSlave.dick > 0 && $activeSlave.balls == 0>>