summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-03-20 22:36:54 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commit19c86689d62ca0c2e03782bcd52cdeac653ef1d0 (patch)
treed49d5d6c656a692627669326845f372503fe6d8f
parentd8a2f8106db2a8a4d6012c4677191b7c439e02dd (diff)
downloadwilderness-war-19c86689d62ca0c2e03782bcd52cdeac653ef1d0.tar.gz
Fix cosmetic display of "boat or land" movement
... when moving further than land allowance.
-rw-r--r--rules.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/rules.js b/rules.js
index d6d72f3..2b08e98 100644
--- a/rules.js
+++ b/rules.js
@@ -1494,6 +1494,16 @@ function movement_allowance(who) {
return m;
}
+function potential_movement_allowance(who) {
+ let m = piece_movement(who);
+ for_each_unit_in_force(who, p => {
+ let pm = piece_movement(p);
+ if (pm > m)
+ m = pm;
+ });
+ return m;
+}
+
function moving_piece() {
return game.move.moving;
}
@@ -2673,6 +2683,10 @@ function max_land_movement_cost() {
return game.events.foul_weather ? 2 : movement_allowance(moving_piece());
}
+function max_potential_land_movement_cost() {
+ return game.events.foul_weather ? 2 : potential_movement_allowance(moving_piece());
+}
+
function max_movement_cost(type) {
switch (type) {
case 'boat-or-land':
@@ -2806,6 +2820,8 @@ function can_infiltrate_search(type, used, carry, from, to) {
type = 'land';
}
}
+ if (used > max_movement_cost('land'))
+ type = 'boat';
}
// See if we must stop.
@@ -2910,6 +2926,8 @@ function apply_move(to) {
game.move.type = 'land';
}
}
+ if (game.move.used > max_potential_land_movement_cost('land'))
+ game.move.type = 'boat';
}
if (game.move.type === 'land' || game.move.type === 'boat-or-land') {