summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-08-22 12:46:59 +0200
committerTor Andersson <tor@ccxvii.net>2024-08-22 13:23:33 +0200
commit2d0cccee7c78c5b7ba8f96c88d44020932b35be9 (patch)
tree328a1eeac5e0b2521b6b21596ec8a79f1f30bd24 /rules.js
parent152f3965d2b73b73592d7795ce1e000e631eea5c (diff)
downloadmaria-2d0cccee7c78c5b7ba8f96c88d44020932b35be9.tar.gz
import friedrich changes
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js42
1 files changed, 22 insertions, 20 deletions
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()
},
}