summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-03-28 19:02:33 +0100
committerTor Andersson <tor@ccxvii.net>2025-03-28 19:02:33 +0100
commitdf0e457626c996d7ec21b71f3ae62d9972c2ac05 (patch)
tree784b9830661961cea103af3bbe3831200eee5c19
parent4040674c4bd153d855b58a38fe1a2e2721eb441d (diff)
downloadland-and-freedom-df0e457626c996d7ec21b71f3ae62d9972c2ac05.tar.gz
Simplify archives code by splitting event and medallion states.
-rw-r--r--play.js6
-rw-r--r--rules.js57
-rw-r--r--rules.ts65
-rw-r--r--types.d.ts2
4 files changed, 82 insertions, 48 deletions
diff --git a/play.js b/play.js
index 281a5fd..5bd18fa 100644
--- a/play.js
+++ b/play.js
@@ -585,9 +585,9 @@ function on_update() { // eslint-disable-line no-unused-vars
action_button("Communist", "Communist")
action_button("Moderate", "Moderate")
- // medallion hero point buttons
- action_button("remove_blank_marker", "Archives")
- action_button("add_to_front", "Volunteers")
+ action_button("archives", "Archives")
+ action_button("volunteers", "Volunteers")
+
action_button("add_glory", "Add to Bag of Glory")
action_button("draw_card", "Draw a Card")
action_button("draw_cards", "Draw Cards")
diff --git a/rules.js b/rules.js
index 7655481..b81022d 100644
--- a/rules.js
+++ b/rules.js
@@ -1679,6 +1679,12 @@ states.player_turn = {
next();
},
};
+function remove_blank_marker(b) {
+ const track_id = Math.floor(b / 11);
+ const space_id = b % 11;
+ array_remove_item(game.triggered_track_effects, b);
+ logi(`Removed Blank from ${get_track_name(track_id)} ${space_id}`);
+}
states.remove_blank_marker = {
inactive: 'remove a Blank marker',
prompt() {
@@ -1696,18 +1702,31 @@ states.remove_blank_marker = {
resolve_spend_hp();
},
blank_marker(b) {
- const faction = get_active_faction();
- const track_id = Math.floor(b / 11);
- const space_id = b % 11;
- game.triggered_track_effects = game.triggered_track_effects.filter((id) => id !== b);
- if (get_active_node_args()?.src === 'medallion') {
- logi(`M${data_1.ARCHIVES_MEDALLION_ID} removed Blank from ${get_track_name(track_id)} ${space_id}`);
- game.used_medallions.push(data_1.ARCHIVES_MEDALLION_ID);
- pay_hero_points(faction, 1);
+ remove_blank_marker(b);
+ resolve_active_and_proceed();
+ },
+ skip() {
+ resolve_active_and_proceed();
+ },
+};
+states.remove_blank_marker_archives = {
+ inactive: 'remove a Blank marker',
+ prompt() {
+ view.prompt = 'Archives Medallion: Remove a Blank marker.';
+ for (const b of game.triggered_track_effects) {
+ gen_action_blank_marker(b);
}
- else {
- logi(`Removed Blank from ${get_track_name(track_id)} ${space_id}`);
+ if (game.triggered_track_effects.length === 0) {
+ view.prompt = 'No Blank marker to remove.';
+ gen_action('skip');
}
+ },
+ blank_marker(b) {
+ const faction = get_active_faction();
+ pay_hero_points(faction, 1);
+ log(`>M${data_1.ARCHIVES_MEDALLION_ID}`);
+ remove_blank_marker(b);
+ game.used_medallions.push(data_1.ARCHIVES_MEDALLION_ID);
resolve_active_and_proceed();
},
skip() {
@@ -1829,13 +1848,13 @@ states.spend_hero_points = {
}
gen_action('draw_card');
if (can_use_medallion(data_1.ARCHIVES_MEDALLION_ID, faction)) {
- gen_action('remove_blank_marker');
+ gen_action('archives');
if (game.triggered_track_effects.length === 0) {
- view.actions['remove_blank_marker'] = 0;
+ view.actions['archives'] = 0;
}
}
if (can_use_medallion(data_1.VOLUNTEERS_MEDALLION_ID, faction)) {
- gen_action('add_to_front');
+ gen_action('volunteers');
}
if (hero_points < 2) {
return;
@@ -1857,11 +1876,11 @@ states.spend_hero_points = {
}
gen_spend_hero_points_move_track(data_1.GOVERNMENT, Math.floor(hero_points / 4));
},
- add_to_front() {
+ volunteers() {
const faction = get_active_faction();
pay_hero_points(faction, 1);
insert_after_active_node(create_state_node('add_to_front', faction, {
- src: 'medallion',
+ src: 'volunteers',
t: data_1.ANY,
v: 1,
}));
@@ -1881,7 +1900,7 @@ states.spend_hero_points = {
draw_hand_cards(faction, 1);
resolve_active_and_proceed();
},
- remove_blank_marker() {
+ archives() {
const faction = get_active_faction();
if (game.used_medallions) {
game.used_medallions.push(data_1.ARCHIVES_MEDALLION_ID);
@@ -1889,7 +1908,7 @@ states.spend_hero_points = {
else {
game.used_medallions = [data_1.ARCHIVES_MEDALLION_ID];
}
- insert_after_active_node(create_state_node('remove_blank_marker', faction, { 'src': 'medallion' }));
+ insert_after_active_node(create_state_node('remove_blank_marker_archives', faction));
resolve_active_and_proceed();
},
tr0(x) {
@@ -2996,8 +3015,8 @@ function get_source_name(source) {
case 'tr4': return tracks[4].name + ' Trigger';
case 'track_icon':
throw "UNUSED";
- case 'medallion':
- return "Medallion";
+ case 'volunteers':
+ return 'Volunteers Medallion';
case data_1.MOMENTUM:
return 'Momentum';
}
diff --git a/rules.ts b/rules.ts
index 2f09ea7..cc1c0f6 100644
--- a/rules.ts
+++ b/rules.ts
@@ -2052,6 +2052,13 @@ states.player_turn = {
},
};
+function remove_blank_marker(b: number) {
+ const track_id = Math.floor(b / 11);
+ const space_id = b % 11;
+ array_remove_item(game.triggered_track_effects, b);
+ logi(`Removed Blank from ${get_track_name(track_id)} ${space_id}`);
+}
+
states.remove_blank_marker = {
inactive: 'remove a Blank marker',
prompt() {
@@ -2070,24 +2077,32 @@ states.remove_blank_marker = {
resolve_spend_hp();
},
blank_marker(b: number) {
- const faction = get_active_faction();
-
- const track_id = Math.floor(b / 11);
- const space_id = b % 11;
- game.triggered_track_effects = game.triggered_track_effects.filter(
- (id) => id !== b
- );
+ remove_blank_marker(b);
+ resolve_active_and_proceed();
+ },
+ skip() {
+ resolve_active_and_proceed();
+ },
+};
- if (get_active_node_args()?.src === 'medallion') {
- // Used Archives medallion
- logi(`M${ARCHIVES_MEDALLION_ID} removed Blank from ${get_track_name(track_id)} ${space_id}`);
- game.used_medallions.push(ARCHIVES_MEDALLION_ID);
- pay_hero_points(faction, 1);
- } else {
- // Used Event
- logi(`Removed Blank from ${get_track_name(track_id)} ${space_id}`);
+states.remove_blank_marker_archives = {
+ inactive: 'remove a Blank marker',
+ prompt() {
+ view.prompt = 'Archives Medallion: Remove a Blank marker.';
+ for (const b of game.triggered_track_effects) {
+ gen_action_blank_marker(b);
}
-
+ if (game.triggered_track_effects.length === 0) {
+ view.prompt = 'No Blank marker to remove.';
+ gen_action('skip');
+ }
+ },
+ blank_marker(b: number) {
+ const faction = get_active_faction();
+ pay_hero_points(faction, 1);
+ log(`>M${ARCHIVES_MEDALLION_ID}`);
+ remove_blank_marker(b);
+ game.used_medallions.push(ARCHIVES_MEDALLION_ID);
resolve_active_and_proceed();
},
skip() {
@@ -2234,13 +2249,13 @@ states.spend_hero_points = {
gen_action('draw_card');
if (can_use_medallion(ARCHIVES_MEDALLION_ID, faction)) {
- gen_action('remove_blank_marker');
+ gen_action('archives');
if (game.triggered_track_effects.length === 0) {
- view.actions['remove_blank_marker'] = 0;
+ view.actions['archives'] = 0;
}
}
if (can_use_medallion(VOLUNTEERS_MEDALLION_ID, faction)) {
- gen_action('add_to_front');
+ gen_action('volunteers');
}
if (hero_points < 2) {
@@ -2275,12 +2290,12 @@ states.spend_hero_points = {
gen_spend_hero_points_move_track(GOVERNMENT, Math.floor(hero_points / 4));
},
- add_to_front() {
+ volunteers() {
const faction = get_active_faction();
pay_hero_points(faction, 1);
insert_after_active_node(
create_state_node('add_to_front', faction, {
- src: 'medallion',
+ src: 'volunteers',
t: ANY,
v: 1,
})
@@ -2301,14 +2316,14 @@ states.spend_hero_points = {
draw_hand_cards(faction, 1);
resolve_active_and_proceed();
},
- remove_blank_marker() {
+ archives() {
const faction = get_active_faction();
if (game.used_medallions) {
game.used_medallions.push(ARCHIVES_MEDALLION_ID);
} else {
game.used_medallions = [ARCHIVES_MEDALLION_ID];
}
- insert_after_active_node(create_state_node('remove_blank_marker', faction, { 'src': 'medallion' }));
+ insert_after_active_node(create_state_node('remove_blank_marker_archives', faction));
resolve_active_and_proceed();
},
tr0(x: number) {
@@ -3727,8 +3742,8 @@ function get_source_name(source: EffectSource): string {
case 'tr4': return tracks[4].name + ' Trigger';
case 'track_icon':
throw "UNUSED"
- case 'medallion':
- return "Medallion";
+ case 'volunteers':
+ return 'Volunteers Medallion'
case MOMENTUM:
return 'Momentum';
}
diff --git a/types.d.ts b/types.d.ts
index 0e6417f..743804b 100644
--- a/types.d.ts
+++ b/types.d.ts
@@ -190,7 +190,7 @@ export interface PlayerCard extends CardBase {
icons: Icon[];
}
-export type EffectSource = 'player_event' | 'fascist_event' | 'fascist_test' | 'track_icon' | 'momentum' | 'tr0' | 'tr1' | 'tr2' | 'tr3' | 'tr4' | 'medallion';
+export type EffectSource = 'player_event' | 'fascist_event' | 'fascist_test' | 'track_icon' | 'momentum' | 'tr0' | 'tr1' | 'tr2' | 'tr3' | 'tr4' | 'volunteers';
export interface Effect {
type: