diff --git a/src/endWeek/economics/neighborsDevelopment.js b/src/endWeek/economics/neighborsDevelopment.js index 9f46bc8a8d6d49746ad5994a96816174db8f9a5e..742766d65d243ddbbdab81f6c66d97cec88b338c 100644 --- a/src/endWeek/economics/neighborsDevelopment.js +++ b/src/endWeek/economics/neighborsDevelopment.js @@ -5,7 +5,7 @@ App.EndWeek.neighborsDevelopment = function() { const el = document.createElement("p"); let He, his; - V.averageProsperity = 0; + let averageProsperity = 0; let _agentBonus = 0; let _corpBonus; let _error; @@ -17,9 +17,9 @@ App.EndWeek.neighborsDevelopment = function() { if (V.arcologies[i].prosperity < 10) { V.arcologies[i].prosperity = 10; } - V.averageProsperity += V.arcologies[i].prosperity; + averageProsperity += V.arcologies[i].prosperity; } - V.averageProsperity = V.averageProsperity / V.arcologies.length; + averageProsperity = averageProsperity / V.arcologies.length; if (V.corp.Incorporated === 1) { _corpBonus = Math.trunc(1000 * Math.pow(App.Corporate.value, 0.1)); @@ -71,15 +71,13 @@ App.EndWeek.neighborsDevelopment = function() { if (arc.honeymoon > 0) { arc.honeymoon -= 1; } - let _agentIndex; + const _agent = App.currentAgent(i); if (arc.government === "your agent") { - const _Agent = App.currentAgent(i); - ({his} = getPronouns(_Agent)); - r.push(`is being run by your agent <span class="deeppink">${SlaveFullName(_Agent)}.</span>`); - _agentIndex = V.slaveIndices[_Agent.ID]; - if (_agentIndex && V.slaves[_agentIndex].assignment !== "be your agent") { - r.push(`<span class="red">BUG: ${V.slaves[_agentIndex].slaveName} also was ${V.slaves[_agentIndex].assignment}!</span>`); - assignJob(V.slaves[_agentIndex], "be your agent"); + ({He} = getPronouns(_agent)); + r.push(`is being run by your agent <span class="deeppink">${SlaveFullName(_agent)}.</span>`); + if (_agent && _agent.assignment !== "be your agent") { + r.push(`<span class="red">BUG: ${_agent} also was ${_agent.assignment}!</span>`); + assignJob(_agent, "be your agent"); } if (_agentBonus > 0) { r.push(`<span class="green">${He} does an excellent job this week.</span>`); @@ -115,11 +113,11 @@ App.EndWeek.neighborsDevelopment = function() { arc.PCminority = 0; } r.push(`<span class="yellow">After a brief power struggle, it undergoes a change of government.</span>`); - if (_agentIndex && _agentIndex !== -1) { - ({his} = getPronouns(V.slaves[_agentIndex])); - r.push(`<span class="deeppink">${V.slaves[_agentIndex].slaveName}</span> manages to escape with the help of a few loyal citizens and returns to you <span class="gold">fearing your displeasure at ${his} failure.</span>`); - V.slaves[_agentIndex].trust -= 40; - assignJob(V.slaves[_agentIndex], "rest"); // this takes care of necessary cleanup for agent and agent companion (if any) + if (_agent) { + ({his} = getPronouns(_agent)); + r.push(`<span class="deeppink">${_agent.slaveName}</span> manages to escape with the help of a few loyal citizens and returns to you <span class="gold">fearing your displeasure at ${his} failure.</span>`); + _agent.trust -= 40; + assignJob(_agent, "rest"); // this takes care of necessary cleanup for agent and agent companion (if any) } r.push(`A controlling interest has been taken by a single individual, leaving the arcology ruled like yours is.`); arc.government = "an individual"; @@ -238,10 +236,10 @@ App.EndWeek.neighborsDevelopment = function() { } } else if (arc.prosperity >= 300) { r.push(`at the maximum possible prosperity.`); - } else if (arc.prosperity > V.averageProsperity + 10) { + } else if (arc.prosperity > averageProsperity + 10) { r.push(`much more prosperous than the rest of the Free City, limiting its economic development.`); arc.prosperity -= 1; - } else if (arc.prosperity >= V.averageProsperity - 10) { + } else if (arc.prosperity >= averageProsperity - 10) { r.push(`about as prosperous as the rest of the Free City.`); } else { if (arc.honeymoon > 0) { @@ -289,7 +287,7 @@ App.EndWeek.neighborsDevelopment = function() { if (arc.government !== "your agent") { if (arc.government !== "your trustees") { if (arc.minority + arc.ownership + arc.PCminority < 100) { - _prosperityDiff = arc.prosperity - V.averageProsperity; + _prosperityDiff = arc.prosperity - averageProsperity; if (_prosperityDiff > random(-10, 50)) { r.push(`Its leadership acquires an increased share of its ownership.`); arc.ownership += 1;