diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-11-20 13:55:28 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 13:02:37 +0100 |
commit | dbde089d9b07e7f3cb74f70a0d92004ad8602092 (patch) | |
tree | 5703dd329585569c793f582e13155be6a9ac55fc | |
parent | 498a33e60fd88f01c541bb0dd07c7572de4b0194 (diff) | |
download | nevsky-dbde089d9b07e7f3cb74f70a0d92004ad8602092.tar.gz |
Discard This Levy and This Campaign events at end of levy and campaign.
-rw-r--r-- | play.js | 7 | ||||
-rw-r--r-- | rules.js | 30 |
2 files changed, 29 insertions, 8 deletions
@@ -298,6 +298,7 @@ const ui = { events: document.getElementById("events"), p1_capabilities: document.getElementById("p1_capabilities"), p2_capabilities: document.getElementById("p2_capabilities"), + hand: document.getElementById("hand"), command: document.getElementById("command"), turn: document.getElementById("turn"), vp1: document.getElementById("vp1"), @@ -761,6 +762,12 @@ function update_arts_of_war() { ui.p2_capabilities.appendChild(ui.arts_of_war[c]) }) + ui.hand.replaceChildren() + if (view.hand) { + for (let c of view.hand) + ui.hand.appendChild(ui.arts_of_war[c]) + } + for (let ix = 0; ix < data.lords.length; ++ix) { let side = ix < 6 ? "teutonic" : "russian" ui.lord_capabilities[ix].replaceChildren() @@ -927,17 +927,17 @@ states.levy_arts_of_war = { let c = game.what[0] view.what = c switch (data.cards[c].when) { - case "this_levy": - case "this_campaign": - case "now": + case 'this_levy': + case 'this_campaign': + case 'now': view.prompt = `Play ${data.cards[c].event}.` view.actions.play = 1 break - case "hold": + case 'hold': view.prompt = `Hold ${data.cards[c].event}.` view.actions.hold = 1 break - case "never": + case 'never': view.prompt = `Discard ${data.cards[c].event}.` view.actions.discard = 1 break @@ -946,7 +946,7 @@ states.levy_arts_of_war = { play() { let c = game.what.shift() log(`Played #${c} ${data.cards[c].event}.`) - if (data.cards[c].when === "this_levy" || data.cards[c].when === "this_campaign") + if (data.cards[c].when === 'this_levy' || data.cards[c].when === 'this_campaign') set_add(game.events, c) log(`TODO implement event`) resume_levy_arts_of_war() @@ -955,9 +955,9 @@ states.levy_arts_of_war = { let c = game.what.shift() log(`Held event card.`) if (game.active === P1) - set_add(game.p1_hand, c) + game.p1_hand.push(c) else - set_add(game.p2_hand, c) + game.p2_hand.push(c) resume_levy_arts_of_war() }, discard() { @@ -1305,6 +1305,10 @@ function end_levy_call_to_arms() { function goto_campaign_plan() { game.turn++ + // Discard "This Levy" events from play. + if (game.events.length > 0) + game.events = game.events.filter(c => data.cards[c].when !== 'this_levy') + log_h1("Campaign " + current_turn_name()) set_active(BOTH) @@ -1609,6 +1613,10 @@ function end_disband() { // === CAMPAIGN: REMOVE MARKERS === function goto_remove_markers() { + // Discard "This Campaign" events from play. + if (game.events.length > 0) + game.events = game.events.filter(c => data.cards[c].when !== 'this_campaign') + game.lords.moved = 0 goto_command_activation() } @@ -1745,11 +1753,17 @@ exports.view = function(state, current) { veche_coin: game.veche_coin, command: game.command, + hand: null, plan: null, who: game.who, where: game.where, } + if (current === P1) + view.hand = game.p1_hand + if (current === P2) + view.hand = game.p2_hand + if (game.state === 'game_over') { view.prompt = game.victory } else if (current === 'Observer' || (game.active !== current && game.active !== BOTH)) { |