diff options
-rw-r--r-- | rules.js | 44 | ||||
-rw-r--r-- | rules.ts | 52 |
2 files changed, 79 insertions, 17 deletions
@@ -948,7 +948,10 @@ states.select_player_with_most_hero_points = { inactive: 'choose a Player', prompt() { const { v } = get_active_node_args(); - view.prompt = v < 0 ? 'Choose player to lose Hero Points' : 'Choose player to gain Hero Points'; + view.prompt = + v < 0 + ? 'Choose player to lose Hero Points' + : 'Choose player to gain Hero Points'; const factions = get_factions_with_most_hero_poins(); for (let faction_id of factions) { gen_action(faction_player_map[faction_id]); @@ -1222,10 +1225,36 @@ states.swap_card_tableau_hand = { } }, }; +function resolve_take_hero_points(faction) { + const { v } = get_active_node_args(); + const amount = Math.min(v, game.hero_points[faction]); + lose_hero_point(faction, amount); + gain_hero_points(get_active_faction(), amount); + resolve_active_and_proceed(); +} states.take_hero_points = { inactive: 'take Hero Points', prompt() { - view.prompt = 'Choose a player to take Hero Points from'; + const { v } = get_active_node_args(); + view.prompt = + v === 1 + ? 'Choose a player to take a Hero Point from' + : `Choose a player to take ${v} Hero Points from`; + const active_faction = get_active_faction(); + for (const faction of role_ids) { + if (faction !== active_faction) { + gen_action(faction_player_map[faction]); + } + } + }, + Anarchist() { + resolve_take_hero_points(data_1.ANARCHISTS_ID); + }, + Communist() { + resolve_take_hero_points(data_1.COMMUNISTS_ID); + }, + Moderate() { + resolve_take_hero_points(data_1.MODERATES_ID); }, }; states.use_organization_medallion = { @@ -1487,14 +1516,15 @@ function gain_hero_points_in_player_order(factions, value) { } } } -function gain_hero_points(faction_id, value) { +function gain_hero_points(faction_id, value, skip_abilities = false) { if (game.hero_points.pool === 0) { return; } - if ((faction_id === data_1.ANARCHISTS_ID && - (game.active_abilities || []).includes(data_1.ANARCHIST_EXTRA_HERO_POINT)) || - (faction_id === data_1.COMMUNISTS_ID && - (game.active_abilities || []).includes(data_1.COMMUNIST_EXTRA_HERO_POINT))) { + if (!skip_abilities && + ((faction_id === data_1.ANARCHISTS_ID && + (game.active_abilities || []).includes(data_1.ANARCHIST_EXTRA_HERO_POINT)) || + (faction_id === data_1.COMMUNISTS_ID && + (game.active_abilities || []).includes(data_1.COMMUNIST_EXTRA_HERO_POINT)))) { value++; } const gain = Math.min(game.hero_points.pool, value); @@ -1164,17 +1164,19 @@ function resolve_player_with_most_hero_points(faction: FactionId) { if (value < 0) { lose_hero_point(faction, value); } else { - gain_hero_points(faction, value) + gain_hero_points(faction, value); } resolve_active_and_proceed(); } - states.select_player_with_most_hero_points = { inactive: 'choose a Player', prompt() { const { v } = get_active_node_args(); - view.prompt = v < 0 ? 'Choose player to lose Hero Points' : 'Choose player to gain Hero Points'; + view.prompt = + v < 0 + ? 'Choose player to lose Hero Points' + : 'Choose player to gain Hero Points'; const factions = get_factions_with_most_hero_poins(); for (let faction_id of factions) { @@ -1506,12 +1508,37 @@ states.swap_card_tableau_hand = { // card(c: CardId) {}, }; -// TODO: implement, card 12 + card 32 + card 44 -// Value should come from args +function resolve_take_hero_points(faction: FactionId) { + const { v } = get_active_node_args(); + const amount = Math.min(v, game.hero_points[faction]); + lose_hero_point(faction, amount); + gain_hero_points(get_active_faction(), amount); + resolve_active_and_proceed(); +} + states.take_hero_points = { inactive: 'take Hero Points', prompt() { - view.prompt = 'Choose a player to take Hero Points from'; + const { v } = get_active_node_args(); + view.prompt = + v === 1 + ? 'Choose a player to take a Hero Point from' + : `Choose a player to take ${v} Hero Points from`; + const active_faction = get_active_faction(); + for (const faction of role_ids) { + if (faction !== active_faction) { + gen_action(faction_player_map[faction]); + } + } + }, + Anarchist() { + resolve_take_hero_points(ANARCHISTS_ID); + }, + Communist() { + resolve_take_hero_points(COMMUNISTS_ID); + }, + Moderate() { + resolve_take_hero_points(MODERATES_ID); }, }; @@ -1853,15 +1880,20 @@ function gain_hero_points_in_player_order(factions: FactionId[], value) { } } -function gain_hero_points(faction_id: FactionId, value: number) { +function gain_hero_points( + faction_id: FactionId, + value: number, + skip_abilities = false // Used to prevent gaining of extra hero points when taking them from another player +) { if (game.hero_points.pool === 0) { return; } if ( - (faction_id === ANARCHISTS_ID && + !skip_abilities && + ((faction_id === ANARCHISTS_ID && (game.active_abilities || []).includes(ANARCHIST_EXTRA_HERO_POINT)) || - (faction_id === COMMUNISTS_ID && - (game.active_abilities || []).includes(COMMUNIST_EXTRA_HERO_POINT)) + (faction_id === COMMUNISTS_ID && + (game.active_abilities || []).includes(COMMUNIST_EXTRA_HERO_POINT))) ) { value++; } |