summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-29 14:37:35 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-29 14:37:35 +0100
commitceb2f4cdb127048a3722a7a1490e5d8392b78ba8 (patch)
tree25c4fdf394d7dfd72c1095af2737533b80414cff /rules.js
parenta8acd76e56f3bbc140520737690429bd440feee2 (diff)
download1989-dawn-of-freedom-ceb2f4cdb127048a3722a7a1490e5d8392b78ba8.tar.gz
Automate inactive prompt during event resolution.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js163
1 files changed, 3 insertions, 160 deletions
diff --git a/rules.js b/rules.js
index d41cef4..1284cf3 100644
--- a/rules.js
+++ b/rules.js
@@ -449,6 +449,8 @@ exports.view = function (state, player) {
} else if (player === "Observer" || (game.active !== player && game.active !== "Both")) {
if (states[game.state]) {
let inactive = states[game.state].inactive
+ if (!inactive)
+ inactive = "resolve " + quoted_card_name[this_card()]
view.prompt = `Waiting for ${game.active} to ${inactive}.`
} else {
view.prompt = "A Unknown state: " + game.state
@@ -605,7 +607,7 @@ states.confirm_card = {
states.play_card = {
get inactive() {
- return `play ${quoted_card_name[game.played_card]}.`
+ return `play ${quoted_card_name[game.played_card]}`
},
prompt() {
view.prompt = "Play " + quoted_card_name[game.played_card] + "."
@@ -5856,9 +5858,6 @@ function vm_kremlin_coup_elite() {
/* ================== VM STATES ============================== */
states.vm_end_event = {
- get inactive() {
- return `resolve ${card_name[this_card()]}.`
- },
prompt() {
prompt_event("Done.")
if (game.vm_infl_to_do || game.return_state === 'vm_tst_8') {
@@ -5879,9 +5878,6 @@ states.vm_end_event = {
}
states.vm_take_control = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.vm_available_ops > 0 && game.valid_spaces.length === 0) {
prompt_event("All spaces controlled.")
@@ -5920,7 +5916,6 @@ states.vm_take_control = {
}
states.vm_add_infl = {
- inactive: 'add Support Points',
prompt() {
if (game.vm_available_ops > 0 && game.valid_spaces.length === 0) {
prompt_event("No available spaces remaining.")
@@ -5959,9 +5954,6 @@ states.vm_add_infl = {
}
states.vm_add_infl_free = {
- get inactive() {
- return `resolve ${card_name[this_card()]}: add SPs.`
- },
prompt() {
if (game.vm_available_ops > 0 && game.valid_spaces.length === 0) {
prompt_event("No available spaces remaining.")
@@ -6002,9 +5994,6 @@ states.vm_add_infl_free = {
}
states.vm_add_x_infl = {
- get inactive() {
- return `resolve ${card_name[this_card()]}: add Support Points.`
- },
prompt() {
if (game.vm_event === 101 && game.valid_spaces.length === 0) {
prompt_event("The Romanian Elite space no longer exists.")
@@ -6033,9 +6022,6 @@ states.vm_add_x_infl = {
}
states.vm_add_limited_infl = {
- get inactive() {
- return `resolve ${card_name[this_card()]}: add Support Points.`
- },
prompt() {
if (game.vm_available_ops > 0 && game.valid_spaces.length > 0) {
if (game.vm_max_infl === 1) {
@@ -6061,7 +6047,6 @@ states.vm_add_limited_infl = {
}
states.vm_remove_infl = {
- inactive: 'remove Support Points',
prompt() {
// Keep this so that there is an undo option in, e.g., Scare Tactics
if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) {
@@ -6106,9 +6091,6 @@ states.vm_remove_infl = {
}
states.vm_remove_x_infl = {
- get inactive() {
- return `resolve ${card_name[this_card()]}: remove SP from ${event_prompt()}.`
- },
prompt() {
if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) {
prompt_event("No SPs to remove.")
@@ -6135,7 +6117,6 @@ states.vm_remove_x_infl = {
}
states.vm_remove_limited_infl = {
- inactive: 'remove SP',
prompt() {
if (game.vm_available_ops > 0 && game.valid_spaces.length > 0) {
prompt_event(`Remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}, no more than ${game.vm_max_infl} per space.`)
@@ -6164,7 +6145,6 @@ states.vm_remove_limited_infl = {
}
states.vm_remove_all_infl = {
- inactive: 'remove Support Points',
prompt() {
if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) {
prompt_event("No SPs to remove.")
@@ -6190,7 +6170,6 @@ states.vm_remove_all_infl = {
}
states.vm_support_check_prep = {
- inactive: 'do Support Checks',
prompt() {
if (game.valid_spaces.length === 0) {
prompt_event(`No valid targets for Support Check.`)
@@ -6244,7 +6223,6 @@ states.vm_support_check_prep = {
}
states.vm_ceh_support_check_prep = {
- inactive: 'do Support Checks',
prompt() {
if (game.vm_available_ops > 0) {
view.prompt = `Select a space. ${pluralize(game.vm_available_ops, 'Support Check')} remaining.`
@@ -6276,7 +6254,6 @@ states.vm_ceh_support_check_prep = {
}
states.vm_ceh_do_support_check = {
- inactive: 'do Support Checks',
prompt() {
view.prompt = `Support Check: ${spaces[game.selected_space].name_unique}. Roll a die.`
gen_action('roll')
@@ -6296,7 +6273,6 @@ states.vm_ceh_do_support_check = {
}
states.vm_austria_hungary_border_reopened_check = {
- inactive: 'decide Austria-Hungary Border Reopened',
prompt() {
view.prompt = 'Austria-Hungary Border Reopened: will all Support Checks be in East Germany?'
gen_action('yes')
@@ -6312,7 +6288,6 @@ states.vm_austria_hungary_border_reopened_check = {
}
states.vm_1_support_check_prep = {
- inactive: 'do Support Checks',
prompt() {
if (game.valid_spaces.length === 0) {
prompt_event("No valid targets for Support Check.")
@@ -6337,7 +6312,6 @@ states.vm_1_support_check_prep = {
}
states.vm_do_support_check = {
- inactive: 'do Support Checks',
prompt() {
view.prompt = `Support Check: ${spaces[game.selected_space].name_unique}. Roll a die.`
gen_action('roll')
@@ -6360,7 +6334,6 @@ states.vm_do_support_check = {
}
states.vm_tiananmen_square_attempt = {
- inactive: 'do Tiananmen Square',
prompt() {
view.prompt = 'Tiananmen Square: roll a die'
gen_action('roll')
@@ -6374,9 +6347,6 @@ states.vm_tiananmen_square_attempt = {
//================================== EVENT SPECIFIC STATES ======================================
states.vm_adamec = {
- get inactive() {
- return `resolve ${card_name[C_ADAMEC]}.`
- },
prompt() {
view.prompt = 'Adamec: roll a die.'
gen_action('roll')
@@ -6403,7 +6373,6 @@ states.vm_adamec = {
}
states.vm_brought_in_for_questioning = {
- inactive: 'discard a card',
prompt() {
if (game.democrat_hand.length === 0) {
view.prompt = 'Brought in for Questioning. No cards to discard.'
@@ -6444,9 +6413,6 @@ states.vm_brought_in_for_questioning = {
}
states.vm_central_committee_reshuffle = {
- get inactive() {
- return `resolve ${card_name[C_CENTRAL_COMMITTEE_RESHUFFLE]}.`
- },
prompt() {
if (game.revolutions.every(n => n === true)) {
view.prompt = 'Central Committee Reshuffle: no countries to choose.'
@@ -6511,9 +6477,6 @@ states.vm_central_committee_reshuffle = {
}
states.vm_common_european_home_choose = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = `Common European Home: play an opponent's card, event does not occur.`
for (let card of game.valid_cards) {
@@ -6530,9 +6493,6 @@ states.vm_common_european_home_choose = {
}
states.vm_common_european_home_play = {
- get inactive() {
- return `resolve ${card_name[this_card()]}.`
- },
prompt() {
view.prompt = `Play ${card_name[this_card()]} for:`
gen_action('influence')
@@ -6567,9 +6527,6 @@ states.vm_common_european_home_play = {
}
states.vm_dash_for_the_west = {
- get inactive() {
- return `resolve ${card_name[C_DASH_FOR_THE_WEST]}.`
- },
prompt() {
view.prompt = 'Dash for the West: roll a die'
gen_action('roll')
@@ -6596,9 +6553,6 @@ states.vm_dash_for_the_west = {
}
states.vm_play_event_from_discard = {
- get inactive() {
- return `resolve ${card_name[this_card()]}.`
- },
prompt() {
if (game.valid_cards.length === 0) {
prompt_event(`No valid cards in discard.`)
@@ -6635,7 +6589,6 @@ states.vm_play_event_from_discard = {
}
states.vm_deutsche_marks_prep = {
- inactive: 'choose a card',
prompt() {
if (game.valid_cards.length === 0) {
view.prompt = 'Deutsche Marks: no cards to give.'
@@ -6662,7 +6615,6 @@ states.vm_deutsche_marks_prep = {
}
states.vm_deutsche_marks_confirm = {
- inactive: 'choose a card',
prompt() {
view.prompt = `Deutsche Marks: gave ${cards[game.vm_event].name}.`
gen_action('done')
@@ -6678,9 +6630,6 @@ states.vm_deutsche_marks_confirm = {
}
states.vm_deutsche_marks = {
- get inactive() {
- return `resolve ${card_name[C_DEUTSCHE_MARKS]}.`
- },
prompt() {
if(cards[game.vm_event].side === 'C' && (cards[game.vm_event].playable || game.playable_cards.includes(game.vm_event))) {
view.prompt = `Deutsche Marks: you must play ${card_name[this_card()]} for the event.`
@@ -6724,9 +6673,6 @@ states.vm_deutsche_marks = {
}
states.vm_exit_visas = {
- get inactive() {
- return `resolve ${card_name[C_EXIT_VISAS]}.`
- },
prompt() {
view.prompt = 'Exit Visas: you may discard cards from your hand and draw replacements.'
for (let card of game.democrat_hand) {
@@ -6755,9 +6701,6 @@ states.vm_exit_visas = {
}
states.vm_exit_visas_finish = {
- get inactive() {
- return `resolve ${card_name[C_EXIT_VISAS]}.`
- },
prompt() {
if (game.temp > 0) {
view.prompt = 'Exit Visas: draw replacement cards.'
@@ -6785,9 +6728,6 @@ states.vm_exit_visas_finish = {
}
states.vm_foreign_currency_debt_burden = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'Choose a country. The Communist may not make Support Checks there for the rest of the turn.'
gen_action('east_germany')
@@ -6829,9 +6769,6 @@ states.vm_foreign_currency_debt_burden = {
}
states.vm_goodbye_lenin = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.valid_cards.length > 0) {
view.prompt = `Play a red event from your opponent's hand, or play Goodbye Lenin for operations.`
@@ -6866,9 +6803,6 @@ states.vm_goodbye_lenin = {
}
states.vm_goodbye_lenin_ops = {
- get inactive() {
- return `resolve ${card_name[this_card()]}.`
- },
prompt() {
view.prompt = `Play ${quoted_card_name[this_card()]}.`
gen_action('influence')
@@ -6904,9 +6838,6 @@ states.vm_goodbye_lenin_ops = {
}
states.vm_honecker = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.valid_cards.length === 0 && game.temp === 0) {
view.prompt = 'Honecker: no valid cards to choose.'
@@ -6937,9 +6868,6 @@ states.vm_honecker = {
}
states.vm_inflationary_currency = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if ((game.active === COM && game.revolutions.every(n => n === false)) || (game.active === DEM && game.revolutions.every(n => n === true))) {
view.prompt = 'Inflationary Currency: no countries to choose.'
@@ -7006,9 +6934,6 @@ states.vm_inflationary_currency = {
}
states.vm_inflationary_currency_discard = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.valid_cards.length === 0) {
view.prompt = 'Inflationary Currency: no valid cards to discard. You must pass.'
@@ -7044,9 +6969,6 @@ states.vm_inflationary_currency_discard = {
}
states.vm_kiss_of_death = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.communist_hand.length === 0) {
view.prompt = 'Kiss of Death. No cards to discard.'
@@ -7093,9 +7015,6 @@ states.vm_kiss_of_death = {
}
states.vm_kiss_of_death_finish = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = `Play ${quoted_card_name[game.vm_event]} for the event.`
gen_action('event')
@@ -7106,9 +7025,6 @@ states.vm_kiss_of_death_finish = {
}
states.vm_kremlin_coup_choose_country = {
- get inactive() {
- return `resolve ${card_name[this_card()]}.`
- },
prompt() {
if (game.temp.length > 0) {
view.prompt = 'Kremlin Coup! Select a country where the Communist retains power.'
@@ -7171,9 +7087,6 @@ states.vm_kremlin_coup_choose_country = {
}
states.vm_kremlin_coup_take_control = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.valid_spaces.includes(game.systematization)) {
view.prompt = `Kremlin Coup! ${country_name(game.vm_active_country)}'s Elite space no longer exists.`
@@ -7212,9 +7125,6 @@ states.vm_kremlin_coup_take_control = {
}
states.vm_kremlin_coup_sc_prep = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = `Kremlin Coup! Conduct a Support Check in ${country_name(game.vm_active_country)}'s Bureaucratic space.`
gen_action_space(game.selected_space)
@@ -7226,7 +7136,6 @@ states.vm_kremlin_coup_sc_prep = {
}
states.vm_kremlin_coup_sc = {
- inactive: 'do Support Checks',
prompt() {
view.prompt = `Support Check: ${spaces[game.selected_space].name_unique}. Roll a die.`
gen_action('roll')
@@ -7243,9 +7152,6 @@ states.vm_kremlin_coup_sc = {
}
states.vm_laszlo_tokes = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = `Laszlo Tokes. Choose to:`
gen_action('influence')
@@ -7269,9 +7175,6 @@ states.vm_laszlo_tokes = {
}
states.vm_switch_infl = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.valid_spaces.length === 0) {
prompt_event(`No SPs to remove.`)
@@ -7300,9 +7203,6 @@ states.vm_switch_infl = {
}
states.vm_malta_summit = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'Malta Summit: roll a die.'
gen_action('roll')
@@ -7339,9 +7239,6 @@ states.vm_malta_summit = {
}
states.vm_modrow = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = `Modrow: roll a die.`
gen_action('roll')
@@ -7364,9 +7261,6 @@ states.vm_modrow = {
}
states.vm_nepotism = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'Nepotism: roll a die.'
gen_action('roll')
@@ -7389,9 +7283,6 @@ states.vm_nepotism = {
}
states.vm_new_years_eve_party = {
- get inactive() {
- return `resolve ${card_name[C_NEW_YEARS_EVE_PARTY]}.`
- },
prompt() {
view.prompt = 'Choose whether the game ends at the end of this turn.'
gen_action('end')
@@ -7423,9 +7314,6 @@ states.vm_new_years_eve_party = {
}
states.vm_nomenklatura = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'Nomenklatura: choose to remove all Democratic SPs from Elite spaces or add 3 SPs to any Elite space(s).'
gen_action('remove')
@@ -7460,9 +7348,6 @@ states.vm_nomenklatura = {
}
states.vm_nomenklatura_remove = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.valid_spaces.length === 0) {
view.prompt = 'Nomenklatura. No SPs to remove: pass.'
@@ -7489,9 +7374,6 @@ states.vm_nomenklatura_remove = {
}
states.vm_nomenklatura_add = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
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) {
@@ -7509,9 +7391,6 @@ states.vm_nomenklatura_add = {
}
states.vm_samizdat = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'Samizdat: you may set aside a card from your hand and draw a replacement.'
for (let card of game.democrat_hand) {
@@ -7534,9 +7413,6 @@ states.vm_samizdat = {
}
states.vm_samizdat_finish = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'Draw a replacement card.'
gen_action('draw')
@@ -7549,9 +7425,6 @@ states.vm_samizdat_finish = {
}
states.vm_shock_therapy = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.revolutions.every(n => n === false)) {
view.prompt = 'Shock Therapy: no countries to choose.'
@@ -7639,9 +7512,6 @@ states.vm_shock_therapy = {
}
states.vm_social_democratic_platform_adopted = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.revolutions.every(n => n === false)) {
view.prompt = 'Social Democratic Platform Adopted: no countries to choose.'
@@ -7699,9 +7569,6 @@ states.vm_social_democratic_platform_adopted = {
}
states.vm_systematization = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'Systematization: eliminate a space in Romania.'
for (let space_id of game.valid_spaces) {
@@ -7719,9 +7586,6 @@ states.vm_systematization = {
}
states.vm_the_chinese_solution = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'The Chinese Solution: you may give up 3 VP to conduct Support Checks in a country where you hold power.'
if (!game.revolutions[0]) {gen_action('poland')}
@@ -7807,9 +7671,6 @@ states.vm_the_chinese_solution = {
}
states.vm_the_tyrant_is_gone = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (!game.the_tyrant_is_gone) {
view.prompt = 'The Tyrant is Gone: Select a space in Romania for the Ceausescus to flee to.'
@@ -7835,9 +7696,6 @@ states.vm_the_tyrant_is_gone = {
}
states.vm_the_wall_must_go = {
- get inactive() {
- return `resolve ${card_name[this_card()]}.`
- },
prompt() {
view.prompt = 'The Wall Must Go! Roll a die.'
gen_action('roll')
@@ -7902,9 +7760,6 @@ states.vm_the_wall_must_go = {
}
states.vm_warsaw_pact_summit = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = 'Choose to play for Support Checks or place SPs.'
gen_action('influence')
@@ -7936,9 +7791,6 @@ states.vm_warsaw_pact_summit = {
}
states.vm_we_are_the_people_remove = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.demInfl[S_LUTHERAN_CHURCH] === 0 && game.vm_available_ops > 0) {
view.prompt = '"We are the People!": no SPs to remove.'
@@ -7972,9 +7824,6 @@ states.vm_we_are_the_people_remove = {
},
}
states.vm_we_are_the_people_add = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = `"We are the People!": you must add the ${pluralize(game.vm_available_ops,'SP')} to spaces in Germany.`
for (let space_id of game.valid_spaces) {
@@ -7992,9 +7841,6 @@ states.vm_we_are_the_people_add = {
}
states.vm_workers_revolt = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
if (game.valid_spaces.length === 0) {
view.prompt = 'Workers Revolt: no valid spaces to select.'
@@ -8019,9 +7865,6 @@ states.vm_workers_revolt = {
}
states.vm_workers_revolt_finish = {
- get inactive() {
- return `resolve ${card_name[game.played_card]}.`
- },
prompt() {
view.prompt = `Target: ${spaces[game.selected_space].name_unique}. Roll a die.`
gen_action('roll')