summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-03-28 18:28:43 +0100
committerTor Andersson <tor@ccxvii.net>2025-03-28 18:28:43 +0100
commitc046cea890bb2e2e447c4b86e45eff1bdefd43b8 (patch)
treeb8f9247f2a272fa4d7c5899f567e7c1f7b203517
parent98676a4bd7731d489e660c873154a08c67688ee2 (diff)
downloadland-and-freedom-c046cea890bb2e2e447c4b86e45eff1bdefd43b8.tar.gz
Streamline Organization and Strategy medallion use.
-rw-r--r--rules.js92
-rw-r--r--rules.ts98
2 files changed, 74 insertions, 116 deletions
diff --git a/rules.js b/rules.js
index abc3dcd..4c90dcd 100644
--- a/rules.js
+++ b/rules.js
@@ -624,51 +624,19 @@ states.activate_icon = {
update_front(f, get_icon_count_in_tableau('add_to_front'), get_active_faction());
resolve_active_and_proceed();
},
- tr0(x) {
- if (can_use_medallion(data_1.ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(data_1.LIBERTY, x);
- }
- else {
- move_track_to(0, x);
- }
- resolve_active_and_proceed();
- },
- tr1(x) {
- if (can_use_medallion(data_1.ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(data_1.COLLECTIVIZATION, x);
- }
- else {
- move_track_to(1, x);
- }
- resolve_active_and_proceed();
- },
- tr2(x) {
- if (can_use_medallion(data_1.ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(data_1.GOVERNMENT, x);
- }
- else {
- move_track_to(2, x);
- }
- resolve_active_and_proceed();
- },
- tr3(x) {
+ trX(x, track) {
+ let old = game.tracks[track];
+ move_track_to(track, x);
if (can_use_medallion(data_1.ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(data_1.SOVIET_SUPPORT, x);
- }
- else {
- move_track_to(3, x);
- }
- resolve_active_and_proceed();
- },
- tr4(x) {
- if (can_use_medallion(data_1.ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(data_1.FOREIGN_AID, x);
- }
- else {
- move_track_to(4, x);
+ insert_use_organization_medallion_node(track, game.tracks[track] - old);
}
resolve_active_and_proceed();
},
+ tr0(x) { this.trX(x, 0); },
+ tr1(x) { this.trX(x, 1); },
+ tr2(x) { this.trX(x, 2); },
+ tr3(x) { this.trX(x, 3); },
+ tr4(x) { this.trX(x, 4); },
draw_card() {
draw_hand_cards(get_active_faction(), get_icon_count_in_tableau('draw_card'));
resolve_active_and_proceed();
@@ -2067,8 +2035,9 @@ function trash_card(faction) {
states.use_organization_medallion = {
inactive: 'choose to use Organization Medallion',
prompt() {
- gen_spend_hero_points();
- view.prompt = 'Use Organization Medallion?';
+ let { t, v } = get_active_node_args();
+ view.prompt = `Organization Medallion: Spend 1 Hero point to increase ${get_track_name(t)} movement?`;
+ gen_action(track_action_name[t], v);
gen_action('yes');
gen_action('no');
},
@@ -2080,32 +2049,34 @@ states.use_organization_medallion = {
pay_hero_points(faction, 1);
game.used_medallions.push(data_1.ORGANIZATION_MEDALLION_ID);
let { t, v } = get_active_node_args();
- if (v > game.tracks[t]) {
- v++;
- }
- else {
- v--;
- }
- move_track(t, v - game.tracks[t]);
+ log("M" + data_1.ORGANIZATION_MEDALLION_ID + ":");
+ move_track_to(t, v);
resolve_active_and_proceed();
},
+ tr0() { this.yes(); },
+ tr1() { this.yes(); },
+ tr2() { this.yes(); },
+ tr3() { this.yes(); },
+ tr4() { this.yes(); },
no() {
- const { t, v } = get_active_node_args();
- move_track(t, v);
resolve_active_and_proceed();
},
};
states.use_strategy_medallion = {
inactive: 'choose to use Strategy Medallion',
prompt() {
- gen_spend_hero_points();
- view.prompt = 'Use Strategy Medallion?';
+ const { f } = get_active_node_args();
+ view.prompt = `Strategy Medallion: Add 1 strength to ${front_names[f]}?`;
+ gen_action_front(f);
gen_action('yes');
gen_action('no');
},
spend_hp() {
resolve_spend_hp();
},
+ front(_) {
+ this.yes();
+ },
yes() {
game.used_medallions.push(data_1.STRATEGY_MEDALLION_ID);
const { f } = get_active_node_args();
@@ -2600,11 +2571,20 @@ function can_use_medallion(medallion_id, faction) {
return can_use;
}
}
-function insert_use_organization_medallion_node(track_id, value) {
+function insert_use_organization_medallion_node(track_id, delta) {
const faction = get_active_faction();
+ if (delta > 0)
+ delta = 1;
+ else if (delta < 0)
+ delta = -1;
+ else
+ return;
+ let v = game.tracks[track_id] + delta;
+ if (v < 0 || v > 10)
+ return;
insert_after_active_node(create_state_node('use_organization_medallion', faction, {
t: track_id,
- v: value,
+ v: v,
}));
}
function update_bonus(bonus_id, status) {
diff --git a/rules.ts b/rules.ts
index b6c4e2b..9a648b5 100644
--- a/rules.ts
+++ b/rules.ts
@@ -868,46 +868,19 @@ states.activate_icon = {
);
resolve_active_and_proceed();
},
- tr0(x: number) {
- if (can_use_medallion(ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(LIBERTY, x);
- } else {
- move_track_to(0, x);
- }
- resolve_active_and_proceed();
- },
- tr1(x: number) {
- if (can_use_medallion(ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(COLLECTIVIZATION, x);
- } else {
- move_track_to(1, x);
- }
- resolve_active_and_proceed();
- },
- tr2(x: number) {
+ trX(x: number, track: number) {
+ let old = game.tracks[track]
+ move_track_to(track, x);
if (can_use_medallion(ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(GOVERNMENT, x);
- } else {
- move_track_to(2, x);
- }
- resolve_active_and_proceed();
- },
- tr3(x: number) {
- if (can_use_medallion(ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(SOVIET_SUPPORT, x);
- } else {
- move_track_to(3, x);
- }
- resolve_active_and_proceed();
- },
- tr4(x: number) {
- if (can_use_medallion(ORGANIZATION_MEDALLION_ID)) {
- insert_use_organization_medallion_node(FOREIGN_AID, x);
- } else {
- move_track_to(4, x);
+ insert_use_organization_medallion_node(track, game.tracks[track] - old);
}
resolve_active_and_proceed();
},
+ tr0(x: number) { this.trX(x, 0) },
+ tr1(x: number) { this.trX(x, 1) },
+ tr2(x: number) { this.trX(x, 2) },
+ tr3(x: number) { this.trX(x, 3) },
+ tr4(x: number) { this.trX(x, 4) },
draw_card() {
draw_hand_cards(
get_active_faction(),
@@ -2496,9 +2469,10 @@ function trash_card(faction: FactionId) {
states.use_organization_medallion = {
inactive: 'choose to use Organization Medallion',
prompt() {
- gen_spend_hero_points();
- view.prompt = 'Use Organization Medallion?';
-
+ // gen_spend_hero_points(); // confusing when available during this question
+ let { t, v } = get_active_node_args();
+ view.prompt = `Organization Medallion: Spend 1 Hero point to increase ${get_track_name(t)} movement?`;
+ gen_action(track_action_name[t], v)
gen_action('yes');
gen_action('no');
},
@@ -2509,25 +2483,17 @@ states.use_organization_medallion = {
const faction = get_active_faction();
pay_hero_points(faction, 1);
game.used_medallions.push(ORGANIZATION_MEDALLION_ID);
-
- // Value is the clicked location on the track
let { t, v } = get_active_node_args();
-
- // If player uses medallion we need to add or subtract
- // depending on direction of movement
- if (v > game.tracks[t]) {
- v++;
- } else {
- v--;
- }
-
- move_track(t, v - game.tracks[t]);
+ log("M" + ORGANIZATION_MEDALLION_ID + ":")
+ move_track_to(t, v);
resolve_active_and_proceed();
},
+ tr0() { this.yes() },
+ tr1() { this.yes() },
+ tr2() { this.yes() },
+ tr3() { this.yes() },
+ tr4() { this.yes() },
no() {
- const { t, v } = get_active_node_args();
-
- move_track(t, v);
resolve_active_and_proceed();
},
};
@@ -2535,15 +2501,19 @@ states.use_organization_medallion = {
states.use_strategy_medallion = {
inactive: 'choose to use Strategy Medallion',
prompt() {
- gen_spend_hero_points();
- view.prompt = 'Use Strategy Medallion?';
-
+ // gen_spend_hero_points(); // confusing when available during this question
+ const { f } = get_active_node_args();
+ view.prompt = `Strategy Medallion: Add 1 strength to ${front_names[f]}?`;
+ gen_action_front(f)
gen_action('yes');
gen_action('no');
},
spend_hp() {
resolve_spend_hp();
},
+ front(_) {
+ this.yes()
+ },
yes() {
game.used_medallions.push(STRATEGY_MEDALLION_ID);
const { f } = get_active_node_args();
@@ -3195,14 +3165,22 @@ function can_use_medallion(medallion_id: number, faction?: FactionId) {
function insert_use_organization_medallion_node(
track_id: number,
- value: number
+ delta: number
) {
const faction = get_active_faction();
-
+ if (delta > 0)
+ delta = 1
+ else if (delta < 0)
+ delta = -1
+ else
+ return;
+ let v = game.tracks[track_id] + delta
+ if (v < 0 || v > 10)
+ return;
insert_after_active_node(
create_state_node('use_organization_medallion', faction, {
t: track_id,
- v: value,
+ v: v,
})
);
}