diff options
-rw-r--r-- | rules.js | 98 |
1 files changed, 73 insertions, 25 deletions
@@ -5,7 +5,8 @@ const VERSAILLES = "Versailles"; var game, view, states = {} -exports.scenarios = [ "Standard" ] +exports.scenarios = [ "Standard", "Censorship" ] + exports.roles = [ COMMUNE, VERSAILLES ] const first_commune_cube = 0 @@ -238,6 +239,16 @@ const ADJACENT_FROM = [ // === GAME STATE === +function discard_card(c) { + array_remove_item(player_hand(game.active), c) + game.discard = c +} + +function recycle_card(c) { + array_remove_item(player_hand(game.active), c) + game.strategy_deck.unshift(c) +} + function is_objective_card(c) { return c >= 42 && c <= 53 } @@ -595,7 +606,15 @@ function for_each_versailles_disc(s, f) { f(p) } -// === OBJECTIVE PHASE === +function commune_political_vp() { + return game.political_vp +} + +function versailles_political_vp() { + return -game.political_vp +} + +// === CHOOSE OBJECTIVE CARD === states.choose_objective_card = { inactive: "choose an objective card", @@ -614,7 +633,7 @@ states.choose_objective_card = { game.blue_hand = game.blue_hand.filter(c => !is_objective_card(c)) } if (game.red_objective > 0 && game.blue_objective > 0) - goto_initiative_phase() + end_choose_objective_card() else if (game.red_objective > 0) game.active = VERSAILLES else if (game.blue_objective > 0) @@ -624,15 +643,11 @@ states.choose_objective_card = { }, } -// === INITIATIVE PHASE === - -function commune_political_vp() { - return game.political_vp +function end_choose_objective_card() { + goto_initiative_phase() } -function versailles_political_vp() { - return -game.political_vp -} +// === INITIATIVE PHASE === function goto_initiative_phase() { let c_level = commune_political_vp() - game.red_momentum @@ -654,18 +669,48 @@ states.initiative_phase = { commune() { log("Initiative: Commune") game.initiative = COMMUNE - game.active = game.initiative - goto_strategy_phase() + end_initiative_phase() }, versailles() { log("Initiative: Versailles") game.initiative = VERSAILLES - game.active = game.initiative + end_initiative_phase() + }, +} + +function end_initiative_phase() { + game.active = game.initiative + if (game.scenario === "Censorship") + goto_censorship_phase() + else goto_strategy_phase() +} + +// === CENSORSHIP PHASE === + +function goto_censorship_phase() { + game.state = "censorship_phase" +} + +states.censorship_phase = { + inactive: "censorship phase", + prompt() { + view.prompt = "Discard a card from your hand." + for (let c of player_hand(game.active)) + if (is_strategy_card(c)) + gen_action("card", c) + }, + card(c) { + log(`Discarded #${c}.`) + discard_card(c) + if (game.active === game.initiative) + game.active = enemy_player() + else + goto_strategy_phase() }, } -// === STRATEGY PHASE === +// === PLAYING STRATEGY CARDS === function goto_strategy_phase() { clear_undo() @@ -709,8 +754,7 @@ states.strategy_phase = { card_event(c) { push_undo() log(`Played #${c} for event.`) - array_remove_item(player_hand(game.active), c) - game.discard = c + discard_card(c) goto_play_event() }, card_ops_political(c) { @@ -718,8 +762,7 @@ states.strategy_phase = { if (c === 17 || c === 34) return goto_final_crisis_discard(c, POLITICAL) log(`Played #${c} for ${card_ops[c]} Political ops.`) - array_remove_item(player_hand(game.active), c) - game.discard = c + discard_card(c) goto_operations(card_ops[c], POLITICAL) }, card_ops_military(c) { @@ -727,15 +770,16 @@ states.strategy_phase = { if (c === 17 || c === 34) return goto_final_crisis_discard(c, MILITARY) log(`Played #${c} for ${card_ops[c]} Military ops.`) - array_remove_item(player_hand(game.active), c) - game.discard = c + discard_card(c) goto_operations(card_ops[c], MILITARY) }, card_advance_momentum(c) { push_undo() log(`Played #${c} to advance momentum.`) - array_remove_item(player_hand(game.active), c) - game.discard = c + if (game.scenario === "Censorship") + recycle_card(c) + else + discard_card(c) if (game.active === COMMUNE) game.red_momentum += 1 else @@ -747,8 +791,7 @@ states.strategy_phase = { push_undo() log(`Discarded #${c} to play #${game.discard}.`) let old_c = game.discard - array_remove_item(player_hand(game.active), c) - game.discard = c + discard_card(c) goto_play_event(old_c) }, } @@ -1017,6 +1060,7 @@ function goto_play_event(c) { exports.setup = function (seed, scenario, options) { game = { seed: seed, + scenario: scenario, log: [], undo: [], active: "Both", @@ -1107,7 +1151,11 @@ exports.setup = function (seed, scenario, options) { shuffle(game.strategy_deck) shuffle(game.objective_deck) - for (let i = 0; i < 4; ++i) { + let n = 4 + if (game.scenario === "Censorship") + n = 5 + + for (let i = 0; i < 5; ++i) { game.red_hand.push(game.strategy_deck.pop()) game.blue_hand.push(game.strategy_deck.pop()) } |