From dfaac7643a383491006c2c72a054336e967f8cd3 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 1 May 2021 21:43:56 +0200 Subject: hammer: Show 'end retreat' button if no possible retreat paths. This will automatically eliminate all remaining blocks. Fixes issue #1. --- rules.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index d44ec6a..557e69c 100644 --- a/rules.js +++ b/rules.js @@ -1780,11 +1780,15 @@ states.retreat = { return view.prompt = "Waiting for " + game.active + " to retreat."; view.prompt = "Retreat: Choose an army to move."; gen_action_undo(view); - if (!is_contested_area(game.where)) - gen_action(view, 'end_retreat'); - for (let b in BLOCKS) - if (game.location[b] == game.where && can_block_retreat(b)) + let can_retreat = false; + for (let b in BLOCKS) { + if (game.location[b] == game.where && can_block_retreat(b)) { gen_action(view, 'block', b); + can_retreat = true; + } + } + if (!is_contested_area(game.where) || !can_retreat) + gen_action(view, 'end_retreat'); }, end_retreat: function () { for (let b in BLOCKS) -- cgit v1.2.3