summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-12-14 18:02:50 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 13:02:38 +0100
commit4d7ea66092beb7555c842e5fa9420ce3ae9f4c3a (patch)
tree40869662e7c1339affe62fc2640859d2aaca82dd /play.js
parenta62774734e3b5fc4b0d43dab2d3ab4b72e202ef9 (diff)
downloadnevsky-4d7ea66092beb7555c842e5fa9420ce3ae9f4c3a.tar.gz
Select and move legate when marching/sailing.
Diffstat (limited to 'play.js')
-rw-r--r--play.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/play.js b/play.js
index fccc25c..6a52ae1 100644
--- a/play.js
+++ b/play.js
@@ -19,6 +19,7 @@ const MAP_DPI = 75
const NOWHERE = -1
const CALENDAR = 100
+const LEGATE = 100
const round = Math.round
const floor = Math.floor
@@ -178,6 +179,14 @@ function is_card_action(c) {
return !!(view.actions && view.actions.card && set_has(view.actions.card, c))
}
+function is_legate_action() {
+ return !!(view.actions && view.actions.legate)
+}
+
+function is_legate_selected() {
+ return view.who === LEGATE || !!(view.group && set_has(view.group, LEGATE))
+}
+
const force_type_count = 7
const force_type_name = [ "knights", "sergeants", "light_horse", "asiatic_horse", "men_at_arms", "militia", "serfs" ]
const force_type_tip = [ "knights", "sergeants", "light horse", "asiatic horse", "men-at-arms", "militia", "serfs" ]
@@ -591,6 +600,11 @@ function on_focus_vassal_service_marker(evt) {
document.getElementById("status").textContent = `(${id}) ${lord.name} / ${vassal.name}`
}
+function on_click_legate(evt) {
+ if (evt.button === 0)
+ send_action('legate')
+}
+
function on_blur(evt) {
document.getElementById("status").textContent = ""
}
@@ -951,6 +965,8 @@ function update_legate() {
ui.legate.classList.add("hide")
} else {
ui.legate.classList.remove("hide")
+ ui.legate.classList.toggle("action", is_legate_action())
+ ui.legate.classList.toggle("selected", is_legate_selected())
if (view.call_to_arms.legate === 100) {
ui.legate.style.top = "1580px"
ui.legate.style.left = "170px"
@@ -1421,6 +1437,8 @@ function build_map() {
document.getElementById("pieces").appendChild(e)
})
+ document.getElementById("legate").addEventListener("mousedown", on_click_legate)
+
for (let name in original_boxes) {
let x = round(original_boxes[name][0] * MAP_DPI / 300)
let y = round(original_boxes[name][1] * MAP_DPI / 300)