diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 37 |
1 files changed, 35 insertions, 2 deletions
@@ -907,6 +907,11 @@ function for_each_axis_unit_on_map(fn) { fn(u) } +function for_each_allied_unit(fn) { + for (let u = first_allied_unit; u <= last_allied_unit; ++u) + fn(u) +} + function for_each_allied_unit_on_map(fn) { for (let u = first_allied_unit; u <= last_allied_unit; ++u) if (is_map_hex(unit_hex(u))) @@ -6350,8 +6355,10 @@ states.axis_player_initiative = { // === VICTORY CHECK === -const EXIT_EAST_EDGE = [ 99, 148, 197 ] +const EXIT_EAST_EDGE = [ 99, 148 ] +const EXIT_WEST_EDGE = [ 175 ] const EXIT_EAST = 47 +const EXIT_WEST = 53 function check_sudden_death_victory() { // Supplied units that move beyond the map "edge" exit the map. @@ -6366,22 +6373,48 @@ function check_sudden_death_victory() { }) } + for (let x of EXIT_WEST_EDGE) { + for_each_allied_unit(u => { + if (unit_hex(u) === x && is_unit_supplied(u)) { + log(`Exited the west map edge.`) + set_unit_hex(u, EXIT_WEST) + } + }) + } + let axis_exited = 0 for_each_axis_unit(u => { if (unit_hex(u) === EXIT_EAST) axis_exited++ }) - if (is_axis_hex(ALEXANDRIA) || axis_exited >= 3) { + let allied_exited = 0 + for_each_allied_unit(u => { + if (unit_hex(u) === EXIT_WEST) + allied_exited++ + }) + + if (is_axis_hex(ALEXANDRIA)) { log_br() log("Axis captured Alexandria!") return goto_game_over(AXIS, "Axis Strategic Victory!") } + if (axis_exited >= 3) { + log_br() + log("Axis exited three supplied units!") + return goto_game_over(AXIS, "Axis Strategic Victory!") + } + if (is_allied_hex(EL_AGHEILA)) { log_br() log("Allied captured El Agheila!") return goto_game_over(ALLIED, "Allied Strategic Victory!") } + if (is_allied_hex(EL_AGHEILA) || allied_exited >= 3) { + log_br() + log("Allied exited three supplied units!") + return goto_game_over(ALLIED, "Allied Strategic Victory!") + } return false } |