diff options
author | Frans Bongers <fransbongers@franss-mbp.home> | 2024-12-31 13:05:16 +0100 |
---|---|---|
committer | Frans Bongers <fransbongers@franss-mbp.home> | 2024-12-31 13:05:16 +0100 |
commit | 1298b27e451f9cbc5c784581b630577ad9d074f7 (patch) | |
tree | 08455b17627523171c91c3dc24065c4f8142dfa5 /rules.js | |
parent | 50d95d906d7d782d155e75635be4d637c1ccfb25 (diff) | |
download | land-and-freedom-1298b27e451f9cbc5c784581b630577ad9d074f7.tar.gz |
random player order and show ui relative to player order
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -5,6 +5,7 @@ exports.action = action; exports.view = game_view; exports.setup = setup; const data_1 = require("./data"); +const OBSERVER = 'Observer'; const states = {}; let game = {}; var view = {}; @@ -297,25 +298,27 @@ function resolve_active_and_proceed(checkpoint = false) { resolve_active_node(checkpoint); next(); } -function game_view(state, player) { +function game_view(state, current) { game = state; - const faction_id = player_faction_map[player]; + const faction = current === OBSERVER ? null : player_faction_map[current]; view = { engine: game.engine, log: game.log, prompt: null, bag_of_glory: game.bag_of_glory, bonuses: game.bonuses, + current, current_events: game.current_events, fronts: game.fronts, glory: game.glory, - hand: game.hands[faction_id], + hand: faction === null ? [] : game.hands[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(faction).map((id) => faction_player_map[id]), selectable_cards: game.selectable_cards, - selected_cards: game.selected_cards[faction_id], + selected_cards: current === OBSERVER ? [] : game.selected_cards[faction], tableaus: game.tableaus, tracks: game.tracks, triggered_track_effects: game.triggered_track_effects, @@ -325,7 +328,7 @@ function game_view(state, player) { if (game.state === 'game_over') { view.prompt = game.victory; } - else if (player !== game.active) { + else if (current !== game.active) { let inactive = states[game.state].inactive || game.state; view.prompt = `Waiting for ${game.active} to ${inactive}.`; } @@ -400,6 +403,7 @@ function setup(seed, _scenario, _options) { pool: [], }, played_card: null, + player_order: [data_1.MODERATE], selectable_cards: [], selected_cards: { a: [], @@ -425,6 +429,8 @@ function setup(seed, _scenario, _options) { turn: 0, year: 0, }; + game.player_order.push(exports.roles[random(2)]); + game.player_order.push(game.player_order[1] === data_1.ANARCHIST ? data_1.COMMUNIST : data_1.ANARCHIST); draw_medallions(); start_year(); return game; @@ -2335,18 +2341,20 @@ function get_player_order(first_player = game.initiative) { return order; } function get_previous_faction(faction_id) { - const index = role_ids.indexOf(faction_id); + const index = game.player_order.indexOf(faction_player_map[faction_id]); if (index === 0) { - return role_ids[2]; + return player_faction_map[game.player_order[2]]; } - return role_ids[index - 1]; + return player_faction_map[game.player_order[index - 1]]; } function get_next_faction(faction_id) { - const index = role_ids.indexOf(faction_id); + console.log('get_next', faction_id); + const index = game.player_order.indexOf(faction_player_map[faction_id]); + console.log('index', index); if (index === 2) { - return role_ids[0]; + return player_faction_map[game.player_order[0]]; } - return role_ids[index + 1]; + return player_faction_map[game.player_order[index + 1]]; } function get_factions_with_most_hero_poins() { let most_hero_points = null; |