From 1439bd62494cf3d8c8072613ab508650111efbb1 Mon Sep 17 00:00:00 2001 From: Frans Bongers Date: Fri, 3 Jan 2025 17:52:15 +0100 Subject: fix: reset first player at end of turn --- data.js | 2 +- data.ts | 2 +- rules.js | 11 +++++++---- rules.ts | 15 ++++++++++----- types.d.ts | 1 + 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/data.js b/data.js index 9ba1493..e54efe7 100644 --- a/data.js +++ b/data.js @@ -919,7 +919,7 @@ const data = { id: 62, effects: [ create_effect('attack', SOUTHERN, -5, INITIATIVE_PLAYER), - create_effect('bonus', MORALE_BONUS, OFF, INITIATIVE_PLAYER), + create_effect('bonus', TEAMWORK_BONUS, OFF, INITIATIVE_PLAYER), create_effect('track', LIBERTY, -1, INITIATIVE_PLAYER), ], test: { diff --git a/data.ts b/data.ts index f3da685..dba608e 100644 --- a/data.ts +++ b/data.ts @@ -951,7 +951,7 @@ const data: StaticData = { id: 62, effects: [ create_effect('attack', SOUTHERN, -5, INITIATIVE_PLAYER), - create_effect('bonus', MORALE_BONUS, OFF, INITIATIVE_PLAYER), + create_effect('bonus', TEAMWORK_BONUS, OFF, INITIATIVE_PLAYER), create_effect('track', LIBERTY, -1, INITIATIVE_PLAYER), ], test: { diff --git a/rules.js b/rules.js index b735703..30dc65e 100644 --- a/rules.js +++ b/rules.js @@ -162,7 +162,8 @@ function setup_player_turn() { next(); } function end_of_player_turn() { - if (get_next_faction(get_active_faction()) === game.first_player) { + const { f: faction } = get_active_node_args(); + if (get_next_faction(faction) === game.first_player) { game.engine = [ create_function_node('resolve_fascist_test'), create_function_node('setup_bag_of_glory'), @@ -309,6 +310,7 @@ function game_view(state, current) { bonuses: game.bonuses, current, current_events: game.current_events, + first_player: game.first_player, fronts: game.fronts, glory: game.glory, hand: faction === null ? [] : game.hands[faction], @@ -316,7 +318,9 @@ function game_view(state, current) { 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]), + player_order: current === OBSERVER + ? game.player_order + : get_player_order(faction).map((id) => faction_player_map[id]), selectable_cards: game.selectable_cards, selected_cards: current === OBSERVER ? [] : game.selected_cards[faction], tableaus: game.tableaus, @@ -1764,6 +1768,7 @@ function end_of_turn() { }); game.active_abilities = []; game.used_medallions = []; + game.first_player = null; if (game.turn === 4) { end_of_year(); } @@ -2348,9 +2353,7 @@ function get_previous_faction(faction_id) { return player_faction_map[game.player_order[index - 1]]; } function get_next_faction(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 player_faction_map[game.player_order[0]]; } diff --git a/rules.ts b/rules.ts index 0692e79..e620ad8 100644 --- a/rules.ts +++ b/rules.ts @@ -316,7 +316,8 @@ function setup_player_turn() { } function end_of_player_turn() { - if (get_next_faction(get_active_faction()) === game.first_player) { + const { f: faction } = get_active_node_args(); + if (get_next_faction(faction) === game.first_player) { game.engine = [ create_function_node('resolve_fascist_test'), create_function_node('setup_bag_of_glory'), @@ -491,7 +492,8 @@ export { game_view as view }; function game_view(state: Game, current: Player | 'Observer') { game = state; - const faction: FactionId | null = current === OBSERVER ? null : player_faction_map[current]; + const faction: FactionId | null = + current === OBSERVER ? null : player_faction_map[current]; view = { engine: game.engine, // TODO: remove @@ -501,6 +503,7 @@ function game_view(state: Game, current: Player | 'Observer') { bonuses: game.bonuses, current, current_events: game.current_events, + first_player: game.first_player, fronts: game.fronts, glory: game.glory, hand: faction === null ? [] : game.hands[faction], @@ -508,7 +511,10 @@ function game_view(state: Game, current: Player | 'Observer') { 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]), + player_order: + current === OBSERVER + ? game.player_order + : get_player_order(faction).map((id) => faction_player_map[id]), selectable_cards: game.selectable_cards, selected_cards: current === OBSERVER ? [] : game.selected_cards[faction], tableaus: game.tableaus, @@ -2179,6 +2185,7 @@ function end_of_turn() { }); game.active_abilities = []; game.used_medallions = []; + game.first_player = null; if (game.turn === 4) { end_of_year(); } else { @@ -2990,9 +2997,7 @@ function get_previous_faction(faction_id: FactionId): FactionId { } function get_next_faction(faction_id: FactionId): FactionId { - 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 player_faction_map[game.player_order[0]]; } diff --git a/types.d.ts b/types.d.ts index 1f179cd..d68a7e9 100644 --- a/types.d.ts +++ b/types.d.ts @@ -86,6 +86,7 @@ export interface View { bag_of_glory: Game['bag_of_glory']; bonuses: Game['bonuses']; current_events: CardId[]; + first_player: Game['first_player']; fronts: Game['fronts']; glory: Game['glory']; hand: CardId[]; -- cgit v1.2.3