From 0a8867f72ea12f351f11a60bba4e873506fd41a8 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 21 Nov 2022 19:27:47 +0100 Subject: Shorten name arts_of_war -> card. --- play.js | 68 ++++++++++++++++++++++++++++++++-------------------------------- rules.js | 47 ++++++++++++++++++++------------------------ 2 files changed, 55 insertions(+), 60 deletions(-) diff --git a/play.js b/play.js index e0510c7..f5fc1dd 100644 --- a/play.js +++ b/play.js @@ -101,8 +101,8 @@ function is_locale_action(locale) { return !!(view.actions && view.actions.locale && set_has(view.actions.locale, locale)) } -function is_arts_of_war_action(c) { - return !!(view.actions && view.actions.arts_of_war && set_has(view.actions.arts_of_war, c)) +function is_card_action(c) { + return !!(view.actions && view.actions.card && set_has(view.actions.card, c)) } const force_type_count = 7 @@ -193,28 +193,28 @@ function is_card_in_use(c) { return false } -function for_each_teutonic_arts_of_war(fn) { +function for_each_teutonic_card(fn) { for (let i = 0; i < 21; ++i) fn(i) } -function for_each_russian_arts_of_war(fn) { +function for_each_russian_card(fn) { for (let i = 21; i < 42; ++i) fn(i) } -function for_each_friendly_arts_of_war(fn) { +function for_each_friendly_card(fn) { if (player === "Teutons") - for_each_teutonic_arts_of_war(fn) + for_each_teutonic_card(fn) else - for_each_russian_arts_of_war(fn) + for_each_russian_card(fn) } -function for_each_enemy_arts_of_war(fn) { +function for_each_enemy_card(fn) { if (player !== "Teutons") - for_each_teutonic_arts_of_war(fn) + for_each_teutonic_card(fn) else - for_each_russian_arts_of_war(fn) + for_each_russian_card(fn) } const original_boxes = { @@ -281,7 +281,7 @@ const ui = { ready_vassals: [], mustered_vassals: [], lord_capabilities: [], - arts_of_war: [], + cards: [], boxes: {}, veche: document.getElementById("veche"), plan_dialog: document.getElementById("plan"), @@ -351,10 +351,10 @@ function on_click_cylinder(evt) { } } -function on_click_arts_of_war(evt) { +function on_click_card(evt) { if (evt.button === 0) { let id = evt.target.my_id - send_action('arts_of_war', id) + send_action('card', id) } } @@ -772,47 +772,47 @@ function update_plan() { } } -function update_arts_of_war() { +function update_cards() { if (view.show_arts_of_war) { ui.arts_of_war_dialog.classList.remove("hide") ui.arts_of_war_list.replaceChildren() - for_each_friendly_arts_of_war(c => { + for_each_friendly_card(c => { if (!is_card_in_use(c)) { - let elt = ui.arts_of_war[c] + let elt = ui.cards[c] ui.arts_of_war_list.appendChild(elt) - elt.classList.toggle("action", is_arts_of_war_action(c)) - elt.classList.toggle("disabled", !is_arts_of_war_action(c)) + elt.classList.toggle("action", is_card_action(c)) + elt.classList.toggle("disabled", !is_card_action(c)) } }) } else { ui.arts_of_war_dialog.classList.add("hide") for (let c = 0; c < 42; ++c) { - let elt = ui.arts_of_war[c] - elt.classList.toggle("action", is_arts_of_war_action(c)) + let elt = ui.cards[c] + elt.classList.toggle("action", is_card_action(c)) elt.classList.remove("disabled") } } ui.events.replaceChildren() for (let c of view.events) - ui.events.appendChild(ui.arts_of_war[c]) + ui.events.appendChild(ui.cards[c]) ui.p1_capabilities.replaceChildren() - for_each_teutonic_arts_of_war(c => { + for_each_teutonic_card(c => { if (view.capabilities.includes(c)) - ui.p1_capabilities.appendChild(ui.arts_of_war[c]) + ui.p1_capabilities.appendChild(ui.cards[c]) }) ui.p2_capabilities.replaceChildren() - for_each_russian_arts_of_war(c => { + for_each_russian_card(c => { if (view.capabilities.includes(c)) - ui.p2_capabilities.appendChild(ui.arts_of_war[c]) + ui.p2_capabilities.appendChild(ui.cards[c]) }) ui.hand.replaceChildren() if (view.hand) { for (let c of view.hand) - ui.hand.appendChild(ui.arts_of_war[c]) + ui.hand.appendChild(ui.cards[c]) } for (let ix = 0; ix < data.lords.length; ++ix) { @@ -820,10 +820,10 @@ function update_arts_of_war() { ui.lord_capabilities[ix].replaceChildren() let c = view.lords.cards[(ix << 1) + 0] if (c >= 0) - ui.lord_capabilities[ix].appendChild(ui.arts_of_war[c]) + ui.lord_capabilities[ix].appendChild(ui.cards[c]) c = view.lords.cards[(ix << 1) + 1] if (c >= 0) - ui.lord_capabilities[ix].appendChild(ui.arts_of_war[c]) + ui.lord_capabilities[ix].appendChild(ui.cards[c]) } } @@ -879,7 +879,7 @@ function on_update() { } update_plan() - update_arts_of_war() + update_cards() action_button("ship", "Ship") action_button("boat", "Boat") @@ -932,11 +932,11 @@ function build_lord_mat(lord, ix, side, name) { ui.lord_mat[ix] = mat } -function build_arts_of_war(side, c) { - let card = ui.arts_of_war[c] = document.createElement("div") +function build_card(side, c) { + let card = ui.cards[c] = document.createElement("div") card.className = `card ${side} aow_${c}` card.my_id = c - card.addEventListener("mousedown", on_click_arts_of_war) + card.addEventListener("mousedown", on_click_card) } function build_plan() { @@ -1085,9 +1085,9 @@ function build_map() { build_plan() for (let c = 0; c < 21; ++c) - build_arts_of_war("teutonic", c) + build_card("teutonic", c) for (let c = 21; c < 42; ++c) - build_arts_of_war("russian", c) + build_card("russian", c) } build_map() diff --git a/rules.js b/rules.js index 4687751..cdb5f55 100644 --- a/rules.js +++ b/rules.js @@ -58,7 +58,7 @@ const SHIP = 6 const data = require("./data.js") -function find_arts_of_war(name) { return data.cards.findIndex(x => x.name === name) } +function find_card(name) { return data.cards.findIndex(x => x.name === name) } function find_lord(name) { return data.lords.findIndex(x => x.name === name) } function find_locale(name) { return data.locales.findIndex(x => x.name === name) } @@ -859,22 +859,22 @@ function setup_pleskau_quickstart() { add_lord_assets(LORD_KNUD_ABEL, BOAT, 1) muster_vassal(LORD_HERMANN, data.lords[LORD_HERMANN].vassals[0]) - set_lord_capability(LORD_HERMANN, 0, find_arts_of_war("T4")) - set_lord_capability(LORD_HERMANN, 1, find_arts_of_war("T14")) + set_lord_capability(LORD_HERMANN, 0, find_card("T4")) + set_lord_capability(LORD_HERMANN, 1, find_card("T14")) - set_lord_capability(LORD_YAROSLAV, 0, find_arts_of_war("T3")) + set_lord_capability(LORD_YAROSLAV, 0, find_card("T3")) - set_add(game.capabilities, find_arts_of_war("T13")) + set_add(game.capabilities, find_card("T13")) game.legate = LOC_DORPAT - set_add(game.capabilities, find_arts_of_war("R8")) + set_add(game.capabilities, find_card("R8")) muster_lord(LORD_DOMASH, LOC_NOVGOROD) add_lord_assets(LORD_DOMASH, BOAT, 2) add_lord_assets(LORD_DOMASH, CART, 2) muster_vassal(LORD_GAVRILO, data.lords[LORD_GAVRILO].vassals[0]) - set_lord_capability(LORD_GAVRILO, 0, find_arts_of_war("R2")) - set_lord_capability(LORD_GAVRILO, 1, find_arts_of_war("R6")) + set_lord_capability(LORD_GAVRILO, 0, find_card("R2")) + set_lord_capability(LORD_GAVRILO, 1, find_card("R6")) game.veche_coin += 1 @@ -930,7 +930,7 @@ function end_setup_lords() { // === LEVY: ARTS OF WAR (FIRST TURN) === -function draw_two_arts_of_war_cards() { +function draw_two_cards() { // TODO: no PASS cards in some scenarios in 2nd ed let deck = [] if (game.active === P1) { @@ -959,7 +959,7 @@ function goto_levy_arts_of_war_first() { log_br() log(game.active) game.state = 'levy_arts_of_war_first' - game.what = draw_two_arts_of_war_cards() + game.what = draw_two_cards() } function resume_levy_arts_of_war_first() { @@ -1024,7 +1024,7 @@ function goto_levy_arts_of_war() { log_br() log(game.active) game.state = 'levy_arts_of_war' - game.what = draw_two_arts_of_war_cards() + game.what = draw_two_cards() } function resume_levy_arts_of_war() { @@ -1356,15 +1356,15 @@ states.muster_capability = { if (!data.cards[c].lords || set_has(data.cards[c].lords, game.who)) { if (data.cards[c].this_lord) { if (!lord_has_capability(game.who, c)) - gen_action_arts_of_war(c) + gen_action_card(c) } else { - gen_action_arts_of_war(c) + gen_action_card(c) } } } }) }, - arts_of_war(c) { + card(c) { push_undo() logi(`Capability %C${c}`) if (data.cards[c].this_lord) { @@ -1386,10 +1386,10 @@ states.muster_capability = { states.muster_capability_discard = { prompt() { view.prompt = `Remove a capability from ${lord_name[game.who]}.` - gen_action_arts_of_war(get_lord_capability(game.who, 0)) - gen_action_arts_of_war(get_lord_capability(game.who, 1)) + gen_action_card(get_lord_capability(game.who, 0)) + gen_action_card(get_lord_capability(game.who, 1)) }, - arts_of_war(c) { + card(c) { push_undo() logi(`Discarded %C${c}`) discard_lord_capability(game.who, c) @@ -1447,6 +1447,8 @@ function plan_selected_lieutenant(first, last) { function plan_can_make_lieutenant(plan, upper, first, last) { for (let lord = first; lord <= last; ++lord) { + if (!is_lord_on_map(lord)) + continue if (lord === upper) continue if (plan.includes(lord)) @@ -1468,11 +1470,7 @@ states.campaign_plan = { let last = (current === P1) ? last_p1_lord : last_p2_lord let upper = plan_selected_lieutenant(first, last) - // view.prompt = "Build a Plan and designate Lieutenants." - //if (plan.length > 0) - //view.prompt = "Build a Plan and designate Lieutenants." view.prompt = "Designate Lieutenants and build a Plan." - view.plan = plan view.who = upper @@ -1899,8 +1897,8 @@ function gen_action_vassal(vassal) { gen_action('vassal', vassal) } -function gen_action_arts_of_war(c) { - gen_action('arts_of_war', c) +function gen_action_card(c) { + gen_action('card', c) } function gen_action_plan(lord) { @@ -1935,9 +1933,6 @@ exports.view = function(state, current) { command: game.command, hand: null, - plan: null, - who: game.who, - where: game.where, } if (current === P1) -- cgit v1.2.3