summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-08-05 19:08:04 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-01 16:11:21 +0200
commit0149d293ddf6415fd1e549c1631795c2c7aa42ee (patch)
tree27ed04597851ddb848bfa6f05f65499521607939 /play.js
parent9f03172473165c0a905f31d9698b3fe8cef4b341 (diff)
downloadwaterloo-campaign-1815-0149d293ddf6415fd1e549c1631795c2c7aa42ee.tar.gz
Stuff.
Diffstat (limited to 'play.js')
-rw-r--r--play.js39
1 files changed, 31 insertions, 8 deletions
diff --git a/play.js b/play.js
index 2912609..2ccc276 100644
--- a/play.js
+++ b/play.js
@@ -8,12 +8,6 @@ const map_h = 31
const first_hex = 1000
const last_hex = 4041
-const hex_name_list = {
- 4006: "Halle",
- 4038: "Jodoigne",
- 3933: "Roux-Miroir",
-}
-
function set_has(set, item) {
if (!set)
return false
@@ -128,8 +122,8 @@ function build_hexes() {
hex.addEventListener("mouseenter", on_focus_hex)
hex.addEventListener("mouseleave", on_blur)
hex.my_id = hex_id
- if (hex_name_list[hex_id])
- hex.my_name = String(hex_id) + " (" + hex_name_list[hex_id] + ")"
+ if (data.map.names[hex_id])
+ hex.my_name = String(hex_id) + " (" + data.map.names[hex_id] + ")"
else
hex.my_name = String(hex_id)
@@ -154,6 +148,25 @@ function is_action(action, arg) {
return !!(view.actions && view.actions[action] && set_has(view.actions[action], arg))
}
+function find_hex_side(a, b) {
+ if (a > b)
+ return find_hex_side(b, a)
+ if (b === a + 1)
+ return (a << 2) + 0
+ if ((a/100) & 1) {
+ if (b === a + 101)
+ return (a << 2) + 1
+ if (b === a + 100)
+ return (a << 2) + 2
+ } else {
+ if (b === a + 100)
+ return (a << 2) + 1
+ if (b === a + 99)
+ return (a << 2) + 2
+ }
+ return -1
+}
+
function on_update() {
ui.stack.fill(0)
@@ -187,6 +200,16 @@ function on_update() {
ui.pieces[id].classList.toggle("action", is_action("piece", id))
}
+ if (view.roads) {
+ for (let road of view.roads) {
+ for (let i = 1; i < road.length; ++i) {
+ let id = find_hex_side(road[i-1], road[i])
+ console.log("id", id)
+ ui.sides[id].classList.add("road")
+ }
+ }
+ }
+
action_button("edit_town", "Town")
action_button("edit_stream", "Stream")
action_button("edit_road", "Road")