summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrans Bongers <fransbongers@franss-mbp.home>2024-12-30 11:44:14 +0100
committerFrans Bongers <fransbongers@franss-mbp.home>2024-12-30 11:44:14 +0100
commit23beb82e0344d895106351fe6d98f40c8ee50dc5 (patch)
treed8a19cd083169d9548e657caf6d2f01883a7c505
parent4e1517da77e796406befa8264242065687c672f5 (diff)
downloadland-and-freedom-23beb82e0344d895106351fe6d98f40c8ee50dc5.tar.gz
take hero points
-rw-r--r--rules.js44
-rw-r--r--rules.ts52
2 files changed, 79 insertions, 17 deletions
diff --git a/rules.js b/rules.js
index 5fbc167..c95b1c4 100644
--- a/rules.js
+++ b/rules.js
@@ -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);
diff --git a/rules.ts b/rules.ts
index dfa17f3..a706f34 100644
--- a/rules.ts
+++ b/rules.ts
@@ -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++;
}