diff options
-rw-r--r-- | play.html | 8 | ||||
-rw-r--r-- | play.js | 18 | ||||
-rw-r--r-- | rules.js | 18 |
3 files changed, 39 insertions, 5 deletions
@@ -723,6 +723,14 @@ body.shift .mustered_vassals { drop-shadow(-2px 0px 0px white); } +#legate.selected { + filter: + drop-shadow(2px 0px 0px yellow) + drop-shadow(0px 2px 0px yellow) + drop-shadow(0px -2px 0px yellow) + drop-shadow(-2px 0px 0px yellow); +} + .cylinder { position: absolute; width: 44px; @@ -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) @@ -2045,6 +2045,8 @@ function do_action_march() { states.march = { prompt() { view.prompt = `March: Select destination.` + view.group = game.group + let here = get_lord_locale(game.who) for (let [to] of data.locales[here].ways) @@ -2089,6 +2091,7 @@ states.march = { states.march_way = { prompt() { view.prompt = `March: Select way.` + view.group = game.group let from = get_lord_locale(game.who) let to = game.where let ways = list_ways(from, to) @@ -2123,6 +2126,7 @@ states.march_laden = { let loot = count_group_assets(LOOT) view.prompt = `March with ${loot} loot, ${prov} prov, and ${transport} usable transport.` + view.group = game.group if (prov <= transport * 2) { if (loot > 0 || prov > transport) { @@ -2191,6 +2195,9 @@ function march_with_group_2(laden) { set_lord_locale(lord, to) set_lord_moved(lord, 1) }) + if (set_has(game.group, LEGATE)) { + game.call_to_arms.legate = to + } if (is_enemy_stronghold(from)) remove_all_siege_markers(from) @@ -2429,6 +2436,8 @@ function do_action_sail() { states.sail = { prompt() { + view.group = game.group + let here = get_lord_locale(game.who) let horses = count_group_horses() let ships = count_group_assets(SHIP) @@ -2446,8 +2455,6 @@ states.sail = { min_overflow = horses * 2 - ships } - console.log("SAIL", ships, overflow, min_overflow) - if (overflow <= 0) { view.prompt = `Sail: Choose a destination Seaport.` for (let to of data.seaports) { @@ -2471,7 +2478,7 @@ states.sail = { }) } } else { - view.prompt = ` Not enough ships!` + view.prompt = `Sail: Too few ships to carry all the horses!` } // 4.3.2 Marshals MAY take other lords @@ -2522,6 +2529,9 @@ states.sail = { set_lord_locale(lord, to) set_lord_moved(lord, 1) }) + if (set_has(game.group, LEGATE)) { + game.call_to_arms.legate = to + } use_all_actions() game.state = "actions" @@ -3033,8 +3043,6 @@ exports.view = function (state, current) { } else { view.actions = {} view.who = game.who - if (game.group && game.group.length > 0) - view.group = game.group if (states[game.state]) states[game.state].prompt(current) else |