summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"