summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-02-06 16:17:35 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commitcf3dc393557f6db7f5ef922bb6a17f5a33c603e8 (patch)
treece1976447f76ca5e6f06c3732efc1238dfdee5cc
parent544a20b11f464df10a07c4d9cf9185fe69f8deb9 (diff)
downloadwilderness-war-cf3dc393557f6db7f5ef922bb6a17f5a33c603e8.tar.gz
Clean up resume_move and fix multiple naval move bug.
-rw-r--r--rules.js43
1 files changed, 24 insertions, 19 deletions
diff --git a/rules.js b/rules.js
index 07d46fd..1c3942a 100644
--- a/rules.js
+++ b/rules.js
@@ -14,7 +14,6 @@
// crucial missing bits
// TODO: track 'held'
-// TODO: re-evaluate fortress ownership and VP when pieces move or are eliminated
// TODO: battle VP awards
// TODO: leaders alone - retreat and stomped by enemies
@@ -1188,7 +1187,7 @@ function has_french_fortress(space) {
return is_fortress(space) && is_french_controlled_space(space);
}
-function has_french_fortification(space) {
+function has_french_fortifications(space) {
return has_french_stockade(space) || has_french_fort(space) || has_french_fortress(space);
}
@@ -2710,24 +2709,30 @@ function resume_move() {
throw Error("WHAT IS THIS");
}
- let who = moving_piece();
-
- const is_lone_ax = is_lone_auxiliary(who);
- const is_lone_ld = is_lone_leader(who);
-console.log("RESUME_MOVE_UNIT is_lone_ax=" + is_lone_ax + " is_lone_ld=" + is_lone_ld);
- game.move.intercept = list_intercept_spaces(is_lone_ld, is_lone_ax);
+ console.log("RESUME_MOVE");
- switch (game.move.type) {
- case 'boat':
- search_boat_move(who, piece_space(who), game.move.start_cost, max_movement_cost());
- break;
- case 'land':
- search_land_move(who, piece_space(who), game.move.start_cost, max_movement_cost());
- break;
- case 'naval':
- if (may_naval_move(who))
- search_naval_move(who, piece_space(who), game.move.start_cost);
- break;
+ let max_cost = max_movement_cost();
+ if (game.move.start_cost < max_cost) {
+ let who = moving_piece();
+ const is_lone_ax = is_lone_auxiliary(who);
+ const is_lone_ld = is_lone_leader(who);
+ game.move.intercept = list_intercept_spaces(is_lone_ld, is_lone_ax);
+ switch (game.move.type) {
+ case 'boat':
+ search_boat_move(who, piece_space(who), game.move.start_cost, max_cost);
+ break;
+ case 'land':
+ search_land_move(who, piece_space(who), game.move.start_cost, max_cost);
+ break;
+ case 'naval':
+ if (may_naval_move(who))
+ search_naval_move(who, piece_space(who), game.move.start_cost);
+ break;
+ break;
+ }
+ } else {
+ game.move.cost = {};
+ game.move.path = {};
}
}