From 0341a2e6c13d2b6e401cff21cc51d11d248ddb6e Mon Sep 17 00:00:00 2001 From: Frans Bongers Date: Mon, 2 Dec 2024 22:03:02 +0100 Subject: resolve icons --- rules.ts | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 3 deletions(-) (limited to 'rules.ts') diff --git a/rules.ts b/rules.ts index e5206bd..51666c3 100644 --- a/rules.ts +++ b/rules.ts @@ -8,6 +8,7 @@ import { FactionId, FunctionNode, Game, + Icon, LeafNode, Player, PlayerCard, @@ -530,9 +531,72 @@ function start_turn() { states.activate_icon = { inactive: 'activate an icon', prompt() { - view.prompt = 'Choose an icon to activate' - } -} + view.prompt = 'Choose an icon to activate'; + const c = cards[game.chosen_cards[get_active_faction_id()]] as PlayerCard; + for (const i of c.icons) { + gen_action(i); + } + }, + add_to_front() { + // insert state to select front + resolve_active_and_proceed(); + }, + collectivization() { + move_track(COLLECTIVIZATION, get_icon_count_in_tableau('collectivization')); + resolve_active_and_proceed(); + }, + d_collectivization() { + move_track( + COLLECTIVIZATION, + -1 * get_icon_count_in_tableau('d_collectivization') + ); + resolve_active_and_proceed(); + }, + d_foreign_aid() { + move_track(FOREIGN_AID, -1 * get_icon_count_in_tableau('d_foreign_aid')); + resolve_active_and_proceed(); + }, + d_government() { + move_track(GOVERNMENT, -1 * get_icon_count_in_tableau('d_government')); + resolve_active_and_proceed(); + }, + d_liberty() { + move_track(LIBERTY, -1 * get_icon_count_in_tableau('d_liberty')); + resolve_active_and_proceed(); + }, + d_soviet_support() { + move_track( + SOVIET_SUPPORT, + -1 * get_icon_count_in_tableau('d_soviet_support') + ); + resolve_active_and_proceed(); + }, + draw_card() { + // TODO: draw cards + resolve_active_and_proceed(); + }, + foreign_aid() { + move_track(FOREIGN_AID, get_icon_count_in_tableau('foreign_aid')); + resolve_active_and_proceed(); + }, + government() { + move_track(GOVERNMENT, get_icon_count_in_tableau('government')); + resolve_active_and_proceed(); + }, + government_to_center() {}, + liberty() { + move_track(LIBERTY, get_icon_count_in_tableau('liberty')); + resolve_active_and_proceed(); + }, + soviet_support() { + move_track(SOVIET_SUPPORT, get_icon_count_in_tableau('soviet_support')); + resolve_active_and_proceed(); + }, + teamwork_on() { + game.bonuses[TEAMWORK_BONUS] = ON; + resolve_active_and_proceed(); + }, +}; states.add_glory = { inactive: 'add tokens to the Bag of Glory', @@ -1275,6 +1339,22 @@ function get_faction_id(player: Player): FactionId { return player_faction_map[player]; } +function get_icon_count_in_tableau( + icon: Icon, + faction: FactionId = get_active_faction_id() +) { + let count = 0; + for (const c of game.tableaus[faction]) { + const card = cards[c] as PlayerCard; + for (const i of card.icons) { + if (i === icon) { + ++count; + } + } + } + return count; +} + function get_player(faction_id: FactionId) { return faction_player_map[faction_id]; } -- cgit v1.2.3