summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/play.js b/play.js
index e5b8e02..fbfcbf3 100644
--- a/play.js
+++ b/play.js
@@ -40,6 +40,11 @@ let ui = {
hex_y: [],
units: [],
battle_units: [],
+ cards: [],
+ axis_supply: document.getElementById("axis_supply"),
+ allied_supply: document.getElementById("allied_supply"),
+ turn_info: document.getElementById("turn_info"),
+ hand: document.getElementById("hand"),
battle: document.getElementById("battle"),
battle_hits: [
@@ -231,6 +236,14 @@ function on_blur(evt) {
document.getElementById("status").textContent = ""
}
+function on_click_real_card(evt) {
+ send_action("real_card")
+}
+
+function on_click_dummy_card(evt) {
+ send_action("dummy_card")
+}
+
function on_click_hex(evt) {
if (evt.button === 0) {
hide_supply()
@@ -462,8 +475,28 @@ function build_units() {
}
}
+function build_cards() {
+ function build_card(i, real) {
+ let elt = ui.cards[i] = document.createElement("div")
+ if (real) {
+ elt.className = "card real hide"
+ elt.addEventListener("mousedown", on_click_real_card)
+ ui.hand.appendChild(elt)
+ } else {
+ elt.className = "card dummy hide"
+ elt.addEventListener("mousedown", on_click_dummy_card)
+ ui.hand.appendChild(elt)
+ }
+ }
+ for (let i = 0; i < 28; ++i)
+ build_card(i, true)
+ for (let i = 28; i < 42; ++i)
+ build_card(i, false)
+}
+
build_hexes()
build_units()
+build_cards()
let stack = new Array(map_w * map_h + 21)
for (let i = 0; i < stack.length; ++i)
@@ -554,6 +587,18 @@ function update_map() {
}
}
+function update_cards() {
+ if (view.cards) {
+ for (let i = 0; i < 28; ++i)
+ ui.cards[i].classList.toggle("hide", i >= view.cards[0])
+ for (let i = 0; i < 14; ++i)
+ ui.cards[i+28].classList.toggle("hide", i >= view.cards[1])
+ } else {
+ for (let i = 0; i < 42; ++i)
+ ui.cards[i+28].classList.add("hide")
+ }
+}
+
function update_battle_line(hex, line, test) {
for (let u = 0; u < units.length; ++u) {
let e = ui.battle_units[u]
@@ -635,6 +680,7 @@ function target_button(action) {
function on_update() {
update_map()
+ update_cards()
if (view.battle)
update_battle()
@@ -646,6 +692,15 @@ function on_update() {
else
ui.pursuit.classList.add("hide")
+ ui.axis_supply.textContent = view.axis_hand
+ ui.allied_supply.textContent = view.allied_hand
+ ui.turn_info.textContent = `Month: ${view.month}\nSupply Commitment: ${view.commit}`
+
+ if (view.actions && (view.actions.real_card || view.actions.dummy_card))
+ ui.cards.forEach(elt => elt.classList.add("action"))
+ else
+ ui.cards.forEach(elt => elt.classList.remove("action"))
+
action_button("select_all", "Select all")
action_button("overrun", "Overrun")