diff --git a/src/js/assignJS.js b/src/js/assignJS.js index 994ab03cd27553eaef4c6609f7b24779732732a4..0002a19f9885bee7d085d8320d7770d3079f6fad 100644 --- a/src/js/assignJS.js +++ b/src/js/assignJS.js @@ -849,13 +849,8 @@ App.activeArcology = function() { return V.arcologies[V.activeArcologyIdx]; }; -App.currentAgent = function() { - const T = State.temporary; - for (let j = 0; j < V.leaders.length; j++) { - if (V.arcologies[T.currentNeighbor].leaderID === V.leaders[j].ID) { - T.Agent = V.leaders[j]; - } - } +App.currentAgent = function(arcology) { + return V.leaders.find((f) => f.ID === V.arcologies[arcology].leaderID); }; /** diff --git a/src/js/economyJS.js b/src/js/economyJS.js index aed04576c486b6a7b7bcceaff396099bb7dbb192..e6a0887b252b11219602d49c5b3f4125aa35b596 100644 --- a/src/js/economyJS.js +++ b/src/js/economyJS.js @@ -2072,3 +2072,33 @@ window.SectorCounts = function() { V.AProsperityCap += V.AProsperityCapModified; }; + +/** + * Calculate the agent bonus for a given arcology governed by an agent. + * @param {number} arcology Arcology Index + * @returns {number} + */ +window.agentBonus = function(arcology) { + const agent = App.currentAgent(arcology); + let bonus = Math.floor((agent.intelligence+agent.intelligenceImplant)/32); + if (agent.actualAge > 35) { + bonus++; + } + if (agent.career === "an arcology owner" || setup.HGCareers.includes(agent.career)) { + bonus++; + } + if (agent.fetishStrength > 95) { + if (agent.fetish === "dom" || agent.fetish === "sadist") { + bonus++; + } else if (agent.fetish === "submissive" || agent.fetish === "masochist") { + bonus--; + } + } + if (agent.energy > 95) { + bonus++; + } + if (bonus > jsRandom(0, 5)) { + bonus++; + } + return bonus; +}; diff --git a/src/uncategorized/neighborInteract.tw b/src/uncategorized/neighborInteract.tw index a96da68807b2a649389996290a7a77e56e45b11a..380c04470737fb8fc89c48bcf8cfa9a03c8cd7d0 100644 --- a/src/uncategorized/neighborInteract.tw +++ b/src/uncategorized/neighborInteract.tw @@ -203,8 +203,8 @@ You have <<print $arcologies.length-1>> neighbors. <br><br> <br> <<for _currentNeighbor = 1; _currentNeighbor < $arcologies.length; _currentNeighbor++>> -<<capture _currentNeighbor>> - <<= App.currentAgent()>> +<<set _Agent = App.currentAgent(_currentNeighbor)>> +<<capture _currentNeighbor, _Agent>> <<set $arcologies[_currentNeighbor].prosperity = Math.clamp($arcologies[_currentNeighbor].prosperity, 1, 300)>> <br>You own $arcologies[_currentNeighbor].PCminority% of <<link "$arcologies[_currentNeighbor].name">> diff --git a/src/uncategorized/neighborsDevelopment.tw b/src/uncategorized/neighborsDevelopment.tw index d98fec636a29a29e988256a46fede98b94da5b79..a5768bd73cdc10db8192ceae5df24cbc247a9acf 100644 --- a/src/uncategorized/neighborsDevelopment.tw +++ b/src/uncategorized/neighborsDevelopment.tw @@ -1,6 +1,6 @@ :: Neighbors Development [nobr] -<<set $averageProsperity = 0>> +<<set $averageProsperity = 0, _agentBonus = 0>> <<for $i = 0; $i < $arcologies.length; $i++>> <<if $arcologies[$i].prosperity < 10>> <<set $arcologies[$i].prosperity = 10>> @@ -23,9 +23,6 @@ /* PROSPERITY */ <<if $arcologies[$i].direction != 0>> -<<if $arcologies[$i].prosperity > 300>> - <<set $arcologies[$i].prosperity = 300>> -<<else>> <<switch $arcologies[$i].government>> <<case "elected officials">> <<set $arcologies[$i].prosperity += random(-1,1)>> @@ -36,12 +33,12 @@ <<case "an individual">> <<set $arcologies[$i].prosperity += random(0,3)>> <<case "your agent">> - <<agentLeadership>> - <<set $arcologies[$i].prosperity += random(0,3) + $agentBonus>> + <<set _agentBonus = agentBonus($i)>> + <<set $arcologies[$i].prosperity += random(0,3) + _agentBonus>> <<default>> <<set $arcologies[$i].prosperity += random(-1,1)>> <</switch>> -<</if>> + <<set $arcologies[$i].prosperity = Math.clamp($arcologies[$i].prosperity, 1, 300)>> <</if>> <<if $arcologies[$i].honeymoon > 0>> @@ -49,20 +46,16 @@ <</if>> <<if $arcologies[$i].government == "your agent">> -<<for _k = 0; _k < $leaders.length; _k++>> -<<if $leaders[_k].ID == $arcologies[$i].leaderID>> - <<setLocalPronouns $leaders[_k]>> - is being run by your agent @@.deeppink;<<= SlaveFullName($leaders[_k])>>.@@ - <<set _agentIndex = $slaveIndices[$leaders[_k].ID]>> + <<set _Agent = App.currentAgent($i)>> + <<setLocalPronouns _Agent>> + is being run by your agent @@.deeppink;<<= SlaveFullName(_Agent)>>.@@ + <<set _agentIndex = $slaveIndices[_Agent.ID]>> <<if (def _agentIndex) && $slaves[_agentIndex].assignment != "be your agent">> @@.red;BUG: $slaves[_agentIndex].slaveName also was <<print $slaves[_agentIndex].assignment>>!@@ <<= assignJob($slaves[_agentIndex], "be your agent")>> <</if>> - <<if $agentBonus > 0>>@@.green;$He does an excellent job this week.@@<</if>> + <<if _agentBonus > 0>>@@.green;$He does an excellent job this week.@@<</if>> The arcology - <<break>> -<</if>> -<</for>> <<elseif $arcologies[$i].government == "your trustees">> is being run by @@.mediumseagreen;your trustees.@@ The arcology <</if>> @@ -652,8 +645,7 @@ has an estimated GSP of @@.yellowgreen;<<print cashFormat(_prosperity)>><<if $sh <<case "an individual">> <<set $efficiency = random(-1,5)>> <<case "your agent">> - <<set $efficiency = random(-1,5)>> - <<if $arcologies[$i].prosperity < 300>><<set $arcologies[$i].prosperity += $agentBonus>><</if>> + <<set $efficiency = _agentBonus + random(-1,1)>> <<case "a corporation">> <<set $efficiency = random(1,2)>> <<default>> diff --git a/src/utility/miscWidgets.tw b/src/utility/miscWidgets.tw index adee9b46db763f178a76202a738cf40be33dcafd..536ccebbff206a387f6622d950b387f84eea5b4d 100644 --- a/src/utility/miscWidgets.tw +++ b/src/utility/miscWidgets.tw @@ -474,42 +474,6 @@ Call as <<SlaveInteractDickGropeOption>> <</if>> <</replace>> <</widget>> -/% -Call as <<agentLeadership>> -Must be within $arcologies[$i] for loop -%/ -<<widget "agentLeadership">> -<<set $agentBonus = 0>> -<<for _j = 0; _j < $leaders.length; _j++>> - <<if $arcologies[$i].leaderID == $leaders[_j].ID>> - <<set $agentBonus = Math.floor(($leaders[_j].intelligence+$leaders[_j].intelligenceImplant)/32)>> - <<if $leaders[_j].actualAge > 35>> - <<set $agentBonus += 1>> - <</if>> - <<if $leaders[_j].career == "an arcology owner">> - <<set $agentBonus += 1>> - <<elseif setup.HGCareers.includes($leaders[_j].career)>> - <<set $agentBonus += 1>> - <</if>> - <<if $leaders[_j].fetishStrength > 95>> - <<if ($leaders[_j].fetish == "dom") || ($leaders[_j].fetish == "sadist")>> - <<set $agentBonus += 1>> - <<elseif ($leaders[_j].fetish == "submissive") || ($leaders[_j].fetish == "masochist")>> - <<set $agentBonus -= 1>> - <</if>> - <</if>> - <<if $leaders[_j].energy > 95>> - <<set $agentBonus += 1>> - <</if>> - <<break>> - <</if>> -<</for>> -<<if $agentBonus > random(0,5)>> - <<set $agentBonus = 1>> -<<else>> - <<set $agentBonus = 0>> -<</if>> -<</widget>> <<widget "Master">><<if def $args[0]>><<run Enunciate($args[0])>><<elseif ndef $titleEnunciate>><<run Enunciate($activeSlave)>><</if>>$titleEnunciate<</widget>> <<widget "say">><<if (def $args[0]) && $sayEnunciate != "lisp">>$args[0]<<else>>$sayEnunciate<</if>><</widget>>