From 9776f1c65f5f8cb7cfed7dd92c5f96145b138bfd Mon Sep 17 00:00:00 2001 From: Blank_Alt <12406-Blank_Alt@users.noreply.gitgud.io> Date: Fri, 8 Jan 2021 16:38:59 -0800 Subject: [PATCH] Hotfix collection --- devNotes/Useful JS Function Documentation.txt | 2 -- src/Mods/SecExp/buildings/securityHQ.tw | 2 +- src/Mods/SecExp/js/Unit.js | 33 ++++++++++++++----- src/Mods/SecExp/js/secExp.js | 2 +- src/Mods/SecExp/js/secExpBC.js | 9 +++-- src/Mods/SecExp/js/securityReport.js | 4 +++ src/Mods/SpecialForce/SpecialForce.js | 3 ++ src/Mods/SpecialForce/WeeklyChoices.tw | 8 +++-- src/npc/surgery/bodySwap/bodySwap.js | 2 +- src/uncategorized/scheduledEvent.tw | 6 +--- 10 files changed, 46 insertions(+), 25 deletions(-) diff --git a/devNotes/Useful JS Function Documentation.txt b/devNotes/Useful JS Function Documentation.txt index 38ab1c21a08..4c85aa3bc1b 100644 --- a/devNotes/Useful JS Function Documentation.txt +++ b/devNotes/Useful JS Function Documentation.txt @@ -403,8 +403,6 @@ releaseRestricted - returns true if the slave has some kind of rule limiting the Other Functions: UtilJS [script] - html5passage(passage_function) - circumvents SugarCube, allowing a plain HTML5 UI within it - cmToInchString() - takes an integer e.g. $activeSlave.hLength, returns a string in the format 10 inches cmToFootInchString() - takes an integer e.g. $activeSlave.height, returns a string in the format 6'5" diff --git a/src/Mods/SecExp/buildings/securityHQ.tw b/src/Mods/SecExp/buildings/securityHQ.tw index 923858dec71..0cbcb456dbc 100644 --- a/src/Mods/SecExp/buildings/securityHQ.tw +++ b/src/Mods/SecExp/buildings/securityHQ.tw @@ -292,7 +292,7 @@ Considering the current upgrades the maximum level of crime is <<print App.SecEx <<if $SecExp.core.authority > 10000>> <<if $SecExp.buildings.secHub.upgrades.readiness.rapidPlatforms == 0>> <br>[[Build rapid deployment platforms|securityHQ][cashX(-Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount), "capEx"), $SecExp.buildings.secHub.upgrades.readiness.rapidPlatforms = 1]] - <br>//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.// + <br>//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 10 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.// <<else>> <br>You have built rapid deployment platforms able to equip and deploy units within very limited time windows. <</if>> diff --git a/src/Mods/SecExp/js/Unit.js b/src/Mods/SecExp/js/Unit.js index fc260d1845a..d98249b95d1 100644 --- a/src/Mods/SecExp/js/Unit.js +++ b/src/Mods/SecExp/js/Unit.js @@ -150,15 +150,24 @@ App.SecExp.unit = (function() { /** Repairs unit if needed. * @param {object} [input] the unit to be checked. */ - function fixBroken(input) { - input.SF = input.SF || 0; - if (!jsDef(input.ID)) { - input.ID = genID(); + function fixBroken(unit, squad) { + squad.SF = squad.SF || 0; + if (!jsDef(squad.ID)) { + squad.ID = genID(); + } + squad.cyber = squad.cyber || 0; + squad.commissars = squad.commissars || 0; + squad.maxTroops = squad.maxTroops || 30; + squad.troops = Math.clamp(squad.troops, 0, squad.maxTroops); + if (squad.platoonName.contains('undefined')) { + if (unit === 'slaves') { + squad.platoonName = squad.platoonName.replace('undefined', 'slave platoon'); + } else if (unit === 'militia') { + squad.platoonName = squad.platoonName.replace('undefined', "citizens' platoon"); + } else if (unit === 'mercs') { + squad.platoonName = squad.platoonName.replace('undefined', 'mercenary platoon'); + } } - input.cyber = input.cyber || 0; - input.commissars = input.commissars || 0; - input.maxTroops = Math.min(30, input.maxTroops); - input.troops = Math.clamp(input.troops, 0, input.maxTroops); } /** Creates the requested unit object. @@ -175,6 +184,14 @@ App.SecExp.unit = (function() { if (type !== 'slaves') { V.SecExp.units[type].free = V.SecExp.units[type].free || updater.free || 0; } + + if (type === 'slaves') { + V.SecExp.units.slaves.defaultName = V.SecExp.units.slaves.defaultName || "slave platoon"; + } else if (type === 'militia') { + V.SecExp.units.militia.defaultName = V.SecExp.units.militia.defaultName || "citizens' platoon"; + } else if (type === 'mercs') { + V.SecExp.units.mercs.defaultName = V.SecExp.units.mercs.defaultName || "mercenary platoon"; + } } return; } diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js index ed05ff7e046..dd291f5f004 100644 --- a/src/Mods/SecExp/js/secExp.js +++ b/src/Mods/SecExp/js/secExp.js @@ -724,7 +724,7 @@ App.SecExp.battle = (function() { * @returns {number} */ function activeUnits() { - return V.SecExp.units.bots.active + App.SecExp.unit.humanSquads().length; + return (jsDef(V.SecExp.units.bots.active) ? V.SecExp.units.bots.active : 0) + App.SecExp.unit.humanSquads().length; } /** Get maximum active units diff --git a/src/Mods/SecExp/js/secExpBC.js b/src/Mods/SecExp/js/secExpBC.js index cb7bda64b44..618acf65d83 100644 --- a/src/Mods/SecExp/js/secExpBC.js +++ b/src/Mods/SecExp/js/secExpBC.js @@ -88,12 +88,10 @@ App.SecExp.generalBC = function() { } App.SecExp.unit.gen('slaves', {count: V.createdSlavesUnits, killed: V.slavesTotalCasualties, squads: V.slaveUnits}); - V.SecExp.units.slaves.defaultName = V.SecExp.units.slaves.defaultName || "slave platoon"; App.SecExp.unit.gen('militia', { count: V.createdMilitiaUnits, killed: V.militiaTotalCasualties, squads: V.militiaUnits, free: V.militiaFreeManpower }); - V.SecExp.units.militia.defaultName = V.SecExp.units.militia.defaultName || "citizens' platoon"; 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; @@ -102,7 +100,6 @@ App.SecExp.generalBC = function() { App.SecExp.unit.gen('mercs', { count: V.createdMercUnits, killed: V.mercTotalCasualties, squads: V.mercUnits, free: V.mercFreeManpower }); - V.SecExp.units.mercs.defaultName = V.SecExp.units.mercs.defaultName || "mercenary platoon"; if (V.SecExp.units.mercs.free === 0) { if (V.mercenaries === 1) { V.SecExp.units.mercs.free = 15; @@ -111,8 +108,10 @@ App.SecExp.generalBC = function() { } } - for (const squad of App.SecExp.unit.humanSquads()) { - App.SecExp.unit.fixBroken(squad); + for (const unit of App.SecExp.unit.list().slice(1)) { + for (const squad of V.SecExp.units[unit].squads) { + App.SecExp.unit.fixBroken(unit, squad); + } } if (V.SecExp.defaultNames) { diff --git a/src/Mods/SecExp/js/securityReport.js b/src/Mods/SecExp/js/securityReport.js index 8a7ee5f3cde..cd09fdd5620 100644 --- a/src/Mods/SecExp/js/securityReport.js +++ b/src/Mods/SecExp/js/securityReport.js @@ -508,6 +508,10 @@ App.SecExp.securityReport = function() { } } } + + if (V.SecExp.settings.battle.enabled > 0) { + App.SecExp.generator.attack(); + } const frag = new DocumentFragment(); $(frag).append(...App.Events.spaceSentences(r)); diff --git a/src/Mods/SpecialForce/SpecialForce.js b/src/Mods/SpecialForce/SpecialForce.js index 63742edcebd..5baccbb55ea 100644 --- a/src/Mods/SpecialForce/SpecialForce.js +++ b/src/Mods/SpecialForce/SpecialForce.js @@ -1443,6 +1443,7 @@ App.SF.AAR = function(endWeekCall = 1) { r += `<br>These activities have, overall, <span class='green'>improved your arcology's prosperity.</span>`; r += ` The goods procured by ${V.SF.Lower} after accounting for the spoils retained by individual soldiers were `; + V.SF.lastWeeksProfit = V.SF.lastWeeksProfit || 1; if (profit > 0) { r += `<span class='green'>more than sufficient to cover expenses.</span> Excess material and human assets totaling <span class='yellowgreen'>${cashFormat(profit)}</span> (after liquidation) and paying expenses were transferred to your accounts.`; if (V.economy < 100) { @@ -1452,6 +1453,8 @@ App.SF.AAR = function(endWeekCall = 1) { r += `<span class='red'>barely enough to cover expenses.</span> More growth will be needed to ensure profitability, <span class='yellow'>hopefully purchasing more upgrades will help.</span>`; r += ` Per the estimates that ${App.SF.SFC()} provides, an additional <span class='yellowgreen'>${cashFormat(profit)}</span> is required for sufficient cover.`; } + r += `An difference of ${profit/V.SF.lastWeeksProfit}% since last week`; + V.SF.lastWeeksProfit = profit; r += ` ${capSF} managed to recruit ${FNG} new soldiers this week, and your reputation has <span class='green'>increased through the improvement of trade security.</span>`; r += `<h3>Your instructions to ${App.SF.SFC()}:</h3>`; diff --git a/src/Mods/SpecialForce/WeeklyChoices.tw b/src/Mods/SpecialForce/WeeklyChoices.tw index f4295fb8b0c..82eb5a01dfb 100644 --- a/src/Mods/SpecialForce/WeeklyChoices.tw +++ b/src/Mods/SpecialForce/WeeklyChoices.tw @@ -67,11 +67,15 @@ <span id="result3"> <br><br>What do you want to do with The Colonel in the HQ? <br><<link "Talk" "Firebase">> - <<set $SF.Colonel.Talk = 2, $SF.Colonel.Status += 3, $SF.FS.Tension -= _colonelTalkTensionRuction>> + <<replace "#result3">> + <<set $SF.Colonel.Talk = 2, $SF.Colonel.Status += 3, $SF.FS.Tension -= _colonelTalkTensionRuction>> + <</replace>> <</link>> <br><<link "Learn" "Firebase">> - <<set $SF.Colonel.Talk = 3,$SF.Colonel.Status += 1, $SF.FS.Tension -= _colonelTalkTensionRuction>> + <<replace "#result3">> + <<set $SF.Colonel.Talk = 3,$SF.Colonel.Status += 1, $SF.FS.Tension -= _colonelTalkTensionRuction>> + <</replace>> <</link>> <<if $SF.Colonel.Status >= 45>> <br> diff --git a/src/npc/surgery/bodySwap/bodySwap.js b/src/npc/surgery/bodySwap/bodySwap.js index e2542c084a6..ee9e342304b 100644 --- a/src/npc/surgery/bodySwap/bodySwap.js +++ b/src/npc/surgery/bodySwap/bodySwap.js @@ -144,7 +144,7 @@ globalThis.bodySwap = function(soul, body, fromGenepool) { soul.haircuts = body.haircuts; soul.ovaryAge = body.ovaryAge; soul.readyOva = body.readyOva; - soul.womb = body.womb; // this is array assigned by reference, if slave body that is ${body} will be still used anywhere in code (not discarded) — it's WRONG (they now technically share one womb object). Please tell me about it then. But if old body body just discarded — it's no problem then. + soul.womb = body.womb; // this is array assigned by reference, if the slave body that is ${body} will be still used anywhere in code (not discarded) — it's WRONG (they now technically share one womb object). Please tell me about it then. But if the previous slave body is just discarded — it's no problem then. soul.pregAdaptation = body.pregAdaptation; soul.geneMods = body.geneMods; soul.NCSyouthening = body.NCSyouthening; diff --git a/src/uncategorized/scheduledEvent.tw b/src/uncategorized/scheduledEvent.tw index a3e1f99e31e..3c89102b59a 100644 --- a/src/uncategorized/scheduledEvent.tw +++ b/src/uncategorized/scheduledEvent.tw @@ -75,15 +75,11 @@ <<set $fcnn.push("...evidence of a planned slave uprising, executed all of their arcology's several thousand...")>> <</if>> -<<if $secExpEnabled > 0 && $SecExp.settings.battle.enabled > 0>> - <<= App.SecExp.generator.attack()>> -<</if>> - <<if $rivalOwner == -1>> <<goto "P rival initiation">> <<elseif $secExpEnabled > 0 && $foughtThisWeek === 0 && ($slaveRebellion === 1 || $citizenRebellion === 1)>> <<goto "rebellionOptions">> -<<elseif $secExpEnabled > 0 && $foughtThisWeek === 0 && $attackThisWeek == 1>> +<<elseif $secExpEnabled > 0 && $foughtThisWeek === 0 && jsDef($SecExp.war)>> <<goto "attackOptions">> <<elseif $PC.labor == 1>> <<goto "SE Player Birth">> -- GitLab