From 551c834b8b842517926a7101edb7ab5bede35b80 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 17 Oct 2024 00:06:51 +0200 Subject: use is_map_space instead of hardcoded < ELIMINATED check --- rules.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rules.js b/rules.js index 718f593..bbfda27 100644 --- a/rules.js +++ b/rules.js @@ -535,7 +535,7 @@ function count_used_troops() { function count_unused_troops_on_map() { let n = 0 for (let p of all_power_generals[game.power]) - if (game.pos[p] < ELIMINATED) + if (is_map_space(game.pos[p])) n += 8 - game.troops[p] return n } @@ -635,7 +635,7 @@ function retire_general(p) { game.troops[p] = 0 set_in_supply(p) - if (s < ELIMINATED) { + if (is_map_space(s)) { for (let p of all_power_generals[game.power]) { if (game.pos[p] === s) { let x = Math.min(n, 8 - game.troops[p]) @@ -1060,7 +1060,7 @@ states.movement = { let done_trains = true for (let p of all_controlled_generals(game.power)) { - if (!set_has(game.moved, p) && game.pos[p] < ELIMINATED) { + if (!set_has(game.moved, p) && is_map_space(game.pos[p])) { if (can_general_move_anywhere(p)) { gen_action_piece(p) done_generals = false @@ -1069,7 +1069,7 @@ states.movement = { } for (let p of all_controlled_trains(game.power)) { - if (!set_has(game.moved, p) && game.pos[p] < ELIMINATED) { + if (!set_has(game.moved, p) && is_map_space(game.pos[p])) { if (can_train_move_anywhere(p)) { gen_action_piece(p) done_trains = false @@ -1424,7 +1424,7 @@ function end_move_piece() { /* RECRUITMENT */ function troop_cost() { - if (game.recruit.re_enter < ELIMINATED) + if (is_map_space(game.recruit.re_enter)) return 8 return 6 } @@ -1532,7 +1532,7 @@ states.re_enter_choose_city = { function has_re_entry_space(p) { let can_re_enter_at = is_general(p) ? can_re_enter_general : can_re_enter_supply_train - if (game.recruit.re_enter < ELIMINATED) + if (is_map_space(game.recruit.re_enter)) return can_re_enter_at(game.recruit.re_enter) for (let s of all_power_depots[game.power]) if (can_re_enter_at(s)) @@ -1687,7 +1687,7 @@ states.re_enter = { let p = game.selected[0] let can_re_enter_at = is_general(p) ? can_re_enter_general : can_re_enter_supply_train - if (game.recruit.re_enter < ELIMINATED) { + if (is_map_space(game.recruit.re_enter)) { if (can_re_enter_at(game.recruit.re_enter)) gen_action_space(game.recruit.re_enter) } else { @@ -1716,11 +1716,11 @@ function goto_combat() { let to = [] for (let p of all_controlled_generals(game.power)) - if (game.pos[p] < ELIMINATED) + if (is_map_space(game.pos[p])) set_add(from, game.pos[p]) for (let p of all_enemy_generals(game.power)) - if (game.pos[p] < ELIMINATED) + if (is_map_space(game.pos[p])) set_add(to, game.pos[p]) game.combat = [] @@ -2629,7 +2629,7 @@ const setup_piece_position = [ // P find_city("Grünberg"), - ELIMINATED, // TODO: find_city("Silesia V"), + find_city("Silesia Victory"), // S find_city("Meißen"), @@ -2733,7 +2733,7 @@ states.setup = { } else { let n_stacks = 0 for (let p of all_power_generals[game.power]) { - if (game.pos[p] < ELIMINATED && !set_has(game.moved, p)) { + if (is_map_space(game.pos[p]) && !set_has(game.moved, p)) { gen_action_piece(p) n_stacks ++ } -- cgit v1.2.3