diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js index f8a3e6c6c52169eecbb5891c7db82bf9ed3b32c8..bf8581ba683f0a93040d86c95ede3edd1aa8b34d 100644 --- a/src/Mods/SecExp/js/secExp.js +++ b/src/Mods/SecExp/js/secExp.js @@ -4,12 +4,6 @@ App.SecExp.generator = (function() { rebellion, }; - function loyaltyCheck(squad) { - if ((squad.loyalty < 10 && random(1, 100) <= 70) || (squad.loyalty < 33 && random(1, 100) <= 30) || (squad.loyalty < 66 && random(1, 100) <= 10)) { - rebellingID.push(squad.ID); - } - } - function shared() { V.SecExp.war = V.SecExp.war || {}; V.SecExp.war.commander = "assistant"; @@ -221,7 +215,7 @@ App.SecExp.generator = (function() { V.SecExp.rebellions.lastEncounterWeeks++; } else { const isSlaveRebellion = V.slaveRebellion === 1; - let weekMod, rebellingID = []; + let weekMod; if (V.week <= 30) { weekMod = 0.75 + (0.01+(V.week/200)); } else if (V.week <= 60) { @@ -241,23 +235,18 @@ App.SecExp.generator = (function() { const rebelPercent = 0.3 * authFactor; const irregularPercent = 0.2 * repFactor; - for (const unit of V.slaveUnits) { - loyaltyCheck(unit); - } - for (const unit of V.militiaUnits) { - loyaltyCheck(unit); - } - for (const unit of V.mercUnits) { - loyaltyCheck(unit); - } - + const isDisloyal = (squad) => ((squad.loyalty < 10 && random(1, 100) <= 70) || (squad.loyalty < 33 && random(1, 100) <= 30) || (squad.loyalty < 66 && random(1, 100) <= 10)); const baseValue = Math.trunc((isSlaveRebellion ? V.ASlaves : V.ACitizens) * rebelPercent * weekMod) + random(-100, 100); const highestValue = isSlaveRebellion ? V.ASlaves : V.ACitizens; V.SecExp.war.attacker.troops = Math.clamp(baseValue, 50, highestValue); 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 = rebellingID; + V.SecExp.war.rebellingID = [].concat( + V.slaveUnits.filter(isDisloyal).map(u => u.ID), + V.militiaUnits.filter(isDisloyal).map(u => u.ID), + V.mercUnits.filter(isDisloyal).map(u => u.ID) + ); } } })();