summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-08 12:08:20 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:47 +0100
commitf86d574e5256e11b5a41fd922033274ab7c4eb61 (patch)
tree461f6725417f3053cc9a0c640925b29c5a323df2 /play.js
parent897c0c2fcd534159b78381036076c48d2db43465 (diff)
downloadtable-battles-f86d574e5256e11b5a41fd922033274ab7c4eb61.tar.gz
Highlight sticks to die.
Diffstat (limited to 'play.js')
-rw-r--r--play.js35
1 files changed, 31 insertions, 4 deletions
diff --git a/play.js b/play.js
index 9aa02db..d4c02ff 100644
--- a/play.js
+++ b/play.js
@@ -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)