diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 44 |
1 files changed, 36 insertions, 8 deletions
@@ -150,7 +150,7 @@ function setup_final_bid() { function setup_player_turn() { const next_faction = game.first_player === null ? get_player_order()[0] - : get_next_faction(get_active_faction()); + : get_next_faction_in_player_order(get_active_faction()); if (game.first_player === null) { game.first_player = next_faction; } @@ -161,9 +161,17 @@ function setup_player_turn() { ]; next(); } +function check_end_of_year_discard() { + const { f: faction } = get_active_node_args(); + if (game.hands[faction].length > get_hand_limit(faction) || + game.tableaus[faction].length > game.year) { + insert_after_active_node(create_leaf_node('end_of_year_discard', faction)); + } + resolve_active_and_proceed(); +} function end_of_player_turn() { const { f: faction } = get_active_node_args(); - if (get_next_faction(faction) === game.first_player) { + if (get_next_faction_in_player_order(faction) === game.first_player) { game.engine = [ create_function_node('resolve_fascist_test'), create_function_node('setup_bag_of_glory'), @@ -182,6 +190,7 @@ function start_of_player_turn() { resolve_active_and_proceed(); } const engine_functions = { + check_end_of_year_discard, checkpoint, end_of_player_turn, end_of_turn, @@ -319,7 +328,7 @@ function game_view(state, current) { played_card: game.played_card, player_order: current === OBSERVER ? game.player_order - : get_player_order(faction).map((id) => faction_player_map[id]), + : get_player_order_in_game(faction).map((id) => faction_player_map[id]), selectable_cards: game.selectable_cards, selected_cards: current === OBSERVER ? [] : game.selected_cards[faction], tableaus: game.tableaus, @@ -985,7 +994,8 @@ states.end_of_year_discard = { view.prompt = 'Discard a card'; const faction_id = get_active_faction(); const hand = game.hands[faction_id]; - if (hand.length > get_hand_limit(faction_id)) { + const hand_limit = get_hand_limit(faction_id); + if (hand.length > hand_limit) { for (let c of hand) gen_action_card(c); } @@ -1246,7 +1256,7 @@ states.player_turn = { else if (can_play_card && !can_spend_hp) { view.prompt = 'Play a card'; } - else if (can_spend_hp || use_ap || use_morale_bonus) { + else if (use_ap || use_morale_bonus) { const text_options = []; if (use_ap) { text_options.push('Action Points'); @@ -1255,10 +1265,13 @@ states.player_turn = { text_options.push('Morale Bonus'); } if (can_spend_hp) { - text_options.push('Hero points'); + text_options.push('spend Hero points'); } view.prompt = `Use ${text_options.join(', ')} or end turn`; } + else if (can_spend_hp) { + view.prompt = 'Spend Hero Points or end turn'; + } else { view.prompt = 'End turn'; } @@ -1670,7 +1683,7 @@ states.use_strategy_medallion = { }; function card1_event2() { const value = game.tracks[data_1.FOREIGN_AID] >= 6 ? 3 : 2; - insert_after_active_node(resolve_effect((0, data_1.create_effect)('track', data_1.FOREIGN_AID, value))); + insert_after_active_node(resolve_effect((0, data_1.create_effect)('front', data_1.NORTHERN, value))); resolve_active_and_proceed(); } function card3_event2() { @@ -1880,7 +1893,7 @@ function end_of_year() { } const players_to_gain_hero_points = role_ids.filter((f) => !glory_this_year[f]); gain_hero_points_in_player_order(players_to_gain_hero_points, game.year); - game.engine = get_player_order().map((f) => create_leaf_node('end_of_year_discard', f)); + game.engine = get_player_order().map((f) => create_function_node('check_end_of_year_discard', { f })); game.engine.push(create_function_node('checkpoint')); game.engine.push(create_function_node('start_year')); game.top_of_events_deck = null; @@ -2005,6 +2018,9 @@ function get_fronts_to_add_to(target, not = []) { else if (target === data_1.ANY) { return data_1.FRONTS.filter((id) => game.fronts[id].status === null && !not.includes(id)); } + else if (game.fronts[target].status === data_1.DEFEAT) { + return get_fronts_closest_to(data_1.CLOSEST_TO_DEFEAT); + } else { return [target]; } @@ -2416,6 +2432,9 @@ function get_player_order(first_player = game.initiative) { } return order; } +function get_next_faction_in_player_order(faction_id) { + return get_player_order(faction_id)[1]; +} function get_previous_faction(faction_id) { const index = game.player_order.indexOf(faction_player_map[faction_id]); if (index === 0) { @@ -2430,6 +2449,15 @@ function get_next_faction(faction_id) { } return player_faction_map[game.player_order[index + 1]]; } +function get_player_order_in_game(first_player = game.initiative) { + const order = []; + let faction = first_player; + for (let i = 0; i < 3; ++i) { + order.push(faction); + faction = get_next_faction(faction); + } + return order; +} function get_factions_with_most_hero_poins() { let most_hero_points = null; let faction_ids = []; |