diff --git a/src/endWeek/economics/arcmgmt.js b/src/endWeek/economics/arcmgmt.js index f3017efe54fd922c015935248868786e2eb0ef56..c8f624d907f92acde7465de2cf5e652b123c45ea 100644 --- a/src/endWeek/economics/arcmgmt.js +++ b/src/endWeek/economics/arcmgmt.js @@ -1,16 +1,6 @@ globalThis.arcmgmt = function() { const el = new DocumentFragment(); let r; - let _slavesSubLaw; - let _slavesSupLaw; - let _citizenRetirementImpact; - let _menialsRetirement; - let _ASlavesRetirement; - let _expirationPC; - let _expirationFD; - let _expirationBR; - let _expirationNPC; - let _expiration; let _banished; let _banishedRatio; let _enslaved; @@ -21,12 +11,6 @@ globalThis.arcmgmt = function() { let _terrain; let _transportHub; let _honeymoon; - let _oldVisitors; - let _weeklyRetiredMenials; - let _weeklyRetiredMenialsof; - let _retirementChance; - let _weeklyRetiredNPCMenials; - let _retirementChance2; let _LCD; let _SCD; let _LSCD; @@ -34,7 +18,6 @@ globalThis.arcmgmt = function() { let _NPCSlavesSold; let _NPCSlavesSoldslaves; let _LCImmigration; - let _intellectualDependencyEnslaved; let _LCEmigration; let _enslavedEmigrants; let _MCD; @@ -53,26 +36,19 @@ globalThis.arcmgmt = function() { let _percUpperClass; let _percASlaves; let _rentMultiplier; - let _movement; - let _rents; - let _bribes; let _menialEarnings; let _fuckdollsEarnings; let _bioreactorEarnings; - let _AL; let _fuckdollsArcade; let _arcadeUpgradeInjectors; let _AWeekGrowth; - const {HeM, heM} = (V.assistant.market) ? getPronouns(assistant.pronouns().market).appendSuffix('M') : getPronouns(assistant.pronouns().main).appendSuffix('M'); // TODO not sure how to set this is market is not defined, using main as fallback for now for testing. - - if (V.useTabs === 0) { App.UI.DOM.appendNewElement("h2", el, "Arcology Management"); } const _schools = App.Utils.schoolCounter(); - el.append(ownershipReport(false)); + App.UI.DOM.appendNewElement("p", el, ownershipReport(false)); /* Sexual Satisfaction */ if (V.arcologies[0].FSDegradationist !== "unset") { @@ -301,7 +277,7 @@ globalThis.arcmgmt = function() { /* A silly policy*/ r.push(`Your citizens are allowed to pay their rents in slaves rather than cash and a few financially challenged individuals make use of this.`); _rentMultiplier *= 0.95; - _movement = random(0, 3); + const _movement = random(0, 3); V.menials += _movement; V.NPCSlaves -= _movement; } @@ -325,7 +301,7 @@ globalThis.arcmgmt = function() { App.Events.addParagraph(el, r); r = []; _rentMultiplier *= 1 + (5 - V.baseDifficulty) / 20; - _rents = Math.trunc((V.lowerClass * V.rent.lowerClass + V.middleClass * V.rent.middleClass + V.upperClass * V.rent.upperClass + V.topClass * V.rent.topClass) * _rentMultiplier / 25); + const _rents = Math.trunc((V.lowerClass * V.rent.lowerClass + V.middleClass * V.rent.middleClass + V.upperClass * V.rent.upperClass + V.topClass * V.rent.topClass) * _rentMultiplier / 25); if (!Number.isInteger(_rents)) { appendDiv(`<span class="red">Error: rents is outside accepted range, please report this issue</span>`); } else { @@ -335,13 +311,12 @@ globalThis.arcmgmt = function() { r.push(`This week, rents from ${V.arcologies[0].name} came to <span class="yellowgreen"> ${cashFormat(_rents)}.</span>`); if (V.difficultySwitch === 0) { if (V.localEcon < 100) { - _bribes = (V.week * 100) + random(-100, 100); + let _bribes = (V.week * 100) + random(-100, 100); if (V.cash > 1000) { _bribes += Math.trunc(V.cash * 0.02); } r.push(`The <span class="red">degenerating world economy</span> makes supplying and maintaining ${V.arcologies[0].name} extremely difficult. This week, bribes and other costs to keep it running came to <span class="yellowgreen">${cashFormat(_bribes)}.</span>`); - _bribes = forceNeg(_bribes); - cashX(_bribes, "rents"); + cashX(forceNeg(_bribes), "rents"); } } @@ -366,7 +341,7 @@ globalThis.arcmgmt = function() { } } if (V.illegalDeals.menialDrug === 1) { - Math.trunc(_menialEarnings *= 1.5); + _menialEarnings = Math.trunc(_menialEarnings * 1.5); } if (V.menials > 1) { r.push(`${num(V.menials)} menial slaves${((V.menialBioreactors > 0) && (V.fuckdolls === 0)) ? ` and`:`,`}`); @@ -394,7 +369,7 @@ globalThis.arcmgmt = function() { if (V.fuckdolls > 0) { - _AL = App.Entity.facilities.arcade.employeesIDs().size; + const _AL = App.Entity.facilities.arcade.employeesIDs().size; if ((V.fuckdolls > V.arcade - _AL) && (V.arcade > _AL)) { _fuckdollsArcade = V.arcade - _AL; } else if (V.fuckdolls < V.arcade - _AL) { @@ -605,17 +580,16 @@ globalThis.arcmgmt = function() { } if (_desc.length > 0) { r.push(`Your arcology's economy benefits from close social alignment with`); - _desc.reduce((res, ch, i, arr) => res + (i === arr.length - 1 ? ' and ' : ', ') + ch); if (_descNeg.length > 0) { - r.push(`, but`); + r.push(`${arrayToSentence(_desc)}, but`); } else { - r.push(`.`); + r.push(`${arrayToSentence(_desc)}.`); } _AWeekGrowth += _desc.length; } if (_descNeg.length > 0) { if (_desc.length === 0) { - r.push(`Your arcology's economy is hindered by social conflicts with ${_descNeg.reduce((res, ch, i, arr) => res + (i === arr.length - 1 ? ' and ' : ', ') + ch)}.`); + r.push(`Your arcology's economy is hindered by social conflicts with ${arrayToSentence(_descNeg)}.`); _AWeekGrowth -= _descNeg.length; } if (V.policies.alwaysSubsidizeGrowth === 1) { @@ -702,6 +676,7 @@ globalThis.arcmgmt = function() { r = []; let _popCap = menialPopCap(); let _menialSlaveValue = menialSlaveCost(); + const {HeM, heM} = getPronouns(assistant.pronouns().market).appendSuffix('M'); // <br> r.push(`Your <span class="bold">business assistant</span> manages the menial slave market.`); if (_menialSlaveValue <= 900 + V.assistant.market.aggressiveness) { /* BUY */ @@ -782,7 +757,7 @@ globalThis.arcmgmt = function() { _upperClassP *= 1 + Math.trunc(Math.min(V.arcologies[0].FSSupremacist, 100) / 20) * 0.002; _topClass += Math.trunc(Math.min(V.arcologies[0].FSSupremacist, 100) / 20) * 2; _topClassP *= 1 + Math.trunc(Math.min(V.arcologies[0].FSSupremacist, 100) / 20) * 0.004; - r.push(`Your racial policies are concentrating power in the hands of ${V.arcologies[0].FSSupremacistRace} people. /*perhaps too obvious to bother with printing?*/`); + r.push(`Your racial policies are concentrating power in the hands of ${V.arcologies[0].FSSupremacistRace} people.`); /* perhaps too obvious to bother with printing? */ } if (V.arcologies[0].FSSubjugationist !== "unset") { _FSScore += Math.min(V.arcologies[0].FSSubjugationist, 100); @@ -796,7 +771,7 @@ globalThis.arcmgmt = function() { _upperClassP *= 1 + Math.trunc(Math.min(V.arcologies[0].FSSubjugationist, 100) / 20) * 0.002; _topClass += Math.trunc(Math.min(V.arcologies[0].FSSubjugationist, 100) / 20) * 2; _topClassP *= 1 + Math.trunc(Math.min(V.arcologies[0].FSSubjugationist, 100) / 20) * 0.004; - r.push(`Your racial policies are stripping all power from the ${V.arcologies[0].FSSubjugationistRace} people.`); /* perhaps too obvious to bother with printing?*/ + r.push(`Your racial policies are stripping all power from the ${V.arcologies[0].FSSubjugationistRace} people.`); /* perhaps too obvious to bother with printing? */ } if (V.arcologies[0].FSGenderRadicalist !== "unset") { _FSScore += Math.min(V.arcologies[0].FSGenderRadicalist, 100); @@ -1232,8 +1207,7 @@ globalThis.arcmgmt = function() { _topClass += 10; _topClassP *= 1.02; if (V.FSSupLawTrigger === 1) { - _slavesSupLaw = 0; - _slavesSupLaw += Math.trunc((V.lowerClass + V.middleClass + V.upperClass) * 0.65); + const _slavesSupLaw = Math.trunc((V.lowerClass + V.middleClass + V.upperClass) * 0.65); V.NPCSlaves += Math.trunc(_slavesSupLaw * 0.7); V.menials += Math.trunc(_slavesSupLaw * 0.2); V.lowerClass = Math.trunc(V.lowerClass * 0.35); @@ -1254,7 +1228,7 @@ globalThis.arcmgmt = function() { _topClass += 5; _topClassP *= 1.01; if (V.FSSubLawTrigger === 1) { - _slavesSubLaw = Math.trunc((V.lowerClass + V.middleClass + V.upperClass) * 0.2); + const _slavesSubLaw = Math.trunc((V.lowerClass + V.middleClass + V.upperClass) * 0.2); V.NPCSlaves += Math.trunc(_slavesSubLaw * 0.7); V.menials += Math.trunc(_slavesSubLaw * 0.2); V.lowerClass = Math.trunc(V.lowerClass * 0.8); @@ -1792,7 +1766,7 @@ globalThis.arcmgmt = function() { V.NPCSlaves += _enslavedNPC; } if (_enslaved > 1) { - appendDiv(`In total <span class="green"> ${_enslaved} lower class citizens</span> were enslaved for failing to pay their debts.`); + appendDiv(`In total <span class="green">${_enslaved} lower class citizens</span> were enslaved for failing to pay their debts.`); appendDiv(`<span class="green">You enslaved ${_enslavedPC}</span> of them while other debtholders in the arcology enslaved the remaining ${_enslavedNPC}.`); } else if (_enslaved > 0) { appendDiv(`<span class="green">As arcology owner you claimed the slave.</span>`); @@ -1822,7 +1796,7 @@ globalThis.arcmgmt = function() { if (V.arcologies[0].honeymoon > 0) { _honeymoon = 10 * V.arcologies[0].honeymoon; } - _oldVisitors = V.visitors; + const _oldVisitors = V.visitors; V.visitors = Math.trunc(((V.arcologies[0].prosperity + _FSScore * 5 + _honeymoon) * _transportHub * _terrain * _crime) * (V.localEcon / 100)); if (V.visitors < 50) { V.visitors = normalRandInt(50, 2); @@ -1831,25 +1805,24 @@ globalThis.arcmgmt = function() { appendDiv(`<span class="red">Visitors is NaN, report this issue!</span>`); V.visitors = _oldVisitors; } - appendDiv(`<span class="green"> ${V.visitors} traders and tourists</span> visited your arcology this week.`); + appendDiv(`<span class="green">${V.visitors} traders and tourists</span> visited your arcology this week.`); /* slaves*/ /* Slaves getting retired*/ if (V.policies.retirement.menial2Citizen === 1) { - _weeklyRetiredMenials = V.menials / ((V.customMenialRetirementAge - 15) * 52); - _weeklyRetiredNPCMenials = V.NPCSlaves / ((V.customMenialRetirementAge - 15) * 52); + let _weeklyRetiredMenials = V.menials / ((V.customMenialRetirementAge - 15) * 52); + let _weeklyRetiredNPCMenials = V.NPCSlaves / ((V.customMenialRetirementAge - 15) * 52); /* This implies a minimum menial age of 15. Even if the player sets minimum ages lower, there's no point having a 3 year old menial slave. 15 seems alright while being nice and round. This also implies ages are distributed evenly, no easy way around that.*/ if (_weeklyRetiredMenials > 1) { _weeklyRetiredMenials = Math.trunc(_weeklyRetiredMenials); if (_weeklyRetiredMenials > 1) { - appendDiv(`<span class="red"> ${_weeklyRetiredMenialsof} your menial slaves</span> retired as free citizens this week.`); + appendDiv(`<span class="red">${_weeklyRetiredMenials} of your menial slaves</span> retired as free citizens this week.`); } else { appendDiv(`<span class="red">One of your menial slaves</span> retired as a free citizen this week.`); } } else { _weeklyRetiredMenials *= 100; - _retirementChance = random(1, 100); - if (_weeklyRetiredMenials > _retirementChance) { + if (_weeklyRetiredMenials > random(1, 100)) { _weeklyRetiredMenials = 1; appendDiv(`<span class="red">One of your menial slaves</span> retired as a free citizen this week.`); } else { @@ -1859,14 +1832,13 @@ globalThis.arcmgmt = function() { if (_weeklyRetiredNPCMenials > 1) { _weeklyRetiredNPCMenials = Math.trunc(_weeklyRetiredNPCMenials); if (_weeklyRetiredNPCMenials > 1) { - appendDiv(`<span class="red"> ${_weeklyRetiredNPCMenials} menial slaves</span> were retired as free citizens by other slave owners in your arcology this week.`); + appendDiv(`<span class="red">${_weeklyRetiredNPCMenials} menial slaves</span> were retired as free citizens by other slave owners in your arcology this week.`); } else { appendDiv(`<span class="red">One menial slave</span> was retired as a free citizen by another slave owner in your arcology this week.`); } } else { _weeklyRetiredNPCMenials *= 100; - _retirementChance2 = random(1, 100); - if (_weeklyRetiredNPCMenials > _retirementChance2) { + if (_weeklyRetiredNPCMenials > random(1, 100)) { _weeklyRetiredNPCMenials = 1; appendDiv(`<span class="red">One menial slave</span> was retired as a free citizen by another slave owner in your arcology this week.`); } else { @@ -1892,7 +1864,7 @@ globalThis.arcmgmt = function() { V.menialDemandFactor -= _NPCSlavesSold; V.NPCSlaves = Math.trunc(_SCD * 1.6); if (_NPCSlavesSold > 1) { - appendDiv(`<span class="red"> ${_NPCSlavesSoldslaves}</span> were sold by your inhabitants. They've got more than enough of them already.`); + appendDiv(`<span class="red">${_NPCSlavesSoldslaves}</span> were sold by your inhabitants. They've got more than enough of them already.`); } else if (_NPCSlavesSold > 0) { appendDiv(`<span class="red">One slave</span> was sold by your inhabitants. They've got more than enough of them already.`); } @@ -1902,7 +1874,7 @@ globalThis.arcmgmt = function() { V.menialDemandFactor -= _NPCSlavesSold; V.NPCSlaves = Math.trunc(_LSCD / _slaveProductivity); if (_NPCSlavesSold > 1) { - appendDiv(`<span class="red"> ${_NPCSlavesSoldslaves}</span> were sold by your inhabitants. There was so little work that they failed to earn their keep.`); + appendDiv(`<span class="red">${_NPCSlavesSoldslaves}</span> were sold by your inhabitants. There was so little work that they failed to earn their keep.`); } else if (_NPCSlavesSold > 0) { appendDiv(`<span class="red">One slave</span> was sold by your inhabitants. There was so little work that it failed to earn its keep.`); } @@ -1913,7 +1885,7 @@ globalThis.arcmgmt = function() { V.menialDemandFactor -= _NPCSlavesSold; V.NPCSlaves -= _NPCSlavesSold; if (_NPCSlavesSold > 1) { - appendDiv(`<span class="red"> ${_NPCSlavesSoldslaves}</span> were sold by your inhabitants. They've got more than enough of them already.`); + appendDiv(`<span class="red">${_NPCSlavesSoldslaves}</span> were sold by your inhabitants. They've got more than enough of them already.`); } else if (_NPCSlavesSold > 0) { appendDiv(`<span class="red">One slave</span> was sold by your inhabitants. They've got more than enough of them already.`); } @@ -1925,7 +1897,7 @@ globalThis.arcmgmt = function() { V.menialDemandFactor -= _NPCSlavesSold; V.NPCSlaves -= _NPCSlavesSold; if (_NPCSlavesSold > 1) { - appendDiv(`<span class="red"> ${_NPCSlavesSoldslaves}</span> were sold by your inhabitants. They saw an opportunity for profit.`); + appendDiv(`<span class="red">${_NPCSlavesSoldslaves}</span> were sold by your inhabitants. They saw an opportunity for profit.`); } else if (_NPCSlavesSold > 0) { appendDiv(`<span class="red">One slave</span> was sold by your inhabitants. They saw an opportunity for profit.`); } @@ -1965,7 +1937,7 @@ globalThis.arcmgmt = function() { if (V.lowerClass < _LCD) { if (V.arcologies[0].FSIntellectualDependencyLaw === 1) { /* Enslaving the dumb lower class immigrants*/ _LCImmigration = Math.trunc((_LCD - V.lowerClass) * (0.3 * _terrain)) + 1; - _intellectualDependencyEnslaved = Math.trunc(_LCImmigration * 0.25); + const _intellectualDependencyEnslaved = Math.trunc(_LCImmigration * 0.25); _LCImmigration -= _intellectualDependencyEnslaved; _enslaved += _intellectualDependencyEnslaved; V.lowerClass += _LCImmigration; @@ -1991,7 +1963,7 @@ globalThis.arcmgmt = function() { if (_LCEmigration > 1) { r.push(`<span class="red">${_LCEmigration} lower class citizens</span> had no work and tried to leave your arcology.`); if (_enslavedEmigrants > 1) { - r.push(`<span class="green"> ${_enslavedEmigrants} of them were enslaved instead.</span>`); + r.push(`<span class="green">${_enslavedEmigrants} of them were enslaved instead.</span>`); } else if (_enslavedEmigrants > 0) { r.push(`<span class="green">One of them was enslaved instead.</span>`); } @@ -2139,7 +2111,7 @@ globalThis.arcmgmt = function() { _TCImmigration = Math.trunc((_TCD - V.topClass) * (0.3 * _terrain)) + 1; V.topClass += _TCImmigration; if (_TCImmigration > 1) { - appendDiv(`<span class="green">${_TCImmigration} millionaires</span> moved to your arcology. /*Fat Cat? One-Percenter?*/`); + appendDiv(`<span class="green">${_TCImmigration} millionaires</span> moved to your arcology.`); /* Fat Cat? One-Percenter? */ } else if (_TCImmigration > 0) { appendDiv(`<span class="green">One millionaire</span> moved to your arcology.`); } @@ -2160,6 +2132,7 @@ globalThis.arcmgmt = function() { const r =[]; /* Slave retirement trigger pulled (one time only)*/ if (V.citizenRetirementTrigger === 1) { + let _citizenRetirementImpact; if (V.customMenialRetirementAge >= 65) { _citizenRetirementImpact = 0.475 - Math.clamp(V.customMenialRetirementAge / 200, 0.325, 0.475); } else { @@ -2169,9 +2142,9 @@ globalThis.arcmgmt = function() { _citizenRetirementImpact *= 2 / 3; } V.lowerClass += Math.trunc((V.NPCSlaves + V.menials) * (0.05 + _citizenRetirementImpact)); - _menialsRetirement = Math.trunc(V.menials * (0.05 + _citizenRetirementImpact)); + const _menialsRetirement = Math.trunc(V.menials * (0.05 + _citizenRetirementImpact)); V.menials = Math.trunc(V.menials * (0.95 - _citizenRetirementImpact)); - _ASlavesRetirement = Math.trunc(V.NPCSlaves * (0.05 + _citizenRetirementImpact)); + const _ASlavesRetirement = Math.trunc(V.NPCSlaves * (0.05 + _citizenRetirementImpact)); V.NPCSlaves = Math.trunc(V.NPCSlaves * (0.95 - _citizenRetirementImpact)); V.citizenRetirementTrigger = 2; r.push(`You have enacted citizen retirement, the slaves of eligible age are granted freedom.`); @@ -2191,11 +2164,11 @@ globalThis.arcmgmt = function() { function expiration() { const r = []; /* Slave expiration*/ - _expirationPC = Math.trunc(V.menials * _expirationFS); - _expirationFD = Math.trunc(V.fuckdolls * _expirationFS); - _expirationBR = Math.trunc(V.menialBioreactors * _expirationFS); - _expirationNPC = Math.trunc(V.NPCSlaves * _expirationFS); - _expiration = _expirationPC + _expirationNPC + _expirationFD + _expirationBR; + const _expirationPC = Math.trunc(V.menials * _expirationFS); + const _expirationFD = Math.trunc(V.fuckdolls * _expirationFS); + const _expirationBR = Math.trunc(V.menialBioreactors * _expirationFS); + const _expirationNPC = Math.trunc(V.NPCSlaves * _expirationFS); + const _expiration = _expirationPC + _expirationNPC + _expirationFD + _expirationBR; V.NPCSlaves -= _expirationNPC; V.menials -= _expirationPC; V.fuckdolls -= _expirationFD; @@ -2231,7 +2204,7 @@ globalThis.arcmgmt = function() { _enslaved = Math.trunc(V.lowerClass * _welfareFS) - _banished; V.lowerClass -= _banished; - appendDiv(`<span class="red"> ${_banished} citizens were banished</span> from your arcology, they committed enslavable offenses but were too old to be enslaved.`); + appendDiv(`<span class="red">${_banished} citizens were banished</span> from your arcology, they committed enslavable offenses but were too old to be enslaved.`); } else { _enslaved = Math.trunc(V.lowerClass * _welfareFS); }