From 31e14b3a7419d50e742e5b6288105cb26419bdcc Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 3 Dec 2022 16:15:16 +0100 Subject: Sail! --- play.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index a127b5b..bd7207e 100644 --- a/play.js +++ b/play.js @@ -253,6 +253,21 @@ function is_card_in_use(c) { return false } +function has_global_capability(cap) { + for (let c of view.capabilities) + if (data.cards[c].capability === cap) + return true + return false +} + +function is_vassal_ready(vassal) { + return view.lords.vassals[vassal] === 0 +} + +function is_vassal_mustered(vassal) { + return view.lords.vassals[vassal] > 0 +} + function for_each_teutonic_card(fn) { for (let i = 0; i < 21; ++i) fn(i) @@ -808,13 +823,17 @@ function update_assets(id, parent, assets) { function update_vassals(ready_parent, mustered_parent, lord_ix) { for (let v of data.lords[lord_ix].vassals) { let e = ui.vassal_service[v] - if (view.lords.vassals[v] === 0) { + if (is_vassal_ready(v)) { e.classList.remove("hide") ready_parent.appendChild(e) - } else { + } + else if (is_vassal_mustered(v)) { e.classList.remove("hide") mustered_parent.appendChild(e) } + else { + e.classList.add("hide") + } e.classList.toggle("action", is_vassal_action(v)) } } -- cgit v1.2.3