diff --git a/src/Mods/SecExp/events/conflictHandler.js b/src/Mods/SecExp/events/conflictHandler.js index 4db2492736222b4436fe479ccc59a364911b643d..9966de4c783fd17fab2e2cc73de1ca73ad883282 100644 --- a/src/Mods/SecExp/events/conflictHandler.js +++ b/src/Mods/SecExp/events/conflictHandler.js @@ -388,20 +388,20 @@ App.Events.conflictHandler = function() { enemyDefense += unitData.defense * armyMod; enemyHp += unitData.hp; - for (const [unit] of Array.from(App.SecExp.unit.list()).slice(1)) { - for (let i = 0; i < V.SecExp.units[unit].squads.length; i++) { - if (App.SecExp.unit.isDeployed(V.SecExp.units[unit].squads[i])) { - if (unit === "slaves") { + for (const [type] of Array.from(App.SecExp.unit.list()).slice(1)) { + for (const unit of V.SecExp.units[type].squads) { + if (App.SecExp.unit.isDeployed(unit)) { + if (type === "slaves") { rebellingSlaves = 1; - } else if (unit === "militia") { + } else if (type === "militia") { rebellingMilitia = 1; - } else if (unit === "mercs") { + } else if (type === "mercs") { rebellingMercs = 1; } - V.SecExp.war.attacker.troops += V.SecExp.units[unit].squads[i].troops; - V.SecExp.units[unit].squads[i].loyalty = 0; - unitData = App.SecExp.getUnit(unit, i); + V.SecExp.war.attacker.troops += unit.troops; + unit.loyalty = 0; + unitData = App.SecExp.getUnit(type, unit); enemyAttack += unitData.attack; enemyDefense += unitData.defense; enemyHp += unitData.hp;