From 2d0cccee7c78c5b7ba8f96c88d44020932b35be9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 22 Aug 2024 12:46:59 +0200 Subject: import friedrich changes --- rules.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 8ed1fa8..2bb4dfb 100644 --- a/rules.js +++ b/rules.js @@ -220,12 +220,6 @@ function is_reserve(c) { return to_suit(c) === RESERVE } -function format_card_list(list) { - if (list.length > 0) - return list.map(format_card).join(", ") - return "nothing" -} - function format_card_list_prompt(list) { if (list.length > 0) return list.map(format_card_prompt).join(", ") @@ -238,8 +232,9 @@ function format_selected() { return game.selected.map(p => piece_name[p]).join(" and ") } -function log_selected() { - log(game.selected.map(p => "P" + p).join(" and ")) +function log_move_to(to) { + let from = game.pos[game.selected[0]] + log("@" + game.selected.join(",") + ";" + from + "," + to) } function log_move_path() { @@ -517,8 +512,11 @@ function retire_general(p) { } } -function eliminate_general(p) { - log(">P" + p + " eliminated") +function eliminate_general(p, indent) { + if (indent) + log(">P" + p + " eliminated") + else + log("P" + p + " eliminated.") game.pos[p] = ELIMINATED game.troops[p] = 0 set_in_supply(p) @@ -973,6 +971,7 @@ function move_general_to(to) { game.move_elim = [] set_add(game.move_elim, p) game.pos[p] = ELIMINATED + // NOTE: eliminating a supply train does not stop movement! } } @@ -1161,7 +1160,7 @@ states.move_give = { } function end_move_piece() { - log_selected_move_path() + log_move_path() if (game.move_elim) { for (let p of game.move_elim) @@ -1414,7 +1413,7 @@ function end_recruit() { else log("Recruited with " + game.recruit.used.map(format_card).join(", ") + ".") map_for_each(game.recruit.pieces, (p,s) => { - log("Re-entered P" + p + " at S" + s) + log("Re-entered P" + p + " at S" + s + ".") }) if (game.recruit.troops) log(">" + game.recruit.troops + " troops") @@ -1758,6 +1757,7 @@ states.combat_attack_reserve = { inactive: inactive_attack, prompt() { prompt_combat(game.count, "Choose value.") + view.draw = [ game.reserve ] gen_play_reserve() }, value(v) { @@ -1770,6 +1770,7 @@ states.combat_defend_reserve = { inactive: inactive_defend, prompt() { prompt_combat(-game.count, "Choose value.") + view.draw = [ game.reserve ] gen_play_reserve() }, value(v) { @@ -1896,7 +1897,7 @@ function resume_retreat() { } states.retreat_eliminate_hits = { - inactive: "retreat loser", + inactive: "retreat", prompt() { prompt("Eliminate generals without troops.") // remove eliminated generals @@ -1905,23 +1906,23 @@ states.retreat_eliminate_hits = { gen_action_piece(p) }, piece(p) { - eliminate_general(p) + eliminate_general(p, false) set_delete(game.selected, p) resume_retreat() }, } states.retreat_eliminate_trapped = { - inactive: "retreat loser", + inactive: "retreat", prompt() { prompt("Eliminate " + format_selected() + " without a retreat path.") for (let p of game.selected) gen_action_piece(p) }, piece(_) { - log("Trapped") + log("Trapped.") for (let p of game.selected) - eliminate_general(p) + eliminate_general(p, false) next_combat() }, } @@ -1988,7 +1989,7 @@ function search_retreat(loser, winner, range) { } states.retreat = { - inactive: "retreat loser", + inactive: "retreat defeated general", prompt() { prompt("Retreat " + format_selected() + " " + Math.abs(game.count) + " cities.") view.selected = game.selected @@ -2006,7 +2007,7 @@ states.retreat = { } states.retreat_done = { - inactive: "retreat loser", + inactive: "retreat defeated general", prompt() { prompt("Retreat done.") view.actions.next = 1 @@ -2245,7 +2246,8 @@ states.supply_eliminate = { let s = game.pos[x] for (let p of all_power_generals[game.power]) if (game.pos[p] === s) - eliminate_general(p) + eliminate_general(p, true) + resume_supply_eliminate() }, } -- cgit v1.2.3