summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-05-01 21:43:56 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 12:53:17 +0100
commitdfaac7643a383491006c2c72a054336e967f8cd3 (patch)
tree2c02d3e436f975476236a926b444bf5938c9c007
parentce31007441aaf7d1bd561d15a0762b60b79b4ffb (diff)
downloadhammer-of-the-scots-dfaac7643a383491006c2c72a054336e967f8cd3.tar.gz
hammer: Show 'end retreat' button if no possible retreat paths.
This will automatically eliminate all remaining blocks. Fixes issue #1.
-rw-r--r--rules.js12
1 files changed, 8 insertions, 4 deletions
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)