diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-02-07 13:38:53 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-02-07 13:38:53 +0100 |
commit | b4a0975f5f92765decd16febfc17a75cb3ce21e1 (patch) | |
tree | 59afb5e78ac3199145f02bc1f351a649c3af1e4f /rules.js | |
parent | 2469f0a6da414c5ad15256b3c4fe22bc11660e9d (diff) | |
download | julius-caesar-master.tar.gz |
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -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) |