From 098b4694a5247c304407b8e7e1a113c7809ba1ba Mon Sep 17 00:00:00 2001 From: iainp5 Date: Fri, 4 Oct 2024 10:46:20 +0100 Subject: Updates to reduce game object --- events.txt | 2 -- play.js | 39 ++++++++++++++++------- rules.js | 103 +++++++++++++++++++++++++++++++++++++++++-------------------- 3 files changed, 96 insertions(+), 48 deletions(-) diff --git a/events.txt b/events.txt index 1cf1485..2ab7233 100644 --- a/events.txt +++ b/events.txt @@ -838,8 +838,6 @@ permanently_remove CARD 109 - Kremlin Coup* # Can only take place if Breakaway Baltic Republics has been played as an event. -3 VPs. In all countries where the Communist retains Power, place sufficient SPs in Elite space for Communist control, then make a support check against the bureaucratic space with a +1 modifier, even if there are no Democratic SPs in the space. kremlin_coup -prompt 'Elite spaces in all countries where the Communist retains Power' -take_control_prep 6 permanently_remove diff --git a/play.js b/play.js index cc703e9..2b8741c 100644 --- a/play.js +++ b/play.js @@ -32,9 +32,9 @@ const countries= ['Poland', 'Hungary', 'East_Germany', 'Bulgaria', 'Czechoslovak "elena", "new_years_eve_party" ]*/ - -const aside_events = [ 2, 9, 15, 24, 26, 39, 48, 49, 53, 58, 59, 65, 69, 70, 73, 97, 100, 101, 104 ] -let aside_events_showing = false +const board_events = [2, 9, 69, 97] +const box_events = [ 15, 24, 26, 39, 48, 49, 53, 58, 59, 65, 70, 73, 100, 101, 104 ] +let box_events_showing = false let show_discard = false const overlay = document.getElementById('overlay'); @@ -529,9 +529,24 @@ if (view.ceausescu_cards.length > 0 && view.is_pwr_struggle === true) { //console.log('strategy discard: ', view.strategy_discard) //console.log('valid spaces: ', view.valid_spaces) -// UPDATE EVENT MARKERS -console.log('view.persistent_events', view.persistent_events) -for (let id of aside_events) { +//console.log('view.persistent_events', view.persistent_events) + +// UPDATE EVENT MARKERS ON THE BOARD + +for (let id of board_events) { + let marker = document.getElementById(`event_${id}`) + console.log('event', id, marker) + if (view.persistent_events.includes(id)) { + marker.style.display = 'block' + } else { + marker.style.display = 'none' + } +} + + +// UPDATE EVENT MARKERS BELOW THE BOARD + +for (let id of box_events) { let marker = document.getElementById(`event_${id}`) console.log('event', id, marker) if (view.persistent_events.includes(id)) { @@ -542,11 +557,11 @@ for (let id of aside_events) { } -// CHECK WHETHER ANY EVENT MARKERS ARE SHOWING IN THE ASIDE -aside_events_showing = false -for (let id of aside_events) { +// CHECK WHETHER ANY EVENT MARKERS ARE SHOWING IN THE EVENTS BOX +box_events_showing = false +for (let id of box_events) { if (view.persistent_events.includes(id)) { - aside_events_showing = true; + box_events_showing = true; } /* //Special check for events which are not true/false @@ -559,7 +574,7 @@ for (let id of aside_events) { */ } -if (aside_events_showing) { +if (box_events_showing) { document.getElementById('events_panel').classList.remove("hide") } else { document.getElementById('events_panel').classList.add("hide") @@ -620,7 +635,7 @@ if (view.persistent_events.includes(97)) { action_button("done", "Done") action_button("undo", "Undo") -console.log('view.revolutions', view.revolutions) +//console.log('view.revolutions', view.revolutions) } // =========================== LOG FUNCTIONS ============================================== diff --git a/rules.js b/rules.js index b7de6ec..e454215 100644 --- a/rules.js +++ b/rules.js @@ -1753,6 +1753,11 @@ states.end_turn_4_5_4 = { } else if (game.persistent_events.includes(104)) { log_h1(`New Year's Eve Party`) + //Check if the Communist receives VP from The Tyrant is Gone + if (game.persistent_events.includes(97)) { + game.vp -= 2 + log(`Communist receives 2 VP from C97`) + } game.persistent_events.push(111) game.state = 'new_years_eve_party' } @@ -2798,7 +2803,7 @@ function do_tst_attempt() { log(`Rolled a ${roll}`); roll += game.available_ops - log(`+${game.available_ops} from card Ops`) + log(`+${game.available_ops} from card ops`) // TIANANMEN SQUARE MODIFIERS @@ -3807,12 +3812,16 @@ function check_control_change(space_id) { }*/ // Check if the Tyrant is Gone has been fulfilled + console.log('check control change_player, game.the_tyrant_is_gone', game.the_tyrant_is_gone) + //console.log('dem control', check_dem_control(game.the_tyrant_is_gone)) if (game.the_tyrant_is_gone > 0 && check_dem_control(game.the_tyrant_is_gone)) { + console.log('in tyrant') log('+2 VP from C97') game.vp += 2 if (check_vp()) { return } + game.persistent_events = game.persistent_events.filter(n => n !== 97) delete game.the_tyrant_is_gone } } @@ -5017,7 +5026,7 @@ function vm_common_european_home() { } } game.valid_cards = valid_cards - game.state = 'vm_common_european_home' + game.state = 'vm_common_european_home_choose' } function vm_dash_for_the_west() { @@ -5300,7 +5309,7 @@ function vm_kohl_proposes_reunification() { } if (game.persistent_events.includes(86)) { game.vm_event = 87 - game.state = 'vm_common_european_home' + game.state = 'vm_common_european_home_play' } else { permanently_remove(87) vm_return() @@ -6411,26 +6420,14 @@ states.vm_central_committee_reshuffle = { } -states.vm_common_european_home = { +states.vm_common_european_home_choose = { get inactive() { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - if (game.vm_event === 0) { - view.prompt = `Common European Home: play an opponent's card, event does not occur.` - for (let card of game.valid_cards) { - gen_action_card(card) - } - } else { - view.prompt = `Play ${clean_name(cards[game.vm_event].name)} for:` - gen_action('influence') - gen_action('support_check') - if (game.active === DEM && game.vm_event === 87 ) { - return /*Special condition if card is actually Kohl Proposes Reunification*/ - } - if (game.active === DEM && game.dem_tst_attempted_this_turn === 0 || game.active === COM && game.com_tst_attempted_this_turn === 0) { - gen_action('tst') - } + view.prompt = `Common European Home: play an opponent's card, event does not occur.` + for (let card of game.valid_cards) { + gen_action_card(card) } }, card(card) { @@ -6439,6 +6436,24 @@ states.vm_common_european_home = { game.valid_cards = [] silent_discard(card) game.vm_event = card + game.state = 'vm_common_european_home_play' + } +} + +states.vm_common_european_home_play = { + get inactive() { + return `resolve ${clean_name(cards[this_card()].name)}.` + }, + prompt() { + view.prompt = `Play ${clean_name(cards[this_card()].name)} for:` + gen_action('influence') + gen_action('support_check') + if (game.active === DEM && game.vm_event === 87 ) { + return /*Special condition if card is actually Kohl Proposes Reunification*/ + } + if (game.active === DEM && game.dem_tst_attempted_this_turn === 0 || game.active === COM && game.com_tst_attempted_this_turn === 0) { + gen_action('tst') + } }, influence(){ push_undo() @@ -6981,7 +6996,7 @@ states.vm_kremlin_coup_choose_country = { } } } else { - view.prompt = 'Kremlin Coup! Done.' + view.prompt = 'Kremlin Coup! There are no countries where the Communist retains power.' gen_action('done') } }, @@ -6989,41 +7004,41 @@ states.vm_kremlin_coup_choose_country = { push_undo() game.vm_active_country = 'East_Germany' game.temp = game.temp.filter(country => country !== game.vm_active_country) - log(`Chose ${country_name(game.vm_active_country)}`) + log(`${country_name(game.vm_active_country)}:`) vm_kremlin_coup_elite() }, poland() { push_undo() game.vm_active_country = 'Poland' - log(`Chose ${country_name(game.vm_active_country)}`) + log(`${country_name(game.vm_active_country)}:`) game.temp = game.temp.filter(country => country !== game.vm_active_country) vm_kremlin_coup_elite() }, czechoslovakia() { push_undo() game.vm_active_country = 'Czechoslovakia' - log(`Chose ${country_name(game.vm_active_country)}`) + log(`${country_name(game.vm_active_country)}:`) game.temp = game.temp.filter(country => country !== game.vm_active_country) vm_kremlin_coup_elite() }, hungary() { push_undo() game.vm_active_country = 'Hungary' - log(`Chose ${country_name(game.vm_active_country)}`) + log(`${country_name(game.vm_active_country)}:`) game.temp = game.temp.filter(country => country !== game.vm_active_country) vm_kremlin_coup_elite() }, romania() { push_undo() game.vm_active_country = 'Romania' - log(`Chose ${country_name(game.vm_active_country)}`) + log(`${country_name(game.vm_active_country)}:`) game.temp = game.temp.filter(country => country !== game.vm_active_country) vm_kremlin_coup_elite() }, bulgaria () { push_undo() game.vm_active_country = 'Bulgaria' - log(`Chose ${country_name(game.vm_active_country)}`) + log(`${country_name(game.vm_active_country)}:`) game.temp = game.temp.filter(country => country !== game.vm_active_country) vm_kremlin_coup_elite() }, @@ -7049,9 +7064,14 @@ states.vm_kremlin_coup_take_control = { } }, infl(space) { - vm_take_control(space) - game.state = 'vm_kremlin_coup_sc_prep' - return + vm_take_control(space) + if (game.vm_active_country === 'East_Germany') {game.selected_space = 3 } + if (game.vm_active_country === 'Poland') {game.selected_space = 17} + if (game.vm_active_country === 'Czechoslovakia') {game.selected_space = 29} + if (game.vm_active_country === 'Hungary') {game.selected_space = 45} + if (game.vm_active_country === 'Romania') {game.selected_space = 61} + if (game.vm_active_country === 'Bulgaria') {game.selected_space = 68} + game.state = 'vm_kremlin_coup_sc_prep' }, done() { if (game.vm_active_country === 'East_Germany') {game.selected_space = 3 } @@ -7069,7 +7089,7 @@ states.vm_kremlin_coup_sc_prep = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - view.prompt = `Conduct a support check in ${game.vm_active_country}'s Bureaucratic space.` + view.prompt = `Kremlin Coup! Conduct a support check in ${game.vm_active_country}'s Bureaucratic space.` gen_action_sc(spaces[game.selected_space].name_unique); }, sc(space) { @@ -7087,8 +7107,24 @@ states.vm_kremlin_coup_sc = { roll() { clear_undo() do_sc(spaces[game.selected_space].name_unique) - game.state = 'vm_kremlin_coup_choose_country' - return + if (game.temp.length > 0 ){ + game.state = 'vm_kremlin_coup_choose_country' + } else { + game.state = 'vm_kremlin_coup_end' + } + } +} + +states.vm_kremlin_coup_end = { + get inactive() { + return `resolve ${clean_name(cards[this_card()].name)}.` + }, + prompt() { + view.prompt = `${clean_name(cards[this_card()].name)}: done.` + gen_action('done') + }, + done() { + vm_next() } } @@ -8087,6 +8123,7 @@ states.vm_tst_6_sc = { clear_undo() do_sc(spaces[game.selected_space].name_unique) game.vm_available_ops-- + game.valid_spaces = [] game.state = 'vm_tst_6' return } @@ -9044,8 +9081,6 @@ CODE[108] = [ // Army Backs Revolution* CODE[109] = [ // Kremlin Coup* [ vm_kremlin_coup ], - [ vm_prompt, 'Elite spaces in all countries where the Communist retains Power' ], - [ vm_take_control_prep, 6 ], [ vm_permanently_remove ], [ vm_return ], ] -- cgit v1.2.3