diff options
author | iainp5 <iain.pearce.ip@gmail.com> | 2024-10-17 13:31:59 +0100 |
---|---|---|
committer | iainp5 <iain.pearce.ip@gmail.com> | 2024-10-17 13:31:59 +0100 |
commit | 5b644b34cc90ae93b0b074c1b58becd0f91b2a03 (patch) | |
tree | 906e022b0e89c9f1bc17c23224adc31d957b2e00 /rules.js | |
parent | bb272b0887a5e4b4e8a7380d02e441874c48ff24 (diff) | |
download | 1989-dawn-of-freedom-5b644b34cc90ae93b0b074c1b58becd0f91b2a03.tar.gz |
Updates for new flow
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 699 |
1 files changed, 469 insertions, 230 deletions
@@ -318,7 +318,10 @@ states.com_init = { inactive: 'place starting SPs.',
prompt() {
console.log('state:', game.state, 'game.valid_spaces', game.valid_spaces)
- if (game.available_ops == 0) {
+ if (game.starting_infl.dem_starting_infl === 2 && game.available_ops === 0 ) {
+ view.prompt = 'Place starting SPs: done. Start Turn 1.';
+ gen_action("start");
+ } else if (game.available_ops === 0) {
view.prompt = 'Place starting SPs: done.';
gen_action("done");
return;
@@ -356,6 +359,11 @@ states.com_init = { delete game.starting_infl
game.state = 'start_game'
}
+ },
+ start() {
+ new_turn()
+ clear_undo()
+ game.state = 'choose_card'
}
}
@@ -398,19 +406,6 @@ states.dem_init = { }
}
-states.start_game = {
- inactive: 'start Turn 1.',
- prompt() {
- console.log('state:', game.state)
- view.prompt = 'Start Turn 1.'
- gen_action('start')
- },
- start() {
- new_turn()
- clear_undo()
- game.state = 'choose_card'
- }
-}
states.choose_card = {
inactive: 'choose a card.',
@@ -471,12 +466,12 @@ states.play_card ={ return `play ${clean_name(cards[game.played_card].name)}.`
},
prompt () {
- if (game.phase >= 1) { /*Finish here when playing your own event */
+ /*if (game.phase >= 1) { /*Finish here when playing your own event
console.log('in play card')
view.prompt = `${clean_name(cards[game.played_card].name)}: done. End the Action Round.`
gen_action('end_round')
return
- }
+ }*/
view.prompt = `Play ${clean_name(cards[game.played_card].name)} for:`
@@ -694,6 +689,7 @@ states.resolve_opponent_event = { game.vm_event_to_do = false
},
end_round() {
+ push_undo()
/*if(game.round_player === COM && game.active === DEM) {
log_h3('End of Communist Action Round')
change_player()
@@ -708,11 +704,11 @@ states.finish_add_infl = { prompt () {
if (game.available_ops === 0) {
view.prompt = 'Place SPs: done.'
- gen_action("done")
+ gen_action("end_round")
return;
}
- view.prompt = `Add SPs: ${game.available_ops} remaining`
+ view.prompt = `Add SPs: ${game.available_ops} remaining.`
// Generate actions for valid spaces
for (let space_id of game.valid_spaces) {
@@ -722,14 +718,15 @@ states.finish_add_infl = { infl(space) {
add_infl(space)
},
- done() {
+ end_round() {
+ push_undo()
if (game.summary.length > 0) {
pop_summary()
log_br()
}
- //end_round()
- game.state = 'end_round'
+ end_round()
+ //game.state = 'end_round'
}
}
@@ -738,7 +735,7 @@ states.finish_support_check_prep = { prompt () {
if (game.available_ops === 0) {
view.prompt = 'Support checks: done.'
- gen_action('done')
+ gen_action('end_round')
//return
} else {
view.prompt = `Select a space. ${pluralize(game.available_ops, 'support check')} remaining.`
@@ -763,9 +760,9 @@ states.finish_support_check_prep = { }
game.state = 'finish_do_support_check'
},
- done () {
- //end_round()
- game.state = 'end_round'
+ end_round () {
+ end_round()
+ //game.state = 'end_round'
}
}
@@ -806,35 +803,41 @@ states.finish_do_support_check = { states.add_influence = {
inactive: 'add SPs.',
prompt () {
- if (game.available_ops <= 0) {
- view.prompt = 'Place SPs: done.'
- gen_action("done")
- return
- }
+ if (game.available_ops <= 0) {
+ view.prompt = 'Place SPs: done.'
+ if (!game.vm_event_to_do) {
+ gen_action("end_round")
+ } else {
+ gen_action('done')
+ }
+ } else {
- view.prompt = `Add SPs: ${game.available_ops} remaining.`
+ view.prompt = `Add SPs: ${game.available_ops} remaining.`
- // Generate actions for valid spaces
- for (let space_id of game.valid_spaces) {
- gen_action_infl(space_id);
+ // Generate actions for valid spaces
+ for (let space_id of game.valid_spaces) {
+ gen_action_infl(space_id);
+ }
}
},
infl(space) {
add_infl(space)
},
- done() {
+ end_round() {
+ push_undo()
if (game.summary.length > 0) {
pop_summary()
log_br()
}
-
- if(game.vm_event_to_do) {
- reset_austria_hungary_border_reopened()
- game.state = 'resolve_opponent_event'}
- else {
- //end_round()
- game.state = 'end_round'
+ end_round()
+ },
+ done() {
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
}
+ reset_austria_hungary_border_reopened()
+ game.state = 'resolve_opponent_event'
}
}
@@ -855,19 +858,21 @@ states.tiananmen_square_attempt_success = { prompt () {
if (game.vm_event > 200) {
view.prompt = 'Tiananmen Square Track attempt successful. Go to TST Award.'
+ gen_action('done')
} else {
view.prompt = 'Tiananmen Square Track attempt successful.'
+ gen_action('end_round')
}
- gen_action('done')
+
},
done () {
push_undo()
- if (game.vm_event > 200) {
- console.log('going to tst award, game.return_state', game.return_state)
- goto_vm(game.vm_event)
- } else {
- game.state = 'tiananmen_square_attempt_done'
- }
+ console.log('going to tst award, game.return_state', game.return_state)
+ goto_vm(game.vm_event)
+ },
+ end_round () {
+ push_undo()
+ end_round()
}
}
@@ -875,18 +880,19 @@ states.tiananmen_square_attempt_fail = { inactive: 'do Tiananmen Square Attempt.',
prompt () {
view.prompt = 'Tiananmen Square Track attempt failed.'
- gen_action('done')
+ gen_action('end_round')
},
- done () {
+ end_round () {
push_undo()
- game.state = 'tiananmen_square_attempt_done'
+ end_round()
+ //game.state = 'tiananmen_square_attempt_done'
}
}
states.tiananmen_square_attempt_done = {
inactive: 'do Tiananmen Square Attempt.',
prompt () {
- view.prompt = 'Tiananmen Square Track attempt: done. End the Action Round.'
+ view.prompt = 'Tiananmen Square Track attempt: done.'
gen_action('done')
},
done () {
@@ -984,12 +990,15 @@ states.tst_goddess_draw = { states.support_check_prep = {
inactive: 'do support checks',
prompt () {
- if (game.available_ops === 0) {
- view.prompt = 'Support checks: done.'
- gen_action('done')
- //return
- }
- if (game.available_ops > 0) {
+ if (game.available_ops === 0) { /*Needs another check for Support Checks done during Crowd Turns against Ceausescu*/
+ if (!game.vm_event_to_do) {
+ view.prompt = 'Support checks: done.'
+ gen_action('end_round')
+ } else {
+ view.prompt = 'Support checks: done.'
+ gen_action('done')
+ }
+ } else if (game.available_ops > 0) {
view.prompt = `Select a space. ${pluralize(game.available_ops, 'support check')} remaining.`
for (let space_id of game.valid_spaces) {
@@ -1016,7 +1025,12 @@ states.support_check_prep = { console.log('game.state after space selected:', game.state)
//}
},
- done () {
+ end_round() {
+ push_undo()
+ end_round()
+ },
+ done() {
+ push_undo()
if (game.is_pwr_struggle) {/*Crowd Turns Against Ceausescu should be the only time you end up here during a power struggle */
if (game.return !== game.active) {
next_player()
@@ -1024,14 +1038,8 @@ states.support_check_prep = { game.state = 'raise_stakes_1'
return
}
-
- if (game.vm_event_to_do) {
- reset_austria_hungary_border_reopened()
- game.state = 'resolve_opponent_event'
- } else {
- //end_round()
- game.state = 'end_round'
- }
+ reset_austria_hungary_border_reopened()
+ game.state = 'resolve_opponent_event'
}
}
@@ -1077,6 +1085,7 @@ states.end_round = { gen_action('end_round')
},
end_round() {
+ push_undo()
end_round()
}
}
@@ -1086,7 +1095,7 @@ states.end_round = { states.draw_power_cards = {
inactive: 'draw cards.',
prompt() {
- view.prompt = 'Draw cards.'
+ view.prompt = `${clean_name(cards[this_card()].name)}: draw cards.`
gen_action('draw')
},
draw() {
@@ -1248,6 +1257,11 @@ states.raise_stakes_1 = { prompt () {
console.log('raise the stakes: game.played_power_card', game.played_power_card, 'game.active', game.active, 'game.view_opp_hand', game.view_opp_hand)
+ if ((game.active === DEM && game.dem_pwr_hand < 3) || (game.active === COM && game.com_pwr_hand < 3)) {
+ view.prompt = 'Raise the stakes: you must pass.'
+ gen_action('pass')
+ return
+ }
if (game.raised_stakes_discard === 3) {
view.prompt = 'Raise the stakes: done.'
gen_action('done')
@@ -1297,7 +1311,11 @@ states.raise_stakes_2 = { inactive: 'raise the stakes',
prompt () {
-
+ if ((game.active === DEM && game.dem_pwr_hand < 3) || (game.active === COM && game.com_pwr_hand < 3)) {
+ view.prompt = 'Raise the stakes: you must pass.'
+ gen_action('pass')
+ return
+ }
if (game.raised_stakes_discard === 3) {
view.prompt = 'Raise the stakes: done.'
gen_action('done')
@@ -1616,16 +1634,16 @@ states.support_loss ={ }
states.vp_roll = {
- inactive: 'do VP Roll',
+ inactive: 'do VP Roll.',
prompt () {
if (game.phase === 0) {
- view.prompt = 'Roll a die for Victory.'
+ view.prompt = `${clean_name(cards[this_card()].name)}: roll a die for Victory.`
gen_action('roll')
} else if (game.phase === 1) {
- view.prompt = 'Take power.'
+ view.prompt = `${clean_name(cards[this_card()].name)}: take power.`
gen_action('take')
} else if (game.phase === 2) {
- view.prompt = 'Proceed to scoring.'
+ view.prompt = `${clean_name(cards[this_card()].name)}: proceed to scoring.`
gen_action('scoring')
}
},
@@ -1781,8 +1799,8 @@ states.finish_scoring ={ return
}
reset_power()
- //end_round()
- game.state = 'end_round'
+ end_round()
+ //game.state = 'end_round'
}
}
@@ -2094,33 +2112,45 @@ states.stasi_end_round = { inactive: 'choose next card due to Stasi.',
prompt() {
console.log('game.stasi_card', game.stasi_card)
- if (!game.stasi_card || game.stasi_card === 0 ) {
- let available_cards = game.democrat_hand
- if (available_cards.length === 0) {
- view.prompt = 'Stasi: no cards remaining.'
- gen_action('pass')
- return
- }
- view.prompt = 'Stasi: you must select your next card to play.'
-
- for (let card of available_cards) {
- gen_action_card(card)
- }
- } else {
- view.prompt = 'Stasi. Choose card: done.'
- gen_action('done')
+ let available_cards = game.democrat_hand
+ if (available_cards.length === 0) {
+ view.prompt = 'Stasi: no cards remaining.'
+ gen_action('pass')
+ return
}
+ view.prompt = 'Stasi: you must select your next card to play.'
+
+ for (let card of available_cards) {
+ gen_action_card(card)
+ }
},
card(card) {
push_undo()
log_gap(`Stasi: selected C${cards[card].number}`)
game.stasi_card = card
+ game.state = 'stasi_finish'
},
pass() {
log('Stasi: Democrat has no remaining cards')
game.stasi_card = 0
end_stasi_choose_card()
},
+ end_round() {
+ push_undo()
+ if (game.stasi_card === 21) {
+ game.state = 'stasi_confirm'
+ } else {
+ end_stasi_choose_card()
+ }
+ }
+}
+
+states.stasi_finish = {
+ inactive: 'choose next card due to Stasi.',
+ prompt() {
+ view.prompt = 'Stasi. Choose card: done.'
+ gen_action('done')
+ },
done() {
push_undo()
if (game.stasi_card === 21) {
@@ -2154,7 +2184,7 @@ states.stasi_play_card = { gen_action("done");
return;*/
//} else
- if (game.stasi_card === 0) {
+ if (game.democrat_hand.length === 0) {
view.prompt = 'Stasi: you must pass.'
gen_action('pass')
} else {
@@ -2174,7 +2204,6 @@ states.stasi_play_card = { game.democrat_hand.splice(find_card, 1);
game.available_ops = get_card_ops(card)
- game.stasi_card = 0
if (game.democrat_hand.includes(21) && cards[card].side === "C") {
game.state = 'stasi_resolve_common_european_home'
} else {
@@ -2734,17 +2763,17 @@ function count_adj(id) { //console.log('adj_piece.space_id', adj_piece.space_id, 'space', space)
if (adj_piece && adj_piece.space_id !== space.space_id) {
if (check_dem_control(adj_piece.space_id)) {
- console.log('added DEM space', spaces[adj_piece.space_id].name)
+ //console.log('added DEM space', spaces[adj_piece.space_id].name)
dem_adj++
}
if (check_com_control(adj_piece.space_id)) {
- console.log('added COM space', spaces[adj_piece.space_id].name)
+ //console.log('added COM space', spaces[adj_piece.space_id].name)
com_adj++
}
}
}
}
- console.log('dem_adj: ', dem_adj, 'com_adj: ', com_adj)
+ //console.log('dem_adj: ', dem_adj, 'com_adj: ', com_adj)
return {dem_adj, com_adj}
}
@@ -3151,6 +3180,15 @@ function get_value(country) { return value
}
+function get_end_infl_prompt() {
+ view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.`
+ if (!game.vm_infl_to_do) {
+ gen_action('end_round')
+ } else {
+ gen_action('done')
+ }
+}
+
function permanently_remove(card) {
console.log('permanently removing card:', card)
if (game.strategy_removed.includes(card)) {return}
@@ -3283,6 +3321,7 @@ function get_events(card){ }
function event_is_playable(card) {
+ console.log('game.stasi_card', game.stasi_card, 'card', card)
//Reformer never playable here
if (card === 67) {
return false
@@ -3405,6 +3444,36 @@ function get_tst_6_ops() { return ops
}
+function finish_the_wall() {
+ if (game.the_wall_must_go['dem_wins'] === 2) {
+ game.persistent_events.push(86)
+ log('+3 VP')
+ game.vp += 3
+ if (check_vp()) {
+ return
+ }
+ for (let i = 1; i < spaces.length; i++) {
+ let space = spaces[i]
+ if (space.country === 'East_Germany' && game.comInfl[i] > 0){
+ game.valid_spaces.push(space.space_id)
+ }
+ }
+ if (!game.vm_infl_to_do) {
+ if (game.round_player === DEM) {
+ game.return = COM
+ } else {
+ game.return = DEM
+ }
+ }
+ if (game.active === DEM) {next_player()}
+ vm_next ()
+ } else {
+ permanently_remove(86)
+ delete game.the_wall_must_go
+ vm_return()
+ }
+}
+
// =========== MOVING THROUGH TURNS ============
@@ -4388,18 +4457,25 @@ function vm_return() { //Check if end event state is needed
if (game.is_pwr_struggle || game.state === 'vm_tst_6' || game.return_state === 'tiananmen_square_attempt_done') {
vm_end_event()
- } else {
- if (!game.vm_infl_to_do) {
+ }
+ //Check if auto-resolve opponent event
+ else if (auto_resolve_events.includes(game.played_card) && ((cards[game.played_card].side === 'C' && game.active === DEM) || (cards[game.played_card].side === 'D' && game.active === COM) )) {
+ vm_end_event()
+ }
+ else {
+
+ game.state = 'vm_end_event'
+ /*if (!game.vm_infl_to_do) {
/*if ((game.active === DEM && game.round_player !==DEM) || (game.active === COM && game.round_player !== COM)) {
game.state = 'vm_end_event'
- } else {*/
+ } else {
game.state = 'vm_end_event'
-
+ //end_round()
//}
} else {
console.log('vm_infl_to_do true')
vm_end_event()
- }
+ }*/
}
}
@@ -5972,14 +6048,21 @@ states.vm_end_event = { },
prompt () {
console.log('in vm_end_event')
- view.prompt = `${clean_name(cards[this_card()].name)}: done. End the Action Round.`
- gen_action('end_round')
+ view.prompt = `${clean_name(cards[this_card()].name)}: done.`
+ if (game.vm_infl_to_do) {
+ gen_action('done')
+ } else {
+ gen_action('end_round')
+ }
+ },
+ done() {
+ push_undo()
+ vm_end_event()
},
- end_round(){
+ end_round() {
console.log('end round clicked - vm_end_event called')
- if (!game.vm_infl_to_do) {
- game.return_state = ''
- }
+ push_undo()
+ game.return_state = ''
vm_end_event()
}
}
@@ -6000,15 +6083,27 @@ states.vm_take_control = { }
} else {
view.prompt = `${clean_name(cards[this_card()].name)}. Take control: done.`
- gen_action('done')
+ if (game.vm_infl_to_do) {
+ gen_action('done')
+ } else {
+ gen_action('end_round')
+ }
}
},
infl(space) {
push_undo()
vm_take_control(space)
game.vm_available_ops--
+ if (game.vm_available_ops === 0) {
+ vm_next()
+ }
},
done() {
+ push_undo()
+ vm_next()
+ },
+ end_round() {
+ push_undo()
vm_next()
}
}
@@ -6028,14 +6123,20 @@ states.vm_add_infl = { gen_action_infl(space_id)
}
} else {
- view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.`
- gen_action('done')
+ get_end_infl_prompt()
}
},
infl(space) {
vm_do_add_infl(space)
if (game.vm_available_ops === 0) {
game.valid_spaces = []
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+
+ game.vm_event_done = true
+ vm_next()
}
},
done () {
@@ -6047,6 +6148,16 @@ states.vm_add_infl = { game.vm_event_done = true
vm_next()
+ },
+ end_round() {
+ push_undo()
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+
+ game.vm_event_done = true
+ vm_next()
}
}
@@ -6058,22 +6169,27 @@ states.vm_add_infl_free = { if (game.vm_available_ops > 0 && game.valid_spaces.length === 0 ) {
view.prompt = `${clean_name(cards[this_card()].name)}. No available spaces remaining. Add SPs: done.`
gen_action('done')
- }
- else if (game.vm_available_ops > 0 ) {
+ } else if (game.vm_available_ops > 0 ) {
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);
}
} else {
- view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.`
- gen_action('done')
+ get_end_infl_prompt()
}
},
infl(space) {
vm_do_add_infl_free(space)
if (game.vm_available_ops === 0) {
game.valid_spaces = []
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+
+ game.vm_event_done = true
+ vm_next()
}
},
done () {
@@ -6085,6 +6201,16 @@ states.vm_add_infl_free = { log_br()
}
vm_next()
+ },
+ end_round () {
+ push_undo()
+ game.valid_spaces = []
+ game.vm_event_done = true
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+ vm_next()
}
}
@@ -6100,25 +6226,32 @@ states.vm_add_x_infl = { for (let space_id of game.valid_spaces) {
gen_action_infl(space_id)
}
- } else {
+ } /*else {
view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.`
gen_action('done')
- }
+ }*/
},
infl(space) {
push_undo()
vm_do_add_x_infl(space)
- if (game.vm_event === 105) {
+ if (game.vm_available_ops === 0) {
+ game.vm_event_done = true
vm_next()
}
+ /*if (game.vm_event === (105 || 68) {
+ vm_next()
+ return
+ } */
+
+
//game.vm_event_done = true
//vm_next()
- },
- done () {
+ }
+ /*done () {
push_undo()
game.vm_event_done = true
vm_next()
- }
+ }*/
}
states.vm_add_limited_infl = {
@@ -6136,18 +6269,24 @@ states.vm_add_limited_infl = { for (let space_id of game.valid_spaces) {
gen_action_infl(space_id);
}
- } else {
+ } /*else {
view.prompt = `${clean_name(cards[this_card()].name)}. Add SPs: done.`
gen_action('done')
- }
+ }*/
},
infl(space) {
vm_do_add_limited_infl(space, game.vm_max_infl)
- if (game.vm_available_ops === 0) {
+ if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) {
game.valid_spaces = []
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+ game.vm_event_done = true
+ vm_next()
}
},
- done () {
+ /*done () {
push_undo()
if (game.summary.length > 0) {
pop_summary()
@@ -6155,23 +6294,30 @@ states.vm_add_limited_infl = { }
game.vm_event_done = true
vm_next()
- }
+ }*/
}
states.vm_remove_infl = {
inactive: 'remove Support Points.',
prompt () {
// Keep this so that there is an undo option in, e.g., Scare Tactics
+ console.log('in vm_remove infl, vm_infl_to_do', game.vm_infl_to_do)
if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: no further SPs to remove.`
gen_action('done')
return
}
- if (game.vm_available_ops === 0 ) {
- view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
- gen_action('done')
- return
- }
+ /*if (game.vm_available_ops === 0 ) {
+ if (game.vm_infl_to_do) {
+ view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
+ gen_action('done')
+ return
+ } else {
+ view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
+ gen_action('done')
+ return
+ }
+ }*/
if (game.remove_opponent_infl) {
view.prompt = `${clean_name(cards[this_card()].name)}: remove ${pluralize(game.vm_available_ops, 'opponent SP')}${event_prompt()}.`
}
@@ -6186,9 +6332,14 @@ states.vm_remove_infl = { push_undo()
vm_do_remove_infl(space)
game.vm_active_country = spaces[space].country
- /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) {
+
+ if (game.vm_available_ops === 0 ) {
vm_next()
- }*/
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+ }
},
done() {
if (game.summary.length > 0) {
@@ -6215,14 +6366,26 @@ states.vm_remove_x_infl = { for (let space_id of game.valid_spaces) {
gen_action_infl(space_id);
}
- } else {
- view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
- gen_action('done')
- }
+ } /*else {
+ if (game.vm_infl_to_do) {
+ view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done. Return control to phasing player.`
+ gen_action('done')
+ return
+ } else {
+ view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
+ gen_action('done')
+ return
+ }
+ }*/
},
infl(space) {
vm_do_remove_x_infl(space)
- if (game.vm_event === 68) {
+ /*if (game.vm_event === 68) {
+ vm_next()
+ return
+ }*/
+ if (game.vm_available_ops === 0) {
+ game.vm_event_done = true
vm_next()
}
/*game.vm_event_done = true
@@ -6246,16 +6409,28 @@ states.vm_remove_limited_infl = { } 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.`
gen_action('done')
- } else {
- view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
- gen_action('done')
- }
+ } /*else {
+ if (game.vm_infl_to_do) {
+ view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done. Return control to phasing player.`
+ gen_action('done')
+ return
+ } else {
+ view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
+ gen_action('done')
+ return
+ }
+ }*/
},
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
@@ -6278,19 +6453,20 @@ states.vm_remove_all_infl = { for (let space_id of game.valid_spaces) {
gen_action_infl(space_id);
}
- } else {
+ } /*else {
view.prompt = `${clean_name(cards[this_card()].name)}. Remove SPs: done.`
gen_action('done')
- }
+ }*/
},
infl(space) {
vm_do_remove_all_infl(space)
game.vm_active_country = spaces[space].country
- /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) {
+ if (game.vm_available_ops === 0) {
vm_next()
- }*/
+ }
},
done() {
+ push_undo()
vm_next()
}
}
@@ -6299,16 +6475,17 @@ states.vm_support_check_prep = { inactive: 'do support checks.',
prompt () {
console.log('in states.vm_support_check_prep, game.vm_available_ops: ', game.vm_available_ops)
- if (game.vm_available_ops === 0) {
+ /*if (game.vm_available_ops === 0) {
view.prompt = `${clean_name(cards[this_card()].name)}. Support check: done.`
gen_action('done')
- } else if (game.valid_spaces.length === 0) {
+ } else */
+ if (game.valid_spaces.length === 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: no valid targets for support check.`
gen_action('done')
} else {
- if (game.vm_available_ops > 0) {
+ //if (game.vm_available_ops > 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: ${event_prompt()}. ${pluralize(game.vm_available_ops, 'support check')} remaining.`
- }
+ //}
for (let space_id of game.valid_spaces) {
if (!space_id) continue
gen_action_sc(space_id);
@@ -6350,11 +6527,11 @@ states.vm_support_check_prep = { states.vm_ceh_support_check_prep = {
inactive: 'do support checks.',
prompt () {
- if (game.vm_available_ops === 0) {
+ /*if (game.vm_available_ops === 0) {
view.prompt = 'Support checks: done.'
gen_action('done')
- //return
- }
+ return
+ }*/
if (game.vm_available_ops > 0) {
view.prompt = `Select a space. ${pluralize(game.vm_available_ops, 'support check')} remaining.`
@@ -6381,9 +6558,9 @@ states.vm_ceh_support_check_prep = { }
game.state = 'vm_ceh_do_support_check'
},
- done () {
+ /*done () {
vm_next ()
- }
+ }*/
}
@@ -6400,9 +6577,11 @@ states.vm_ceh_do_support_check = { game.vm_available_ops--
if (game.vm_available_ops === 0) {
game.valid_spaces = []
+ vm_next()
+ } else {
+ game.state = 'vm_ceh_support_check_prep'
+ return
}
- game.state = 'vm_ceh_support_check_prep'
- return
}
}
@@ -6425,10 +6604,10 @@ states.vm_austria_hungary_border_reopened_check = { states.vm_1_support_check_prep = {
inactive: 'do support checks.',
prompt () {
- if (game.vm_available_ops === 0) {
+ /*if (game.vm_available_ops === 0) {
view.prompt = `${clean_name(cards[this_card()].name)}. Support check: done.`
gen_action('done')
- } else if (game.valid_spaces.length === 0) {
+ } else */if (game.valid_spaces.length === 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: no valid targets for support check.`
gen_action('done')
} else {
@@ -6462,32 +6641,36 @@ states.vm_do_support_check = { clear_undo()
do_sc(game.selected_space)
game.vm_available_ops--
+ console.log('game.vm_available_ops', game.vm_available_ops)
if (game.vm_available_ops === 0) {
game.valid_spaces = []
+ vm_next()
+ return
+ } else {
+ game.state = 'vm_support_check_prep'
+ return
}
- game.state = 'vm_support_check_prep'
- return
}
}
states.vm_tiananmen_square_attempt = {
inactive: 'do Tiananmen Square',
prompt () {
- if (game.active === DEM && game.dem_tst_attempted_this_turn > 0 || game.active === COM && game.com_tst_attempted_this_turn > 0) {
+ /*if (game.active === DEM && game.dem_tst_attempted_this_turn > 0 || game.active === COM && game.com_tst_attempted_this_turn > 0) {
view.prompt = 'Tiananmen Square Track attempt: done.'
gen_action('done')
return
- }
- view.prompt = 'Roll a die'
+ }*/
+ view.prompt = 'Tiananmen Square: roll a die'
gen_action('roll')
},
roll() {
clear_undo()
do_tst_attempt ()
},
- done () {
+ /*done () {
vm_next()
- }
+ }*/
}
//================================== EVENT SPECIFIC STATES ======================================
@@ -6579,30 +6762,35 @@ states.vm_central_committee_reshuffle = { if (!game.revolutions[5]) {gen_action('romania')}
},
east_germany() {
+ push_undo()
game.vm_active_country = "East_Germany"
log(`Chose ${country_name(game.vm_active_country)}`)
game.valid_spaces = [1,2,3,4,5,6,7,8,9,10,11,12]
vm_next()
},
poland() {
+ push_undo()
game.vm_active_country = "Poland"
log(`Chose ${country_name(game.vm_active_country)}`)
game.valid_spaces = [13,14,15,16,17,18,19,20,21,22,23,24,25,26]
vm_next()
},
czechoslovakia() {
+ push_undo()
game.vm_active_country = "Czechoslovakia"
log(`Chose ${country_name(game.vm_active_country)}`)
game.valid_spaces = [27,28,29,30,31,32,33,34,35,36,37]
vm_next()
},
hungary() {
+ push_undo()
game.vm_active_country = "Hungary"
log(`Chose ${country_name(game.vm_active_country)}`)
game.valid_spaces = [38,39,40,41,42,43,44,45,46,47,48,49]
vm_next()
},
romania() {
+ push_undo()
game.vm_active_country = "Romania"
log(`Chose ${country_name(game.vm_active_country)}`)
game.valid_spaces = [50,51,52,53,54,55,56,57,58,59,60,61,62,63]
@@ -6610,6 +6798,7 @@ states.vm_central_committee_reshuffle = { vm_next()
},
bulgaria () {
+ push_undo()
game.vm_active_country = "Bulgaria"
log(`Chose ${country_name(game.vm_active_country)}`)
game.valid_spaces = [64,65,66,67,68,69,70,71,72,73,74,75]
@@ -6670,6 +6859,7 @@ states.vm_common_european_home_play = { valid_spaces_sc()
},
tst() {
+ push_undo()
game.state = 'vm_tiananmen_square_attempt'
}
}
@@ -6727,10 +6917,10 @@ states.vm_play_event_from_discard = { gen_action('pass')
gen_action_card(card)
}
- } else {
+ } /*else {
view.prompt = 'Choose a card: done.'
gen_action('done')
- }
+ }*/
},
card(card) {
push_undo()
@@ -6752,10 +6942,11 @@ states.vm_play_event_from_discard = { }
vm_next()
},
- done(){
+/* done(){
+ push_undo()
game.discard = false
vm_next()
- }
+ }*/
}
states.vm_deutsche_marks_prep = {
@@ -6781,6 +6972,7 @@ states.vm_deutsche_marks_prep = { game.vm_event = card
},
pass() {
+ push_undo()
vm_next()
}
}
@@ -6815,6 +7007,7 @@ states.vm_deutsche_marks = { }
},
event() {
+ push_undo()
log(`Played C${cards[game.vm_event].number} for the event`)
console.log('game.active', game.active)
if (!game.vm_infl_to_do) {
@@ -6888,19 +7081,20 @@ states.vm_exit_visas_finish = { if (game.temp > 0 ) {
view.prompt = 'Exit Visas: draw replacement cards.'
gen_action('draw')
- } else {
+ } /*else {
view.prompt = 'Exit Visas. Draw cards: done.'
gen_action('done')
- }
+ } */
},
draw() {
clear_undo()
draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.democrat_hand.length + game.temp, game.communist_hand.length)
game.temp = 0
+ vm_next()
},
- done() {
+ /*done() {
vm_next()
- }
+ }*/
}
states.vm_foreign_currency_debt_burden = {
@@ -6974,6 +7168,7 @@ states.vm_goodbye_lenin = { goto_vm(card)
},
ops() {
+ push_undo()
if (game.valid_cards.length === 0) {
logi('No red events')
}
@@ -7018,6 +7213,7 @@ states.vm_goodbye_lenin_ops = { valid_spaces_sc()
},
tst() {
+ push_undo()
game.state = 'vm_tiananmen_square_attempt'
}
}
@@ -7036,10 +7232,10 @@ states.vm_honecker = { gen_action_card(card)
gen_action('pass')
}
- } else {
+ } /*else {
view.prompt = 'Honecker. Choose a card: done.'
gen_action('done')
- }
+ }*/
},
card(card) {
push_undo()
@@ -7050,18 +7246,20 @@ states.vm_honecker = { game.strategy_discard.splice(card_index, 1)
game.communist_hand.push(card)
console.log('removed after honecker', game.strategy_removed)
+ vm_next()
},
pass(){
log('Did not take a card')
+ game.discard = false
vm_next()
},
- done(){
+ /*done(){
if (game.temp === 0) {
log('Did not take a card')
}
game.discard = false
vm_next()
- }
+ } */
}
@@ -7071,7 +7269,7 @@ states.vm_inflationary_currency = { },
prompt() {
console.log('game.revolutions', game.revolutions, 'length', game.revolutions.length)
- if (game.revolutions.every(n => n === false)) {
+ 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.'
gen_action('pass')
} else {
@@ -7158,8 +7356,10 @@ states.vm_inflationary_currency_discard = { push_undo()
discard(card)
game.temp = card
+
},
pass() {
+ push_undo()
log('Did not discard')
next_player()
game.vm_available_ops = 1
@@ -7319,6 +7519,7 @@ states.vm_kremlin_coup_take_control = { }
},
infl(space) {
+ push_undo()
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}
@@ -7329,6 +7530,7 @@ states.vm_kremlin_coup_take_control = { game.state = 'vm_kremlin_coup_sc_prep'
},
done() {
+ push_undo()
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}
@@ -7349,6 +7551,7 @@ states.vm_kremlin_coup_sc_prep = { },
sc(space) {
//game.selected_space = space
+ push_undo()
game.state = 'vm_kremlin_coup_sc'
}
}
@@ -7365,11 +7568,12 @@ states.vm_kremlin_coup_sc = { if (game.temp.length > 0 ){
game.state = 'vm_kremlin_coup_choose_country'
} else {
- game.state = 'vm_kremlin_coup_end'
+ //game.state = 'vm_kremlin_coup_end'
+ vm_next()
}
}
}
-
+/*
states.vm_kremlin_coup_end = {
get inactive() {
return `resolve ${clean_name(cards[this_card()].name)}.`
@@ -7382,7 +7586,7 @@ states.vm_kremlin_coup_end = { vm_next()
}
}
-
+*/
states.vm_laszlo_tokes = {
get inactive() {
return `resolve ${clean_name(cards[game.played_card].name)}.`
@@ -7582,6 +7786,7 @@ states.vm_new_years_eve_party = { vm_next()
},
continue() {
+ push_undo()
log('Chooses to continue')
permanently_remove(104)
vm_next()
@@ -7630,8 +7835,8 @@ states.vm_nomenklatura_remove = { return `resolve ${clean_name(cards[game.played_card].name)}.`
},
prompt() {
- if (game.vm_available_ops === 0 || game.valid_spaces.length === 0 ) {
- view.prompt = 'Nomenklatura. Remove SPs: done.'
+ if (game.vm_available_ops > 0 && game.valid_spaces.length === 0 ) {
+ view.prompt = 'Nomenklatura. No SPs to remove: done.'
gen_action('done')
} else {
view.prompt = 'Nomenklatura: remove all Democratic SPs from Elite spaces.'
@@ -7644,9 +7849,9 @@ states.vm_nomenklatura_remove = { infl(space) {
push_undo()
vm_do_remove_all_infl(space)
- /*if (game.vm_available_ops === 0) {
+ if (game.valid_spaces.length === 0) {
vm_next()
- }*/
+ }
},
done() {
vm_next()
@@ -7658,29 +7863,36 @@ states.vm_nomenklatura_add = { return `resolve ${clean_name(cards[game.played_card].name)}.`
},
prompt() {
- if (game.vm_available_ops === 0 || game.valid_spaces.length === 0 ) {
+ /*if (game.vm_available_ops === 0 || game.valid_spaces.length === 0 ) {
view.prompt = 'Nomenklatura. Add SPs: done.'
gen_action('done')
- } else {
+ } 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);
}
- }
+ //}
},
infl(space) {
push_undo()
vm_do_add_infl_free(space)
- if (game.vm_available_ops === 0 ) {game.valid_spaces = []}
+ if (game.vm_available_ops === 0 ) {
+ game.valid_spaces = []
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+ vm_next()
+ }
},
- done() {
+/* done() {
push_undo()
if (game.summary.length > 0) {
pop_summary()
log_br()
}
vm_next()
- }
+ }*/
}
states.vm_samizdat = {
@@ -7702,6 +7914,7 @@ states.vm_samizdat = { game.state = 'vm_samizdat_finish'
},
pass() {
+ push_undo()
//if (game.samizdat_card > 0) {game.state = 'vm_samizdat_finish'}
/*else { */
log('Did not set aside a card')
@@ -7747,10 +7960,11 @@ states.vm_shock_therapy = { if (game.revolutions[3]) {gen_action('bulgaria')}
if (game.revolutions[4]) {gen_action('czechoslovakia')}
if (game.revolutions[5]) {gen_action('romania')}
- } else if (game.phase === 2) {
+ } /*else if (game.phase === 2) {
view.prompt = 'Shock Therapy: done.'
gen_action('done')
- } else {
+ } */
+ else {
view.prompt = 'Shock Therapy: roll a die.'
gen_action('roll')
}
@@ -7802,13 +8016,15 @@ states.vm_shock_therapy = { vm_next()
} else {
log('C93 is unsuccessful. Required 3 or more')
- game.phase++
+ //game.phase++
+ permanently_remove(93)
+ vm_return()
}
},
- done() {
+ /*done() {
permanently_remove(93)
vm_return()
- }
+ }*/
}
states.vm_social_democratic_platform_adopted = {
@@ -7968,6 +8184,7 @@ states.vm_the_chinese_solution = { vm_next()
},
pass() {
+ push_undo()
permanently_remove(96)
vm_return()
}
@@ -7978,16 +8195,16 @@ states.vm_the_tyrant_is_gone = { return `resolve ${clean_name(cards[game.played_card].name)}.`
},
prompt() {
- if (!game.the_tyrant_is_gone) {
+ //if (!game.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);
}
- } else {
+ /* } else {
view.prompt = 'Select a space: done.'
gen_action('done')
- }
+ }*/
},
infl(space) {
push_undo()
@@ -7995,10 +8212,11 @@ states.vm_the_tyrant_is_gone = { game.the_tyrant_is_gone = space
game.valid_spaces = []
game.persistent_events.push(97)
+ vm_next()
},
- done () {
+ /*done () {
vm_next()
- }
+ }*/
}
states.vm_tyrant_block ={
@@ -8021,13 +8239,13 @@ states.vm_the_wall_must_go = { return `resolve ${clean_name(cards[this_card()].name)}.`
},
prompt() {
- if (game.the_wall_must_go['dem_wins'] === 2 || game.the_wall_must_go['com_wins'] === 2) {
+ /*if (game.the_wall_must_go['dem_wins'] === 2 || game.the_wall_must_go['com_wins'] === 2) {
view.prompt = '"The Wall Must Go!" Rolls: done.'
gen_action('done')
- } else {
+ } else { */
view.prompt = ('The Wall Must Go! Roll a die.')
gen_action('roll')
- }
+ //}
},
roll() {
clear_undo()
@@ -8071,10 +8289,12 @@ states.vm_the_wall_must_go = { }
if (game.the_wall_must_go['dem_wins'] === 2) {
log('The Democrat wins C86')
+ finish_the_wall()
return
}
if (game.the_wall_must_go['com_wins'] === 2) {
log('The Communist wins C86')
+ finish_the_wall()
return
}
if (game.the_wall_must_go['dem_roll'] === 0 || game.the_wall_must_go['com_roll'] === 0) {
@@ -8084,7 +8304,7 @@ states.vm_the_wall_must_go = { game.the_wall_must_go['com_roll'] = 0
}
},
- done() {
+ /*done() {
if (game.the_wall_must_go['dem_wins'] === 2) {
game.persistent_events.push(86)
log('+3 VP')
@@ -8112,7 +8332,7 @@ states.vm_the_wall_must_go = { delete game.the_wall_must_go
vm_return()
}
- }
+ }*/
}
states.vm_warsaw_pact_summit = {
@@ -8193,14 +8413,13 @@ states.vm_we_are_the_people_add = { return `resolve ${clean_name(cards[game.played_card].name)}.`
},
prompt() {
- if (!game.vm_influence_added[6]) {
+ /* if (!game.vm_influence_added[6]) {
view.prompt = '"We are the People!" Add SPs: done.'
gen_action('done')
return
- }
+ }*/
view.prompt = `"We are the People!": you must add the ${pluralize(game.vm_influence_added[6],'SP')} to spaces in Germany.`
- gen_action('done')
for (let space_id of game.valid_spaces) {
gen_action_infl(space_id);
}
@@ -8208,16 +8427,23 @@ states.vm_we_are_the_people_add = { infl(space) {
vm_do_add_infl_free(space)
game.vm_influence_added[6]--
- if (game.vm_influence_added[6] === 0 ) {game.valid_spaces = []}
+ if (game.vm_influence_added[6] === 0 ) {
+ game.valid_spaces = []
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+ vm_next()
+ }
},
- done() {
+ /*done() {
push_undo()
if (game.summary.length > 0) {
pop_summary()
log_br()
}
vm_next()
- }
+ }*/
}
states.vm_workers_revolt = {
@@ -8240,6 +8466,7 @@ states.vm_workers_revolt = { vm_next()
},
infl(space) {
+ push_undo()
game.selected_space = space
log(`Chose %${game.selected_space}`)
game.state = 'vm_workers_revolt_finish'
@@ -8252,13 +8479,13 @@ states.vm_workers_revolt_finish = { return `resolve ${clean_name(cards[game.played_card].name)}.`
},
prompt() {
- if (game.selected_space > 0) {
+ //if (game.selected_space > 0) {
view.prompt = `Target: ${spaces[game.selected_space].name_unique}. Roll a die.`
gen_action('roll')
- } else {
+ /* } else {
view.prompt = 'Workers Revolt: done.'
gen_action('done')
- }
+ }*/
},
roll() {
@@ -8279,10 +8506,11 @@ states.vm_workers_revolt_finish = { vm_replace_all_infl(game.temp)
} else {log('Workers Revolt fails. Required 4 or more')}
game.selected_space = 0
+ vm_next()
},
- done() {
+ /*done() {
vm_next()
- }
+ }*/
}
// ==================== TIANANMEN SQUARE TRACK STATES =====================
@@ -8318,10 +8546,10 @@ states.vm_tst_3 = { for (let card of game.valid_cards) {
gen_action_card(card)
}
- } else {
+ } /*else {
view.prompt = 'Discard cards: done.'
gen_action('done')
- }
+ }*/
},
card(card) {
push_undo()
@@ -8329,11 +8557,12 @@ states.vm_tst_3 = { game.temp ++
if (game.temp === 2) {
game.valid_cards = []
+ vm_next()
}
},
- done() {
+ /*done() {
vm_next()
- }
+ }*/
}
states.vm_tst_4 = {
@@ -8352,6 +8581,13 @@ states.vm_tst_4 = { },
infl(space) {
vm_do_remove_infl(space)
+ if (game.vm_available_ops === 0) {
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
+ vm_next()
+ }
},
done() {
if (game.summary.length > 0) {
@@ -8365,18 +8601,18 @@ states.vm_tst_4 = { states.vm_tst_6 = {
inactive: 'make their free support check.',
prompt() {
- if (game.vm_available_ops === 0) {
+ /* if (game.vm_available_ops === 0) {
view.prompt = 'Tiananmen Square Track award support check: done.'
gen_action('done')
return
- } else {
+ } else {*/
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);
}
}
- }
+ //}
},
sc(space) {
push_undo()
@@ -8386,10 +8622,10 @@ states.vm_tst_6 = { }
game.state = 'vm_tst_6_sc'
},
- done () {
+ /*done () {
push_undo()
vm_next()
- }
+ }*/
}
states.vm_tst_6_sc = {
@@ -8403,7 +8639,8 @@ states.vm_tst_6_sc = { do_sc(game.selected_space)
game.vm_available_ops--
game.valid_spaces = []
- game.state = 'vm_tst_6'
+ vm_next()
+ //game.state = 'vm_tst_6'
return
}
}
@@ -8425,7 +8662,7 @@ states.vm_tst_8 = { gen_action('event')
}
else if (!game.vm_event_to_do && !game.vm_infl_to_do) {
- view.prompt = 'Event and operations: done. End the Action Round'
+ view.prompt = 'Event and operations: done.'
gen_action('end_round')
}
},
@@ -8445,6 +8682,7 @@ states.vm_tst_8 = { goto_vm(208)
},
end_round() {
+ push_undo()
game.tst_8 = true
end_round()
}
@@ -8477,6 +8715,7 @@ states.vm_tst_8_ops = { game.state = 'vm_support_check_prep'
},
tst() {
+ push_undo()
game.state = 'vm_tiananmen_square_attempt'
}
}
|