diff options
-rw-r--r-- | play.js | 69 | ||||
-rw-r--r-- | rules.js | 60 |
2 files changed, 90 insertions, 39 deletions
@@ -8,6 +8,8 @@ const MAP_DPI = 75 +const CALENDAR = 100 + const round = Math.round const floor = Math.floor const ceil = Math.ceil @@ -164,6 +166,7 @@ function is_card_action(c) { 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" ] const asset_type_count = 7 const asset_type_name = [ "prov", "coin", "loot", "cart", "sled", "boat", "ship" ] @@ -442,8 +445,59 @@ function on_click_plan(evt) { } function on_focus_cylinder(evt) { - let id = evt.target.my_id - document.getElementById("status").textContent = `(${id}) ${data.lords[id].full_name} [${data.lords[id].command}] - ${data.lords[id].title}` + let lord = evt.target.my_id + let info = data.lords[lord] + let loc = view.lords.locale[lord] + if (loc >= CALENDAR) { + document.getElementById("status").textContent = `${info.full_name} - ${info.fealty} Fealty` + } else { + let tip = `${info.full_name}` + + /* + if (view.turn & 1) + tip += ` - ${info.command} Command` + else + tip += ` - ${info.lordship} Lordship` + */ + + let first = true + let assets = view.lords.assets[lord] + for (let i = 0; i < asset_type_count; ++i) { + let x = pack4_get(assets, i) + if (x > 0) { + if (first) + tip += " \u2013 " + else + tip += ", " + tip += `${x} ${asset_type_name[i]}` + first = false + } + } + + first = true + let forces = view.lords.forces[lord] + let routed = view.lords.routed[lord] + for (let i = 0; i < force_type_count; ++i) { + let x = pack4_get(forces, i) + pack4_get(routed, i) + if (x > 0) { + if (first) + tip += " \u2013 " + else + tip += ", " + tip += `${x} ${force_type_tip[i]}` + first = false + } + } + + let c = view.lords.cards[(lord<<1)] + if (c >= 0) + tip += ` \u2013 ${data.cards[c].capability}` + c = view.lords.cards[(lord<<1) + 1] + if (c >= 0) + tip += `, ${data.cards[c].capability}` + + document.getElementById("status").textContent = tip + } } function on_click_lord_service_marker(evt) { @@ -454,10 +508,11 @@ function on_click_lord_service_marker(evt) { } function on_focus_lord_service_marker(evt) { - let id = evt.target.my_id - document.getElementById("status").textContent = `(${id}) ${data.lords[id].full_name} - ${data.lords[id].title}` - if (expand_calendar !== view.lords.service[id]) { - expand_calendar = view.lords.service[id] + let lord = evt.target.my_id + let info = data.lords[lord] + document.getElementById("status").textContent = `${info.full_name} - ${info.title}` + if (expand_calendar !== view.lords.service[lord]) { + expand_calendar = view.lords.service[lord] layout_calendar() } } @@ -768,7 +823,7 @@ function update_lord_mat(ix) { update_assets(ix, ui.assets[ix], view.lords.assets[ix]) update_vassals(ui.ready_vassals[ix], ui.mustered_vassals[ix], ix) update_forces(ui.forces[ix], view.lords.forces[ix]) - update_forces(ui.routed[ix], view.lords.routed_forces[ix]) + update_forces(ui.routed[ix], view.lords.routed[ix]) } function update_lord(ix) { @@ -303,7 +303,7 @@ function get_lord_forces(lord, n) { } function get_lord_routed_forces(lord, n) { - return pack4_get(game.lords.routed_forces[lord], n) + return pack4_get(game.lords.routed[lord], n) } function set_lord_locale(lord, locale) { @@ -351,7 +351,7 @@ function set_lord_routed_forces(lord, n, x) { x = 0 if (x > 15) x = 15 - game.lords.routed_forces[lord] = pack4_set(game.lords.routed_forces[lord], n, x) + game.lords.routed[lord] = pack4_set(game.lords.routed[lord], n, x) } function add_lord_routed_forces(lord, n, x) { @@ -749,7 +749,7 @@ exports.setup = function (seed, scenario, options) { service: Array(lord_count).fill(NEVER), assets: Array(lord_count).fill(0), forces: Array(lord_count).fill(0), - routed_forces: Array(lord_count).fill(0), + routed: Array(lord_count).fill(0), cards: Array(lord_count << 1).fill(NOTHING), moved: 0, besieged: 0, @@ -1743,30 +1743,29 @@ states.actions = { view.prompt = `${lord_name[game.who]} has ${avail}x actions.` if (avail > 0) { - if (can_action_march()) - view.actions.march = 1 - - if (can_action_siege()) - view.actions.siege = 1 - if (can_action_storm()) - view.actions.storm = 1 - if (can_action_sally()) - view.actions.sally = 1 - - if (can_action_supply()) - view.actions.supply = 1 - if (can_action_forage()) - view.actions.forage = 1 - if (can_action_ravage()) - view.actions.ravage = 1 - - if (can_action_tax()) - view.actions.tax = 1 - - if (can_action_sail()) - view.actions.sail = 1 - - view.actions.pass = 1 + if (is_lord_besieged(game.who)) { + if (can_action_sally()) + view.actions.sally = 1 + view.actions.pass = 1 + } else { + if (can_action_march()) + view.actions.march = 1 + if (can_action_siege()) + view.actions.siege = 1 + if (can_action_storm()) + view.actions.storm = 1 + if (can_action_supply()) + view.actions.supply = 1 + if (can_action_forage()) + view.actions.forage = 1 + if (can_action_ravage()) + view.actions.ravage = 1 + if (can_action_tax()) + view.actions.tax = 1 + if (can_action_sail()) + view.actions.sail = 1 + view.actions.pass = 1 + } } else { view.actions.done = 1 } @@ -1776,6 +1775,7 @@ states.actions = { march: do_action_march, pass() { clear_undo() + log("Passed.") end_actions() }, done() { @@ -1824,8 +1824,6 @@ function can_action_supply() { function can_action_forage() { let where = get_lord_locale(game.who) - if (is_lord_besieged(game.who)) - return false if (has_ravaged_marker(where)) return false if (current_season() === SUMMER) @@ -1847,8 +1845,6 @@ function do_action_forage() { function can_action_ravage() { let where = get_lord_locale(game.who) - if (is_lord_besieged(game.who)) - return false // TODO: cost 2 if enemy lord is adjacent in 2nd ed // TODO: adjacent ability @@ -2209,7 +2205,7 @@ function disband_lord(lord) { set_lord_capability(lord, 1, NOTHING) game.lords.assets[lord] = 0 game.lords.forces[lord] = 0 - game.lords.routed_forces[lord] = 0 + game.lords.routed[lord] = 0 set_lord_besieged(lord, 0) set_lord_moved(lord, 0) |