diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-08 12:08:20 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-08 16:36:47 +0100 |
commit | f86d574e5256e11b5a41fd922033274ab7c4eb61 (patch) | |
tree | 461f6725417f3053cc9a0c640925b29c5a323df2 /play.js | |
parent | 897c0c2fcd534159b78381036076c48d2db43465 (diff) | |
download | table-battles-f86d574e5256e11b5a41fd922033274ab7c4eb61.tar.gz |
Highlight sticks to die.
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 35 |
1 files changed, 31 insertions, 4 deletions
@@ -20,6 +20,7 @@ let ui = { dice: [], sticks: [], + hit_sticks: [], cubes: [], } @@ -209,7 +210,7 @@ function create_formation_card(id) { function fill_card_row(top, parent, list) { parent.replaceChildren() for (let id of list) { - let i, n + let i, n, x if (!ui.cards[id]) ui.cards[id] = create_formation_card(id) @@ -225,7 +226,15 @@ function fill_card_row(top, parent, list) { add_cube(ui.slot_cubes[id]) n = map_get(view.sticks, id, 0) - for (let i = 0; i < n; ++i) + x = 0 + if (view.selected === id) + x = view.self + if (view.target === id) + x = view.hits + console.log("STICKS", id, x, n) + for (let i = 0; i < x; ++i) + add_hit_stick(ui.slot_sticks[id]) + for (let i = x; i < n; ++i) add_stick(ui.slot_sticks[id]) } } @@ -250,6 +259,16 @@ function add_stick(parent) { throw Error("OUT OF CUBES ERROR") } +function add_hit_stick(parent) { + for (let i = 0; i < 80; ++i) { + if (ui.hit_sticks[i].parentElement === null) { + parent.appendChild(ui.hit_sticks[i]) + return + } + } + throw Error("OUT OF CUBES ERROR") +} + function on_update() { let p1 = 0, p2 = 1 if (player === "First") @@ -269,6 +288,8 @@ function on_update() { e.remove() for (let e of ui.sticks) e.remove() + for (let e of ui.hit_sticks) + e.remove() for (let i = 0; i < view.morale[0]; ++i) add_cube(ui.morale[p1]) @@ -308,10 +329,14 @@ function on_update() { for (let e of animation_registry) animate_position(e) + action_button("attack", "Attack") action_button("bombard", "Bombard") + action_button("command", "Command") + action_button("screen", "Screen") + action_button("counterattack", "Counterattack") + action_button("absorb", "Absorb") action_button("roll", "Roll") action_button("pass", "Pass") - action_button("done", "Done") action_button("end_turn", "End turn") action_button("undo", "Undo") } @@ -321,8 +346,10 @@ for (let i = 0; i < 10; ++i) { // register_animation(ui.cubes[i], 500) } -for (let i = 0; i < 80; ++i) +for (let i = 0; i < 80; ++i) { ui.sticks[i] = create_div("stick") + ui.hit_sticks[i] = create_div("stick hit") +} for (let i = 0; i < 12; ++i) { ui.dice[i] = register_action(create_div("die d0"), "die", i) |