diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -520,6 +520,13 @@ function update_presence_and_control() { } } +function update_operations_possible() { + game.possible = 0 + for (let s of game.spaces) + if (is_present(s) || is_adjacent_to_control(s)) + game.possible |= (1 << s) +} + function is_present(s) { if (game.active === COMMUNE) return game.presence & (1 << s) @@ -1612,6 +1619,7 @@ function goto_operations(count, spaces) { function goto_operations_remove() { update_presence_and_control() + update_operations_possible() if (can_operations_remove()) game.state = "operations_remove" else @@ -1626,7 +1634,7 @@ function can_operations_remove() { } function can_operations_remove_space(s) { - if (is_present(s) || is_adjacent_to_control(s)) { + if (game.possible & (1 << s)) { let c = has_enemy_cube(s) let d = has_enemy_disc(s) if (c || d) { @@ -1690,8 +1698,9 @@ states.operations_remove = { if (is_military_space(s)) { let str = military_strength(s) if (str >= 3) { - logi("Remove " + pn + " from S" + s + ".") + log("Remove " + pn + " from S" + s + ".") remove_piece(p) + update_presence_and_control() resume_operations_remove() } else { log("Remove " + pn + " from S" + s + ".") @@ -1701,6 +1710,7 @@ states.operations_remove = { } else { log("Removed " + pn + " from S" + s + ".") remove_piece(p) + update_presence_and_control() resume_operations_remove() } }, @@ -1756,6 +1766,7 @@ function attempt_remove_piece(extra) { logi("Strength " + str + " vs " + ops) if (str >= ops) { remove_piece(p) + update_presence_and_control() logi("Success") } else { logi("Failure") @@ -1775,6 +1786,7 @@ function resume_operations_remove() { function goto_operations_place() { update_presence_and_control() + update_operations_possible() if (can_operations_place()) game.state = "operations_place" else @@ -1791,7 +1803,7 @@ function can_operations_place() { } function can_operations_place_space(s) { - if (is_present(s) || is_adjacent_to_control(s)) { + if (game.possible & (1 << s)) { if (can_place_cube(s)) { let d = has_enemy_disc(s) if (!d || game.count >= 2) @@ -3301,6 +3313,7 @@ exports.setup = function (seed, scenario, options) { presence: 0, control: 0, + possible: 0, pieces: [ // Commune cubes |