diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js index f9d117c916b3cdafe92ea0ab50a7ec52e06fad6e..65b20c1d0bad4b4dc86c6b6c90195ace9d3d3035 100644 --- a/src/Mods/SecExp/js/secExp.js +++ b/src/Mods/SecExp/js/secExp.js @@ -1,5 +1,34 @@ +/** + * Returns the effect (if any) the Special Force provides. + * @param {string} [report] which report is this function being called from. + * @param {string} [section=''] which sub section (if any) is this function being called from. + * @returns {number} + * @returns {string} + */ +App.SecExp.SF_effect = function(report, section = '') { + const size = V.SF.Toggle && V.SF.Active >= 1 ? App.SF.upgrades.total() : 0; + let r = ``, bonus = 0; + if (size > 10) { + if (report === 'authority' || report === 'trade') { + r += `Having a powerful special force increases ${report === 'authority' ? 'your authority' : 'trade security'}.`; + bonus += size/10; + } else if (report === 'security') { + r += `Having a powerful special force attracts a lot of ${section === 'militia' ? 'citizens' : 'mercenaries'}, hopeful that they may be able to fight along side it.`; + if (section === 'militia') { + bonus *= 1 + (random(1, (Math.round(size / 10))) / 20); // not sure how high size goes, so I hope this makes sense + } else if (section === 'mercs') { + bonus += random(1, Math.round(size/10)); + } + } + } + return {text: r, bonus: bonus}; +}; + /** * Returns the effect of a campaign launched from the PR hub. + * @param {string} [focus] campaign option to check against. + * @returns {number} + * @returns {string} */ App.SecExp.propagandaEffects = function(focus) { let t = ``, increase = 0; @@ -41,6 +70,7 @@ App.SecExp.propagandaEffects = function(focus) { /** * Returns the raw percetnage of socity that can be drafted. + * @returns {number} */ App.SecExp.militiaCap = function(x = 0) { x = x || V.SecExp.edicts.defense.militia; diff --git a/src/Mods/SecExp/js/tradeReport.js b/src/Mods/SecExp/js/tradeReport.js index ef4a95debe357214ae302a9f51ab78d4092e4637..3cc97f6e62853a4bb6c7ecb95d64f988ae35dd0f 100644 --- a/src/Mods/SecExp/js/tradeReport.js +++ b/src/Mods/SecExp/js/tradeReport.js @@ -1,7 +1,5 @@ App.SecExp.tradeReport = function() { - let r = []; - let tradeChange = 0; - + let r = [], tradeChange = 0, bonus = 0; if (V.week < 30) { r.push(`The world economy is in good enough shape to sustain economic growth. Trade flows liberally in all the globe.`); tradeChange += 1; @@ -18,51 +16,44 @@ App.SecExp.tradeReport = function() { tradeChange -= 2; } - const countBattles = V.SecExp.battles.victories + V.SecExp.battles.losses; - const countRebellions = V.SecExp.rebellions.victories + V.SecExp.rebellions.losses; - if (V.SecExp.battles.lastEncounterWeeks < 2 && countBattles > 0) { - r.push(`The recent attack has a negative effect on the trade of the arcology.`); - tradeChange -= 1; - } else if (V.SecExp.battles.lastEncounterWeeks < 4 && countBattles > 0) { - r.push(`While some time has passed, the last attack still has a negative effect on the commercial activity of the arcology.`); - tradeChange -= 0.5; - } - if (V.SecExp.rebellions.lastEncounterWeeks < 2 && countRebellions > 0) { - r.push(`The recent rebellion has a negative effect on the trade of the arcology.`); - tradeChange -= 1; - } else if (V.SecExp.rebellions.lastEncounterWeeks < 4 && countRebellions > 0) { - r.push(`While some time has passed, the last rebellion still has a negative effect on the commercial activity of the arcology.`); - tradeChange -= 0.5; - } + const warEffects = function(type) { + if (V.SecExp[type].victories + V.SecExp[type].losses >= 1) { + if (V.SecExp[type].lastEncounterWeeks < 2) { + r.push(`The recent ${type === 'battles' ? 'attack' : 'rebellion'} has a negative effect on the trade of the arcology.`); + tradeChange -= 1; + } else if (V.SecExp[type].lastEncounterWeeks < 4) { + r.push(`While some time has passed, the last ${type === 'battles' ? 'attack' : 'rebellion'} still has a negative effect on the commercial activity of the arcology.`); + tradeChange -= 0.5; + } + } + }; + + warEffects('battles'); + warEffects('rebellions'); if (V.terrain === "urban") { r.push(`Since your arcology is located in the heart of an urban area, its commerce is naturally vibrant.`); tradeChange++; - } - if (V.terrain === "ravine") { + } else if (V.terrain === "ravine") { r.push(`Since your arcology is located in the heart of a ravine, its commerce is hindered by a lack of accessibility.`); tradeChange -= 0.5; } - if (V.PC.career === "wealth" || V.PC.career === "capitalist" || V.PC.career === "celebrity" || V.PC.career === "BlackHat") { + if (["wealth", "capitalist", "celebrity", "BlackHat"].includes(V.PC.career)) { tradeChange += 1; - } else if (V.PC.career === "escort" || V.PC.career === "servant" || V.PC.career === "gang") { + } else if (["escort", "servant", "gang"].includes(V.PC.career)) { tradeChange -= 0.5; } - if (V.rep > 18000) { - r.push(`Your extremely high reputation attracts trade from all over the world.`); - } else if (V.rep > 12000) { - r.push(`Your high reputation attracts trade from all over the world.`); + if (V.rep > 12000) { + r.push(`Your ${V.rep > 18000 ? 'extremely' : ''} high reputation attracts trade from all over the world.`); + tradeChange += (V.rep > 18000 ? 2 : 1); } - - const {himA} = getPronouns(assistant.pronouns().main).appendSuffix('A'); - if (V.assistant.power === 1) { - r.push(`Thanks to the computing power available to ${himA}, ${V.assistant.name} is able to guide the commercial development of the arcology to greater levels.`); - tradeChange++; - } else if (V.assistant.power >= 2) { - r.push(`Thanks to the incredible computing power available to ${himA}, ${V.assistant.name} is able to guide the commercial development of the arcology to greater levels.`); - tradeChange += 2; + + if (V.assistant.power > 0) { + const lowPower = V.assistant.power === 1; + r.push(`Due to ${lowPower ? '' : 'incredible'} computing power, ${V.assistant.name} is able to guide the commercial development of the arcology to greater levels.`); + tradeChange += (lowPower ? 1 : 2); } if (V.SecExp.edicts.tradeLegalAid === 1) { @@ -126,11 +117,8 @@ App.SecExp.tradeReport = function() { } } - const SFsize = App.SF.upgrades.total(); - if (V.SF.Toggle && V.SF.Active >= 1 && SFsize > 10) { - r.push(`Having a powerful special force increases trade security.`); - tradeChange += SFsize / 10; - } + const SF = App.SecExp.SF_effect('trade'); + r.push(SF.text); tradeChange += SF.bonus; if (tradeChange > 0) { r.push(`This week <span class="green">trade improved.</span>`); @@ -141,25 +129,21 @@ App.SecExp.tradeReport = function() { } V.SecExp.core.trade = Math.clamp(V.SecExp.core.trade + tradeChange, 0, 100); - - let AWeekGrowth = 0; if (V.SecExp.core.trade <= 20) { r.push(`The almost non-existent trade crossing the arcology <span class="yellow">does little to promote growth.</span>`); } else if (V.SecExp.core.trade <= 40) { r.push(`The low level of trade crossing the arcology promotes a <span class="green">slow yet steady growth</span> of its economy.`); - AWeekGrowth += 1.5; + bonus += 1.5; } else if (V.SecExp.core.trade <= 60) { r.push(`With trade at positive levels, the <span class="green">prosperity of the arcology grows more powerful.</span>`); - AWeekGrowth += 2.5; + bonus += 2.5; } else if (V.SecExp.core.trade <= 80) { r.push(`With trade at high levels, the <span class="green">prosperity of the arcology grows quickly and violently.</span>`); - AWeekGrowth += 3.5; + bonus += 3.5; } else { r.push(`With trade at extremely high levels, the <span class="green">prosperity of the arcology grows with unprecedented speed.</span>`); - AWeekGrowth += 4.5; + bonus += 4.5; } - - const para = document.createElement("p"); - $(para).append(r.join(' ')); - return {output: para, growth: AWeekGrowth}; -}; + + return {text: r.join(" "), bonus: bonus}; +} \ No newline at end of file diff --git a/src/endWeek/economics/arcmgmt.js b/src/endWeek/economics/arcmgmt.js index cec242c0fe782572febb7da9c3416b4ded9f6538..6cd8c26ef337d485687563b776996a4ea2952229 100644 --- a/src/endWeek/economics/arcmgmt.js +++ b/src/endWeek/economics/arcmgmt.js @@ -574,6 +574,8 @@ globalThis.arcmgmt = function() { _AWeekGrowth++; } if (V.secExpEnabled > 0) { + App.Events.addParagraph(el, r); + r = []; if (V.SecExp.core.authority > 18000) { r.push(`Your authority is so high it discourages new business, slowing down the economic growth of the arcology.`); _AWeekGrowth--; @@ -585,6 +587,7 @@ globalThis.arcmgmt = function() { r.push(`Your arcology's low security is an instability factor simply too dangerous to be ignored. Many businesses avoid your arcology because of this.`); _AWeekGrowth--; } + if (V.SecExp.edicts.weaponsLaw === 3) { r.push(`The free flow of weapons in your arcology has a positive impact on its economy.`); _AWeekGrowth++; @@ -622,6 +625,12 @@ globalThis.arcmgmt = function() { V.garrison.reactorTime--; IncreasePCSkills('engineering', 0.1); } + + const secExpTrade = App.SecExp.tradeReport(); + r.push(secExpTrade.text) + _AWeekGrowth += secExpTrade.bonus; + App.Events.addParagraph(el, r); + r = []; } _AWeekGrowth = Math.trunc(0.5 * _AWeekGrowth); if (_AWeekGrowth > 0) { @@ -635,12 +644,6 @@ globalThis.arcmgmt = function() { App.Events.addNode(el, r); r = []; - if (V.secExpEnabled > 0) { - const {output, growth} = App.SecExp.tradeReport(); - _AWeekGrowth += growth; - el.append(output); - } - if (isNaN(_AWeekGrowth)) { r.push(App.UI.DOM.makeElement("div", `Error: AWeekGrowth is NaN`, "red")); } else { diff --git a/src/js/economyJS.js b/src/js/economyJS.js index f783843a6a16834531b998c214e69e01ee0a6d3a..3747ccb3dd7661708a02b4a550806ca1d7aa2d8a 100644 --- a/src/js/economyJS.js +++ b/src/js/economyJS.js @@ -620,16 +620,14 @@ globalThis.calculateCosts = (function() { // security expansion function getSecurityExpansionCost() { - let secExpCost = 0, soldierMod = 0; + let secExpCost = 0, soldierMod = 1.5; // V.SecExp.edicts.defense.soldierWages === 1 if (V.secExpEnabled > 0) { secExpCost += App.SecExp.upkeep.edictsCash(); secExpCost += App.SecExp.upkeep.SF(); secExpCost += App.SecExp.upkeep.buildings(); if (V.SecExp.edicts.defense.soldierWages === 0) { soldierMod = 1; - } else if (V.SecExp.edicts.defense.soldierWages === 1) { - soldierMod = 1.5; - } else { + } else if (V.SecExp.edicts.defense.soldierWages === 2) { soldierMod = 2; } const militiaUnits = V.militiaUnits.length, slaveUnits = V.slaveUnits.length, mercUnits = V.mercUnits.length; // predefined for optimization