summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-04-25 11:00:56 +0200
committerTor Andersson <tor@ccxvii.net>2025-04-25 11:00:56 +0200
commit4d20309060980a722b0f799277fc9df4cdb5e880 (patch)
tree3f9b50b9f93142679092e8cf293dcad4e89d6087 /rules.js
parent5f00aad6743dea47fbffe37324188533c2c06bc1 (diff)
downloadwilderness-war-4d20309060980a722b0f799277fc9df4cdb5e880.tar.gz
Allow leaders to continue moving after ax/dt must stop on land.
Track stop-on-land status separately. Downgrade land-or-boat movement to boat only after moving stopped-on-land units, rather than when they get flagged. This means we need to check if movement should be downgraded when leader is not moving alone.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js33
1 files changed, 26 insertions, 7 deletions
diff --git a/rules.js b/rules.js
index 49255e3..4cfc3f2 100644
--- a/rules.js
+++ b/rules.js
@@ -3215,6 +3215,16 @@ function gen_regular_move() {
let is_lone_ld = is_lone_leader(who)
let is_lone_ax = is_lone_auxiliary(who)
let has_dt = force_has_drilled_troops(who)
+ let type = game.move.type
+
+ // when ax/dt must stop moving on land, may continue by boat; leader may continue alone
+ if (game.move.stop_land && !is_lone_ld) {
+ if (type === 'boat-or-land')
+ type = 'boat'
+ else if (type !== 'boat')
+ return
+ }
+
for_each_exit(from, to => {
if (is_lone_ld) {
// Lone leaders can never enter an enemy occupied space
@@ -3229,7 +3239,7 @@ function gen_regular_move() {
}
}
- switch (game.move.type) {
+ switch (type) {
case 'boat-or-land':
if (can_move_by_boat_or_land(game.move.used, game.move.did_carry, from, to))
gen_action_move(from, to)
@@ -3249,11 +3259,17 @@ function stop_move() {
game.move.used = 9
}
-function stop_land_move() {
- if (game.move.type === 'boat-or-land')
- game.move.type = 'boat'
- else
- game.move.used = 9
+function stop_land_move(stop_all) {
+ if (stop_all) {
+ // nobody can continue by land
+ if (game.move.type === 'boat-or-land')
+ game.move.type = 'boat'
+ else
+ game.move.used = 9
+ } else {
+ // stop ax/dt but allow leader to continue by land
+ game.move.stop_land = 1
+ }
}
function would_be_infiltration_move(who, from, to) {
@@ -3296,6 +3312,9 @@ function apply_move(to) {
}
if (game.move.used > max_land_movement_cost('land'))
game.move.type = 'boat'
+ if (game.move.type === 'boat-or-land')
+ if (game.move.stop_land && !is_lone_leader(who))
+ game.move.type = 'boat'
}
if (game.move.type === 'land' || game.move.type === 'boat-or-land') {
@@ -3306,7 +3325,7 @@ function apply_move(to) {
// Must stop on mountains.
if (is_mountain(to) && !to_ff)
- stop_land_move()
+ stop_land_move(true)
// Must stop in the next space after passing through...
if (game.move.used > 1 && !from_ff) {