From 0374d8a8382112cc2ed82c0ec06ab5b0ecdf40ba Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 29 Jan 2025 15:46:37 +0100 Subject: fixup use of can_naval_blockade_route and add fix for states.supply_source use common convenience function --- rules.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index a54a52c..b00a282 100644 --- a/rules.js +++ b/rules.js @@ -3502,7 +3502,7 @@ states.supply_source = { if (port_supply > 0 && stronghold_supply === 0) { game.where = loc; // blockade at source or destination - if (can_naval_blockade(get_lord_locale(game.command)) || can_naval_blockade(game.where)) { + if (can_naval_blockade_supply()) { game.state = "blockade_supply"; } else { @@ -3541,6 +3541,15 @@ function end_supply() { delete game.supply; game.where = NOWHERE; } +function can_naval_blockade_supply() { + if (can_naval_blockade(game.where)) + return true; + if (is_exile_box(get_lord_locale(game.command))) { + let dist = map_get(game.supply, game.where, 0); + return can_naval_blockade_route(dist); + } + return false; +} states.select_supply_type = { inactive: "Supply", prompt() { @@ -3556,7 +3565,7 @@ states.select_supply_type = { }, port() { // blockade at source or destination - if (can_naval_blockade(game.where) || (is_exile_box(get_lord_locale(game.command)) && can_naval_blockade_route(get_lord_locale(game.command)))) { + if (can_naval_blockade_supply()) { game.state = "blockade_supply"; } else { -- cgit v1.2.3