summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-26 00:20:13 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-30 21:59:25 +0200
commit66dfcd920e52ea0966cf5f4602545965cea2754c (patch)
tree1c6fa78a995806a709fe4eaf2c27581681e3dc66
parentc1ade0f7b543591989ffb90a54d147de155e3d0a (diff)
downloadfriedrich-66dfcd920e52ea0966cf5f4602545965cea2754c.tar.gz
moving away from daun shouldn't create new battles
-rw-r--r--rules.js36
1 files changed, 20 insertions, 16 deletions
diff --git a/rules.js b/rules.js
index 71b3e02..146e786 100644
--- a/rules.js
+++ b/rules.js
@@ -427,13 +427,17 @@ states.prussians_who_are_attacked_by_daun_may_move = {
},
piece(p) {
push_undo()
+ remove_stack_from_combat(game.pos[p])
game.selected = select_stack(game.pos[p])
game.state = "move_to_any_empty_adjacent_city"
},
next() {
clear_undo()
set_active_to_power(P_AUSTRIA)
- goto_combat_2()
+ if (game.combat.length > 0)
+ game.state = "combat"
+ else
+ goto_retroactive_conquest()
},
}
@@ -2301,18 +2305,6 @@ function inactive_defend() {
function goto_combat() {
set_clear(game.moved)
- if (game.fx === NEXT_TURN_ANY_PRUSSIANS_WHO_ARE_ATTACKED_BY_DAUN_MAY_MOVE_TO_ANY_EMPTY_ADJACENT_CITY) {
- if (are_prussians_attacked_by_daun()) {
- set_active_to_power(P_PRUSSIA)
- game.state = "prussians_who_are_attacked_by_daun_may_move"
- return
- }
- }
-
- goto_combat_2()
-}
-
-function goto_combat_2() {
let from = []
let to = []
@@ -2336,6 +2328,14 @@ function goto_combat_2() {
}
}
+ if (game.fx === NEXT_TURN_ANY_PRUSSIANS_WHO_ARE_ATTACKED_BY_DAUN_MAY_MOVE_TO_ANY_EMPTY_ADJACENT_CITY) {
+ if (are_prussians_attacked_by_daun()) {
+ set_active_to_power(P_PRUSSIA)
+ game.state = "prussians_who_are_attacked_by_daun_may_move"
+ return
+ }
+ }
+
if (game.combat.length > 0)
game.state = "combat"
else
@@ -2724,15 +2724,19 @@ function set_active_winner() {
set_active_defender()
}
+function remove_stack_from_combat(s) {
+ for (let i = game.combat.length - 2; i >= 0; i -= 2)
+ if (game.combat[i] === s || game.combat[i + 1] === s)
+ array_remove_pair(game.combat, i)
+}
+
function goto_retreat() {
let hits = Math.abs(game.count)
let loser = get_loser()
// no more fighting for the loser
- for (let i = game.combat.length - 2; i >= 0; i -= 2)
- if (game.combat[i] === loser || game.combat[i+1] === loser)
- array_remove_pair(game.combat, i)
+ remove_stack_from_combat(loser)
log("P" + get_supreme_commander(loser) + " lost " + hits + " troops.")