diff options
author | iainp5 <iain.pearce.ip@gmail.com> | 2024-10-25 13:28:31 +0100 |
---|---|---|
committer | iainp5 <iain.pearce.ip@gmail.com> | 2024-10-25 13:28:31 +0100 |
commit | e85e39c90fd3d6b375a4ce48d3347531b75f5f56 (patch) | |
tree | 04436e300fca552087ef0929cb7a6d4e75f71267 /rules.js | |
parent | a8874fde796f8fa563a8a80aa429f3a7c40eec44 (diff) | |
download | 1989-dawn-of-freedom-e85e39c90fd3d6b375a4ce48d3347531b75f5f56.tar.gz |
Merged infl sc into spaces action
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 139 |
1 files changed, 72 insertions, 67 deletions
@@ -282,6 +282,11 @@ function gen_action(action, argument) { //console.log('view.actions: ', view.actions, 'view.actions[action]: ', view.actions[action]) } +function gen_action_space(space){ + gen_action("space", space) +} + + function gen_action_infl(space){ gen_action("infl", space) } @@ -335,10 +340,10 @@ states.com_init = { view.prompt = `Place ${pluralize(game.available_ops,'starting SP')}.` } for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } }, - infl(space) { + space(space) { add_infl(space) }, @@ -385,10 +390,10 @@ states.dem_init = { view.prompt = `Place ${pluralize(game.available_ops,'starting SP')}.` } for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } }, - infl(space) { + space(space) { add_infl(space) }, @@ -716,10 +721,10 @@ states.finish_add_infl = { // Generate actions for valid spaces for (let space_id of game.valid_spaces) { - gen_action_infl(space_id) + gen_action_space(space_id) } }, - infl(space) { + space(space) { add_infl(space) }, end_round() { @@ -744,11 +749,11 @@ states.finish_support_check_prep = { } else { view.prompt = `Select a space. ${pluralize(game.available_ops, 'support check')} remaining.` for (let space_id of game.valid_spaces) { - gen_action_sc(space_id) + space(space_id) } } }, - sc(space) { + space(space) { push_undo() game.selected_space = space // Check for Austria-Hungary Border Reopened - check on first support check only @@ -820,11 +825,11 @@ states.add_influence = { // Generate actions for valid spaces for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } }, - infl(space) { + space(space) { add_infl(space) }, end_round() { @@ -1009,11 +1014,11 @@ states.support_check_prep = { view.prompt = `Select a space. ${pluralize(game.available_ops, 'support check')} remaining.` for (let space_id of game.valid_spaces) { - gen_action_sc(space_id) + space(space_id) } } }, - sc(space) { + space(space) { push_undo() game.selected_space = space @@ -1245,10 +1250,10 @@ states.the_crowd_turns_against_ceausescu_infl = { view.prompt = `Add SPs: ${game.vm_available_ops} remaining` for (let space of game.valid_spaces) { - gen_action_infl(space) + gen_action_space(space) } }, - infl(space) { + space(space) { vm_do_add_infl(space) }, done() { @@ -1588,7 +1593,7 @@ states.support_loss ={ view.prompt = `Power Struggle - ${country_name(game.pwr_struggle_in)}. Support Loss: remove ${pluralize(game.available_ops,'SP')}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id) + gen_action_space(space_id) } } else if (game.phase === 1 && game.available_ops === 0 ) { view.prompt = `Power Struggle - ${country_name(game.pwr_struggle_in)}. Support Loss: finished.` @@ -1605,7 +1610,7 @@ states.support_loss ={ view.prompt = `New Year's Eve Party - ${country_name(game.pwr_struggle_in)}. Support Loss: remove ${pluralize(game.available_ops,'SP')}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id) + gen_action_space(space_id) } } else if (game.phase === 1 && game.available_ops === 0 ) { view.prompt = `New Year's Eve Party - ${country_name(game.pwr_struggle_in)}. Support Loss: finished.` @@ -1657,7 +1662,7 @@ states.support_loss ={ valid_spaces_support_loss() } }, - infl (space) { + space(space) { game.remove_opponent_infl = false /* Don't know why this is needed... */ remove_infl(space) if (game.available_ops === 0 ) { @@ -6171,7 +6176,7 @@ states.vm_take_control = { } else if (game.vm_available_ops > 0 ) { view.prompt = `${clean_name(cards[this_card()].name)}: take control of ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } else { view.prompt = `${clean_name(cards[this_card()].name)}. Take control: done.` @@ -6182,7 +6187,7 @@ states.vm_take_control = { } } }, - infl(space) { + space(space) { push_undo() vm_take_control(space) game.vm_available_ops-- @@ -6212,13 +6217,13 @@ states.vm_add_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: add ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id) + gen_action_space(space_id) } } else { get_end_infl_prompt() } }, - infl(space) { + space(space) { vm_do_add_infl(space) if (game.vm_available_ops === 0) { game.valid_spaces = [] @@ -6265,13 +6270,13 @@ states.vm_add_infl_free = { view.prompt = `${clean_name(cards[this_card()].name)}: add ${game.vm_available_ops} SPs to ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } else { get_end_infl_prompt() } }, - infl(space) { + space(space) { vm_do_add_infl_free(space) if (game.vm_available_ops === 0) { game.valid_spaces = [] @@ -6320,14 +6325,14 @@ states.vm_add_x_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: Add ${game.vm_available_ops} SPs to ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id) + gen_action_space(space_id) } } /*else { view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` gen_action('done') }*/ }, - infl(space) { + space(space) { push_undo() vm_do_add_x_infl(space) if (game.vm_available_ops === 0) { @@ -6363,14 +6368,14 @@ states.vm_add_limited_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: add ${pluralize(game.vm_available_ops,'SP')} to ${event_prompt()}.` } for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } /*else { view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` gen_action('done') }*/ }, - infl(space) { + space(space) { vm_do_add_limited_infl(space, game.vm_max_infl) if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) { game.valid_spaces = [] @@ -6414,10 +6419,10 @@ states.vm_remove_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}.` } for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } }, - infl(space) { + space(space) { push_undo() vm_do_remove_infl(space) game.vm_active_country = spaces[space].country @@ -6454,7 +6459,7 @@ states.vm_remove_x_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops,'SP')} from ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } /*else { if (game.vm_infl_to_do) { @@ -6468,7 +6473,7 @@ states.vm_remove_x_infl = { } }*/ }, - infl(space) { + space(space) { vm_do_remove_x_infl(space) /*if (game.vm_event === 68) { vm_next() @@ -6494,7 +6499,7 @@ states.vm_remove_limited_infl = { view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}, no more than ${game.vm_max_infl} per space.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } else if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) { view.prompt = `${clean_name(cards[this_card()].name)}: no further SP to remove.` @@ -6511,7 +6516,7 @@ states.vm_remove_limited_infl = { } }*/ }, - infl(space) { + space(space) { vm_do_remove_limited_infl(space, game.vm_max_infl) if (game.vm_available_ops === 0) { game.vm_event_done = true @@ -6541,14 +6546,14 @@ states.vm_remove_all_infl = { } else if (game.vm_available_ops > 0) { view.prompt = `${clean_name(cards[this_card()].name)}: remove all SPs from ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } /*else { view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.` gen_action('done') }*/ }, - infl(space) { + space(space) { vm_do_remove_all_infl(space) game.vm_active_country = spaces[space].country if (game.vm_available_ops === 0) { @@ -6577,11 +6582,11 @@ states.vm_support_check_prep = { //} for (let space_id of game.valid_spaces) { if (!space_id) continue - gen_action_sc(space_id); + space(space_id); } } }, - sc(space) { + space(space) { push_undo() game.selected_space = space @@ -6625,11 +6630,11 @@ states.vm_ceh_support_check_prep = { view.prompt = `Select a space. ${pluralize(game.vm_available_ops, 'support check')} remaining.` for (let space_id of game.valid_spaces) { - gen_action_sc(space_id) + space(space_id) } } }, - sc(space) { + space(space) { push_undo() game.selected_space = space @@ -6704,11 +6709,11 @@ states.vm_1_support_check_prep = { for (let space_id of game.valid_spaces) { if (!space_id) continue - gen_action_sc(space_id); + space(space_id); } } }, - sc(space) { + space(space) { push_undo() game.selected_space = space game.state = 'vm_do_support_check' @@ -7618,11 +7623,11 @@ states.vm_kremlin_coup_take_control = { } else { view.prompt = `Kremlin Coup! Take control of the Elite space in ${country_name(game.vm_active_country)}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } }, - infl(space) { + space(space) { push_undo() vm_take_control(space) if (game.vm_active_country === 'East_Germany') {game.selected_space = 3 } @@ -7651,9 +7656,9 @@ states.vm_kremlin_coup_sc_prep = { }, prompt() { view.prompt = `Kremlin Coup! Conduct a support check in ${country_name(game.vm_active_country)}'s Bureaucratic space.` - gen_action_sc(game.selected_space); + space(game.selected_space); }, - sc(space) { + space(space) { //game.selected_space = space push_undo() game.state = 'vm_kremlin_coup_sc' @@ -7731,14 +7736,14 @@ states.vm_switch_infl = { /*if (game.vm_available_ops > 0 ) {*/ view.prompt = `${clean_name(cards[game.played_card].name)}: ${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } /*else { view.prompt = 'Influence replaced.' gen_action('done') }*/ }, - infl(space) { + space(space) { push_undo() vm_switch_infl(space) if (game.vm_available_ops === 0) { @@ -7947,11 +7952,11 @@ states.vm_nomenklatura_remove = { view.prompt = 'Nomenklatura: remove all Democratic SPs from Elite spaces.' for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } }, - infl(space) { + space(space) { push_undo() vm_do_remove_all_infl(space) if (game.valid_spaces.length === 0) { @@ -7975,11 +7980,11 @@ states.vm_nomenklatura_add = { } else { */ view.prompt = `Nomenklatura: add 3 SPs to any Elite space(s). ${pluralize(game.vm_available_ops, 'SP')} remaining.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } //} }, - infl(space) { + space(space) { push_undo() vm_do_add_infl_free(space) if (game.vm_available_ops === 0 ) { @@ -8208,14 +8213,14 @@ states.vm_systematization = { /*if (game.systematization === 0) { */ view.prompt = 'Systematization: eliminate a space in Romania.' for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } /*} else { view.prompt = 'Systematization: done.' gen_action('done') }*/ }, - infl(space) { + space(space) { push_undo() vm_eliminate(space) game.valid_spaces = [] @@ -8324,14 +8329,14 @@ states.vm_the_tyrant_is_gone = { view.prompt = 'The Tyrant is Gone: Select a space in Romania for the Ceausescus to flee to.' for (let space_id of game.valid_spaces) { if (!space_id) continue - gen_action_infl(space_id); + gen_action_space(space_id); } } else { view.prompt = 'The Tyrant is Gone: done.' gen_action('done') } }, - infl(space) { + space(space) { push_undo() log(`The Ceausescus flee to %${space}`) game.the_tyrant_is_gone = space @@ -8509,14 +8514,14 @@ states.vm_we_are_the_people_remove = { view.prompt = '"We are the People!": remove up to 4 SPs from the Lutherian Church.' gen_action('done') for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } } else { view.prompt = '"We are the People!" Remove SPs: done.' gen_action('done') } }, - infl(space) { + space(space) { vm_do_remove_infl(space) }, done() { @@ -8546,10 +8551,10 @@ states.vm_we_are_the_people_add = { view.prompt = `"We are the People!": you must add the ${pluralize(game.vm_influence_added[6],'SP')} to spaces in Germany.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } }, - infl(space) { + space(space) { vm_do_add_infl_free(space) game.vm_influence_added[6]-- if (game.vm_influence_added[6] === 0 ) { @@ -8583,14 +8588,14 @@ states.vm_workers_revolt = { } view.prompt = 'Workers Revolt: select a Worker Space in a country your opponent has power.' for (let space_id of game.valid_spaces) { - gen_action_infl(space_id) + gen_action_space(space_id) } }, pass() { push_undo() vm_next() }, - infl(space) { + space(space) { push_undo() game.selected_space = space log(`Chose %${game.selected_space}`) @@ -8699,10 +8704,10 @@ states.vm_tst_4 = { view.prompt = `Tiananmen Square Track award: remove ${pluralize(game.vm_available_ops,'SP')}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } }, - infl(space) { + space(space) { vm_do_remove_infl(space) if (game.vm_available_ops === 0) { if (game.summary.length > 0) { @@ -8732,12 +8737,12 @@ states.vm_tst_6 = { view.prompt = 'Tiananmen Square Track award: you have a free 2 Ops support check.' for (let space_id of game.valid_spaces) { if (space_id) { - gen_action_sc(space_id); + space(space_id); } } //} }, - sc(space) { + space(space) { push_undo() game.selected_space = space if (game.active === DEM && game.persistent_events.includes(58) && spaces[space].country === "East_Germany") { @@ -8862,10 +8867,10 @@ states.vm_scare_tactics = { } view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops, 'opponent SP')}${event_prompt()}.` for (let space_id of game.valid_spaces) { - gen_action_infl(space_id); + gen_action_space(space_id); } }, - infl(space) { + space(space) { push_undo() vm_do_remove_infl(space) }, |