summaryrefslogtreecommitdiff
path: root/rules.ts
diff options
context:
space:
mode:
Diffstat (limited to 'rules.ts')
-rw-r--r--rules.ts71
1 files changed, 67 insertions, 4 deletions
diff --git a/rules.ts b/rules.ts
index d306cf5..8eef855 100644
--- a/rules.ts
+++ b/rules.ts
@@ -1406,14 +1406,77 @@ states.move_track = {
},
};
+/**
+ * A player can always move a track up, unless Communist player
+ * during their turn
+ */
+function can_move_track_up(track_id: number): boolean {
+ const faction = get_active_faction();
+ return game.faction_turn === COMMUNISTS_ID &&
+ faction === COMMUNISTS_ID &&
+ track_id === GOVERNMENT
+ ? false
+ : true;
+}
+
+/**
+ * Not allowed for:
+ * - Anarchist and Liberty or Collectivization
+ * - Communist and Soviet Support
+ * - Moderate and Forgeign Aid
+ * Note: all during their turn
+ */
+function can_move_track_down(track_id): boolean {
+ const faction = get_active_faction();
+ if (
+ game.faction_turn === ANARCHISTS_ID &&
+ faction === ANARCHISTS_ID &&
+ (track_id === LIBERTY || track_id === COLLECTIVIZATION)
+ ) {
+ return false;
+ }
+
+ if (
+ game.faction_turn === COMMUNISTS_ID &&
+ faction === COMMUNISTS_ID &&
+ track_id === SOVIET_SUPPORT
+ ) {
+ return false;
+ }
+
+ if (
+ game.faction_turn === MODERATES_ID &&
+ faction === MODERATES_ID &&
+ (track_id === GOVERNMENT || track_id === FOREIGN_AID)
+ ) {
+ return false;
+ }
+
+ return true;
+}
+
states.move_track_up_or_down = {
inactive: 'move a track',
prompt() {
gen_spend_hero_points();
- const node = get_active_node();
- view.prompt = `Move ${get_track_name(node.a.track_id)} up or down`;
- gen_action('up');
- gen_action('down');
+ const { track_id } = get_active_node_args();
+ const can_move_up = can_move_track_up(track_id);
+ const can_move_down = can_move_track_down(track_id);
+ const track_name = get_track_name(track_id);
+ if (can_move_down && can_move_up) {
+ view.prompt = `Move ${track_name} up or down`;
+ } else if (can_move_up) {
+ view.prompt = `Move ${track_name} up`;
+ } else {
+ view.prompt = `Move ${track_name} down`;
+ }
+
+ if (can_move_up) {
+ gen_action('up');
+ }
+ if (can_move_down) {
+ gen_action('down');
+ }
},
spend_hp() {
resolve_spend_hp();