diff options
-rw-r--r-- | rules.js | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -4,7 +4,6 @@ /* TODO -victory & elector marker victory check supreme commander in mixed stacks supply phase @@ -537,6 +536,13 @@ function is_friendly_minor_home_country(s) { return false } +function get_home_power(s) { + for (let pow of all_powers) + if (set_has(all_home_country_fortresses[pow], s)) + return pow + return -1 +} + function is_enemy_controlled_fortress(s) { for (let other of all_enemy_powers(game.power)) if (is_power_controlled_fortress(other, s)) @@ -575,14 +581,14 @@ function is_space_protected_by_piece(s, p) { } function is_protected_from_conquest(s) { - /* - TODO - for (let pow of all_powers) { - for (let p of all_power_generals[pow]) - if (is_space_protected_by_piece(s, p)) - return true - } - */ + let owner = map_get(game.elector, s, -1) + if (owner < 0) + owner = map_get(game.victory, s, -1) + if (owner < 0) + owner = get_home_power(s) + for (let p of all_coop_generals(owner)) + if (is_space_protected_by_piece(s, p)) + return true return false } |