summaryrefslogtreecommitdiff
path: root/rules.ts
diff options
context:
space:
mode:
Diffstat (limited to 'rules.ts')
-rw-r--r--rules.ts101
1 files changed, 51 insertions, 50 deletions
diff --git a/rules.ts b/rules.ts
index 97b2350..cc35bdf 100644
--- a/rules.ts
+++ b/rules.ts
@@ -174,7 +174,7 @@ export function action(
) {
game = state;
- if (action !== 'undo' && game.state !== 'choose_card') {
+ if (action !== 'undo' && game.state !== 'choose_card' && !game.fascist) {
push_undo();
}
@@ -242,6 +242,8 @@ function setup_bag_of_glory() {
}
function setup_choose_card() {
+ game.fascist = 0;
+
game.engine = [create_state_node('choose_card', 'all')];
game.engine.push(create_function_node('setup_player_turn'));
@@ -249,6 +251,8 @@ function setup_choose_card() {
}
function setup_final_bid() {
+ game.fascist = 0;
+
log_h1('Final Bid');
const player_order = get_player_order();
game.engine = player_order.map((faction_id) =>
@@ -261,6 +265,8 @@ function setup_final_bid() {
}
function setup_player_turn() {
+ game.fascist = 0;
+
const next_faction =
game.first_player === null
? get_player_order()[0]
@@ -513,39 +519,36 @@ function game_view(state: Game, current: Player | 'Observer') {
current === OBSERVER ? null : player_faction_map[current];
view = {
- active: game.active,
- engine: game.engine, // TODO: remove
+ // active: game.active,
+ // engine: game.engine, // TODO: remove
log: game.log,
prompt: null,
- state: game.state,
+ // state: game.state,
bag_of_glory: game.bag_of_glory,
bag_of_glory_count: game.bag_of_glory.length,
bonuses: game.bonuses,
- current,
- current_player_faction: faction,
+ // current,
+ // current_player_faction: faction,
current_events: game.current_events,
first_player: game.first_player,
fronts: game.fronts,
glory: game.glory,
hand: faction === null ? [] : game.hands[faction],
- discard: faction === null ? [] : game.discard[faction],
- trash: faction === null ? [] : game.trash[faction],
- deck: faction === null ? [] : list_deck(faction),
+ // discard: faction === null ? [] : game.discard[faction],
+ // trash: faction === null ? [] : game.trash[faction],
+ // deck: faction === null ? [] : list_deck(faction),
hero_points: game.hero_points,
initiative: game.initiative,
medallions: game.medallions,
played_card: game.played_card,
- player_order:
- current === OBSERVER
- ? game.player_order
- : get_player_order_in_game(faction).map((id) => faction_player_map[id]),
- selectable_cards: game.selectable_cards,
+ player_order: current === OBSERVER ? get_player_order() : get_player_order_in_game(faction),
selected_cards: current === OBSERVER ? [] : game.selected_cards[faction],
tableaus: game.tableaus,
tracks: game.tracks,
triggered_track_effects: game.triggered_track_effects,
used_medallions: game.used_medallions,
year: game.year,
+ fascist: game.fascist,
};
if (game.state === 'game_over') {
@@ -580,7 +583,6 @@ export function setup(seed: number, _scenario: string, _options: unknown) {
active: ANARCHIST,
active_abilities: [],
bag_of_glory: [ANARCHISTS_ID, COMMUNISTS_ID, MODERATES_ID],
- blank_markers: [[], [], [], [], []],
bonuses: [ON, ON],
current_events: [],
discard: {
@@ -635,7 +637,6 @@ export function setup(seed: number, _scenario: string, _options: unknown) {
},
played_card: null,
player_order: [MODERATE],
- selectable_cards: [],
selected_cards: {
a: [],
c: [],
@@ -660,6 +661,7 @@ export function setup(seed: number, _scenario: string, _options: unknown) {
turn: 0,
year: 0,
glory_current_year: null,
+ fascist: 0,
};
// Randomly choose second player
@@ -727,6 +729,7 @@ function start_turn() {
log_h2('Fascist Event', 'fascist');
log(card.title);
+ game.fascist = 1;
game.engine = card.effects.map((effect) =>
resolve_effect(effect, 'fascist_event')
);
@@ -1719,7 +1722,8 @@ states.peek_fascist_cards = {
prompt() {
gen_spend_hero_points();
view.prompt = 'Choose one card to return to the top of the deck';
- for (const c of game.selectable_cards) {
+ view.fascist_cards = game.fascist_cards
+ for (const c of game.fascist_cards) {
gen_action_card(c);
}
},
@@ -1728,12 +1732,12 @@ states.peek_fascist_cards = {
},
card(c: CardId) {
game.top_of_events_deck = c;
- for (const ec of game.selectable_cards) {
+ for (const ec of game.fascist_cards) {
if (ec !== c) {
game.discard.f.push(ec);
}
}
- game.selectable_cards = [];
+ delete game.fascist_cards;
resolve_active_and_proceed();
},
};
@@ -2011,16 +2015,22 @@ states.remove_attack_from_fronts = {
};
states.return_card = {
- inactive: 'return a card to their hand',
+ inactive: "return a card to their hand",
prompt() {
+ const faction = get_active_faction();
gen_spend_hero_points();
- view.prompt = 'Choose a card to return to your hand';
- if (game.selectable_cards.length === 0) {
- view.prompt = 'No card in trash to return. You must skip';
- gen_action('skip');
+ view.prompt = "Choose a card to return to your hand";
+ view.trash = game.trash[faction]
+ let possible = false;
+ for (let c of game.trash[faction]) {
+ if (c !== game.played_card) {
+ gen_action_card(c);
+ possible = true;
+ }
}
- for (const c of game.selectable_cards) {
- gen_action_card(c);
+ if (!possible) {
+ view.prompt = "No card in trash to return. You must skip";
+ gen_action("skip");
}
},
spend_hp() {
@@ -2031,15 +2041,12 @@ states.return_card = {
array_remove(game.trash[faction], game.trash[faction].indexOf(c));
game.hands[faction].push(c);
logi(`${faction_player_map[faction]} returns a card to their hand`);
-
- game.selectable_cards = [];
resolve_active_and_proceed();
},
skip() {
- game.selectable_cards = [];
resolve_active_and_proceed();
},
-};
+}
states.spend_hero_points = {
inactive: 'spend Hero points',
@@ -2484,8 +2491,9 @@ function card45_event2() {
}
function card46_event3() {
+ game.fascist_cards = []
for (let i = 0; i < 3; ++i) {
- game.selectable_cards.push(draw_fascist_card());
+ game.fascist_cards.push(draw_fascist_card());
}
resolve_active_and_proceed();
}
@@ -2513,10 +2521,6 @@ function card54_event1() {
}
function setup_return_card_from_trash() {
- const faction = get_active_faction();
- game.selectable_cards = game.trash[faction].filter(
- (c) => c !== game.played_card
- );
resolve_active_and_proceed();
}
@@ -2779,6 +2783,8 @@ function play_card(
}
function resolve_fascist_test() {
+ game.fascist = 1
+
log_h2('Fascist Test', 'fascist');
const test = get_current_event().test;
@@ -3357,7 +3363,7 @@ function log_h1(msg: string) {
function log_h2(msg: string, player?: Player | 'fascist') {
log_br();
- log(`.h2${player ? `.${player}` : ''} ${msg}`);
+ log(`#${player[0].toLowerCase()} ${msg}`);
log_br();
}
@@ -3538,21 +3544,16 @@ function list_deck(id: FactionId | 'f') {
const card_list: CardId[] =
id === FASCIST_ID ? fascist_decks[game.year] : faction_cards[id];
card_list.forEach((card) => {
- if (
- game.discard[id].includes(card) ||
- game.selectable_cards.includes(card)
- ) {
- return;
- }
-
- if (id === FASCIST_ID && game.current_events.includes(card)) {
- return;
+ if (id === FASCIST_ID) {
+ if (game.current_events.includes(card))
+ return;
+ if (game.discard[id].includes(card))
+ return;
} else if (
- id !== FASCIST_ID &&
- (game.hands[id].includes(card) ||
- game.discard[id].includes(card) ||
- game.tableaus[id].includes(card) ||
- game.trash[id].includes(card))
+ game.hands[id].includes(card) ||
+ game.discard[id].includes(card) ||
+ game.tableaus[id].includes(card) ||
+ game.trash[id].includes(card)
) {
return;
}