From b4a0975f5f92765decd16febfc17a75cb3ce21e1 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 7 Feb 2025 13:38:53 +0100 Subject: Fix amphibious movement pinning! --- rules.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 56e0ff2..5645b57 100644 --- a/rules.js +++ b/rules.js @@ -432,6 +432,21 @@ function is_pinned(who) { return false } +function is_transport(b) { + return is_navis(b) && set_has(game.sea_moved, b) && !set_has(game.moved, b) +} + +function count_friendly_transports(where) { + let count = 0 + let p = game.active + for (let b = 0; b < block_count; ++b) { + if (game.location[b] === where && block_owner(b) === p) + if (is_transport(b)) + ++count + } + return count +} + function is_city(where) { let t = SPACES[where].type return t === "city" || t === "major-port" || t === "port" @@ -679,7 +694,7 @@ function can_block_move(b) { let from = game.location[b] if (is_pinned(b)) return false - if (set_has(game.sea_moved, from) && count_friendly(from) <= 1) + if (is_transport(b) && count_friendly_transports(from) <= 1) return false for (let to of SPACES[from].exits) { if (can_block_move_to(b, to)) { @@ -1496,7 +1511,9 @@ states.move_where = { log_move_start(from, to) logp("amphibious moved.") if (is_sea(to)) { - set_add(game.sea_moved, to) + for (let b = 0; b < block_count; ++b) + if (is_navis(b) && game.location[b] === to) + set_add(game.sea_moved, b) game.state = "amphibious_move_to" } else { set_add(game.moved, game.who) @@ -1570,7 +1587,9 @@ states.amphibious_move_to = { game.location[game.who] = to log_move_continue(to) if (is_sea(to)) { - set_add(game.sea_moved, to) + for (let b = 0; b < block_count; ++b) + if (is_navis(b) && game.location[b] === to) + set_add(game.sea_moved, b) game.state = "amphibious_move_to" } else { set_add(game.moved, game.who) -- cgit v1.2.3