summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-27 16:46:56 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-30 21:59:25 +0200
commit3cd960930b75a45acdc331fa1b97639d96e4a777 (patch)
tree20858bf670307de49d6756ed9532a85bb72e679f
parent71fc03ac47fbc858737734e2777d06eed52aeacb (diff)
downloadfriedrich-3cd960930b75a45acdc331fa1b97639d96e4a777.tar.gz
log supply
-rw-r--r--play.css8
-rw-r--r--rules.js55
2 files changed, 44 insertions, 19 deletions
diff --git a/play.css b/play.css
index 9ec9ce5..d891938 100644
--- a/play.css
+++ b/play.css
@@ -73,12 +73,16 @@
#log { background-color: #f3ebd4 }
+#log div:empty {
+ min-height: 4px;
+}
+
#log .city_tip:hover { cursor: pointer; text-decoration: underline; }
#log .h {
background-color: tan;
border-top: 1px solid black; border-bottom: 1px solid black;
- margin: 4px 0;
+ margin: 8px 0;
}
#log .h.fate { text-align: center; }
@@ -91,7 +95,7 @@
#log .h.imperial { background-color: var(--color-light-imperial); }
#log .h.france { background-color: var(--color-light-france); }
-#log .q { font-style: italic; margin: 8px 0; }
+#log .q { font-style: italic; }
#log .i { padding-left: 20px }
#log .ii { padding-left: 32px }
diff --git a/rules.js b/rules.js
index 88786e1..5afbba0 100644
--- a/rules.js
+++ b/rules.js
@@ -785,7 +785,7 @@ function retire_general(p) {
}
function eliminate_general(p) {
- log("P" + p + " eliminated.")
+ log(">P" + p + " eliminated")
game.pos[p] = ELIMINATED
game.troops[p] = 0
set_in_supply(p)
@@ -1286,6 +1286,11 @@ states.movement = {
end_movement() {
push_undo()
+ if (game.moved.length === 0)
+ log("No moves.")
+
+ set_clear(game.moved)
+
log_conquest(game.move_conq, game.move_reconq)
delete game.move_conq
delete game.move_reconq
@@ -1712,7 +1717,6 @@ function spend_recruit_cost() {
while (spend > 0) {
let c = find_largest_card(game.recruit.pool)
let v = to_value(c)
- console.log(" REMOVE CARD", v)
set_delete(game.recruit.pool, c)
set_add(game.recruit.used, c)
if (v > spend) {
@@ -1749,8 +1753,6 @@ function can_re_enter_supply_train(s) {
function goto_recruit() {
game.count = 0
- log_br()
-
// TODO: reveal too much if we skip recruitment phase?
if (!can_recruit_anything()) {
end_recruit()
@@ -1966,8 +1968,6 @@ states.re_enter = {
/* COMBAT (CHOOSE TARGETS) */
function goto_combat() {
- set_clear(game.moved)
-
let from = []
let to = []
@@ -2005,7 +2005,6 @@ function goto_combat() {
function next_combat() {
clear_undo()
- log_br()
set_active_to_current_action_step()
game.count = 0
delete game.attacker
@@ -2484,7 +2483,6 @@ states.retreat_eliminate_hits = {
gen_action_piece(p)
},
piece(p) {
- log("P" + p + " eliminated.")
eliminate_general(p)
set_delete(game.selected, p)
resume_retreat()
@@ -2734,32 +2732,55 @@ function should_supply_flip() {
}
function goto_supply() {
- log_br()
-
set_clear(game.moved)
search_supply(6)
+
if (should_supply_restore())
- resume_supply_restore()
+ goto_supply_restore()
else if (should_supply_eliminate())
- resume_supply_eliminate()
+ goto_supply_eliminate()
else if (should_supply_flip())
- resume_supply_flip()
+ goto_supply_flip()
else
end_supply()
}
+function goto_supply_restore() {
+ log_br()
+ log("In supply")
+ resume_supply_restore()
+}
+
+function goto_supply_eliminate() {
+ log_br()
+ log("Out of supply")
+ resume_supply_eliminate()
+}
+
+function goto_supply_flip() {
+ log_br()
+ log("Out of supply")
+ resume_supply_flip()
+}
+
function resume_supply_restore() {
if (should_supply_restore())
game.state = "supply_restore"
+ else if (should_supply_eliminate())
+ goto_supply_eliminate()
+ else if (should_supply_flip())
+ goto_supply_flip()
else
- resume_supply_eliminate()
+ end_supply()
}
function resume_supply_eliminate() {
if (should_supply_eliminate())
game.state = "supply_eliminate"
+ else if (should_supply_flip())
+ goto_supply_flip()
else
- resume_supply_flip()
+ end_supply()
}
function resume_supply_flip() {
@@ -2786,7 +2807,7 @@ states.supply_restore = {
if (game.pos[p] === s) {
set_add(game.moved, p)
set_in_supply(p)
- log("P" + p + " restored supply.")
+ log(">P" + p + " at S" + s)
}
}
resume_supply_restore()
@@ -2828,7 +2849,7 @@ states.supply_flip = {
let s = game.pos[x]
for (let p of all_power_generals[game.power]) {
if (game.pos[p] === s) {
- log("P" + p + " out of supply.")
+ log(">P" + p + " at S" + s)
set_out_of_supply(p)
}
}