diff --git a/simulator.php b/simulator.php index 4deb8fc3..086d5382 100644 --- a/simulator.php +++ b/simulator.php @@ -215,45 +215,42 @@ function ($value, $key) use ($TechEquivalents) { } if (MORALE_ENABLED) { - if (!empty($AttackingFleets)) { - foreach ($AttackingFleets as $ThisUser => $ThisData) { - $ThisMoraleLevel = intval($_POST['atk_morale'][($ThisUser + 1)]); - $ThisMoraleLevel = keepInRange($ThisMoraleLevel, -100, 100); - - $AttackersData[$ThisUser]['moraleData'] = [ - 'morale_level' => $ThisMoraleLevel, - 'morale_points' => 0, - ]; + foreach ($AttackingFleets as $ThisUser => $ThisData) { + $ThisMoraleLevel = intval($_POST['atk_morale'][($ThisUser + 1)]); + $ThisMoraleLevel = keepInRange($ThisMoraleLevel, -100, 100); - $moraleCombatModifiers = Flights\Utils\Modifiers\calculateMoraleCombatModifiers([ - 'moraleLevel' => $ThisMoraleLevel, - ]); + $AttackersData[$ThisUser]['moraleData'] = [ + 'morale_level' => $ThisMoraleLevel, + 'morale_points' => 0, + ]; - $AttackingTechs[$ThisUser] = array_merge( - $AttackingTechs[$ThisUser], - $moraleCombatModifiers - ); - } + $moraleCombatModifiers = Flights\Utils\Modifiers\calculateMoraleCombatModifiers([ + 'moraleLevel' => $ThisMoraleLevel, + ]); + + $AttackingTechs[$ThisUser] = array_merge( + $AttackingTechs[$ThisUser], + $moraleCombatModifiers + ); } - if (!empty($DefendingFleets)) { - foreach ($DefendingFleets as $ThisUser => $ThisData) { - $ThisMoraleLevel = intval($_POST['def_morale'][($ThisUser + 1)]); - $ThisMoraleLevel = keepInRange($ThisMoraleLevel, -100, 100); - - $DefendersData[$ThisUser]['moraleData'] = [ - 'morale_level' => $ThisMoraleLevel, - 'morale_points' => 0, - ]; - $moraleCombatModifiers = Flights\Utils\Modifiers\calculateMoraleCombatModifiers([ - 'moraleLevel' => $ThisMoraleLevel, - ]); + foreach ($DefendingFleets as $ThisUser => $ThisData) { + $ThisMoraleLevel = intval($_POST['def_morale'][($ThisUser + 1)]); + $ThisMoraleLevel = keepInRange($ThisMoraleLevel, -100, 100); - $DefendingTechs[$ThisUser] = array_merge( - $DefendingTechs[$ThisUser], - $moraleCombatModifiers - ); - } + $DefendersData[$ThisUser]['moraleData'] = [ + 'morale_level' => $ThisMoraleLevel, + 'morale_points' => 0, + ]; + + $moraleCombatModifiers = Flights\Utils\Modifiers\calculateMoraleCombatModifiers([ + 'moraleLevel' => $ThisMoraleLevel, + ]); + + $DefendingTechs[$ThisUser] = array_merge( + $DefendingTechs[$ThisUser], + $moraleCombatModifiers + ); } }