From 034875897c20a28d569ceec2622d7ead7e436c08 Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:46:08 +0100 Subject: card actions WIP --- rules.js | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index acae9ac..ba32e48 100644 --- a/rules.js +++ b/rules.js @@ -112,7 +112,7 @@ function init_player_cards(first_card) { function draw_card(deck) { if (deck.length === 0) throw Error("can't draw from empty deck") - return deck.splice(-1) + return deck.pop() } function start_turn() { @@ -190,12 +190,41 @@ function goto_operations_phase() { begin_player_round() } +function current_player_hand() { + if (game.active === SUF) { + return game.support_hand + } else if (game.active === OPP) { + return game.opposition_hand + } + return [] +} + states.operations_phase = { inactive: "to do Operations Phase", prompt() { view.prompt = "Operations Phase: Play a Card" + + for (let c of current_player_hand()) { + gen_action("card_event", c) + gen_action("card_campaigning", c) + gen_action("card_organizing", c) + gen_action("card_lobbying", c) + } + gen_action("done") }, + card_event(c) { + log(`Playing C${c} as Event`) + }, + card_campaigning(c) { + log(`Playing C${c} for Campaigning Action`) + }, + card_organizing(c) { + log(`Playing C${c} for Organizing Action`) + }, + card_lobbying(c) { + log(`Playing C${c} for Lobbying Action`) + }, done() { end_player_round() } @@ -272,9 +301,13 @@ function end_cleanup_phase() { // public functions function gen_action(action, argument) { - if (!(action in view.actions)) - view.actions[action] = [] - view.actions[action].push(argument) + if (argument === undefined) { + view.actions[action] = 1 + } else { + if (!(action in view.actions)) + view.actions[action] = [] + view.actions[action].push(argument) + } } exports.action = function (state, player, action, arg) { -- cgit v1.2.3