From 1eca5c6b7e2b781284ea30c2a0a7b574f49d83ab Mon Sep 17 00:00:00 2001 From: Blank_Alt <12406-Blank_Alt@users.noreply.gitgud.io> Date: Fri, 11 Jun 2021 19:02:58 +0000 Subject: [PATCH] Sec exp backport functions cleanup --- src/Mods/SecExp/buildings/secBarracks.tw | 16 +- .../SecExp/buildings/weaponsManufacturing.tw | 44 +- src/Mods/SecExp/events/attackHandler.tw | 8 +- src/Mods/SecExp/events/rebellionHandler.tw | 14 +- src/Mods/SecExp/events/rebellionOptions.tw | 4 +- src/Mods/SecExp/js/Unit.js | 161 +-- src/Mods/SecExp/js/buildingsJS.js | 305 +++-- .../SecExp/js/reportingRelatedFunctions.js | 1084 +++++++++++++++++ src/Mods/SecExp/js/secExp.js | 1009 +-------------- src/Mods/SecExp/js/secExpBC.js | 9 +- src/Mods/SecExp/js/securityReport.js | 6 +- 11 files changed, 1316 insertions(+), 1344 deletions(-) create mode 100644 src/Mods/SecExp/js/reportingRelatedFunctions.js diff --git a/src/Mods/SecExp/buildings/secBarracks.tw b/src/Mods/SecExp/buildings/secBarracks.tw index 996a4d7db41..68eafd2d0e9 100644 --- a/src/Mods/SecExp/buildings/secBarracks.tw +++ b/src/Mods/SecExp/buildings/secBarracks.tw @@ -169,7 +169,7 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> ( <div id="Bots" class="tab-content"> <div class="content"> <<set _secBotsCost = 500, _secBotsUpgradeCost = 250>> - <<= App.SecExp.getUnit("Bots").describe()>> <br> + <<= App.SecExp.getUnit("bots").describe()>> <br> <<if $SecExp.units.bots.active == 1>> <<if $SecExp.units.bots.maxTroops > $SecExp.units.bots.troops>> <<link "Replenish the unit" "secBarracks">> @@ -207,7 +207,7 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> ( <br>Your drones are equipped with top tier weaponry and armor. <</if>> <<if $SecExp.settings.showStats == 1>> - <br><<= App.SecExp.getUnit("Bots").printStats()>> + <br><<= App.SecExp.getUnit("bots").printStats()>> <</if>> <<else>> <<link "Rebuild the unit" "secBarracks">> @@ -233,7 +233,7 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> ( <<set _sL = $SecExp.units.slaves.squads.length>> <<for _i = 0; _i < _sL; _i++>> <<capture _i>> - <<= App.SecExp.getUnit("Slaves", _i).describe()>> <br> + <<= App.SecExp.getUnit("slaves", _i).describe()>> <br> Rename unit <<textbox "$SecExp.units.slaves.squads[_i].platoonName" $SecExp.units.slaves.squads[_i].platoonName "secBarracks">> | <<link "Disband the unit" "secBarracks">> <<set $menials += $SecExp.units.slaves.squads[_i].troops>> @@ -265,7 +265,7 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> ( <</if>> <</if>> | <<includeDOM App.SecExp.unit.bulkUpgrade($SecExp.units.slaves.squads[_i])>> - <<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("Slaves", _i).printStats()>> <</if>> + <<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("slaves", _i).printStats()>> <</if>> <<includeDOM App.SecExp.unit.humanUpgradeList($SecExp.units.slaves.squads[_i])>> <</capture>> <</for>> @@ -296,7 +296,7 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> ( <<set _mL = $SecExp.units.militia.squads.length>> <<for _i = 0; _i < _mL; _i++>> <<capture _i>> - <<= App.SecExp.getUnit("Militia", _i).describe()>> <br> + <<= App.SecExp.getUnit("militia", _i).describe()>> <br> Rename unit <<textbox "$SecExp.units.militia.squads[_i].platoonName" $SecExp.units.militia.squads[_i].platoonName "secBarracks">> | <<link "Disband the unit" "secBarracks">> <<set $SecExp.units.militia.free += $SecExp.units.militia.squads[_i].troops>> @@ -328,7 +328,7 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> ( <</if>> <</if>> | <<includeDOM App.SecExp.unit.bulkUpgrade($SecExp.units.militia.squads[_i])>> - <<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("Militia", _i).printStats()>> <</if>> + <<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("militia", _i).printStats()>> <</if>> <<includeDOM App.SecExp.unit.humanUpgradeList($SecExp.units.militia.squads[_i])>> <</capture>> <</for>> @@ -350,7 +350,7 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> ( <<set _meL = $SecExp.units.mercs.squads.length>> <<for _i = 0; _i < _meL; _i++>> <<capture _i>> - <<= App.SecExp.getUnit("Mercs", _i).describe()>> <br> + <<= App.SecExp.getUnit("mercs", _i).describe()>> <br> Rename unit <<textbox "$SecExp.units.mercs.squads[_i].platoonName" $SecExp.units.mercs.squads[_i].platoonName "secBarracks">> | <<link "Disband the unit" "secBarracks">> <<set $SecExp.units.mercs.free += $SecExp.units.mercs.squads[_i].troops>> @@ -382,7 +382,7 @@ Your current maximum number of units is <<print App.SecExp.battle.maxUnits()>> ( <</if>> <</if>> | <<includeDOM App.SecExp.unit.bulkUpgrade($SecExp.units.mercs.squads[_i])>> - <<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("Mercs", _i).printStats()>> <</if>> + <<if $SecExp.settings.showStats == 1>> <<= App.SecExp.getUnit("mercs", _i).printStats()>> <</if>> <<includeDOM App.SecExp.unit.humanUpgradeList($SecExp.units.mercs.squads[_i])>> <</capture>> <</for>> diff --git a/src/Mods/SecExp/buildings/weaponsManufacturing.tw b/src/Mods/SecExp/buildings/weaponsManufacturing.tw index cfccb3ccf3d..6918ec4e16d 100644 --- a/src/Mods/SecExp/buildings/weaponsManufacturing.tw +++ b/src/Mods/SecExp/buildings/weaponsManufacturing.tw @@ -1,6 +1,6 @@ :: weaponsManufacturing [nobr jump-to-safe jump-from-safe] -<<set $nextButton = "Back", $nextLink = "Main", _baseUpgradeTime = App.SecExp.weapManuUpgrade.baseTime()>> +<<set $nextButton = "Back", $nextLink = "Main", _baseUpgradeTime = App.SecExp.weapManu.baseTime()>> This sector of the arcology has been dedicated to weapons manufacturing. These factories supply <<if $SecExp.units.militia.squads.length > 0>> your militia and<</if>> @@ -76,11 +76,11 @@ You own <<print num($menials)>> free menial slaves. This manufacturing complex c <br> <<link "Invest in automating the complex" "weaponsManufacturing">> <<run cashX(forceNeg(10000 * $SecExp.buildings.weapManu.productivity), "capEx")>> <<set $SecExp.buildings.weapManu.productivity++>> - <<for _i = 0; _i < $SecExp.buildings.weapManu.upgrades.queue.length; _i++>> - <<if $SecExp.buildings.weapManu.upgrades.queue[_i].time > 0>> - <<set _percentComplete = $SecExp.buildings.weapManu.upgrades.queue[_i].time / (_baseUpgradeTime / ($SecExp.buildings.weapManu.productivity - 1))>> + <<for _upgrade range $SecExp.buildings.weapManu.upgrades.queue>> + <<if _upgrade.time > 0>> + <<set _percentComplete = _upgrade.time / (_baseUpgradeTime / ($SecExp.buildings.weapManu.productivity - 1))>> <<set _newTime = Math.ceil(_percentComplete * _baseUpgradeTime / $SecExp.buildings.weapManu.productivity)>> - <<set $SecExp.buildings.weapManu.upgrades.queue[_i].time = _newTime>> + <<set _upgrade.time = _newTime>> <</if>> <</for>> <</link>> @@ -132,7 +132,7 @@ You own <<print num($menials)>> free menial slaves. This manufacturing complex c <<set _time = Math.ceil(_baseUpgradeTime / $SecExp.buildings.weapManu.productivity)>> <br><br>Upgrades: With our current industrial and research capabilities upgrades will be finished in _time weeks. -<<if App.SecExp.weapManuUpgrade.fully().bots && App.SecExp.weapManuUpgrade.fully().human>> +<<if App.SecExp.weapManu.upgrade("fully").all>> <<run delete $SecExp.buildings.weapManu.upgrades.queue>> <<else>> <<set $SecExp.buildings.weapManu.upgrades.queue = $SecExp.buildings.weapManu.upgrades.queue || []>> @@ -141,15 +141,15 @@ You own <<print num($menials)>> free menial slaves. This manufacturing complex c <br>Upgrade the research facility further to unlock additional upgrades. <</if>> <br>Security Drones: - <<if App.SecExp.weapManuUpgrade.fully().bots>> + <<if App.SecExp.weapManu.upgrade("fully").bots>> You have fully upgraded the security drones. <<else>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(-1)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", -1)>> </div> <<if $SecExp.buildings.weapManu.lab >= 2>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(-2)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", -2)>> </div> <</if>> <<if $SecExp.buildings.weapManu.lab >= 3>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(-3)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", -3)>> </div> <</if>> <br> <</if>> @@ -176,30 +176,30 @@ You own <<print num($menials)>> free menial slaves. This manufacturing complex c You have fully upgraded your human troops. <</if>> <</if>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(0)>> </div> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(1)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 0)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 1)>> </div> <<if $SecExp.buildings.weapManu.lab >= 2>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(2)>> </div> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(3)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 2)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 3)>> </div> <</if>> <<if $SecExp.buildings.weapManu.lab >= 3>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(4)>> </div> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(5)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 4)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 5)>> </div> <</if>> <<if $SF.Toggle && $SF.Active >= 1>> <<if $SecExp.buildings.weapManu.lab >= 2 && $SecExp.edicts.SFSupportLevel >= 2 && $SF.Squad.Firebase >= 7>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(6)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 6)>> </div> <</if>> <<if $SecExp.buildings.weapManu.lab >= 2 && $SecExp.edicts.SFSupportLevel >= 4 && $SF.Squad.Drugs >= 8>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(7)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 7)>> </div> <</if>> <<if $SecExp.buildings.weapManu.lab >= 3 && $SecExp.edicts.SFSupportLevel >= 5>> - <div> <<includeDOM App.SecExp.weapManuUpgrade.purchase(8)>> </div> + <div> <<includeDOM App.SecExp.weapManu.upgrade("buy", 8)>> </div> <</if>> <</if>> <<for _i = 0; _i < $SecExp.buildings.weapManu.upgrades.queue.length; _i++>> - <<set _current = App.SecExp.weapManuUpgrade.current($SecExp.buildings.weapManu.upgrades.queue[_i].ID)>> + <<set _current = App.SecExp.weapManu.upgrade("current", $SecExp.buildings.weapManu.upgrades.queue[_i].ID)>> <<if _i === 0>><br>Currently developing<<else>><br><<= ordinalSuffix(_i + 1)>> in queue<</if>>: _current.dec for _current.unit. It will enhance their _current.purpose. Estimated completion time is <<= numberWithPluralOne($SecExp.buildings.weapManu.upgrades.queue[_i].time, "week")>> @@ -211,9 +211,9 @@ You own <<print num($menials)>> free menial slaves. This manufacturing complex c <p> You have completed the following projects: <<for _i = 0; _i < _completed.length; _i++>> - <<= App.SecExp.weapManuUpgrade.current($SecExp.buildings.weapManu.upgrades.completed[_i]).dec>><<if _i < _completed.length - 1>>,<<else>>.<</if>> + <<= App.SecExp.weapManu.upgrade("current", _completed[_i]).dec>><<if _i < _completed.length - 1>>,<<else>>.<</if>> <</for>> </p> <</if>> <<set _cost = Math.trunc(10000*$upgradeMultiplierArcology)>> -<p>[[Return this sector to standard manufacturing|Main][delete $SecExp.buildings.weapManu, cashX(-_cost, "capEx"), App.Arcology.cellUpgrade($building, App.Arcology.Cell.Manufacturing, "Weapon Manufacturing", "Manufacturing")]] //Costs <<print cashFormat(_cost)>>//</p> +<p>[[Return this sector to standard manufacturing|Main][delete $SecExp.buildings.weapManu, cashX(-_cost, "capEx"), App.Arcology.cellUpgrade($building, App.Arcology.Cell.Manufacturing, "Weapon Manufacturing", "Manufacturing")]] //Costs <<print cashFormat(_cost)>>//</p> \ No newline at end of file diff --git a/src/Mods/SecExp/events/attackHandler.tw b/src/Mods/SecExp/events/attackHandler.tw index 28e9217dbab..53a34b487e3 100644 --- a/src/Mods/SecExp/events/attackHandler.tw +++ b/src/Mods/SecExp/events/attackHandler.tw @@ -209,14 +209,14 @@ /* calculates PC army stats */ <<if App.SecExp.battle.deployedUnits('bots')>> - <<set _unit = App.SecExp.getUnit("Bots")>> + <<set _unit = App.SecExp.getUnit("bots")>> <<set _attack += _unit.attack * _atkMod>> <<set _defense += _unit.defense * _defMod>> <<set _hp += _unit.hp>> <</if>> <<for _i = 0; _i < $SecExp.units.militia.squads.length; _i++>> <<if $SecExp.units.militia.squads[_i].isDeployed == 1>> - <<set _unit = App.SecExp.getUnit("Militia", _i)>> + <<set _unit = App.SecExp.getUnit("militia", _i)>> <<set _attack += _unit.attack * _atkMod>> <<set _defense += _unit.defense * _defMod>> <<set _hp += _unit.hp>> @@ -224,7 +224,7 @@ <</for>> <<for _i = 0; _i < $SecExp.units.slaves.squads.length; _i++>> <<if $SecExp.units.slaves.squads[_i].isDeployed == 1>> - <<set _unit = App.SecExp.getUnit("Slaves", _i)>> + <<set _unit = App.SecExp.getUnit("slaves", _i)>> <<set _attack += _unit.attack * _atkMod>> <<set _defense += _unit.defense * _defMod>> <<set _hp += _unit.hp>> @@ -232,7 +232,7 @@ <</for>> <<for _i = 0; _i < $SecExp.units.mercs.squads.length; _i++>> <<if $SecExp.units.mercs.squads[_i].isDeployed == 1>> - <<set _unit = App.SecExp.getUnit("Mercs", _i)>> + <<set _unit = App.SecExp.getUnit("mercs", _i)>> <<set _attack += _unit.attack * _atkMod>> <<set _defense += _unit.defense * _defMod>> <<set _hp += _unit.hp>> diff --git a/src/Mods/SecExp/events/rebellionHandler.tw b/src/Mods/SecExp/events/rebellionHandler.tw index ffa703f6475..ca49a456cc9 100644 --- a/src/Mods/SecExp/events/rebellionHandler.tw +++ b/src/Mods/SecExp/events/rebellionHandler.tw @@ -48,7 +48,7 @@ <</if>> <<if $SecExp.units.bots.active == 1>> - <<set _unit = App.SecExp.getUnit("Bots")>> + <<set _unit = App.SecExp.getUnit("bots")>> <<set _attack += _unit.attack>> <<set _defense += _unit.defense>> <<set _hp += _unit.hp>> @@ -56,7 +56,7 @@ <<for _i = 0; _i < $SecExp.units.militia.squads.length; _i++>> <<if $SecExp.units.militia.squads[_i].active == 1 && (!$SecExp.war.rebellingID.includes($SecExp.units.militia.squads[_i].ID))>> - <<set _unit = App.SecExp.getUnit("Militia", _i)>> + <<set _unit = App.SecExp.getUnit("militia", _i)>> <<set _attack += _unit.attack>> <<set _defense += _unit.defense>> <<set _hp += _unit.hp>> @@ -64,7 +64,7 @@ <</for>> <<for _i = 0; _i < $SecExp.units.slaves.squads.length; _i++>> <<if $SecExp.units.slaves.squads[_i].active == 1 && (!$SecExp.war.rebellingID.includes($SecExp.units.slaves.squads[_i].ID))>> - <<set _unit = App.SecExp.getUnit("Slaves", _i)>> + <<set _unit = App.SecExp.getUnit("slaves", _i)>> <<set _attack += _unit.attack>> <<set _defense += _unit.defense>> <<set _hp += _unit.hp>> @@ -72,7 +72,7 @@ <</for>> <<for _i = 0; _i < $SecExp.units.mercs.squads.length; _i++>> <<if $SecExp.units.mercs.squads[_i].active == 1 && (!$SecExp.war.rebellingID.includes($SecExp.units.mercs.squads[_i].ID))>> - <<set _unit = App.SecExp.getUnit("Mercs", _i)>> + <<set _unit = App.SecExp.getUnit("mercs", _i)>> <<set _attack += _unit.attack>> <<set _defense += _unit.defense>> <<set _hp += _unit.hp>> @@ -150,7 +150,7 @@ <<set _rebellingMilitia = 1>> <<set $SecExp.war.attacker.troops += $SecExp.units.militia.squads[_i].troops>> <<set $SecExp.units.militia.squads[_i].loyalty = 0>> - <<set _unit = App.SecExp.getUnit("Militia", _i)>> + <<set _unit = App.SecExp.getUnit("militia", _i)>> <<set _enemyAttack += _unit.attack>> <<set _enemyDefense += _unit.defense>> <<set _enemyHp += _unit.hp>> @@ -161,7 +161,7 @@ <<set _rebellingSlaves = 1>> <<set $SecExp.war.attacker.troops += $SecExp.units.slaves.squads[_i].troops>> <<set $SecExp.units.slaves.squads[_i].loyalty = 0>> - <<set _unit = App.SecExp.getUnit("Slaves", _i)>> + <<set _unit = App.SecExp.getUnit("slaves", _i)>> <<set _enemyAttack += _unit.attack>> <<set _enemyDefense += _unit.defense>> <<set _enemyHp += _unit.hp>> @@ -172,7 +172,7 @@ <<set _rebellingMercs = 1>> <<set $SecExp.war.attacker.troops += $SecExp.units.mercs.squads[_i].troops>> <<set $SecExp.units.mercs.squads[_i].loyalty = 0>> - <<set _unit = App.SecExp.getUnit("Mercs", _i)>> + <<set _unit = App.SecExp.getUnit("mercs", _i)>> <<set _enemyAttack += _unit.attack>> <<set _enemyDefense += _unit.defense>> <<set _enemyHp += _unit.hp>> diff --git a/src/Mods/SecExp/events/rebellionOptions.tw b/src/Mods/SecExp/events/rebellionOptions.tw index 8f456dd42b2..6a6617cb0d5 100644 --- a/src/Mods/SecExp/events/rebellionOptions.tw +++ b/src/Mods/SecExp/events/rebellionOptions.tw @@ -1,7 +1,7 @@ :: rebellionOptions [nobr] <<set $nextButton = " ", $encyclopedia = "Battles">> -<<set _isSlaveRebellion = $SecExp.war.type.includes("Slave"), _loyalUnits = App.SecExp.unit.list().slice(1).reduce((acc, cur) => {acc + V.SecExp.units[cur].squads.length;}, 0) - $SecExp.war.rebellingID.length>> +<<set _isSlaveRebellion = $SecExp.war.type.includes("Slave"), _loyalUnits = App.SecExp.unit.humanSquads().length - $SecExp.war.rebellingID.length>> <strong> $SecExp.war.type!</strong> <hr> @@ -107,4 +107,4 @@ In order to preserve the structural integrity of the building and the lives of o <br><br> <<includeDOM App.SecExp.unit.replenishAll()>> [[Proceed|rebellionHandler][$SecExp.war.result = 4, $SecExp.war.foughtThisWeek = 1]] /* sets $SecExp.war.result to a value outside accepted range (-3,3) to avoid evaluation problems */ -<br>[[Surrender|rebellionReport][$SecExp.war.result = -1, $SecExp.war.foughtThisWeek = 1]] \ No newline at end of file +<br>[[Surrender|rebellionReport][$SecExp.war.result = -1, $SecExp.war.foughtThisWeek = 1]] diff --git a/src/Mods/SecExp/js/Unit.js b/src/Mods/SecExp/js/Unit.js index 2a53c6d509b..3cf54a27deb 100644 --- a/src/Mods/SecExp/js/Unit.js +++ b/src/Mods/SecExp/js/Unit.js @@ -2,7 +2,6 @@ App.SecExp.unit = (function() { return { list, bulkUpgrade, - humanLoyaltyChanges, fixBroken, gen:generate, deployMenu, @@ -97,89 +96,13 @@ App.SecExp.unit = (function() { el.append(App.UI.DOM.link(`Bulk upgrade for ${cashFormat(price)}`, () => { unit.map(upgradeUnit).reduce((acc, cur) => acc + cur, 0); cashX(-price, "securityExpansion"); - }, - [], passage() + App.UI.reload(); + } )); } return el; } - /** Reports changes to the supplied unit's loyalty. - * @param {FC.SecExp.PlayerHumanUnitData} input the unit type to be checked. - * @param {FC.SecExp.PlayerHumanUnitType} type - * @returns {HTMLDivElement} - */ - function humanLoyaltyChanges(input, type) { - let loyaltyChange = 0, el = document.createElement("div"); - - el.append(`${input.platoonName}: `); - if (V.SecExp.buildings.barracks && V.SecExp.buildings.barracks.loyaltyMod >= 1) { - el.append("is periodically sent to the indoctrination facility in the barracks for thought correction therapy. "); - loyaltyChange += 2 * V.SecExp.buildings.barracks.loyaltyMod; - } - if (input.commissars >= 1) { - el.append("The commissars attached to the unit carefully monitor the officers and grunts for signs of insubordination. "); - loyaltyChange += 2 * input.commissars; - } - if (V.SecExp.edicts.defense.soldierWages === 2) { - if (type === 'slaves') { - el.append("The slaves greatly appreciate the generous wage given to them for their service as soldiers. Occasions to earn money for a slave are scarce after all. "); - } else if (type === 'militia') { - el.append("The soldiers greatly appreciate the generous wage given to them for their service. They are proud to defend their homes while making a small fortune out of it. "); - } else if (type === 'mercs') { - el.append("The mercenaries greatly appreciate the generous wage given to them for their service. After all coin is the fastest way to reach their hearts. "); - } - loyaltyChange += random(5, 10); - } else if (V.SecExp.edicts.defense.soldierWages === 1) { - if (type === 'slaves') { - el.append("The slaves appreciate the wage given to them for their service as soldiers, despite it being just adequate. Occasions to earn money for a slave are scarce after all. "); - } else if (type === 'militia') { - el.append("The soldiers appreciate the wage given to them for their service, despite it being just adequate. They are proud to defend their homes, though at the cost of possible financial gains. "); - } else if (type === 'mercs') { - el.append("The mercenaries do not appreciate the barely adequate wage given to them for their service. Still their professionalism keeps them determined to finish their contract. "); - } - loyaltyChange += random(-5, 5); - } else { - if (type === 'slaves') { - el.append("The slaves do not appreciate the low wage given to them for their service as soldiers, but occasions to earn money for a slave are scarce, so they're not too affected by it. "); - } else if (type === 'militia') { - el.append("The soldiers do not appreciate the low wage given to them for their service. Their sense of duty keeps them proud of their role as defenders of the arcology, but many do feel its financial weight. "); - } else if (type === 'mercs') { - el.append("The mercenaries do not appreciate the low wage given to them for their service. Their skill would be better served by a better contract and this world does not lack demand for guns for hire. "); - } - loyaltyChange -= random(5, 10); - } - if (type === 'slaves' && V.SecExp.edicts.defense.privilege.slaveSoldier) { - el.append("Allowing them to hold material possessions earns you their devotion and loyalty. "); - loyaltyChange += random(1, 2); - } - if (type === 'militia' && V.SecExp.edicts.defense.privilege.militiaSoldier) { - el.append("Allowing them to avoid rent payment for their military service earns you their happiness and loyalty. "); - loyaltyChange += random(1, 2); - } - if (type === 'mercs' && V.SecExp.edicts.defense.privilege.mercSoldier) { - el.append("Allowing them to keep part of the loot gained from your enemies earns you their trust and loyalty. "); - loyaltyChange += random(1, 2); - } - - el.append("This week, the loyalty of this unit "); - if (loyaltyChange > 0) { - App.UI.DOM.appendNewElement("span", el, "increased.", "green"); - } else if (loyaltyChange === 0) { - App.UI.DOM.appendNewElement("span", el, "did not change.", "yellow"); - } else { - App.UI.DOM.appendNewElement("span", el, "decreased.", "red"); - } - input.loyalty = Math.clamp(input.loyalty + loyaltyChange, 0, 100); - if (input.training < 100 && V.SecExp.buildings && V.SecExp.buildings.barracks.training >= 1) { - let options = document.createElement("div"); - options.append("The unit is able to make use of the training facilities to better prepare its soldiers, slowly increasing their experience level. "); - el.append(options); - input.training += random(2, 4) * 1.5 * V.SecExp.buildings.barracks.training; - } - - return el; - } /** Repairs unit if needed. * @param {string} [unit] unit type @@ -268,9 +191,9 @@ App.SecExp.unit = (function() { if (input.active === 1 && input.troops > 0) { if (type === "bots") { - $(el).append(App.SecExp.getUnit("Bots").describe()); + $(el).append(App.SecExp.getUnit("bots").describe()); } else { - $(el).append(App.SecExp.getUnit(capFirstChar(type), count).describe()); + $(el).append(App.SecExp.getUnit(type, count).describe()); } options = document.createElement("div"); options.append(App.UI.DOM.link(`${canDeploy ? 'Deploy' : 'Remove'} the unit`, () => { @@ -296,8 +219,8 @@ App.SecExp.unit = (function() { options.append(App.UI.DOM.link("officers with intensive training", () => { input.maxTroops += 10; cashX(-(5000 + 10 * equipUpgradeCost * (input.equip + input.commissars + input.cyber + input.SF)), "securityExpansion"); - }, - [], passage() + App.UI.reload(); + } )); options.append(` to increase the maximum number of soldiers in the unit by 10.`); } else { @@ -311,8 +234,8 @@ App.SecExp.unit = (function() { options.append(App.UI.DOM.link("better equipment", () => { input.equip++; cashX(-(equipUpgradeCost * input.maxTroops + 1000), "securityExpansion"); - }, - [], passage() + App.UI.reload(); + } )); options.append(` to increase this unit's attack and defense by 15% per investement.`); } else { @@ -326,8 +249,8 @@ App.SecExp.unit = (function() { options.append(App.UI.DOM.link("commissars", () => { input.commissars++; cashX(-(equipUpgradeCost * input.maxTroops + 1000), "securityExpansion"); - }, - [], passage() + App.UI.reload(); + } )); options.append(` to slowly increase this unit's loyalty.`); } @@ -345,8 +268,8 @@ App.SecExp.unit = (function() { options.append(App.UI.DOM.link("augment all soldiers of the unit", () => { input.cyber++; cashX(-(equipUpgradeCost * input.maxTroops + 2000), "securityExpansion"); - }, - [], passage() + App.UI.reload(); + } )); options.append(` with high tech cyber enhancements that will increase attack, defense and base hp values.`); } else { @@ -361,8 +284,8 @@ App.SecExp.unit = (function() { options.append(App.UI.DOM.link("attach trained medics to the unit", () => { input.medics++; cashX(-(equipUpgradeCost * input.maxTroops + 1000), "securityExpansion"); - }, - [], passage() + App.UI.reload(); + } )); options.append(' which will decrease the number of casualties suffered during battle.'); } else { @@ -378,8 +301,8 @@ App.SecExp.unit = (function() { options.append(App.UI.DOM.link("attach Special Force advisors", () => { input.SF++; cashX(-(equipUpgradeCost * input.maxTroops + 5000), "securityExpansion"); - }, - [], passage() + App.UI.reload(); + } )); options.append(' which will slightly increase the base stats of the unit.'); } else { @@ -456,8 +379,8 @@ App.SecExp.unit = (function() { } } } - }, - [], passage() + App.UI.reload(); + } )); el.append(` Will replenish units as long as requirements are met.\n\n`); } @@ -486,7 +409,7 @@ App.SecExp.unit = (function() { * @returns {App.SecExp.Unit} */ App.SecExp.getUnit = function(type, index) { - if (type === "Bots") { + if (type === "bots") { return new App.SecExp.DroneUnit(V.SecExp.units.bots, App.SecExp.BaseDroneUnit); } else if (type === "SF") { return new App.SecExp.SFUnit(); @@ -495,11 +418,11 @@ App.SecExp.getUnit = function(type, index) { } switch (type) { - case "Militia": + case "militia": return new App.SecExp.HumanUnit(V.SecExp.units.militia.squads[index], App.SecExp.BaseMilitiaUnit, type); - case "Slaves": + case "slaves": return new App.SecExp.HumanUnit(V.SecExp.units.slaves.squads[index], App.SecExp.BaseSlaveUnit, type); - case "Mercs": + case "mercs": return new App.SecExp.HumanUnit(V.SecExp.units.mercs.squads[index], App.SecExp.BaseMercUnit, type); default: throw `Unknown unit type: ${type}`; @@ -528,16 +451,16 @@ App.SecExp.getEnemyUnit = function(type, troops, equipment) { }; /** Irregular unit factory - get an irregular unit (without organization/upgrade bonuses) based on its type and basic data - * @param {string} type - "Militia", "Slaves", or "Mercs" + * @param {string} type - "militia", "slaves", or "mercs" * @param {number} troops * @param {number} equipment * @returns {App.SecExp.Unit} */ App.SecExp.getIrregularUnit = function(type, troops, equipment) { const baseUnitMap = new Map([ - ["Militia", App.SecExp.BaseMilitiaUnit], - ["Slaves", App.SecExp.BaseSlaveUnit], - ["Mercs", App.SecExp.BaseMercUnit], + ["militia", App.SecExp.BaseMilitiaUnit], + ["slaves", App.SecExp.BaseSlaveUnit], + ["mercs", App.SecExp.BaseMercUnit], ]); const unitData = { troops: troops, @@ -572,7 +495,7 @@ App.SecExp.trainingValueToBonusFactor = function(value) { * @returns {object} bouns values after checking for completed upgrades. */ App.SecExp.getAppliedUpgrades = function(type) { - let hp = 0, morale = 0, def = 0, attack = 0; + let hp = 0; let morale = 0; let def = 0; let attack = 0; if (V.SecExp.buildings.weapManu) { if (type === 'drone') { if (V.SecExp.buildings.weapManu.upgrades.completed.includes(-3)) { @@ -624,7 +547,7 @@ App.SecExp.getAppliedUpgrades = function(type) { App.SecExp.getEdictUpgradeVal = (function() { const data = { - Militia: new Map([ + militia: new Map([ ["legionTradition", {defense: 2, morale: 5, hp: 1}], ["imperialTradition", {defense: 1, morale: 5, hp: 1}], ["pharaonTradition", {attack: 2, defense: 2, morale: 10}], @@ -632,13 +555,13 @@ App.SecExp.getEdictUpgradeVal = (function() { ["eliteOfficers", {morale: 5}], ["lowerRequirements", {defense: -1, hp: -1}] ]), - Slave: new Map([ + slave: new Map([ ["mamluks", {attack: 2, morale: 10, hp: 1}], ["sunTzu", {attack: 1, defense: 1, morale: 5}], ["eliteOfficers", {morale: -5}], ["martialSchool", {morale: 5}] ]), - Merc: new Map([ + merc: new Map([ ["eagleWarriors", {attack: 4, defense: -2, morale: 10}], ["ronin", {attack: 2, defense: 2, morale: 10}], ["sunTzu", {attack: 1, defense: 1, morale: 5}], @@ -676,19 +599,19 @@ App.SecExp.getEdictUpgradeVal = (function() { /** @implements {BaseUnit} */ App.SecExp.BaseMilitiaUnit = class BaseMilitiaUnit { static get attack() { - return 7 + App.SecExp.getAppliedUpgrades('human').attack + App.SecExp.getEdictUpgradeVal("Militia", "attack"); + return 7 + App.SecExp.getAppliedUpgrades('human').attack + App.SecExp.getEdictUpgradeVal("militia", "attack"); } static get defense() { - return 5 + App.SecExp.getAppliedUpgrades('human').defense + App.SecExp.getEdictUpgradeVal("Militia", "defense"); + return 5 + App.SecExp.getAppliedUpgrades('human').defense + App.SecExp.getEdictUpgradeVal("militia", "defense"); } static get morale() { - return 140 + App.SecExp.getAppliedUpgrades('human').morale + App.SecExp.getEdictUpgradeVal("Militia", "morale"); + return 140 + App.SecExp.getAppliedUpgrades('human').morale + App.SecExp.getEdictUpgradeVal("militia", "morale"); } static get hp() { - return 3 + App.SecExp.getAppliedUpgrades('human').hp + App.SecExp.getEdictUpgradeVal("Militia", "hp"); + return 3 + App.SecExp.getAppliedUpgrades('human').hp + App.SecExp.getEdictUpgradeVal("militia", "hp"); } }; @@ -696,38 +619,38 @@ App.SecExp.BaseMilitiaUnit = class BaseMilitiaUnit { /** @implements {BaseUnit} */ App.SecExp.BaseSlaveUnit = class BaseSlaveUnit { static get attack() { - return 8 + App.SecExp.getAppliedUpgrades('human').attack + App.SecExp.getEdictUpgradeVal("Slave", "attack"); + return 8 + App.SecExp.getAppliedUpgrades('human').attack + App.SecExp.getEdictUpgradeVal("slave", "attack"); } static get defense() { - return 3 + App.SecExp.getAppliedUpgrades('human').defense + App.SecExp.getEdictUpgradeVal("Slave", "defense"); + return 3 + App.SecExp.getAppliedUpgrades('human').defense + App.SecExp.getEdictUpgradeVal("slave", "defense"); } static get morale() { - return 110 + App.SecExp.getAppliedUpgrades('human').morale + App.SecExp.getEdictUpgradeVal("Slave", "morale"); + return 110 + App.SecExp.getAppliedUpgrades('human').morale + App.SecExp.getEdictUpgradeVal("slave", "morale"); } static get hp() { - return 3 + App.SecExp.getAppliedUpgrades('human').hp + App.SecExp.getEdictUpgradeVal("Slave", "hp"); + return 3 + App.SecExp.getAppliedUpgrades('human').hp + App.SecExp.getEdictUpgradeVal("slave", "hp"); } }; /** @implements {BaseUnit} */ App.SecExp.BaseMercUnit = class BaseMercUnit { static get attack() { - return 8 + App.SecExp.getAppliedUpgrades('human').attack + App.SecExp.getEdictUpgradeVal("Merc", "attack"); + return 8 + App.SecExp.getAppliedUpgrades('human').attack + App.SecExp.getEdictUpgradeVal("merc", "attack"); } static get defense() { - return 4 + App.SecExp.getAppliedUpgrades('human').defense + App.SecExp.getEdictUpgradeVal("Merc", "defense"); + return 4 + App.SecExp.getAppliedUpgrades('human').defense + App.SecExp.getEdictUpgradeVal("merc", "defense"); } static get morale() { - return 125 + App.SecExp.getAppliedUpgrades('human').morale + App.SecExp.getEdictUpgradeVal("Merc", "morale"); + return 125 + App.SecExp.getAppliedUpgrades('human').morale + App.SecExp.getEdictUpgradeVal("merc", "morale"); } static get hp() { - return 4 + App.SecExp.getAppliedUpgrades('human').hp + App.SecExp.getEdictUpgradeVal("Merc", "hp"); + return 4 + App.SecExp.getAppliedUpgrades('human').hp + App.SecExp.getEdictUpgradeVal("merc", "hp"); } }; diff --git a/src/Mods/SecExp/js/buildingsJS.js b/src/Mods/SecExp/js/buildingsJS.js index 1db4424c933..f40d623b709 100644 --- a/src/Mods/SecExp/js/buildingsJS.js +++ b/src/Mods/SecExp/js/buildingsJS.js @@ -1,167 +1,3 @@ -App.SecExp.weapManuUpgrade = (function() { - return { - baseTime, - current, - purchase, - fully, - }; - - /** Weeks to completion without any modification. - * @returns {number} - */ - function baseTime() { return 10; } - - /** Checks the supplied ID value and assigns values. - * @param {number} [x=null] the optional ID value to use instead of the current upgrades ID. - * @returns {Object} - */ - function current(x = null) { - let o = {unit: "our human troops", ID: jsDef(x) ? x : V.SecExp.buildings.weapManu.upgrades.queue[0].ID}; - switch(o.ID) { - case -3: - Object.assign(o, { - dec: "advanced synthetic alloys", type: "hp", unit: "the security drones", - cost: 10000*V.HackingSkillMultiplier, - }); - break; - case -2: - Object.assign(o, { - dec: "adaptive armored frames", type: "defense", unit: "the security drones", - cost: 10000 - }); - break; - case -1: - Object.assign(o, { - dec: "dynamic battle aware AI", type: "attack", unit: "the security drones", - cost: 30000 - }); - break; - case 0: - Object.assign(o, { - dec: "magnetic based ballistic weaponry", type: "attack", - cost: 30000 - }); - break; - case 1: - Object.assign(o, { - dec: "ceramo-metallic alloys", type: "defense", - cost: 30000 - }); - break; - case 2: - Object.assign(o, { - dec: "rapid action stimulants", type: "hp", - cost: 60000 - }); - break; - case 3: - Object.assign(o, { - dec: "fast response neural stimulant", type: "morale", - cost: 60000 - }); - break; - case 4: - Object.assign(o, { - dec: "universal cyber enhancements", type: "attack and defense", - cost: 120000*V.HackingSkillMultiplier - }); - break; - case 5: - Object.assign(o, { - dec: "remote neural links", type: "hp and morale", - cost: 120000*V.HackingSkillMultiplier - }); - break; - case 6: - Object.assign(o, { - dec: "combined training regimens with the special force", type: "attack and defense", - cost: 0 - }); - break; - case 7: - Object.assign(o, { - dec: `a variant of the stimulant cocktail that the ${V.SF.Lower} created`, type: "hp and morale", - cost: 300000 - }); - break; - case 8: - Object.assign(o, { - dec: "a mesh network based off the custom network of the special force", type: "all", - cost: 1000000*V.HackingSkillMultiplier - }); - break; - } - - switch(o.type) { - case "hp": - Object.assign(o, {purpose: "survivability"}); break; - case "defense": - Object.assign(o, {purpose: "defensive capabilities"}); break; - case "attack": - Object.assign(o, {purpose: "attack power"}); break; - case "morale": - Object.assign(o, {purpose: "standing power"}); break; - case "attack and defense": - Object.assign(o, {purpose: "offensive and defensive effectiveness."}); break; - case "hp and morale": - Object.assign(o, {purpose: "morale and survivability"}); break; - case "all": - Object.assign(o, {purpose: "offensive,defensive effectiveness in addition to morale and survivability"}); break; - } - return o; - } - - /** Prints a line that allows a user to purchase an upgrade. - * @param {number} [x] ID value to use. - * @returns {Node} - */ - function purchase(x) { - let el = document.createElement("div"), found = null; - if (!V.SecExp.buildings.weapManu.upgrades.completed.includes(x)) { - for (let i = 0; i < V.SecExp.buildings.weapManu.upgrades.queue.length; i++) { - if (V.SecExp.buildings.weapManu.upgrades.queue[i].ID === x) { - found = i; break; - } - } - const item = current(x), time = Math.ceil(baseTime() / V.SecExp.buildings.weapManu.productivity); - if (!jsDef(found)) { - el.append(App.UI.DOM.link(`Develop ${item.dec}.`, () => { - V.SecExp.buildings.weapManu.upgrades.queue.push({ID: x, time: time}); - cashX(-item.cost, "capEx"); - }, - [], passage() - )); - el.append(`This will take ${time} weeks`); - if (item.cost > 0) { - el.append(`, cost ${cashFormat(item.cost)}`); - } - el.append(` and will increase `); - if (item.type !== "all") { - el.append(`the base ${item.type} value${item.type.contains("and") ? 's' : ''}`); - } else { - el.append('all base stats'); - } - el.append(` of ${item.unit}.`); - } else { - el.append(App.UI.DOM.link(`Remove ${item.dec} from the queue`, () => { - V.SecExp.buildings.weapManu.upgrades.queue.deleteAt(found); - }, - [], passage() - )); - } - } - return el; - } - - function fully() { - const human = (V.SF.Toggle && V.SF.Active >= 1) ? [0, 1, 2, 3, 4, 5, 6, 7, 8] : [0, 1, 2, 3, 4, 5]; - return { - human: V.SecExp.buildings.weapManu.upgrades.completed.includesAll(human), - bots: V.SecExp.buildings.weapManu.upgrades.completed.includesAll(-1, -2, -3), - }; - } -})(); - App.SecExp.propHub = (function() { return { Init, @@ -406,6 +242,8 @@ App.SecExp.weapManu = (function() { return { Init, BC, + baseTime, + upgrade, }; function Init() { @@ -445,7 +283,7 @@ App.SecExp.weapManu = (function() { V.SecExp.buildings.weapManu.upgrades = V.SecExp.buildings.weapManu.upgrades || {}; V.SecExp.buildings.weapManu.upgrades.completed = V.SecExp.buildings.weapManu.upgrades.completed || V.completedUpgrades || []; - if (!App.SecExp.weapManuUpgrade.fully().bots && !App.SecExp.weapManuUpgrade.fully().human) { + if (!upgrade("fully").all) { V.SecExp.buildings.weapManu.upgrades.queue = V.SecExp.buildings.weapManu.upgrades.queue || []; if (jsDef(V.currentUpgrade)) { if (!jsDef(V.currentUpgrade.ID)) { @@ -489,6 +327,143 @@ App.SecExp.weapManu = (function() { } } } + + /** Weeks to completion without any modification. + * @returns {number} + */ + function baseTime() { return 10; } + + function upgrade(mode, upgradeID = null) { + if (mode === "current") { + /** Checks the supplied ID value and assigns values. + * @param {number} the optional ID value to use instead of the current upgrades ID. + * @returns {object} + */ + const ID = jsDef(upgradeID) ? upgradeID : V.SecExp.buildings.weapManu.upgrades.queue[0].ID; + switch(ID) { + case -3: + return { + dec: "advanced synthetic alloys", type: "hp", + purpose: "survivability", cost: 10000*V.HackingSkillMultiplier, + unit: "the security drones", ID: ID + }; + case -2: + return { + dec: "adaptive armored frames", type: "defense", + purpose: "defensive capabilities", cost: 10000, + unit: "the security drones", ID: ID + }; + case -1: + return { + dec: "dynamic battle aware AI", type: "attack", + purpose: "attack power", cost: 30000, + unit: "the security drones", ID: ID + }; + case 0: + return { + dec: "magnetic based ballistic weaponry", type: "attack", + purpose: "attack power", cost: 30000, + unit: "our human troops", ID: ID + }; + case 1: + return { + dec: "ceramo-metallic alloys", type: "defense", + purpose: "defensive capabilities", cost: 30000, + unit: "our human troops", ID: ID + }; + case 2: + return { + dec: "rapid action stimulants", type: "hp", + purpose: "survivability", cost: 60000, + unit: "our human troops", ID: ID + }; + case 3: + return { + dec: "fast response neural stimulant", type: "morale", + purpose: "standing power", cost: 60000, + unit: "our human troops", ID: ID + }; + case 4: + return { + dec: "universal cyber enhancements", type: "attack and defense", + purpose: "offensive and defensive effectiveness.", cost: 120000*V.HackingSkillMultiplier, + unit: "our human troops", ID: ID + }; + case 5: + return { + dec: "remote neural links", type: "hp and morale", + purpose: "morale and survivability", cost: 120000*V.HackingSkillMultiplier, + unit: "our human troops", ID: ID + }; + case 6: + return { + dec: "combined training regimens with the special force", type: "attack and defense", + purpose: "offensive and defensive effectiveness.", cost: 0, + unit: "our human troops", ID: ID + }; + case 7: + return { + dec: `a variant of the stimulant cocktail that the ${V.SF.Lower} created`, type: "hp and morale", + purpose: "morale and survivability", cost: 300000, + unit: "our human troops", ID: ID + }; + case 8: + return { + dec: "a mesh network based off the custom network of the special force", type: "all", + purpose: "offensive,defensive effectiveness in addition to morale and survivability", cost: 1000000*V.HackingSkillMultiplier, + unit: "our human troops", ID: ID + }; + } + } else if (mode === "buy") { + /** Prints a line that allows a user to purchase an upgrade. + * @param {number} [x] ID value to use. + * @returns {Node} + */ + let el = document.createElement("div"); + let found; + if (!V.SecExp.buildings.weapManu.upgrades.completed.includes(upgradeID)) { + for (let i = 0; i < V.SecExp.buildings.weapManu.upgrades.queue.length; i++) { + if (V.SecExp.buildings.weapManu.upgrades.queue[i].ID === upgradeID) { + found = i; break; + } + } + const item = upgrade("current", upgradeID); const time = Math.ceil(baseTime() / V.SecExp.buildings.weapManu.productivity); + if (!jsDef(found)) { + el.append(App.UI.DOM.link(`Develop ${item.dec}.`, () => { + V.SecExp.buildings.weapManu.upgrades.queue.push({ID: upgradeID, time: time}); + cashX(-item.cost, "capEx"); + App.UI.reload(); + } + )); + el.append(`This will take ${time} weeks`); + if (item.cost > 0) { + el.append(`, cost ${cashFormat(item.cost)}`); + } + el.append(` and will increase `); + if (item.type !== "all") { + el.append(`the base ${item.type} value${item.type.contains("and") ? 's' : ''}`); + } else { + el.append('all base stats'); + } + el.append(` of ${item.unit}.`); + } else { + el.append(App.UI.DOM.link(`Remove ${item.dec} from the queue`, () => { + V.SecExp.buildings.weapManu.upgrades.queue.deleteAt(found); + App.UI.reload(); + } + )); + } + } + return el; + } else if (mode === "fully") { + const human = (V.SF.Toggle && V.SF.Active >= 1) ? [0, 1, 2, 3, 4, 5, 6, 7, 8] : [0, 1, 2, 3, 4, 5]; + return { + human: V.SecExp.buildings.weapManu.upgrades.completed.includesAll(human), + bots: V.SecExp.buildings.weapManu.upgrades.completed.includesAll(-1, -2, -3), + all: V.SecExp.buildings.weapManu.upgrades.completed.includesAll(human.concat(-1, -2, -3)), + }; + } + } })(); App.SecExp.transportHub = (function() { diff --git a/src/Mods/SecExp/js/reportingRelatedFunctions.js b/src/Mods/SecExp/js/reportingRelatedFunctions.js new file mode 100644 index 00000000000..146c5e9a3f0 --- /dev/null +++ b/src/Mods/SecExp/js/reportingRelatedFunctions.js @@ -0,0 +1,1084 @@ +/** + * 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 {{text:string, bonus:number}} + */ +App.SecExp.assistanceSF = function(report, section = '') { + const size = V.SF.Toggle && V.SF.Active >= 1 ? App.SF.upgrades.total() : 0; + let r = ``; let 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 {{text:string, effect:number}}} + */ +App.SecExp.propagandaEffects = function(focus) { + let t = ``; let increase = 0; + if (V.secExpEnabled > 0 && V.SecExp.buildings.propHub && V.SecExp.buildings.propHub.upgrades.campaign >= 1 && V.SecExp.buildings.propHub.focus === focus) { + let campaign; let modifier; + const forcedViewing = V.SecExp.edicts.propCampaignBoost === 1; + const noRecruiter = V.SecExp.buildings.propHub.recruiterOffice === 0 || V.RecruiterID === 0; + const recruiterActive = V.SecExp.buildings.propHub.recruiterOffice && V.RecruiterID > 0; + switch (focus) { + case "social engineering": + campaign = 'societal engineering'; + modifier = forcedViewing ? V.SecExp.buildings.propHub.upgrades.campaign : 1; + if (noRecruiter) { + increase += (forcedViewing ? 2 : 1) * modifier; + } else if (recruiterActive) { + increase += modifier + Math.floor((S.Recruiter.intelligence + S.Recruiter.intelligenceImplant) / 32); + } + break; + case "recruitment": + campaign = 'militia recruitment'; + modifier = forcedViewing ? 0.2 : 0.15; + if (noRecruiter) { + increase += modifier + (forcedViewing ? 0.1 : 0.05); + } else if (recruiterActive) { + increase += modifier + Math.floor((S.Recruiter.intelligence + S.Recruiter.intelligenceImplant) / 650); + } + break; + case "immigration": + modifier = forcedViewing ? V.SecExp.buildings.propHub.upgrades.campaign : 1; + if (noRecruiter) { + increase += (forcedViewing ? random(1, 4) : random(1, 2)) * modifier; + } else if (recruiterActive) { + increase += modifier + Math.floor((S.Recruiter.intelligence + S.Recruiter.intelligenceImplant) / 16); + } + t = `Your advertisement campaign outside the free city brings more people to the gates of your arcology`; + break; + case "enslavement": + modifier = forcedViewing ? V.SecExp.buildings.propHub.upgrades.campaign : 1; + if (noRecruiter) { + increase += (forcedViewing ? random(0, 4) : random(0, 2)) * modifier; + } else if (recruiterActive) { + increase += modifier + Math.floor((S.Recruiter.intelligence + S.Recruiter.intelligenceImplant) / 16); + } + t = `Many were attracted by your advertisement campaigns.`; + break; + } + + if (focus === "social engineering" || focus === "recruitment") { + t += `<span class='green'>Your propaganda campaign helps further your ${campaign} efforts.`; + if (recruiterActive) { + t += ` <span class='slave-name'>${SlaveFullName(S.Recruiter)}</span> is boosting your ${campaign} campaign.`; + } + t += `</span>`; + } + } + return {text: t, effect: Math.round(increase)}; +}; + +App.SecExp.slavesDamaged = function(adjustValue) { + V.NPCSlaves -= Math.trunc((V.NPCSlaves / V.ASlaves) * adjustValue); + V.menials -= Math.trunc((V.menials / V.ASlaves) * adjustValue); + V.fuckdolls -= Math.trunc((V.fuckdolls / V.ASlaves) * adjustValue); + V.menialBioreactors -= Math.trunc((V.menialBioreactors / V.ASlaves) * adjustValue); +}; + +App.SecExp.updateFacilityDamage = function(facility) { + let text = ``; + let securityEffect = 0; + let crimeEffect = 0; + let growthEffect = 0; + if (V.SecExp.rebellions.repairTime[facility] !== undefined) { + if (facility === 'assistant') { + text += `With the central CPU core of the assistant down, managing security is a much harder task. Inevitably some little but important details will slip past your agents.`; + securityEffect = 1; + crimeEffect = 1; + } else if (facility === 'reactor') { + text += `The damage to the reactor caused by the last rebellion is extensive. Businesses and private citizens struggle to operate with the unreliable and limited energy production offered by the auxiliary generators.`; + growthEffect = random(1, 2); + } else if (facility === 'waterway') { + text += `The damage caused to the water supply of the arcology discourages immigration and causes the death of some of the poorest residents.`; + V.lowerClass -= random(20, 40); + V.middleClass -= random(10, 20); + V.upperClass -= random(10, 20); + V.topClass -= random(10, 20); + } else if (facility === 'arc') { + text += `The recent rebellion left the arcology wounded and it falls to its owner to fix it.`; + cashX(-5000, "personalBusiness"); + } + text += ` It will still take ${numberWithPluralOne(V.SecExp.rebellions.repairTime[facility], 'week')} to finish repair works.`; + + V.SecExp.rebellions.repairTime[facility]--; + IncreasePCSkills('engineering', 0.1); + if (V.SecExp.rebellions.repairTime[facility] === 0) { + delete V.SecExp.rebellions.repairTime[facility]; + } + } + return { + text: text, security: securityEffect, crime: crimeEffect, growth: growthEffect + }; +}; + +App.SecExp.commanderEffectiveness = function(passage) { + const r = []; + const oldRep = V.rep; + const oldAuth = V.SecExp.core.authority; + const commander = V.SecExp.war.commander; + const inHandler = passage === "handler"; + const { + HisA, + himA, + } = getPronouns(V.assistant.personality > 0 ? assistant.pronouns().main : {pronoun: App.Data.Pronouns.Kind.ai}).appendSuffix("A"); + const {hisP} = getPronouns(V.PC).appendSuffix("P"); + + let woundChance = 5; // leader has a base chance of 5% to get wounded + let slaveMod = 0; + let mercMod = 0; + let militiaMod = 0; + let SFMod = 0; + let enemyMod = 0; + let atkMod = 0; + let defMod = 0; + let tacChance = 0; + let slave; + let isBodyguard; + + if (commander === "headGirl" && S.HeadGirl) { + slave = S.HeadGirl; + } else if (commander === "bodyguard" && S.Bodyguard) { + slave = S.Bodyguard; + isBodyguard = true; + } + + switch(commander) { + case "PC": + if (inHandler) { + if (V.SecExp.core.authority <= 2500 && V.SecExp.core.authority > 1000) { + slaveMod -= 0.10; + } else if (V.SecExp.core.authority <= 1000) { + slaveMod -= 0.25; + } else if (V.SecExp.core.authority >= 5000 && V.SecExp.core.authority < 15000) { + slaveMod += 0.10; + } else if (V.SecExp.core.authority >= 15000) { + slaveMod += 0.25; + } + if (["escort", "prostitute", "servant"].includes(V.PC.career)) { + slaveMod += 0.10; + } else if (V.PC.career === "child prostitute" && V.PC.visualAge >= V.minimumSlaveAge) { + slaveMod += 0.05; + } else if (["slaver", "slave overseer", "slave tender"].includes(V.PC.career)) { + slaveMod -= 0.10; + } + if (V.rep <= 2500 && V.rep > 1000) { + militiaMod -= 0.10; + } else if (V.rep <= 1000) { + militiaMod -= 0.25; + } else if (V.rep >= 5000 && V.rep < 15000) { + militiaMod += 0.10; + } else if (V.rep >= 15000) { + militiaMod += 0.25; + } + if (V.PC.career === "celebrity" || V.PC.career === "capitalist") { + militiaMod += 0.10; + } else if (V.PC.career === "gang" || V.PC.career === "escort") { + militiaMod -= 0.10; + } + if (V.PC.career === "mercenary" || V.PC.skill.warfare > 75) { + mercMod += 0.10; + SFMod += 0.10; + } else if (V.PC.career === "wealth" || V.PC.career === "servant") { + mercMod -= 0.10; + SFMod -= 0.10; + } + if (V.rep >= 15000) { + enemyMod -= 0.10; + } + if (V.PC.skill.warfare <= 25 && V.PC.skill.warfare > 10) { + atkMod -= 0.15; + tacChance -= 0.15; + } else if (V.PC.skill.warfare <= 10) { + atkMod -= 0.20; + defMod -= 0.10; + tacChance -= 0.30; + } else if (V.PC.skill.warfare >= 50 && V.PC.skill.warfare < 75) { + atkMod += 0.15; + tacChance += 0.15; + } else if (V.PC.skill.warfare >= 75) { + atkMod += 0.20; + defMod += 0.10; + tacChance += 0.30; + } + // 80% chance of increasing warfare + if (V.PC.skill.warfare < 100 && random(1, 100) <= 80) { + V.SecExp.war.gainedWarfare = 1; + IncreasePCSkills('warfare', 10); + V.PC.skill.warfare = Math.clamp(V.PC.skill.warfare, -100, 100); + } + // does the PC get wounded? + if (V.PC.career === "mercenary" || V.PC.career === "gang") { + woundChance -= 3; + } else if (V.PC.skill.warfare >= 75) { + woundChance -= 2; + } + if (V.PC.physicalAge >= 60) { + woundChance += 1; + } + if (V.PC.belly > 5000) { + woundChance += 1; + } + if (V.PC.boobs >= 1000) { + woundChance += 1; + } + if (V.PC.butt >= 4) { + woundChance += 1; + } + if (V.PC.preg >= 30) { + woundChance += 1; + } + if (V.PC.balls >= 20) { + woundChance += 1; + } + if (V.PC.balls >= 9) { + woundChance += 1; + } + if (random(1, 100) <= woundChance) { + V.SecExp.war.leaderWounded = 1; + militiaMod -= 0.2; + slaveMod -= 0.2; + mercMod -= 0.2; + SFMod -= 0.2; + enemyMod += 0.2; + healthDamage(V.PC, 60); + } + } else { + r.push(`You decided to personally lead the defense of your arcology.`); + if (App.SecExp.battle.deployedUnits('militia') >= 1) { + if (oldRep <= 2500) { + if (oldRep > 1000) { + r.push(`You're not particularly popular between the inhabitants of your arcology, so your presence does little to reassure the volunteers.`); + } else { + r.push(`As your low reputation proves, your volunteers do not particularly enjoy your company. As far as they are concerned your presence is more of a hindrance than an advantage.`); + } + if (V.PC.career === "celebrity") { + r.push(`Still, your past celebrity does carry some weight, and many look forward to fight alongside a famous name.`); + } else if (V.PC.career === "capitalist") { + r.push(`Still, your past life as a famous venture capitalist does carry some weight, and many trust in your cunning to save them in the incoming battle.`); + } else if (V.PC.career === "gang") { + r.push(`The situation is not made easier by your past. Many still remember you as the gang leader who used to be on the other side of their guns.`); + } else if (V.PC.career === "escort") { + r.push(`The situation is not made easier by your past. Many still remember your past career as an escort and doubt you'll be of any use during the fighting.`); + } else if (V.PC.career === "mercenary") { + r.push(`Still, your past mercenary work does carry some weight, and many look forward to fight alongside a battle hardened name.`); + } + } else if (oldRep >= 5000) { + if (oldRep < 15000) { + r.push(`Your citizens are honored that their arcology owner is willing to put ${hisP} life in danger.`); + } else { + r.push(`Many among the volunteers are awed by your presence; never would they have thought they would fight shoulder to shoulder with their famous arcology owner.`); + } + if (V.PC.career === "celebrity") { + r.push(`They consider it a priceless opportunity to fight together with someone with such a renowned past as yours. Your celebrity past still carries weight.`); + } else if (V.PC.career === "capitalist") { + r.push(`They consider it a priceless opportunity to fight together with one of the great capitalist sharks of their time. Such a fine mind on their side can only bring victory!`); + } else if (V.PC.career === "gang") { + r.push(`Your past, however, does not help you. Many still remember you as the gang leader who used to be on the other side of their guns.`); + } else if (V.PC.career === "escort") { + r.push(`Your past, however, does not help you. Many still remember your past career as an escort and doubt you'll be of any use during the fighting.`); + } else if (V.PC.career === "mercenary") { + r.push(`Your past mercenary work does carries some weight, and many look forward to fight alongside a battle hardened name.`); + } + } + } + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + if (oldAuth <= 2500) { + if (oldAuth > 1000) { + r.push(`Your slave soldiers do not feel bound to you as much as they should, as your authority is far from absolute.`); + } else { + r.push(`Your slave soldiers are often openly rebellious. Only the threat of execution holds them in line.`); + } + if (V.PC.career === "escort") { + r.push(`Fortunately many feel some level of kinship with you, thanks to your past as an escort.`); + } else if (V.PC.career === "servant") { + r.push(`Fortunately many feel some level of kinship with you, thanks to your past as a servant.`); + } else if (V.PC.career === "slaver") { + r.push(`Things are made worse by your past as a notorious slaver.`); + } else if (V.PC.career === "mercenary") { + r.push(`Your past mercenary work carries some weight, and many look forward to fighting alongside a battle hardened name.`); + } + } else if (oldAuth >= 5000) { + if (oldAuth < 15000) { + r.push(`Your slave soldiers show a surprising amount of discipline, thanks to your high authority.`); + } else { + r.push(`Your slave soldiers show almost a fanatical level of martial discipline. Your absolute authority has a great effect on them.`); + } + if (V.PC.career === "escort") { + r.push(`Many have an instinctual feeling of kinship towards you because of your past as an escort.`); + } else if (V.PC.career === "servant") { + r.push(`Many have an instinctual feeling of kinship towards you because of your past as a servant.`); + } else if (V.PC.career === "slaver") { + r.push(`Still, some rebellious looks can be spotted once in a while. In their eyes your slaver past will always paint you in a dark light.`); + } else if (V.PC.career === "mercenary") { + r.push(`Your past mercenary work carries some weight, and many look forward to fighting alongside a battle hardened name.`); + } + } + } + if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + const mercLoyalty = App.SecExp.mercenaryAvgLoyalty(); + if (mercLoyalty <= 25) { + if (mercLoyalty <= 10) { + r.push(`Your mercenaries barely bother to pretend being loyal; their battle performance is obviously barely passable.`); + } else { + r.push(`Your presence does little to spur your mercenaries into action; their loyalty is straining and their performance suffers.`); + } + if (V.PC.career === "mercenary") { + r.push(`Thankfully they hold in high regard someone who made their fortune as a mercenary themselves.`); + } else if (V.PC.career === "wealth") { + r.push(`They do little to hide the contempt they have for someone who was born into wealth, rather than gaining it through blood, sweat, and tears.`); + } else if (V.PC.career === "servant") { + r.push(`They do little to hide their disgust at being ordered around by an ex-servant.`); + } else if (V.PC.career === "BlackHat") { + r.push(`They do little to hide their disgust at being ordered around by some unscrupulous code monkey.`); + } + } else if (mercLoyalty >= 50) { + if (mercLoyalty < 75) { + r.push(`Your mercenaries are ready to fight their hardest for you, their loyalty a testament to your capability as a leader.`); + } else { + r.push(`Your mercenaries fight with a martial fury worthy of religious fanatics. Their loyalty to you is absolute.`); + } + if (V.PC.career === "mercenary") { + r.push(`They're more than willing to follow someone who walked their same steps once as a gun for hire.`); + } else if (V.PC.career === "wealth") { + r.push(`Unfortunately many still resent you being born into your wealth and power, rather than having earned it through blood, sweat, and tears.`); + } else if (V.PC.career === "servant") { + r.push(`Unfortunately some still resent the fact they are ordered around by an ex-servant.`); + } else if (V.PC.career === "BlackHat") { + r.push(`Unfortunately some still resent the fact they are ordered around by an unscrupulous hacker.`); + } + } + if (oldRep >= 15000) { + r.push(`Your reputation is so high your name carries power by itself. Having you on the battlefield puts fear even in the hardiest of warriors.`); + } + } + if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + if (V.PC.career === "mercenary" || V.PC.career === "slaver" || V.PC.career === "capitalist" || V.PC.career === "gang" || V.PC.skill.warfare > 75) { + r.push(`The soldiers of ${V.SF.Lower} are ready and willing to follow you into battle, confident in your past experience.`); + } else if (V.PC.career === "wealth" || V.PC.career === "medicine" || V.PC.career === "engineer") { + r.push(`The soldiers of ${V.SF.Lower}, as loyal as they are, are not enthusiastic to follow the orders of someone who has no experience leading men.`); + } else if (V.PC.career === "servant") { + r.push(`The soldiers of ${V.SF.Lower}, as loyal as they are, are not enthusiastic to follow the orders of an ex-servant.`); + } else if (V.PC.career === "escort") { + r.push(`The soldiers of ${V.SF.Lower}, as loyal as they are, are not enthusiastic to follow the orders of an ex-escort.`); + } else if (V.PC.career === "BlackHat") { + r.push(`The soldiers of ${V.SF.Lower}, as loyal as they are, are not enthusiastic to follow the orders of a dubious incursion specialist.`); + } + } + if (V.PC.skill.warfare <= 25 && V.PC.skill.warfare > 10) { + r.push(`Your inexperience in military matters has a negative impact on your troops performance and the effectiveness of your battle plan.`); + } else if (V.PC.skill.warfare <= 10) { + r.push(`Your ignorance in military matters has a severe negative impact on your troops performance and the effectiveness of your battle plan.`); + } else if (V.PC.skill.warfare >= 50) { + r.push(`Your experience in military matters has a positive impact on your troops performance and the effectiveness of your battle plan.`); + } else if (V.PC.skill.warfare >= 75) { + r.push(`Your great experience in military matters has a major positive impact on your troops performance and the effectiveness of your battle plan.`); + } + if (V.SecExp.war.gainedWarfare) { + r.push(`Battlefield experience increased your understanding of warfare, making you a better commander.`); + } + if (V.PC.health.shortDamage >= 60) { + r.push(`During the fighting <span class="red">you were wounded.</span> Your medics assure you it's nothing life threatening, but you'll be weakened for a few weeks.`); + } + } + break; + case "assistant": + if (inHandler) { + if (V.rep < 10000 && V.SecExp.core.authority < 10000) { + militiaMod -= 0.15; + slaveMod -= 0.15; + mercMod -= 0.15; + SFMod -= 0.15; + } + if (V.assistant.power === 0) { + atkMod -= 0.10; + defMod -= 0.10; + tacChance -= 0.20; + } else if (V.assistant.power === 2) { + atkMod += 0.10; + defMod += 0.10; + tacChance += 0.20; + } else if (V.assistant.power >= 3) { + atkMod += 0.15; + defMod += 0.15; + tacChance += 0.30; + } + } else { + r.push(`${V.assistant.name} lead the troops.`); + if (App.SecExp.battle.deployedUnits('mercs') >= 1 || App.SecExp.battle.deployedUnits('militia') >= 1 || App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`No soldier trusts a computer to be their commander,`); + if (oldRep < 10000 && oldAuth < 10000) { + r.push(`no algorithm can substitute experience,`); + if (V.assistant.power === 0) { + r.push(`and as expected,`); + } else { + r.push(`however,`); + } + } else { + r.push(`but they trust you enough to not question your decision,`); + if (V.assistant.power === 0) { + r.push(`however`); + } else { + r.push(`and`); + } + } + } else { + r.push(`You find`); + } + if (V.assistant.power === 0) { + r.push(`your assistant gave a rather poor field performance, due to the limited computing power available to ${himA}.`); + } else if (V.assistant.power === 1) { + r.push(`your assistant performed decently. While nothing to write home about your men are pleasantly surprised.`); + } else if (V.assistant.power === 2) { + r.push(`your assistant performed admirably. ${HisA} upgraded computing power allows ${himA} to monitor the battlefield closely, enhancing the efficiency of your troops and the effectiveness of your battle plan.`); + } else if (V.assistant.power >= 3) { + r.push(`your assistant performed admirably. ${HisA} vast computing power allows ${himA} to be everywhere on the battlefield, greatly enhancing the efficiency of your troops and the effectiveness of your battle plan.`); + } + } + break; + case "bodyguard": + case "HeadGirl": + const CareerGivesBonus = App.Data.Careers.Leader.bodyguard.includes(slave.career) || App.Data.Careers.Leader.HG.includes(slave.career) || setup.secExCombatPrestige.includes(slave.prestigeDesc); + const TotalIntelligence = slave.intelligence + slave.intelligenceImplant; + + if (inHandler) { + if (slave.devotion < -20) { + slaveMod -= 0.15; + } else if (slave.devotion > 50) { + slaveMod += 0.15; + } + if ((V.rep < 10000 && V.SecExp.core.authority < 10000) || slave.prestige < 1) { + militiaMod -= 0.15; + mercMod -= 0.15; + SFMod -= 0.15; + } else if (slave.prestige >= 2) { + militiaMod += 0.10; + mercMod += 0.10; + SFMod += 0.10; + } + if (CareerGivesBonus && TotalIntelligence > 95) { + atkMod += 0.25; + defMod += 0.25; + tacChance += 0.50; + } else if (TotalIntelligence > 95) { + atkMod += 0.20; + defMod += 0.15; + tacChance += 0.35; + } else if (CareerGivesBonus && TotalIntelligence > 50) { + atkMod += 0.15; + defMod += 0.10; + tacChance += 0.25; + } else if (TotalIntelligence > 50) { + atkMod += 0.10; + defMod += 0.10; + tacChance += 0.20; + } else if (CareerGivesBonus && TotalIntelligence > 15) { + atkMod += 0.10; + defMod += 0.05; + tacChance += 0.15; + } else if (TotalIntelligence > 15) { + atkMod += 0.5; + defMod += 0.05; + tacChance += 0.10; + } else if (!CareerGivesBonus || TotalIntelligence < -50) { + atkMod -= 0.15; + defMod -= 0.15; + tacChance -= 0.30; + } else if (TotalIntelligence < -50) { + atkMod -= 0.15; + defMod -= 0.10; + tacChance -= 0.25; + } else if (!CareerGivesBonus || TotalIntelligence < -15) { + atkMod -= 0.10; + defMod -= 0.10; + tacChance -= 0.20; + } else if (TotalIntelligence < -15) { + atkMod -= 0.10; + defMod -= 0.05; + tacChance -= 0.15; + } + // does she get wounded? + if (slave.skill.combat === 1) { + woundChance -= 3; + } + woundChance -= 0.25 * (getLimbCount(slave, 105)); + if (slave.health.condition >= 50) { + woundChance -= 1; + } + if (slave.weight > 130) { + woundChance += 1; + } + if (slave.muscles < -30) { + woundChance += 1; + } + if (getBestVision(slave) === 0) { + woundChance += 1; + } + if (slave.heels === 1) { + woundChance += 1; + } + if (slave.boobs >= 1400) { + woundChance += 1; + } + if (slave.butt >= 6) { + woundChance += 1; + } + if (slave.belly >= 10000) { + woundChance += 1; + } + if (slave.dick >= 8) { + woundChance += 1; + } + if (slave.balls >= 8) { + woundChance += 1; + } + if (TotalIntelligence < -95) { + woundChance += 1; + } + if (random(1, 100) <= woundChance) { + V.SecExp.war.leaderWounded = 1; + militiaMod -= 0.2; + slaveMod -= 0.2; + mercMod -= 0.2; + SFMod -= 0.2; + enemyMod += 0.2; + } + // 60% chance of getting combat skill if not already have it + if (slave.skill.combat === 0 && random(1,100) <= 60) { + V.SecExp.war.gainedCombat = 1; + slave.skill.combat = 1; + } + } else { + const { + His, He, + his, he, him + } = getPronouns(slave); + r.push(`Your ${isBodyguard ? 'bodyguard' : 'Head Girl'} lead the troops.`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + if (slave.devotion < -20) { + r.push(`${His} low devotion has a negative impact on the morale of your slave soldiers.`); + } else if (slave.devotion > 51) { + r.push(`${His} devotion to you has a positive impact on the morale of your slave soldiers, proud to be led by one of their own.`); + } + } + if (oldRep < 10000 && oldAuth < 10000 || slave.prestige < 1) { + if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Your volunteers`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`however`); + } + r.push(`are not enthusiastic to have a slave as a`); + if (V.SF.Toggle && V.SF.Active >= 1 && App.SecExp.battle.deployedUnits('mercs') === 1 && V.SecExp.war.deploySF) { + r.push(`commander, and neither are your mercenaries or your soldiers.`); + } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`commander, and neither are your mercenaries.`); + } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`commander, and neither are your soldiers.`); + } else { + r.push(`commander.`); + } + } else if (V.SF.Toggle && V.SF.Active >= 1 && App.SecExp.battle.deployedUnits('mercs') === 1 && V.SecExp.war.deploySF) { + r.push(`Your mercenaries and soldiers`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`however`); + } + r.push(`are not enthusiastic to have a slave as a commander.`); + } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Your mercenaries`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`however`); + } + r.push(`are not enthusiastic to have a slave as a commander.`); + } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`Your soldiers`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`however`); + } + r.push(`are not enthusiastic to have a slave as a commander.`); + } + } else if (slave.prestige >= 2) { + if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Your`); + if (App.SecExp.battle.deployedUnits('mercs') === 1 && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`volunteers, your mercenaries and your soldiers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); + } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`volunteers and your mercenaries are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); + } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`volunteers and your soldiers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); + } else { + r.push(`volunteers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); + } + } else if (App.SecExp.battle.deployedUnits('mercs') === 1 && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`Your mercenaries and soldiers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); + } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Your mercenaries are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); + } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`Your soldiers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); + } + } else { + if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Your volunteers`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`however`); + } + r.push(`are not enthusiastic to have a slave as a`); + if (App.SecExp.battle.deployedUnits('mercs') === 1 && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`commander, and neither are your mercenaries and soldiers, but they trust you enough not to question your decision.`); + } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`commander, and neither are your mercenaries, but they trust you enough not to question your decision.`); + } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`commander, and neither are your soldiers, but they trust you enough not to question your decision.`); + } else { + r.push(`commander, but they trust you enough not to question your decision.`); + } + } else if (App.SecExp.battle.deployedUnits('mercs') === 1 && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`Your mercenaries and soldiers`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`however,`); + } + r.push(`are not enthusiastic to have a slave as a commander, but they trust you enough not to question your decision.`); + } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Your mercenaries`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`however,`); + } + r.push(`are not enthusiastic to have a slave as a commander, but they trust you enough not to question your decision.`); + } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`Your soldiers`); + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`however,`); + } + r.push(`are not enthusiastic to have a slave as a commander, but they trust you enough not to question your decision.`); + } + } + + if (CareerGivesBonus && TotalIntelligence > 95) { + r.push(`With ${his} experience and ${his} great intellect, ${he} is able to exploit the smallest of tactical advantages, making your troops very effective.`); + } else if (TotalIntelligence > 95) { + r.push(`While ${he} lacks experience, ${his} great intellect allows ${him} to seize and exploit any tactical advantage the battlefield offers ${him}.`); + } else if (CareerGivesBonus && TotalIntelligence > 50) { + r.push(`Having both the experience and the intelligence, ${he} performs admirably as your commander. ${His} competence greatly increases the efficiency of your troops.`); + } else if (TotalIntelligence > 50) { + r.push(`Despite not having a lot of experience as a leader, ${his} intelligence makes ${him} a good commander, increasing the efficiency of your troops.`); + } else if (CareerGivesBonus && TotalIntelligence > 15) { + r.push(`Thanks to ${his} experience, ${he} is a decent commander, competently guiding your troops through the battle.`); + } else if (TotalIntelligence > 15) { + r.push(`Lacking experience, ${his} performance as a commander is rather forgettable.`); + } else if (CareerGivesBonus && TotalIntelligence < -50) { + r.push(`Despite the experience ${he} accumulated during ${his} past career, ${his} very low intelligence is a great disadvantage for your troops.`); + } else if (TotalIntelligence < -50) { + r.push(`Without experience and low intelligence, ${he} performs horribly as a commander, greatly affecting your troops.`); + } else if (CareerGivesBonus && TotalIntelligence < -15) { + r.push(`Despite the experience ${he} accumulated during ${his} past career, ${he} lacks the intelligence to apply it quickly and effectively, making for a rather poor performance in the field.`); + } else if (TotalIntelligence < -15) { + r.push(`${He} lacks the experience and the intelligence to be an effective commander, the performance of your troops suffers because of ${his} poor leadership.`); + } + if (V.SecExp.war.gainedCombat) { + r.push(`During the battle, ${he} had to fight for ${his} life, giving ${him} experience in modern combat. ${He} is now proficient with modern firearms and hand to hand combat.`); + } + if (V.SecExp.war.leaderWounded) { + r.push(`Unfortunately, <span class="red">${he} sustained major injuries.</span>`); + const woundType = App.SecExp.inflictBattleWound(slave); + if (woundType === "voice") { + r.push(`A stray bullet hit ${his} neck. While ${he} fortunately avoided fatal hemorrhaging, ${his} vocal cords were irreparably damaged.`); + } else if (woundType === "eyes") { + r.push(`Some shrapnel found ${his} eyes as their final target, blinding ${him} permanently.`); + } else if (woundType === "legs") { + r.push(`A grenade landed close to ${him}, and ${his} badly mangled legs had to be amputated.`); + } else if (woundType === "arm") { + r.push(`A shrapnel blast mangled one of ${his} arms, which had to be amputated.`); + } else if (woundType === "flesh") { + r.push(`While gravely wounded, it seems ${he} will be able to fully recover, given enough time.`); + } + r.push(`Your troops were greatly affected by the loss of their leader.`); + } + if (V.SecExp.war.result === 3 && V.SecExp.settings.battle.allowSlavePrestige === 1) { + let found; + for (const victory of V.SecExp.battles.slaveVictories) { + if (victory.ID === (isBodyguard ? V.BodyguardID : V.HeadGirlID)) { + victory.victories++; + found = 1; + if (victory.victories >= 10) { + if (slave.prestige < 3) { + slave.prestige++; + if (slave.prestige === 1) { + slave.prestigeDesc = "$He is well known for being a great commander."; + } else if (slave.prestige === 2) { + slave.prestigeDesc = "$He is famous for being an incredible commander."; + } else if (slave.prestige === 3) { + slave.prestigeDesc = "$He is known as a legendary commander all over the world."; + } + victory.victories = 0; + r.push(`${He} brought your army to victory so many times that ${his} <span class="green">prestige has increased.</span>`); + } + } + break; + } + } + if (!found) { + const newSlave = {ID: (isBodyguard ? V.BodyguardID : V.HeadGirlID), victories: 0}; + V.SecExp.battles.slaveVictories.push(newSlave); + } + } + } + break; + case "citizen": + if (inHandler) { + if (V.arcologies[0].FSDegradationist === "unset" && V.arcologies[0].FSPaternalist === "unset") { + militiaMod += 0.15; + slaveMod -= 0.15; + } else if (V.arcologies[0].FSPaternalist !== "unset") { + militiaMod += 0.15; + slaveMod += 0.10; + } else if (V.arcologies[0].FSDegradationist !== "unset") { + militiaMod += 0.15; + slaveMod -= 0.35; + } + if (V.arcologies[0].FSRomanRevivalist !== "unset" || V.arcologies[0].FSNeoImperialist !== "unset") { + mercMod += 0.10; + SFMod += 0.10; + } else { + mercMod -= 0.10; + SFMod -= 0.10; + } + atkMod += either(-1, 1) * random(10) * 0.1; + defMod += either(-1, 1) * random(10) * 0.1; + tacChance += either(-1, 1) * random(20) * 0.1; + } else { + r.push(`One of your volunteers was the commander.`); + if (V.arcologies[0].FSDegradationist === "unset" && V.arcologies[0].FSPaternalist === "unset") { + if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Your volunteers are honored and pleased that one of their own is leading the defense force of the city.`); + } + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`Your slaves${(App.SecExp.battle.deployedUnits('militia') >= 1) ? `, however,` : ``}are not thrilled by the news.`); + } + } else if (V.arcologies[0].FSPaternalist !== "unset") { + if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Your volunteers are honored and pleased that one of their own is leading the defense force of the city.`); + } + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`Thanks to your paternalistic society, your slave soldiers trust your chosen citizen to treat them as more than cannon fodder.`); + } + } else if (V.arcologies[0].FSDegradationist !== "unset") { + if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Your volunteers are honored and pleased that one of their own is leading the defense force of the city.`); + } + if (App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`Because of your degradationist society,`); + if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`however,`); + } + r.push(`your slave soldiers are deeply distrustful of the new leader.`); + } + } + if (V.arcologies[0].FSRomanRevivalist !== "unset" && App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Since you decided to revive old Rome, many of your citizens took on themselves to educate themselves in martial matters, because of this your mercenaries feel safe enough in the hands of one of your volunteers.`); + } else if (V.arcologies[0].FSNeoImperialist !== "unset" && App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Since having instituted an Imperial society, your citizens have become adept at modern warfare and your hardened mercenaries feel far more comfortable with one of your Imperial Knights in command.`); + } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Your mercenaries are not thrilled to be lead by a civilian without any formal martial training or education.`); + } + if (V.arcologies[0].FSRomanRevivalist !== "unset" && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`Since you decided to revive old Rome, many of your citizens took on themselves to educate themselves in martial matters, because of this your soldiers feel safe enough in the hands of one of your volunteers.`); + } else if (V.arcologies[0].FSNeoImperialist !== "unset" && App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Since having instituted an Imperial society, your citizens have become adept at modern warfare and the line soldiers feel much more comfortable being commanded by one of your Imperial Knights.`); + } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`You soldiers are not thrilled to be lead by a civilian without any formal martial training or education.`); + } + } + break; + case "mercenary": + if (inHandler) { + mercMod += 0.10; + SFMod += 0.10; + if (V.arcologies[0].FSRomanRevivalist !== "unset" || V.arcologies[0].FSNeoImperialist !== "unset") { + militiaMod += 0.10; + } else { + militiaMod -= 0.10; + } + if (V.arcologies[0].FSDegradationist !== "unset") { + slaveMod -= 0.35; + } + atkMod += random(15) * 0.1; + defMod += random(15) * 0.1; + tacChance += random(30) * 0.1; + } else { + r.push(`One of your mercenary officers took command.`); + if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Your mercenaries of course approve of your decision.`); + } + if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`Your soldiers feel more confident going into battle with an experienced commander.`); + } + if (V.arcologies[0].FSRomanRevivalist !== "unset" && App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Since you decided to revive old Rome, your volunteers are more willing to trust one of your mercenaries as their leader.`); + } else if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Your volunteers are not enthusiastic at the prospect of being commanded around by a gun for hire.`); + } + if (V.arcologies[0].FSDegradationist !== "unset" && App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`Because of your degradationist society, your slave soldiers are highly distrustful of the gun for hire you forced them to accept as leader.`); + } + } + break; + case "colonel": + if (inHandler) { + mercMod += 0.10; + SFMod += 0.15; + if (V.arcologies[0].FSRomanRevivalist !== "unset" || V.arcologies[0].FSNeoImperialist !== "unset") { + militiaMod += 0.10; + } else { + militiaMod -= 0.10; + } + if (V.arcologies[0].FSDegradationist !== "unset") { + slaveMod -= 0.35; + } + atkMod += random(30) * 0.1; + defMod += random(30) * 0.1; + tacChance += random(40) * 0.1; + } else { + r.push(`The Colonel was the commander.`); + if (App.SecExp.battle.deployedUnits('mercs') >= 1) { + r.push(`Your mercenaries approve of such decisions, as they feel more confident by having a good, experienced commander.`); + } + if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { + r.push(`The soldiers of ${V.SF.Lower} obviously approved of your decision.`); + } + if (V.arcologies[0].FSRomanRevivalist !== "unset" && App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Since you decided to revive old Rome, your volunteers are more willing to trust one of your soldiers as their leader.`); + } else if (V.arcologies[0].FSNeoImperialist !== "unset" && App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Under the strict hierarchy of your Imperial society, the militia is more willing to follow the Colonel's commands.`); + } else if (App.SecExp.battle.deployedUnits('militia') >= 1) { + r.push(`Your volunteers are not enthusiastic at the prospect of being commanded around by an old style military officer.`); + } + if (V.arcologies[0].FSDegradationist !== "unset" && App.SecExp.battle.deployedUnits('slaves') >= 1) { + r.push(`Because of your degradationist society, your slave soldiers are highly distrustful of the soldier you forced them to accept as leader.`); + } + } + } + + if (!inHandler && ["citizen", "mercenary", "colonel"].includes(commander) && V.SecExp.war.leaderWounded) { + r.push(`During the battle a stray bullet managed to reach them. Your troops were greatly affected by the loss.`); + } + + if (inHandler) { + return { + "slaveMod": slaveMod, + "militiaMod": militiaMod, + "mercMod": mercMod, + "SFMod": SFMod, + "enemyMod": enemyMod, + "atkMod": atkMod, + "defMod": defMod, + "tacChance": tacChance, + }; + } else { + return r; + } +}; + +App.SecExp.upkeep = (function() { + return { + edictsCash, + edictsAuth, + SF, + buildings + }; + + /** Upkeep cost of edicts, in cash + * @returns {number} + */ + function edictsCash() { + let value = 0; + if (V.SecExp.edicts.slaveWatch) { value++; } + if (V.SecExp.edicts.subsidyChurch) { value++; } + if (V.SecExp.edicts.tradeLegalAid) { value++; } + if (V.SecExp.edicts.propCampaignBoost) { value++; } + + if (V.SecExp.edicts.defense.martialSchool) { value++; } + + if (V.SecExp.edicts.defense.legionTradition) { value++; } + if (V.SecExp.edicts.defense.pharaonTradition) { value++; } + if (V.SecExp.edicts.defense.eagleWarriors) { value++; } + if (V.SecExp.edicts.defense.ronin) { value++; } + if (V.SecExp.edicts.defense.mamluks) { value++; } + if (V.SecExp.edicts.defense.sunTzu) { value++; } + + return value * 1000; + } + + /** Upkeep cost of edicts, in authority + * @returns {number} + */ + function edictsAuth() { + let value = 0; + if (V.SecExp.edicts.enslavementRights > 0) { + value += 10; + } + if (V.SecExp.edicts.sellData === 1) { + value += 10; + } + if (V.SecExp.edicts.defense.privilege.slaveSoldier === 1) { + value += 10; + } + if (V.SecExp.edicts.weaponsLaw === 0) { + value += 30; + } else if (V.SecExp.edicts.weaponsLaw === 1) { + value += 20; + } else if (V.SecExp.edicts.weaponsLaw === 2) { + value += 10; + } + if (V.SecExp.edicts.defense.slavesOfficers === 1) { + value += 10; + } + return value; + } + + /** Upkeep cost of Special Forces (why is this here? who knows!) + * @returns {number} + */ + function SF() { + let value = 0; + if (V.SecExp.edicts.SFSupportLevel >= 1) { + value += 1000; + } + if (V.SecExp.edicts.SFSupportLevel >= 2) { + value += 2000; + } + if (V.SecExp.edicts.SFSupportLevel >= 3) { + value += 3000; + } + if (V.SecExp.edicts.SFSupportLevel >= 4) { + value += 3000; + } + if (V.SecExp.edicts.SFSupportLevel >= 5) { + value += 4000; + } + return value; + } + + /** Upkeep cost of buildings (in cash) + * @returns {number} + */ + function buildings() { + let value = 0; + const base = V.facilityCost * 5; const upgrade = 50; + if (V.SecExp.buildings.propHub) { + value += base + upgrade * Object.values(V.SecExp.buildings.propHub.upgrades).reduce((a, b) => a + b); + } + if (V.SecExp.buildings.secHub) { + value += base + 20 * V.SecExp.buildings.secHub.menials; + value += upgrade * Object.values(V.SecExp.buildings.secHub.upgrades.security).reduce((a, b) => a + b); + value += upgrade * Object.values(V.SecExp.buildings.secHub.upgrades.crime).reduce((a, b) => a + b); + value += upgrade * Object.values(V.SecExp.buildings.secHub.upgrades.readiness).reduce((a, b) => a + b); + value += upgrade * Object.values(V.SecExp.buildings.secHub.upgrades.intel).reduce((a, b) => a + b); + value += V.SecExp.edicts.SFSupportLevel >= 5 ? 1000 : 0; + } + if (V.SecExp.buildings.barracks) { + value += base + upgrade * Object.values(V.SecExp.buildings.barracks).reduce((a, b) => a + b); + } + if (V.SecExp.buildings.riotCenter) { + value += base + upgrade * Object.values(V.SecExp.buildings.riotCenter.upgrades).reduce((a, b) => a + b); + if (V.SecExp.buildings.riotCenter.brainImplant < 106 && V.SecExp.buildings.riotCenter.brainImplantProject > 0) { + value += 5000 * V.SecExp.buildings.riotCenter.brainImplantProject; + } + if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.rebellions.sfArmor) { + value += 15000; + } + } + return value; + } +})(); + +/** Reports changes to the supplied unit's loyalty. + * @param {FC.SecExp.PlayerHumanUnitData} input the unit type to be checked. + * @param {FC.SecExp.PlayerHumanUnitType} type + * @returns {HTMLDivElement} + */ +App.SecExp.humanLoyaltyChanges = function(input, type) { + let loyaltyChange = 0, el = document.createElement("div"); + + el.append(`${input.platoonName}: `); + if (V.SecExp.buildings.barracks && V.SecExp.buildings.barracks.loyaltyMod >= 1) { + el.append("is periodically sent to the indoctrination facility in the barracks for thought correction therapy. "); + loyaltyChange += 2 * V.SecExp.buildings.barracks.loyaltyMod; + } + if (input.commissars >= 1) { + el.append("The commissars attached to the unit carefully monitor the officers and grunts for signs of insubordination. "); + loyaltyChange += 2 * input.commissars; + } + if (V.SecExp.edicts.defense.soldierWages === 2) { + if (type === 'slaves') { + el.append("The slaves greatly appreciate the generous wage given to them for their service as soldiers. Occasions to earn money for a slave are scarce after all. "); + } else if (type === 'militia') { + el.append("The soldiers greatly appreciate the generous wage given to them for their service. They are proud to defend their homes while making a small fortune out of it. "); + } else if (type === 'mercs') { + el.append("The mercenaries greatly appreciate the generous wage given to them for their service. After all coin is the fastest way to reach their hearts. "); + } + loyaltyChange += random(5, 10); + } else if (V.SecExp.edicts.defense.soldierWages === 1) { + if (type === 'slaves') { + el.append("The slaves appreciate the wage given to them for their service as soldiers, despite it being just adequate. Occasions to earn money for a slave are scarce after all. "); + } else if (type === 'militia') { + el.append("The soldiers appreciate the wage given to them for their service, despite it being just adequate. They are proud to defend their homes, though at the cost of possible financial gains. "); + } else if (type === 'mercs') { + el.append("The mercenaries do not appreciate the barely adequate wage given to them for their service. Still their professionalism keeps them determined to finish their contract. "); + } + loyaltyChange += random(-5, 5); + } else { + if (type === 'slaves') { + el.append("The slaves do not appreciate the low wage given to them for their service as soldiers, but occasions to earn money for a slave are scarce, so they're not too affected by it. "); + } else if (type === 'militia') { + el.append("The soldiers do not appreciate the low wage given to them for their service. Their sense of duty keeps them proud of their role as defenders of the arcology, but many do feel its financial weight. "); + } else if (type === 'mercs') { + el.append("The mercenaries do not appreciate the low wage given to them for their service. Their skill would be better served by a better contract and this world does not lack demand for guns for hire. "); + } + loyaltyChange -= random(5, 10); + } + if (type === 'slaves' && V.SecExp.edicts.defense.privilege.slaveSoldier) { + el.append("Allowing them to hold material possessions earns you their devotion and loyalty. "); + loyaltyChange += random(1, 2); + } + if (type === 'militia' && V.SecExp.edicts.defense.privilege.militiaSoldier) { + el.append("Allowing them to avoid rent payment for their military service earns you their happiness and loyalty. "); + loyaltyChange += random(1, 2); + } + if (type === 'mercs' && V.SecExp.edicts.defense.privilege.mercSoldier) { + el.append("Allowing them to keep part of the loot gained from your enemies earns you their trust and loyalty. "); + loyaltyChange += random(1, 2); + } + + el.append("This week, the loyalty of this unit "); + if (loyaltyChange > 0) { + App.UI.DOM.appendNewElement("span", el, "increased.", "green"); + } else if (loyaltyChange === 0) { + App.UI.DOM.appendNewElement("span", el, "did not change.", "yellow"); + } else { + App.UI.DOM.appendNewElement("span", el, "decreased.", "red"); + } + input.loyalty = Math.clamp(input.loyalty + loyaltyChange, 0, 100); + if (input.training < 100 && V.SecExp.buildings && V.SecExp.buildings.barracks.training >= 1) { + let options = document.createElement("div"); + options.append("The unit is able to make use of the training facilities to better prepare its soldiers, slowly increasing their experience level. "); + el.append(options); + input.training += random(2, 4) * 1.5 * V.SecExp.buildings.barracks.training; + } + + return el; +} diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js index db828c8e063..215bb2bd193 100644 --- a/src/Mods/SecExp/js/secExp.js +++ b/src/Mods/SecExp/js/secExp.js @@ -233,98 +233,11 @@ App.SecExp.generator = (function() { V.SecExp.war.attacker.equip = Math.clamp(V.SecExp.edicts.weaponsLaw + random((isSlaveRebellion ? -2 : -1), 1), 0, 4); V.SecExp.war.irregulars = Math.clamp(Math.trunc(V.ACitizens * irregularPercent * weekMod) + random(-100, 100), 50, V.ACitizens); V.SecExp.war.engageRule = 0; - V.SecExp.war.rebellingID = [].concat(App.SecExp.unit.humanSquads().map(u => u.loyalty).filter(isDisloyal)); + V.SecExp.war.rebellingID = App.SecExp.unit.humanSquads().map(u => u.loyalty).filter(isDisloyal); } } })(); -/** - * 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 {{text:string, bonus:number}} - */ -App.SecExp.assistanceSF = function(report, section = '') { - const size = V.SF.Toggle && V.SF.Active >= 1 ? App.SF.upgrades.total() : 0; - let r = ``; let 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 {{text:string, effect:number}}} - */ -App.SecExp.propagandaEffects = function(focus) { - let t = ``; let increase = 0; - if (V.secExpEnabled > 0 && V.SecExp.buildings.propHub && V.SecExp.buildings.propHub.upgrades.campaign >= 1 && V.SecExp.buildings.propHub.focus === focus) { - let campaign; let modifier; - const forcedViewing = V.SecExp.edicts.propCampaignBoost === 1; - const noRecruiter = V.SecExp.buildings.propHub.recruiterOffice === 0 || V.RecruiterID === 0; - const recruiterActive = V.SecExp.buildings.propHub.recruiterOffice && V.RecruiterID > 0; - switch (focus) { - case "social engineering": - campaign = 'societal engineering'; - modifier = forcedViewing ? V.SecExp.buildings.propHub.upgrades.campaign : 1; - if (noRecruiter) { - increase += (forcedViewing ? 2 : 1) * modifier; - } else if (recruiterActive) { - increase += modifier + Math.floor((S.Recruiter.intelligence + S.Recruiter.intelligenceImplant) / 32); - } - break; - case "recruitment": - campaign = 'militia recruitment'; - modifier = forcedViewing ? 0.2 : 0.15; - if (noRecruiter) { - increase += modifier + (forcedViewing ? 0.1 : 0.05); - } else if (recruiterActive) { - increase += modifier + Math.floor((S.Recruiter.intelligence + S.Recruiter.intelligenceImplant) / 650); - } - break; - case "immigration": - modifier = forcedViewing ? V.SecExp.buildings.propHub.upgrades.campaign : 1; - if (noRecruiter) { - increase += (forcedViewing ? random(1, 4) : random(1, 2)) * modifier; - } else if (recruiterActive) { - increase += modifier + Math.floor((S.Recruiter.intelligence + S.Recruiter.intelligenceImplant) / 16); - } - t = `Your advertisement campaign outside the free city brings more people to the gates of your arcology`; - break; - case "enslavement": - modifier = forcedViewing ? V.SecExp.buildings.propHub.upgrades.campaign : 1; - if (noRecruiter) { - increase += (forcedViewing ? random(0, 4) : random(0, 2)) * modifier; - } else if (recruiterActive) { - increase += modifier + Math.floor((S.Recruiter.intelligence + S.Recruiter.intelligenceImplant) / 16); - } - t = `Many were attracted by your advertisement campaigns.`; - break; - } - - if (focus === "social engineering" || focus === "recruitment") { - t += `<span class='green'>Your propaganda campaign helps further your ${campaign} efforts.`; - if (recruiterActive) { - t += ` <span class='slave-name'>${SlaveFullName(S.Recruiter)}</span> is boosting your ${campaign} campaign.`; - } - t += `</span>`; - } - } - return {text: t, effect: Math.round(increase)}; -}; - /** * Returns the raw percentage of society that can be drafted. * @returns {number} @@ -471,119 +384,6 @@ App.SecExp.generalInit = function() { App.SecExp.initTrade(); }; -App.SecExp.upkeep = (function() { - return { - edictsCash, - edictsAuth, - SF, - buildings - }; - - /** Upkeep cost of edicts, in cash - * @returns {number} - */ - function edictsCash() { - let value = 0; - if (V.SecExp.edicts.slaveWatch) { value++; } - if (V.SecExp.edicts.subsidyChurch) { value++; } - if (V.SecExp.edicts.tradeLegalAid) { value++; } - if (V.SecExp.edicts.propCampaignBoost) { value++; } - - if (V.SecExp.edicts.defense.martialSchool) { value++; } - - if (V.SecExp.edicts.defense.legionTradition) { value++; } - if (V.SecExp.edicts.defense.pharaonTradition) { value++; } - if (V.SecExp.edicts.defense.eagleWarriors) { value++; } - if (V.SecExp.edicts.defense.ronin) { value++; } - if (V.SecExp.edicts.defense.mamluks) { value++; } - if (V.SecExp.edicts.defense.sunTzu) { value++; } - - return value * 1000; - } - - /** Upkeep cost of edicts, in authority - * @returns {number} - */ - function edictsAuth() { - let value = 0; - if (V.SecExp.edicts.enslavementRights > 0) { - value += 10; - } - if (V.SecExp.edicts.sellData === 1) { - value += 10; - } - if (V.SecExp.edicts.defense.privilege.slaveSoldier === 1) { - value += 10; - } - if (V.SecExp.edicts.weaponsLaw === 0) { - value += 30; - } else if (V.SecExp.edicts.weaponsLaw === 1) { - value += 20; - } else if (V.SecExp.edicts.weaponsLaw === 2) { - value += 10; - } - if (V.SecExp.edicts.defense.slavesOfficers === 1) { - value += 10; - } - return value; - } - - /** Upkeep cost of Special Forces (why is this here? who knows!) - * @returns {number} - */ - function SF() { - let value = 0; - if (V.SecExp.edicts.SFSupportLevel >= 1) { - value += 1000; - } - if (V.SecExp.edicts.SFSupportLevel >= 2) { - value += 2000; - } - if (V.SecExp.edicts.SFSupportLevel >= 3) { - value += 3000; - } - if (V.SecExp.edicts.SFSupportLevel >= 4) { - value += 3000; - } - if (V.SecExp.edicts.SFSupportLevel >= 5) { - value += 4000; - } - return value; - } - - /** Upkeep cost of buildings (in cash) - * @returns {number} - */ - function buildings() { - let value = 0; - const base = V.facilityCost * 5; const upgrade = 50; - if (V.SecExp.buildings.propHub) { - value += base + upgrade * Object.values(V.SecExp.buildings.propHub.upgrades).reduce((a, b) => a + b); - } - if (V.SecExp.buildings.secHub) { - value += base + 20 * V.SecExp.buildings.secHub.menials; - value += upgrade * Object.values(V.SecExp.buildings.secHub.upgrades.security).reduce((a, b) => a + b); - value += upgrade * Object.values(V.SecExp.buildings.secHub.upgrades.crime).reduce((a, b) => a + b); - value += upgrade * Object.values(V.SecExp.buildings.secHub.upgrades.readiness).reduce((a, b) => a + b); - value += upgrade * Object.values(V.SecExp.buildings.secHub.upgrades.intel).reduce((a, b) => a + b); - value += V.SecExp.edicts.SFSupportLevel >= 5 ? 1000 : 0; - } - if (V.SecExp.buildings.barracks) { - value += base + upgrade * Object.values(V.SecExp.buildings.barracks).reduce((a, b) => a + b); - } - if (V.SecExp.buildings.riotCenter) { - value += base + upgrade * Object.values(V.SecExp.buildings.riotCenter.upgrades).reduce((a, b) => a + b); - if (V.SecExp.buildings.riotCenter.brainImplant < 106 && V.SecExp.buildings.riotCenter.brainImplantProject > 0) { - value += 5000 * V.SecExp.buildings.riotCenter.brainImplantProject; - } - if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.rebellions.sfArmor) { - value += 15000; - } - } - return value; - } -})(); - App.SecExp.battle = (function() { "use strict"; return { @@ -945,810 +745,3 @@ App.SecExp.inflictBattleWound = (function() { return doWound; })(); -App.SecExp.slavesDamaged = function(adjustValue) { - V.NPCSlaves -= Math.trunc((V.NPCSlaves / V.ASlaves) * adjustValue); - V.menials -= Math.trunc((V.menials / V.ASlaves) * adjustValue); - V.fuckdolls -= Math.trunc((V.fuckdolls / V.ASlaves) * adjustValue); - V.menialBioreactors -= Math.trunc((V.menialBioreactors / V.ASlaves) * adjustValue); -}; - -App.SecExp.updateFacilityDamage = function(facility) { - let text = ``; - let securityEffect = 0; - let crimeEffect = 0; - let growthEffect = 0; - if (V.SecExp.rebellions.repairTime[facility] !== undefined) { - if (facility === 'assistant') { - text += `With the central CPU core of the assistant down, managing security is a much harder task. Inevitably some little but important details will slip past your agents.`; - securityEffect = 1; - crimeEffect = 1; - } else if (facility === 'reactor') { - text += `The damage to the reactor caused by the last rebellion is extensive. Businesses and private citizens struggle to operate with the unreliable and limited energy production offered by the auxiliary generators.`; - growthEffect = random(1, 2); - } else if (facility === 'waterway') { - text += `The damage caused to the water supply of the arcology discourages immigration and causes the death of some of the poorest residents.`; - V.lowerClass -= random(20, 40); - V.middleClass -= random(10, 20); - V.upperClass -= random(10, 20); - V.topClass -= random(10, 20); - } else if (facility === 'arc') { - text += `The recent rebellion left the arcology wounded and it falls to its owner to fix it.`; - cashX(-5000, "personalBusiness"); - } - text += ` It will still take ${numberWithPluralOne(V.SecExp.rebellions.repairTime[facility], 'week')} to finish repair works.`; - - V.SecExp.rebellions.repairTime[facility]--; - IncreasePCSkills('engineering', 0.1); - if (V.SecExp.rebellions.repairTime[facility] === 0) { - delete V.SecExp.rebellions.repairTime[facility]; - } - } - return { - text: text, security: securityEffect, crime: crimeEffect, growth: growthEffect - }; -}; - -App.SecExp.commanderEffectiveness = function(passage) { - const r = []; - const oldRep = V.rep; - const oldAuth = V.SecExp.core.authority; - const commander = V.SecExp.war.commander; - const inHandler = passage === "handler"; - const { - HisA, - himA, - } = getPronouns(V.assistant.personality > 0 ? assistant.pronouns().main : {pronoun: App.Data.Pronouns.Kind.ai}).appendSuffix("A"); - const {hisP} = getPronouns(V.PC).appendSuffix("P"); - - let woundChance = 5; // leader has a base chance of 5% to get wounded - let slaveMod = 0; - let mercMod = 0; - let militiaMod = 0; - let SFMod = 0; - let enemyMod = 0; - let atkMod = 0; - let defMod = 0; - let tacChance = 0; - let slave; - let isBodyguard; - - if (commander === "headGirl" && S.HeadGirl) { - slave = S.HeadGirl; - } else if (commander === "bodyguard" && S.Bodyguard) { - slave = S.Bodyguard; - isBodyguard = true; - } - - switch(commander) { - case "PC": - if (inHandler) { - if (V.SecExp.core.authority <= 2500 && V.SecExp.core.authority > 1000) { - slaveMod -= 0.10; - } else if (V.SecExp.core.authority <= 1000) { - slaveMod -= 0.25; - } else if (V.SecExp.core.authority >= 5000 && V.SecExp.core.authority < 15000) { - slaveMod += 0.10; - } else if (V.SecExp.core.authority >= 15000) { - slaveMod += 0.25; - } - if (["escort", "prostitute", "servant"].includes(V.PC.career)) { - slaveMod += 0.10; - } else if (V.PC.career === "child prostitute" && V.PC.visualAge >= V.minimumSlaveAge) { - slaveMod += 0.05; - } else if (["slaver", "slave overseer", "slave tender"].includes(V.PC.career)) { - slaveMod -= 0.10; - } - if (V.rep <= 2500 && V.rep > 1000) { - militiaMod -= 0.10; - } else if (V.rep <= 1000) { - militiaMod -= 0.25; - } else if (V.rep >= 5000 && V.rep < 15000) { - militiaMod += 0.10; - } else if (V.rep >= 15000) { - militiaMod += 0.25; - } - if (V.PC.career === "celebrity" || V.PC.career === "capitalist") { - militiaMod += 0.10; - } else if (V.PC.career === "gang" || V.PC.career === "escort") { - militiaMod -= 0.10; - } - if (V.PC.career === "mercenary" || V.PC.skill.warfare > 75) { - mercMod += 0.10; - SFMod += 0.10; - } else if (V.PC.career === "wealth" || V.PC.career === "servant") { - mercMod -= 0.10; - SFMod -= 0.10; - } - if (V.rep >= 15000) { - enemyMod -= 0.10; - } - if (V.PC.skill.warfare <= 25 && V.PC.skill.warfare > 10) { - atkMod -= 0.15; - tacChance -= 0.15; - } else if (V.PC.skill.warfare <= 10) { - atkMod -= 0.20; - defMod -= 0.10; - tacChance -= 0.30; - } else if (V.PC.skill.warfare >= 50 && V.PC.skill.warfare < 75) { - atkMod += 0.15; - tacChance += 0.15; - } else if (V.PC.skill.warfare >= 75) { - atkMod += 0.20; - defMod += 0.10; - tacChance += 0.30; - } - // 80% chance of increasing warfare - if (V.PC.skill.warfare < 100 && random(1, 100) <= 80) { - V.SecExp.war.gainedWarfare = 1; - IncreasePCSkills('warfare', 10); - V.PC.skill.warfare = Math.clamp(V.PC.skill.warfare, -100, 100); - } - // does the PC get wounded? - if (V.PC.career === "mercenary" || V.PC.career === "gang") { - woundChance -= 3; - } else if (V.PC.skill.warfare >= 75) { - woundChance -= 2; - } - if (V.PC.physicalAge >= 60) { - woundChance += 1; - } - if (V.PC.belly > 5000) { - woundChance += 1; - } - if (V.PC.boobs >= 1000) { - woundChance += 1; - } - if (V.PC.butt >= 4) { - woundChance += 1; - } - if (V.PC.preg >= 30) { - woundChance += 1; - } - if (V.PC.balls >= 20) { - woundChance += 1; - } - if (V.PC.balls >= 9) { - woundChance += 1; - } - if (random(1, 100) <= woundChance) { - V.SecExp.war.leaderWounded = 1; - militiaMod -= 0.2; - slaveMod -= 0.2; - mercMod -= 0.2; - SFMod -= 0.2; - enemyMod += 0.2; - healthDamage(V.PC, 60); - } - } else { - r.push(`You decided to personally lead the defense of your arcology.`); - if (App.SecExp.battle.deployedUnits('militia') >= 1) { - if (oldRep <= 2500) { - if (oldRep > 1000) { - r.push(`You're not particularly popular between the inhabitants of your arcology, so your presence does little to reassure the volunteers.`); - } else { - r.push(`As your low reputation proves, your volunteers do not particularly enjoy your company. As far as they are concerned your presence is more of a hindrance than an advantage.`); - } - if (V.PC.career === "celebrity") { - r.push(`Still, your past celebrity does carry some weight, and many look forward to fight alongside a famous name.`); - } else if (V.PC.career === "capitalist") { - r.push(`Still, your past life as a famous venture capitalist does carry some weight, and many trust in your cunning to save them in the incoming battle.`); - } else if (V.PC.career === "gang") { - r.push(`The situation is not made easier by your past. Many still remember you as the gang leader who used to be on the other side of their guns.`); - } else if (V.PC.career === "escort") { - r.push(`The situation is not made easier by your past. Many still remember your past career as an escort and doubt you'll be of any use during the fighting.`); - } else if (V.PC.career === "mercenary") { - r.push(`Still, your past mercenary work does carry some weight, and many look forward to fight alongside a battle hardened name.`); - } - } else if (oldRep >= 5000) { - if (oldRep < 15000) { - r.push(`Your citizens are honored that their arcology owner is willing to put ${hisP} life in danger.`); - } else { - r.push(`Many among the volunteers are awed by your presence; never would they have thought they would fight shoulder to shoulder with their famous arcology owner.`); - } - if (V.PC.career === "celebrity") { - r.push(`They consider it a priceless opportunity to fight together with someone with such a renowned past as yours. Your celebrity past still carries weight.`); - } else if (V.PC.career === "capitalist") { - r.push(`They consider it a priceless opportunity to fight together with one of the great capitalist sharks of their time. Such a fine mind on their side can only bring victory!`); - } else if (V.PC.career === "gang") { - r.push(`Your past, however, does not help you. Many still remember you as the gang leader who used to be on the other side of their guns.`); - } else if (V.PC.career === "escort") { - r.push(`Your past, however, does not help you. Many still remember your past career as an escort and doubt you'll be of any use during the fighting.`); - } else if (V.PC.career === "mercenary") { - r.push(`Your past mercenary work does carries some weight, and many look forward to fight alongside a battle hardened name.`); - } - } - } - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - if (oldAuth <= 2500) { - if (oldAuth > 1000) { - r.push(`Your slave soldiers do not feel bound to you as much as they should, as your authority is far from absolute.`); - } else { - r.push(`Your slave soldiers are often openly rebellious. Only the threat of execution holds them in line.`); - } - if (V.PC.career === "escort") { - r.push(`Fortunately many feel some level of kinship with you, thanks to your past as an escort.`); - } else if (V.PC.career === "servant") { - r.push(`Fortunately many feel some level of kinship with you, thanks to your past as a servant.`); - } else if (V.PC.career === "slaver") { - r.push(`Things are made worse by your past as a notorious slaver.`); - } else if (V.PC.career === "mercenary") { - r.push(`Your past mercenary work carries some weight, and many look forward to fighting alongside a battle hardened name.`); - } - } else if (oldAuth >= 5000) { - if (oldAuth < 15000) { - r.push(`Your slave soldiers show a surprising amount of discipline, thanks to your high authority.`); - } else { - r.push(`Your slave soldiers show almost a fanatical level of martial discipline. Your absolute authority has a great effect on them.`); - } - if (V.PC.career === "escort") { - r.push(`Many have an instinctual feeling of kinship towards you because of your past as an escort.`); - } else if (V.PC.career === "servant") { - r.push(`Many have an instinctual feeling of kinship towards you because of your past as a servant.`); - } else if (V.PC.career === "slaver") { - r.push(`Still, some rebellious looks can be spotted once in a while. In their eyes your slaver past will always paint you in a dark light.`); - } else if (V.PC.career === "mercenary") { - r.push(`Your past mercenary work carries some weight, and many look forward to fighting alongside a battle hardened name.`); - } - } - } - if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - const mercLoyalty = App.SecExp.mercenaryAvgLoyalty(); - if (mercLoyalty <= 25) { - if (mercLoyalty <= 10) { - r.push(`Your mercenaries barely bother to pretend being loyal; their battle performance is obviously barely passable.`); - } else { - r.push(`Your presence does little to spur your mercenaries into action; their loyalty is straining and their performance suffers.`); - } - if (V.PC.career === "mercenary") { - r.push(`Thankfully they hold in high regard someone who made their fortune as a mercenary themselves.`); - } else if (V.PC.career === "wealth") { - r.push(`They do little to hide the contempt they have for someone who was born into wealth, rather than gaining it through blood, sweat, and tears.`); - } else if (V.PC.career === "servant") { - r.push(`They do little to hide their disgust at being ordered around by an ex-servant.`); - } else if (V.PC.career === "BlackHat") { - r.push(`They do little to hide their disgust at being ordered around by some unscrupulous code monkey.`); - } - } else if (mercLoyalty >= 50) { - if (mercLoyalty < 75) { - r.push(`Your mercenaries are ready to fight their hardest for you, their loyalty a testament to your capability as a leader.`); - } else { - r.push(`Your mercenaries fight with a martial fury worthy of religious fanatics. Their loyalty to you is absolute.`); - } - if (V.PC.career === "mercenary") { - r.push(`They're more than willing to follow someone who walked their same steps once as a gun for hire.`); - } else if (V.PC.career === "wealth") { - r.push(`Unfortunately many still resent you being born into your wealth and power, rather than having earned it through blood, sweat, and tears.`); - } else if (V.PC.career === "servant") { - r.push(`Unfortunately some still resent the fact they are ordered around by an ex-servant.`); - } else if (V.PC.career === "BlackHat") { - r.push(`Unfortunately some still resent the fact they are ordered around by an unscrupulous hacker.`); - } - } - if (oldRep >= 15000) { - r.push(`Your reputation is so high your name carries power by itself. Having you on the battlefield puts fear even in the hardiest of warriors.`); - } - } - if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - if (V.PC.career === "mercenary" || V.PC.career === "slaver" || V.PC.career === "capitalist" || V.PC.career === "gang" || V.PC.skill.warfare > 75) { - r.push(`The soldiers of ${V.SF.Lower} are ready and willing to follow you into battle, confident in your past experience.`); - } else if (V.PC.career === "wealth" || V.PC.career === "medicine" || V.PC.career === "engineer") { - r.push(`The soldiers of ${V.SF.Lower}, as loyal as they are, are not enthusiastic to follow the orders of someone who has no experience leading men.`); - } else if (V.PC.career === "servant") { - r.push(`The soldiers of ${V.SF.Lower}, as loyal as they are, are not enthusiastic to follow the orders of an ex-servant.`); - } else if (V.PC.career === "escort") { - r.push(`The soldiers of ${V.SF.Lower}, as loyal as they are, are not enthusiastic to follow the orders of an ex-escort.`); - } else if (V.PC.career === "BlackHat") { - r.push(`The soldiers of ${V.SF.Lower}, as loyal as they are, are not enthusiastic to follow the orders of a dubious incursion specialist.`); - } - } - if (V.PC.skill.warfare <= 25 && V.PC.skill.warfare > 10) { - r.push(`Your inexperience in military matters has a negative impact on your troops performance and the effectiveness of your battle plan.`); - } else if (V.PC.skill.warfare <= 10) { - r.push(`Your ignorance in military matters has a severe negative impact on your troops performance and the effectiveness of your battle plan.`); - } else if (V.PC.skill.warfare >= 50) { - r.push(`Your experience in military matters has a positive impact on your troops performance and the effectiveness of your battle plan.`); - } else if (V.PC.skill.warfare >= 75) { - r.push(`Your great experience in military matters has a major positive impact on your troops performance and the effectiveness of your battle plan.`); - } - if (V.SecExp.war.gainedWarfare) { - r.push(`Battlefield experience increased your understanding of warfare, making you a better commander.`); - } - if (V.PC.health.shortDamage >= 60) { - r.push(`During the fighting <span class="red">you were wounded.</span> Your medics assure you it's nothing life threatening, but you'll be weakened for a few weeks.`); - } - } - break; - case "assistant": - if (inHandler) { - if (V.rep < 10000 && V.SecExp.core.authority < 10000) { - militiaMod -= 0.15; - slaveMod -= 0.15; - mercMod -= 0.15; - SFMod -= 0.15; - } - if (V.assistant.power === 0) { - atkMod -= 0.10; - defMod -= 0.10; - tacChance -= 0.20; - } else if (V.assistant.power === 2) { - atkMod += 0.10; - defMod += 0.10; - tacChance += 0.20; - } else if (V.assistant.power >= 3) { - atkMod += 0.15; - defMod += 0.15; - tacChance += 0.30; - } - } else { - r.push(`${V.assistant.name} lead the troops.`); - if (App.SecExp.battle.deployedUnits('mercs') >= 1 || App.SecExp.battle.deployedUnits('militia') >= 1 || App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`No soldier trusts a computer to be their commander,`); - if (oldRep < 10000 && oldAuth < 10000) { - r.push(`no algorithm can substitute experience,`); - if (V.assistant.power === 0) { - r.push(`and as expected,`); - } else { - r.push(`however,`); - } - } else { - r.push(`but they trust you enough to not question your decision,`); - if (V.assistant.power === 0) { - r.push(`however`); - } else { - r.push(`and`); - } - } - } else { - r.push(`You find`); - } - if (V.assistant.power === 0) { - r.push(`your assistant gave a rather poor field performance, due to the limited computing power available to ${himA}.`); - } else if (V.assistant.power === 1) { - r.push(`your assistant performed decently. While nothing to write home about your men are pleasantly surprised.`); - } else if (V.assistant.power === 2) { - r.push(`your assistant performed admirably. ${HisA} upgraded computing power allows ${himA} to monitor the battlefield closely, enhancing the efficiency of your troops and the effectiveness of your battle plan.`); - } else if (V.assistant.power >= 3) { - r.push(`your assistant performed admirably. ${HisA} vast computing power allows ${himA} to be everywhere on the battlefield, greatly enhancing the efficiency of your troops and the effectiveness of your battle plan.`); - } - } - break; - case "bodyguard": - case "HeadGirl": - const CareerGivesBonus = App.Data.Careers.Leader.bodyguard.includes(slave.career) || App.Data.Careers.Leader.HG.includes(slave.career) || setup.secExCombatPrestige.includes(slave.prestigeDesc); - const TotalIntelligence = slave.intelligence + slave.intelligenceImplant; - - if (inHandler) { - if (slave.devotion < -20) { - slaveMod -= 0.15; - } else if (slave.devotion > 50) { - slaveMod += 0.15; - } - if ((V.rep < 10000 && V.SecExp.core.authority < 10000) || slave.prestige < 1) { - militiaMod -= 0.15; - mercMod -= 0.15; - SFMod -= 0.15; - } else if (slave.prestige >= 2) { - militiaMod += 0.10; - mercMod += 0.10; - SFMod += 0.10; - } - if (CareerGivesBonus && TotalIntelligence > 95) { - atkMod += 0.25; - defMod += 0.25; - tacChance += 0.50; - } else if (TotalIntelligence > 95) { - atkMod += 0.20; - defMod += 0.15; - tacChance += 0.35; - } else if (CareerGivesBonus && TotalIntelligence > 50) { - atkMod += 0.15; - defMod += 0.10; - tacChance += 0.25; - } else if (TotalIntelligence > 50) { - atkMod += 0.10; - defMod += 0.10; - tacChance += 0.20; - } else if (CareerGivesBonus && TotalIntelligence > 15) { - atkMod += 0.10; - defMod += 0.05; - tacChance += 0.15; - } else if (TotalIntelligence > 15) { - atkMod += 0.5; - defMod += 0.05; - tacChance += 0.10; - } else if (!CareerGivesBonus || TotalIntelligence < -50) { - atkMod -= 0.15; - defMod -= 0.15; - tacChance -= 0.30; - } else if (TotalIntelligence < -50) { - atkMod -= 0.15; - defMod -= 0.10; - tacChance -= 0.25; - } else if (!CareerGivesBonus || TotalIntelligence < -15) { - atkMod -= 0.10; - defMod -= 0.10; - tacChance -= 0.20; - } else if (TotalIntelligence < -15) { - atkMod -= 0.10; - defMod -= 0.05; - tacChance -= 0.15; - } - // does she get wounded? - if (slave.skill.combat === 1) { - woundChance -= 3; - } - woundChance -= 0.25 * (getLimbCount(slave, 105)); - if (slave.health.condition >= 50) { - woundChance -= 1; - } - if (slave.weight > 130) { - woundChance += 1; - } - if (slave.muscles < -30) { - woundChance += 1; - } - if (getBestVision(slave) === 0) { - woundChance += 1; - } - if (slave.heels === 1) { - woundChance += 1; - } - if (slave.boobs >= 1400) { - woundChance += 1; - } - if (slave.butt >= 6) { - woundChance += 1; - } - if (slave.belly >= 10000) { - woundChance += 1; - } - if (slave.dick >= 8) { - woundChance += 1; - } - if (slave.balls >= 8) { - woundChance += 1; - } - if (TotalIntelligence < -95) { - woundChance += 1; - } - if (random(1, 100) <= woundChance) { - V.SecExp.war.leaderWounded = 1; - militiaMod -= 0.2; - slaveMod -= 0.2; - mercMod -= 0.2; - SFMod -= 0.2; - enemyMod += 0.2; - } - // 60% chance of getting combat skill if not already have it - if (slave.skill.combat === 0 && random(1,100) <= 60) { - V.SecExp.war.gainedCombat = 1; - slave.skill.combat = 1; - } - } else { - const { - His, He, - his, he, him - } = getPronouns(slave); - r.push(`Your ${isBodyguard ? 'bodyguard' : 'Head Girl'} lead the troops.`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - if (slave.devotion < -20) { - r.push(`${His} low devotion has a negative impact on the morale of your slave soldiers.`); - } else if (slave.devotion > 51) { - r.push(`${His} devotion to you has a positive impact on the morale of your slave soldiers, proud to be led by one of their own.`); - } - } - if (oldRep < 10000 && oldAuth < 10000 || slave.prestige < 1) { - if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Your volunteers`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`however`); - } - r.push(`are not enthusiastic to have a slave as a`); - if (V.SF.Toggle && V.SF.Active >= 1 && App.SecExp.battle.deployedUnits('mercs') === 1 && V.SecExp.war.deploySF) { - r.push(`commander, and neither are your mercenaries or your soldiers.`); - } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`commander, and neither are your mercenaries.`); - } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`commander, and neither are your soldiers.`); - } else { - r.push(`commander.`); - } - } else if (V.SF.Toggle && V.SF.Active >= 1 && App.SecExp.battle.deployedUnits('mercs') === 1 && V.SecExp.war.deploySF) { - r.push(`Your mercenaries and soldiers`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`however`); - } - r.push(`are not enthusiastic to have a slave as a commander.`); - } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Your mercenaries`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`however`); - } - r.push(`are not enthusiastic to have a slave as a commander.`); - } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`Your soldiers`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`however`); - } - r.push(`are not enthusiastic to have a slave as a commander.`); - } - } else if (slave.prestige >= 2) { - if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Your`); - if (App.SecExp.battle.deployedUnits('mercs') === 1 && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`volunteers, your mercenaries and your soldiers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); - } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`volunteers and your mercenaries are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); - } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`volunteers and your soldiers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); - } else { - r.push(`volunteers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); - } - } else if (App.SecExp.battle.deployedUnits('mercs') === 1 && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`Your mercenaries and soldiers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); - } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Your mercenaries are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); - } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`Your soldiers are delighted to have such a prestigious individual as their commander, almost forgetting ${he} is a slave.`); - } - } else { - if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Your volunteers`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`however`); - } - r.push(`are not enthusiastic to have a slave as a`); - if (App.SecExp.battle.deployedUnits('mercs') === 1 && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`commander, and neither are your mercenaries and soldiers, but they trust you enough not to question your decision.`); - } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`commander, and neither are your mercenaries, but they trust you enough not to question your decision.`); - } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`commander, and neither are your soldiers, but they trust you enough not to question your decision.`); - } else { - r.push(`commander, but they trust you enough not to question your decision.`); - } - } else if (App.SecExp.battle.deployedUnits('mercs') === 1 && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`Your mercenaries and soldiers`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`however,`); - } - r.push(`are not enthusiastic to have a slave as a commander, but they trust you enough not to question your decision.`); - } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Your mercenaries`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`however,`); - } - r.push(`are not enthusiastic to have a slave as a commander, but they trust you enough not to question your decision.`); - } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`Your soldiers`); - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`however,`); - } - r.push(`are not enthusiastic to have a slave as a commander, but they trust you enough not to question your decision.`); - } - } - - if (CareerGivesBonus && TotalIntelligence > 95) { - r.push(`With ${his} experience and ${his} great intellect, ${he} is able to exploit the smallest of tactical advantages, making your troops very effective.`); - } else if (TotalIntelligence > 95) { - r.push(`While ${he} lacks experience, ${his} great intellect allows ${him} to seize and exploit any tactical advantage the battlefield offers ${him}.`); - } else if (CareerGivesBonus && TotalIntelligence > 50) { - r.push(`Having both the experience and the intelligence, ${he} performs admirably as your commander. ${His} competence greatly increases the efficiency of your troops.`); - } else if (TotalIntelligence > 50) { - r.push(`Despite not having a lot of experience as a leader, ${his} intelligence makes ${him} a good commander, increasing the efficiency of your troops.`); - } else if (CareerGivesBonus && TotalIntelligence > 15) { - r.push(`Thanks to ${his} experience, ${he} is a decent commander, competently guiding your troops through the battle.`); - } else if (TotalIntelligence > 15) { - r.push(`Lacking experience, ${his} performance as a commander is rather forgettable.`); - } else if (CareerGivesBonus && TotalIntelligence < -50) { - r.push(`Despite the experience ${he} accumulated during ${his} past career, ${his} very low intelligence is a great disadvantage for your troops.`); - } else if (TotalIntelligence < -50) { - r.push(`Without experience and low intelligence, ${he} performs horribly as a commander, greatly affecting your troops.`); - } else if (CareerGivesBonus && TotalIntelligence < -15) { - r.push(`Despite the experience ${he} accumulated during ${his} past career, ${he} lacks the intelligence to apply it quickly and effectively, making for a rather poor performance in the field.`); - } else if (TotalIntelligence < -15) { - r.push(`${He} lacks the experience and the intelligence to be an effective commander, the performance of your troops suffers because of ${his} poor leadership.`); - } - if (V.SecExp.war.gainedCombat) { - r.push(`During the battle, ${he} had to fight for ${his} life, giving ${him} experience in modern combat. ${He} is now proficient with modern firearms and hand to hand combat.`); - } - if (V.SecExp.war.leaderWounded) { - r.push(`Unfortunately, <span class="red">${he} sustained major injuries.</span>`); - const woundType = App.SecExp.inflictBattleWound(slave); - if (woundType === "voice") { - r.push(`A stray bullet hit ${his} neck. While ${he} fortunately avoided fatal hemorrhaging, ${his} vocal cords were irreparably damaged.`); - } else if (woundType === "eyes") { - r.push(`Some shrapnel found ${his} eyes as their final target, blinding ${him} permanently.`); - } else if (woundType === "legs") { - r.push(`A grenade landed close to ${him}, and ${his} badly mangled legs had to be amputated.`); - } else if (woundType === "arm") { - r.push(`A shrapnel blast mangled one of ${his} arms, which had to be amputated.`); - } else if (woundType === "flesh") { - r.push(`While gravely wounded, it seems ${he} will be able to fully recover, given enough time.`); - } - r.push(`Your troops were greatly affected by the loss of their leader.`); - } - if (V.SecExp.war.result === 3 && V.SecExp.settings.battle.allowSlavePrestige === 1) { - let found; - for (const victory of V.SecExp.battles.slaveVictories) { - if (victory.ID === (isBodyguard ? V.BodyguardID : V.HeadGirlID)) { - victory.victories++; - found = 1; - if (victory.victories >= 10) { - if (slave.prestige < 3) { - slave.prestige++; - if (slave.prestige === 1) { - slave.prestigeDesc = "$He is well known for being a great commander."; - } else if (slave.prestige === 2) { - slave.prestigeDesc = "$He is famous for being an incredible commander."; - } else if (slave.prestige === 3) { - slave.prestigeDesc = "$He is known as a legendary commander all over the world."; - } - victory.victories = 0; - r.push(`${He} brought your army to victory so many times that ${his} <span class="green">prestige has increased.</span>`); - } - } - break; - } - } - if (!found) { - const newSlave = {ID: (isBodyguard ? V.BodyguardID : V.HeadGirlID), victories: 0}; - V.SecExp.battles.slaveVictories.push(newSlave); - } - } - } - break; - case "citizen": - if (inHandler) { - if (V.arcologies[0].FSDegradationist === "unset" && V.arcologies[0].FSPaternalist === "unset") { - militiaMod += 0.15; - slaveMod -= 0.15; - } else if (V.arcologies[0].FSPaternalist !== "unset") { - militiaMod += 0.15; - slaveMod += 0.10; - } else if (V.arcologies[0].FSDegradationist !== "unset") { - militiaMod += 0.15; - slaveMod -= 0.35; - } - if (V.arcologies[0].FSRomanRevivalist !== "unset" || V.arcologies[0].FSNeoImperialist !== "unset") { - mercMod += 0.10; - SFMod += 0.10; - } else { - mercMod -= 0.10; - SFMod -= 0.10; - } - atkMod += either(-1, 1) * random(10) * 0.1; - defMod += either(-1, 1) * random(10) * 0.1; - tacChance += either(-1, 1) * random(20) * 0.1; - } else { - r.push(`One of your volunteers was the commander.`); - if (V.arcologies[0].FSDegradationist === "unset" && V.arcologies[0].FSPaternalist === "unset") { - if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Your volunteers are honored and pleased that one of their own is leading the defense force of the city.`); - } - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`Your slaves${(App.SecExp.battle.deployedUnits('militia') >= 1) ? `, however,` : ``}are not thrilled by the news.`); - } - } else if (V.arcologies[0].FSPaternalist !== "unset") { - if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Your volunteers are honored and pleased that one of their own is leading the defense force of the city.`); - } - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`Thanks to your paternalistic society, your slave soldiers trust your chosen citizen to treat them as more than cannon fodder.`); - } - } else if (V.arcologies[0].FSDegradationist !== "unset") { - if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Your volunteers are honored and pleased that one of their own is leading the defense force of the city.`); - } - if (App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`Because of your degradationist society,`); - if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`however,`); - } - r.push(`your slave soldiers are deeply distrustful of the new leader.`); - } - } - if (V.arcologies[0].FSRomanRevivalist !== "unset" && App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Since you decided to revive old Rome, many of your citizens took on themselves to educate themselves in martial matters, because of this your mercenaries feel safe enough in the hands of one of your volunteers.`); - } else if (V.arcologies[0].FSNeoImperialist !== "unset" && App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Since having instituted an Imperial society, your citizens have become adept at modern warfare and your hardened mercenaries feel far more comfortable with one of your Imperial Knights in command.`); - } else if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Your mercenaries are not thrilled to be lead by a civilian without any formal martial training or education.`); - } - if (V.arcologies[0].FSRomanRevivalist !== "unset" && V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`Since you decided to revive old Rome, many of your citizens took on themselves to educate themselves in martial matters, because of this your soldiers feel safe enough in the hands of one of your volunteers.`); - } else if (V.arcologies[0].FSNeoImperialist !== "unset" && App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Since having instituted an Imperial society, your citizens have become adept at modern warfare and the line soldiers feel much more comfortable being commanded by one of your Imperial Knights.`); - } else if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`You soldiers are not thrilled to be lead by a civilian without any formal martial training or education.`); - } - } - break; - case "mercenary": - if (inHandler) { - mercMod += 0.10; - SFMod += 0.10; - if (V.arcologies[0].FSRomanRevivalist !== "unset" || V.arcologies[0].FSNeoImperialist !== "unset") { - militiaMod += 0.10; - } else { - militiaMod -= 0.10; - } - if (V.arcologies[0].FSDegradationist !== "unset") { - slaveMod -= 0.35; - } - atkMod += random(15) * 0.1; - defMod += random(15) * 0.1; - tacChance += random(30) * 0.1; - } else { - r.push(`One of your mercenary officers took command.`); - if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Your mercenaries of course approve of your decision.`); - } - if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`Your soldiers feel more confident going into battle with an experienced commander.`); - } - if (V.arcologies[0].FSRomanRevivalist !== "unset" && App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Since you decided to revive old Rome, your volunteers are more willing to trust one of your mercenaries as their leader.`); - } else if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Your volunteers are not enthusiastic at the prospect of being commanded around by a gun for hire.`); - } - if (V.arcologies[0].FSDegradationist !== "unset" && App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`Because of your degradationist society, your slave soldiers are highly distrustful of the gun for hire you forced them to accept as leader.`); - } - } - break; - case "colonel": - if (inHandler) { - mercMod += 0.10; - SFMod += 0.15; - if (V.arcologies[0].FSRomanRevivalist !== "unset" || V.arcologies[0].FSNeoImperialist !== "unset") { - militiaMod += 0.10; - } else { - militiaMod -= 0.10; - } - if (V.arcologies[0].FSDegradationist !== "unset") { - slaveMod -= 0.35; - } - atkMod += random(30) * 0.1; - defMod += random(30) * 0.1; - tacChance += random(40) * 0.1; - } else { - r.push(`The Colonel was the commander.`); - if (App.SecExp.battle.deployedUnits('mercs') >= 1) { - r.push(`Your mercenaries approve of such decisions, as they feel more confident by having a good, experienced commander.`); - } - if (V.SF.Toggle && V.SF.Active >= 1 && V.SecExp.war.deploySF) { - r.push(`The soldiers of ${V.SF.Lower} obviously approved of your decision.`); - } - if (V.arcologies[0].FSRomanRevivalist !== "unset" && App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Since you decided to revive old Rome, your volunteers are more willing to trust one of your soldiers as their leader.`); - } else if (V.arcologies[0].FSNeoImperialist !== "unset" && App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Under the strict hierarchy of your Imperial society, the militia is more willing to follow the Colonel's commands.`); - } else if (App.SecExp.battle.deployedUnits('militia') >= 1) { - r.push(`Your volunteers are not enthusiastic at the prospect of being commanded around by an old style military officer.`); - } - if (V.arcologies[0].FSDegradationist !== "unset" && App.SecExp.battle.deployedUnits('slaves') >= 1) { - r.push(`Because of your degradationist society, your slave soldiers are highly distrustful of the soldier you forced them to accept as leader.`); - } - } - } - - if (!inHandler && ["citizen", "mercenary", "colonel"].includes(commander) && V.SecExp.war.leaderWounded) { - r.push(`During the battle a stray bullet managed to reach them. Your troops were greatly affected by the loss.`); - } - - if (inHandler) { - return { - "slaveMod": slaveMod, - "militiaMod": militiaMod, - "mercMod": mercMod, - "SFMod": SFMod, - "enemyMod": enemyMod, - "atkMod": atkMod, - "defMod": defMod, - "tacChance": tacChance, - }; - } else { - return r; - } -}; diff --git a/src/Mods/SecExp/js/secExpBC.js b/src/Mods/SecExp/js/secExpBC.js index 1f9091c3cdd..74d5742d1c3 100644 --- a/src/Mods/SecExp/js/secExpBC.js +++ b/src/Mods/SecExp/js/secExpBC.js @@ -40,8 +40,8 @@ App.SecExp.generalBC = function() { V.SecExp.edicts.SFSupportLevel = V.SecExp.edicts.SFSupportLevel || V.SFSupportLevel || 0; V.SecExp.edicts.limitImmigration = V.SecExp.edicts.limitImmigration || V.limitImmigration || 0; V.SecExp.edicts.openBorders = V.SecExp.edicts.openBorders || V.openBorders || 0; - V.SecExp.edicts.weaponsLaw = V.weaponsLaw || V.SecExp.edicts.weaponsLaw.isBetween(0, 3, true) ? V.SecExp.edicts.weaponsLaw : 3; - + V.SecExp.edicts.weaponsLaw = V.weaponsLaw || Math.clamp(V.SecExp.edicts.weaponsLaw, 0, 3) || 3; + V.SecExp.edicts.defense.soldierWages = V.SecExp.edicts.defense.soldierWages || V.soldierWages || 1; V.SecExp.edicts.defense.slavesOfficers = V.SecExp.edicts.defense.slavesOfficers || V.slavesOfficers || 0; V.SecExp.edicts.defense.discountMercenaries = V.SecExp.edicts.defense.discountMercenaries || V.discountMercenaries || 0; @@ -101,10 +101,6 @@ App.SecExp.generalBC = function() { App.SecExp.unit.gen('militia', { count: V.createdMilitiaUnits, killed: V.militiaTotalCasualties, squads: V.militiaUnits, free: V.militiaFreeManpower }); - if (jsDef(V.SecExp.defaultNames) && (V.SecExp.defaultNames.milita || V.SecExp.defaultNames.militia)) { - V.SecExp.units.militia.defaultName = V.SecExp.defaultNames.milita || V.SecExp.defaultNames.militia; - delete V.SecExp.defaultNames.milita; delete V.SecExp.defaultNames.militia; - } App.SecExp.unit.gen('mercs', { count: V.createdMercUnits, killed: V.mercTotalCasualties, squads: V.mercUnits, free: V.mercFreeManpower @@ -125,6 +121,7 @@ App.SecExp.generalBC = function() { if (V.SecExp.defaultNames) { V.SecExp.units.slaves.defaultName = V.SecExp.defaultNames.slaves; + V.SecExp.units.militia.defaultName = V.SecExp.defaultNames.milita || V.SecExp.defaultNames.militia; V.SecExp.units.mercs.defaultName = V.SecExp.defaultNames.mercs; delete V.SecExp.defaultNames; } diff --git a/src/Mods/SecExp/js/securityReport.js b/src/Mods/SecExp/js/securityReport.js index 386dd731b3b..c7cd4628362 100644 --- a/src/Mods/SecExp/js/securityReport.js +++ b/src/Mods/SecExp/js/securityReport.js @@ -448,7 +448,7 @@ App.SecExp.securityReport = function() { if (activeUnits > 0) { // loyalty and training for (const unit of App.SecExp.unit.list().slice(1)) { for (const squad of V.SecExp.units[unit].squads) { - r.push(App.SecExp.unit.humanLoyaltyChanges(squad, unit)); + r.push(App.SecExp.humanLoyaltyChanges(squad, unit)); } } } @@ -473,11 +473,11 @@ App.SecExp.securityReport = function() { } if (V.SecExp.buildings.weapManu) { - if (App.SecExp.weapManuUpgrade.fully().bots && App.SecExp.weapManuUpgrade.fully().human) { + if (App.SecExp.weapManu.upgrade("fully").all) { delete V.SecExp.buildings.weapManu.upgrades.queue; } if (jsDef(V.SecExp.buildings.weapManu.upgrades.queue) && V.SecExp.buildings.weapManu.upgrades.queue.length > 0 && V.SecExp.buildings.weapManu.upgrades.queue[0].time > 0) { - let current = App.SecExp.weapManuUpgrade.current(); V.SecExp.buildings.weapManu.upgrades.queue[0].time--; + let current = App.SecExp.weapManu.upgrade("current"); V.SecExp.buildings.weapManu.upgrades.queue[0].time--; r.push(`<br>In the research lab, ${current.dec}`); switch (current.dec) { case "adaptive armored frames": -- GitLab