summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-16 16:55:01 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:48 +0100
commit56998842f45f473c31e41cb4b1a06f9f2c82377b (patch)
tree789a853d75894af79c1833a686a0e263c499f6b1
parent02da527ebfd7455706e0adf79f1ee1a0ec699e1f (diff)
downloadtable-battles-56998842f45f473c31e41cb4b1a06f9f2c82377b.tar.gz
log formatting
-rw-r--r--play.html10
-rw-r--r--rules.js62
2 files changed, 33 insertions, 39 deletions
diff --git a/play.html b/play.html
index bc1e177..9ef7a26 100644
--- a/play.html
+++ b/play.html
@@ -40,13 +40,9 @@
margin: 8px 0;
}
-#log .i1 {
- padding-left: 20px;
-}
-
-#log .i2 {
- padding-left: 32px;
-}
+#log div { padding-left: 20px; text-indent: -12px; }
+#log div.i1 { padding-left: 32px; text-indent: -12px; }
+#log div.i2 { padding-left: 44px; text-indent: -12px; }
#log .i {
font-style: italic;
diff --git a/rules.js b/rules.js
index 66e0930..276bd82 100644
--- a/rules.js
+++ b/rules.js
@@ -1480,8 +1480,7 @@ function roll_dice_in_pool() {
}
}
- log("Roll")
- log(">" + rolled.map(d => "D" + d).join(" "))
+ log("Roll\n" + rolled.map(d => "D" + d).join(" "))
game.rolled = rolled.length
game.summary = 0
@@ -1561,8 +1560,7 @@ function end_roll_phase() {
if (game.summary & (1 << d))
if (get_dice_location(d) === c)
s.push("D" + get_dice_value(d))
- log(">C" + c)
- log(">>" + s.join(" "))
+ log(">C" + c + "\n" + s.join(" "))
}
}
@@ -2158,8 +2156,7 @@ states.action = {
retire(c) {
push_undo()
- log("C" + c)
- log("> Retire")
+ log("Retire\nC" + c)
if (game.scenario === S38_FLEURUS) {
if (c === S38_LUXEMBOURGS_HORSE) {
@@ -2310,9 +2307,7 @@ states.shift_to = {
next() {
// TODO: skip action phase?
- log(`Shift ${get_shift_sticks(game.target2)}`)
- log(">C" + game.selected)
- log(">C" + game.target2)
+ log("Shift " + get_shift_sticks(game.target2) + "\nC" + game.selected + "\nC" + game.target2)
end_action_phase()
},
@@ -2387,8 +2382,7 @@ states.s42_marlborough = {
}
function goto_null(c) {
- log("Null")
- log(">C" + c)
+ log("Null\nC" + c)
pay_for_action(c)
end_action_phase()
@@ -2518,8 +2512,7 @@ states.bombard = {
view.actions.bombard = 1
},
bombard() {
- log("Bombard")
- log(">C" + c)
+ log("Bombard\nC" + c)
let opp = 1 - player_index()
game.morale[opp] --
@@ -2769,9 +2762,7 @@ states.attack = {
view.actions.attack = 1
},
attack() {
- log("Attack")
- log(">C" + game.selected)
- log(">C" + game.target)
+ log("Attack\nC" + game.selected + "\nC" + game.target)
if (can_opponent_react()) {
clear_undo()
@@ -2837,12 +2828,25 @@ states.attack = {
function resume_attack() {
pay_for_action(game.selected)
- if (game.self > 0)
- remove_sticks(game.selected, game.self)
+ if (game.hits > 0 && game.self > 0) {
+ log(">" + game.hits + " hits. " + game.self + " self.")
+ }
+ else if (game.hits > 0) {
+ log(">" + game.hits + " hits.")
+ }
+ else if (game.self > 0) {
+ log(">" + game.self + " self.")
+ }
+
if (game.hits > 0)
remove_sticks(game.target, game.hits)
- if (game.target2 >= 0 && game.hits2 > 0)
+ if (game.self > 0)
+ remove_sticks(game.selected, game.self)
+
+ if (game.target2 >= 0 && game.hits2 > 0) {
+ log(">" + game.hits2 + " hits on C" + game.target2)
remove_sticks(game.target2, game.hits2)
+ }
if (game.scenario === S44_HOHENFRIEDBERG) {
// remove after first attack
@@ -2897,9 +2901,7 @@ states.command = {
gen_action_card(t)
},
card(c) {
- log("Command")
- log(">C" + game.selected)
- log(">C" + c)
+ log("Command\nC" + game.selected + "\nC" + c)
let p = player_index()
set_delete(game.reserve[p], c)
@@ -3212,8 +3214,7 @@ states.screen = {
view.actions.screen = 1
},
screen() {
- log("Screen")
- log(">C" + game.target)
+ log("Screen\nC" + game.target)
pay_for_action(game.target)
@@ -3289,8 +3290,7 @@ states.absorb = {
view.actions.absorb = 1
},
absorb() {
- log("Absorb")
- log(">C" + game.target)
+ log("Absorb\nC" + game.target)
pay_for_action(game.target)
end_reaction()
@@ -3354,8 +3354,7 @@ states.counterattack = {
view.actions.counterattack = 1
},
counterattack() {
- log("Counterattack")
- log(">C" + game.target)
+ log("Counterattack\nC" + game.target)
pay_for_action(game.target)
end_reaction()
@@ -3581,11 +3580,10 @@ states.routing = {
game.routed[p] += data.cards[c].morale
rout_card(c)
} else if (should_retire_card(c)) {
- log("C" + c + " retired.")
+ log("Retire\nC" + c)
retire_card(c)
} else if (should_pursue(c)) {
- log("C" + c)
- log(">Pursuit")
+ log("Pursuit\nC" + c)
pursue_card(c)
} else {
remove_card(c)
@@ -3689,7 +3687,7 @@ function end_reserve() {
}
function bring_out_of_reserve(c) {
- log("C" + c + " came out of reserve.")
+ log("Reserve\nC" + c)
let p = find_card_owner(c)
set_delete(game.reserve[p], c)
set_add(game.front[p], c)