From 7396312cd495803df67a2e8ca17cf7b01927cfdb Mon Sep 17 00:00:00 2001 From: iainp5 Date: Thu, 10 Oct 2024 22:29:33 +0100 Subject: Adding undo steps --- rules.js | 119 +++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 53 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 6d15377..6a8501a 100644 --- a/rules.js +++ b/rules.js @@ -3585,7 +3585,7 @@ function get_card_ops(card) { ops ++ } if (game.persistent_events.includes(50) && game.active === DEM) { - if(game.state === 'choose_card' || game.state === 'stasi_play_card') { + if(game.state === 'choose_card' || game.state === 'stasi_play_card' || game.state === 'vm_laszlo_tokes') { log('+1 op from C50') } ops ++ @@ -3599,7 +3599,7 @@ function get_card_ops(card) { } if ((game.active === DEM && game.prudence && game.prudence.DEM !== 0)) { - if(game.state === 'choose_card' || game.state === 'stasi_play_card') { + if(game.state === 'choose_card' || game.state === 'stasi_play_card' || game.state === 'vm_laszlo_tokes') { if (ops > 2) { log(`${pluralize(game.prudence.DEM,'op')} from C8`) } else { @@ -4683,7 +4683,6 @@ function vm_opp_hand_false() { } function vm_valid_spaces() { - //vm_assert_argcount(6) let space_1 = vm_operand(1) let space_2 = vm_operand(2) let space_3 = vm_operand(3) @@ -6330,27 +6329,26 @@ states.vm_add_infl_free = { for (let space_id of game.valid_spaces) { gen_action_infl(spaces[space_id].name_unique); } - } /* else { - view.prompt = 'Add influence: done.' + } else { + view.prompt = `${clean_name(cards[this_card()].name)}. Add influence: done.` gen_action('done') - } */ + } }, infl(space) { vm_do_add_infl_free(space) - if (game.vm_available_ops === 0 ) { - game.valid_spaces = [] - game.vm_event_done = true - if (game.summary.length > 0) { - pop_summary() - log_br() - } - vm_next() - } + /*if (game.vm_available_ops === 0 ) { + + }*/ }, - /*done () { + done () { + game.valid_spaces = [] game.vm_event_done = true + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() - }*/ + } } states.vm_add_x_infl = { @@ -6365,20 +6363,21 @@ states.vm_add_x_infl = { for (let space_id of game.valid_spaces) { gen_action_infl(spaces[space_id].name_unique) } - } /*else { - view.prompt = 'Add influence: done.' + } else { + view.prompt = `${clean_name(cards[this_card()].name)}. Add influence: done.` gen_action('done') - }*/ + } }, infl(space) { + push_undo() vm_do_add_x_infl(space) - game.vm_event_done = true - vm_next() + //game.vm_event_done = true + //vm_next() }, - /*done () { + done () { game.vm_event_done = true vm_next() - }*/ + } } states.vm_add_limited_infl = { @@ -6397,7 +6396,7 @@ states.vm_add_limited_infl = { gen_action_infl(spaces[space_id].name_unique); } } else { - view.prompt = `${clean_name(cards[this_card()].name)}: done.` + view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.` gen_action('done') } }, @@ -6411,14 +6410,14 @@ states.vm_add_limited_infl = { } vm_next() }*/ - if (game.vm_available_ops === 0 || game.valid_spaces.length === 0 ) { + /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0 ) { if (game.summary.length > 0) { pop_summary() log_br() } game.vm_event_done = true vm_next() - } + }*/ }, done () { if (game.summary.length > 0) { @@ -6478,25 +6477,25 @@ states.vm_remove_x_infl = { return `resolve ${clean_name(cards[this_card()].name)}: remove SP from ${event_prompt()}.` }, prompt () { - if (game.valid_spaces.length === 0) { + if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) { view.prompt = `${clean_name(cards[this_card()].name)}: no SPs to remove.` gen_action('done') - } else { + } else if (game.vm_available_ops > 0) { 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(spaces[space_id].name_unique); } - } /*else { - view.prompt = 'Remove influence: done.' + } else { + view.prompt = `${clean_name(cards[this_card()].name)}. Remove influence: done.` gen_action('done') - }*/ + } }, infl(space) { vm_do_remove_x_infl(space) - game.vm_event_done = true - vm_next() + /*game.vm_event_done = true + vm_next()*/ }, done () { game.vm_event_done = true @@ -6520,17 +6519,16 @@ states.vm_remove_limited_infl = { }, infl(space) { vm_do_remove_limited_infl(space, game.vm_max_infl) - if (game.vm_available_ops === 0) { + /*if (game.vm_available_ops === 0) { game.vm_event_done = true - if (game.summary.length > 0) { - pop_summary() - log_br() - } - vm_next() - } + } */ }, done () { game.vm_event_done = true + if (game.summary.length > 0) { + pop_summary() + log_br() + } vm_next() } } @@ -6538,24 +6536,26 @@ states.vm_remove_limited_infl = { states.vm_remove_all_infl = { inactive: 'remove Support Points', prompt () { - if (game.valid_spaces.length === 0) { + if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) { view.prompt = `${clean_name(cards[this_card()].name)}: no SPs to remove.` gen_action('done') - return - } - 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(spaces[space_id].name_unique); + } 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(spaces[space_id].name_unique); + } + } else { + view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.` + gen_action('done') } }, infl(space) { vm_do_remove_all_infl(space) const clicked_space = find_space_index(space) game.vm_active_country = spaces[clicked_space].country - if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) { + /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) { vm_next() - } + }*/ }, done() { vm_next() @@ -7037,11 +7037,12 @@ states.vm_deutsche_marks_prep = { } }, card(card) { + push_undo() log(`Gave C${cards[card].number}`) game.valid_cards = [] silent_discard(card) - next_player() - game.state = 'vm_deutsche_marks' + //next_player() + game.state = 'vm_deutsche_marks_confirm' game.vm_event = card }, pass() { @@ -7049,6 +7050,18 @@ 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') + }, + done() { + next_player() + game.state = 'vm_deutsche_marks' + } +} + states.vm_deutsche_marks = { get inactive() { return `resolve ${clean_name(cards[20].name)}.` @@ -9240,7 +9253,7 @@ CODE[66] = [ // New Forum ] CODE[67] = [ // Reformer Rehabilitated* - [ vm_prompt, 'Chose any non-scoring card in the discard pile. Event takes place immediately' ], + [ vm_prompt, 'Reformer Rehabilitated: chose any non-scoring card in the discard pile. Event takes place immediately' ], [ vm_reformer_rehabilitated ], [ vm_return ], ] -- cgit v1.2.3