summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/play.js b/play.js
index d72c78f..0a9a40b 100644
--- a/play.js
+++ b/play.js
@@ -465,6 +465,11 @@ let ui = {
document.getElementById("bk_cylinder"),
document.getElementById("ve_cylinder"),
],
+ pool: [
+ document.getElementById("pool_a"),
+ document.getElementById("pool_d"),
+ ],
+ dice: []
}
function create(t, p, ...c) {
@@ -603,6 +608,15 @@ function init_ui() {
create_piece_list(MI, TROOPS, "piece mongol cube", 2, 0)
+ // dice
+ for (let d = 0; d < 6; ++d) {
+ let e = null
+ let pool = (d < 4) ? "pool_a" : "pool_d"
+ ui.dice[d] = e = create("div", { className: "die d0" })
+ register_action(e, "die", d)
+ document.getElementById(pool).append(e)
+ }
+
}
/* UPDATE */
@@ -907,7 +921,7 @@ function on_update() {
let discs = [ ]
for (let s = 0; s < data.spaces.length; ++s) {
let xy
-
+
if (s <= last_province) {
items.length = discs.length = 0
filter_piece_list(discs, s, DS, DISC)
@@ -1021,6 +1035,14 @@ function on_update() {
for (let i = 0; i < ui.pieces.length; ++i)
ui.pieces[i].classList.toggle("selected", set_has(view.who, i))
+ // Update dice
+ for (let i = 0; i < 6; ++i) {
+ let v = view.dice[i]
+ if (v >= 0)
+ ui.dice[i].className = "die d" + v
+ ui.dice[i].classList.toggle("action", is_action("die", i))
+ }
+
// Influence
layout_influence()
@@ -1041,12 +1063,14 @@ function on_update() {
action_button("end_march", "End March")
// Command buttons
+ action_button("attack", "Attack")
action_button("migrate", "Migrate")
action_button("end_migrate", "End Migrate")
action_button("rally", "Rally")
action_button("end_rally", "End Rally")
action_button("rebel", "Rebel")
action_button("end_rebel", "End Rebel")
+ action_button("roll", "Roll")
// Decree buttons
action_button("build", "Build")
@@ -1072,6 +1096,7 @@ function on_update() {
action_button("end_gifts", "Refuse Compromising Gifts")
// Other buttons
+ action_button("roll", "Roll")
action_button("end_cavalry", "End Cavalry Selection")
action_button("next", "Next")
@@ -1404,6 +1429,14 @@ function on_log(text) {
text = text.substring(3)
p.className = "indent italic"
}
+ else if (text.match(/^\.ad/)) {
+ text = text.substring(4)
+ p.className += " adice"
+ }
+ else if (text.match(/^\.dd/)) {
+ text = text.substring(4)
+ p.className += " ddice"
+ }
text = text.replace(/C(\d+)/g, sub_card)
text = text.replace(/S(\d+)/g, sub_space)