summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-11-02 16:46:08 +0100
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-11-02 16:46:08 +0100
commit034875897c20a28d569ceec2622d7ead7e436c08 (patch)
treeca98642f01cb4424e2c83d1c1ca75d71a211ccfd /rules.js
parentf34de1c19e40bd5fbab52ae09f00125c053af20e (diff)
downloadvotes-for-women-034875897c20a28d569ceec2622d7ead7e436c08.tar.gz
card actions WIP
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js41
1 files changed, 37 insertions, 4 deletions
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) {