summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-08 02:29:44 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-08 02:29:44 +0100
commitbc4f9c520a403e7dea42e9c9d9198afab8a8f858 (patch)
tree93b8df97860e37a748ed1d5bb85e44b9eada29a2 /rules.js
parent150f4a380872f89db60cad9f476a650861024f79 (diff)
downloadmaria-bc4f9c520a403e7dea42e9c9d9198afab8a8f858.tar.gz
fix retreat mixed french/bavarian at map edge.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/rules.js b/rules.js
index 04974e2..d29a7d7 100644
--- a/rules.js
+++ b/rules.js
@@ -117,6 +117,7 @@ const IMPERIAL_ELECTION = 24
const ELIMINATED = data.cities.name.length
const ARENBERG = 17
+const BAVARIAN_GENERAL = 18
const SAXONY_GENERAL = 19
const PRUSSIAN_TRAIN_2 = 23
@@ -1317,10 +1318,10 @@ function count_generals(to) {
function select_stack(s) {
let list = []
- for (let p of all_generals)
+ for (let p of all_generals_by_rank)
if ((game.supreme & (1<<p)) && game.pos[p] === s)
list.push(p)
- for (let p of all_generals)
+ for (let p of all_generals_by_rank)
if (!(game.supreme & (1<<p)) && game.pos[p] === s)
list.push(p)
return list
@@ -4135,8 +4136,6 @@ function resume_retreat() {
set_active_winner()
game.state = "retreat"
} else {
- // TODO: if mixed french/bavarian, eliminate bavarians and try again?
- // eliminate if there are no retreat possibilities
delete game.retreat
game.state = "retreat_eliminate_trapped"
}
@@ -4167,17 +4166,21 @@ states.retreat_eliminate_trapped = {
inactive: "retreat",
prompt() {
prompt("Eliminate " + format_selected() + " without a retreat path.")
- for (let p of game.selected)
- gen_action_piece(p)
+ // special case - bavarian + french mixed stack - eliminate bavarian first in case
+ // french can retreat to flanders.
+ if (game.selected.includes(BAVARIAN_GENERAL) && game.selected.length > 1)
+ gen_action_piece(BAVARIAN_GENERAL)
+ else
+ for (let p of game.selected)
+ gen_action_piece(p)
},
- piece(_) {
+ piece(p) {
log("Trapped.")
- for (let p of game.selected) {
- game.lost_generals += 1
- game.lost_troops += game.troops[p]
- eliminate_general(p, false)
- }
- finish_combat()
+ game.lost_generals += 1
+ game.lost_troops += game.troops[p]
+ eliminate_general(p, false)
+ array_remove_item(game.selected, p)
+ resume_retreat()
},
}
@@ -6889,7 +6892,7 @@ exports.action = function (state, _player, action, arg) {
/* COMMON FRAMEWORK */
-function goto_game_over(result, reason) {
+function goto_game_over(result, victory_reason) {
log("# The End")
game.active = "None"
game.state = "game_over"