summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-10-28 19:05:50 +0000
committeriainp5 <iain.pearce.ip@gmail.com>2024-10-28 19:05:50 +0000
commit73efed05a32ae5a581e905e1865c9e4f3abf9c20 (patch)
tree4007d48691263ace3dd0a5d6a9c9a02e82199168 /rules.js
parent9565333f487e538a78f14ecfad6305e195682d10 (diff)
download1989-dawn-of-freedom-73efed05a32ae5a581e905e1865c9e4f3abf9c20.tar.gz
Tidying up code
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js575
1 files changed, 142 insertions, 433 deletions
diff --git a/rules.js b/rules.js
index 8541df9..55f064c 100644
--- a/rules.js
+++ b/rules.js
@@ -307,20 +307,13 @@ exports.setup = function (seed, scenario, options) {
}
log_h1("1989 Dawn of Freedom")
-
game.active = COM
start_game()
-
return game
}
function start_game() {
- //starting influence
-
// Draw cards
-
- //console.log('start game')
-
game.strategy_deck = draw_deck()
reset_power()
@@ -344,12 +337,11 @@ function start_game() {
game.valid_spaces = valid_spaces_setup()
game.available_ops = 2
- game.phase = 0
+ //game.phase = 0 /* Now redundant? */
log_h1("Place starting Support Points")
log_side()
}
-
exports.view = function(state, player) {
game = state
@@ -394,20 +386,16 @@ exports.view = function(state, player) {
hand: [],
set_aside: [],
pwr_hand: [],
-
-
}
if (game.is_pwr_struggle) {
view.power_struggle_discard = game.power_struggle_discard
view.played_power_card = game.played_power_card
- console.log('game.com_power_card', game.com_power_card, 'game.dem_power_card', game.dem_power_card)
view.power_card_1 = game.power_card_1
view.power_card_2 = game.power_card_2
}
view.strategy_discard = game.strategy_discard
-
if (player === game.active && game.vm && game.vm.draw)
view.drawn = game.vm.draw
@@ -471,11 +459,9 @@ exports.view = function(state, player) {
view.actions.undo = 0
}
}
-
return view
}
-
// === ACTIONS ===========
function gen_action(action, argument) {
@@ -493,11 +479,6 @@ function gen_action_space(space){
gen_action("space", space)
}
-
-function gen_action_infl(space){
- gen_action("infl", space)
-}
-
function gen_action_card(card){
gen_action("card", card)
}
@@ -506,14 +487,6 @@ function gen_action_power_card(card){
gen_action("power_card", card)
}
-function gen_action_sc(space){
- gen_action("sc", space)
-}
-
-function gen_action_scoring(){
- gen_action("scoring")
-}
-
exports.action = function (state, player, action, arg) {
game = state
if (states[game.state] && action in states[game.state]) {
@@ -550,14 +523,9 @@ states.com_init = {
},
space(space) {
add_infl(space)
-
},
done() {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
-
+ do_log_summary()
game.starting_infl.com_starting_infl++
if (game.starting_infl.com_starting_infl == 1){
game.available_ops = 3
@@ -575,6 +543,7 @@ states.com_init = {
}
},
start() {
+ do_log_summary()
new_turn()
clear_undo()
game.state = 'choose_card'
@@ -600,13 +569,8 @@ states.dem_init = {
space(space) {
add_infl(space)
},
-
done() {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
-
+ do_log_summary()
game.starting_infl.dem_starting_infl++
if (game.starting_infl.dem_starting_infl == 1){
game.available_ops = 3
@@ -619,7 +583,6 @@ states.dem_init = {
}
}
-
states.choose_card = {
inactive: 'choose a card.',
prompt() {
@@ -685,7 +648,6 @@ states.play_card ={
}
// Check for Reformer Rehabilitated
-
if (game.played_card === C_REFORMER_REHABILITATED && game.playable_cards.includes(C_REFORMER_REHABILITATED)){
if (game.active === DEM && (game.dem_tst_position > game.com_tst_position)) {
gen_action('event')
@@ -700,7 +662,6 @@ states.play_card ={
if ((game.active === DEM && cards[game.played_card].side === 'C' && game.dem_tst_position >= 7 && game.com_tst_position < 7 && !game.tst_7) || (game.active === COM && cards[game.played_card].side === 'D' && game.com_tst_position >= 7 && game.dem_tst_position < 7 && !game.tst_7)){
gen_action('tst_7')
}
-
if ((game.active === DEM && cards[game.played_card].side !== 'C' && game.dem_tst_position >= 8 && game.com_tst_position < 8 && !game.tst_8) || (game.active === COM && cards[game.played_card].side !== 'D' && game.com_tst_position >= 8 && game.dem_tst_position < 8 && !game.tst_8)){
gen_action('tst_8')
}
@@ -715,14 +676,11 @@ states.play_card ={
if ((game.active === DEM && game.dem_tst_attempted_this_turn === 0 && game.dem_tst_position < 8 ) || (game.active === COM && game.com_tst_attempted_this_turn === 0 && game.com_tst_position < 8)) {
gen_action('tst')
}
-
},
event() {
push_undo()
log_gap(`Played C${game.played_card} for the event`)
game.vm_infl_to_do = false
- if (scoring_cards.includes(game.played_card)) {game.phase = 0}
- else {game.phase = 1}
game.return = game.active
if (switch_events.includes(game.played_card)) {next_player()}
game.vm_event = game.played_card
@@ -731,7 +689,7 @@ states.play_card ={
opp_event() {
push_undo()
log_gap(`Played C${game.played_card} for the event`)
- game.phase = 1 /*Do I still need this?*/
+ //game.phase = 1 /*Do I still need this?*/
game.vm_infl_to_do = true
game.return = game.active
game.vm_event = game.played_card
@@ -746,22 +704,18 @@ states.play_card ={
influence() {
push_undo()
log_gap(`Played C${game.played_card} to place SPs`)
-
// Check if Common European Home played for influence
if (game.played_card === C_COMMON_EUROPEAN_HOME) {
if (game.active === DEM) {
game.vp --
log('-1 VP')
- if (check_vp()) {
- return
- }
} else {
game.vp ++
log('+1 VP')
- if (check_vp()) {
- return
- }
+ }
+ if (check_vp()) {
+ return
}
}
// Check if card is opponent card with event that needs to be resolved
@@ -818,7 +772,6 @@ states.play_card ={
end_round () {
end_round()
}
-
}
states.resolve_opponent_event = {
@@ -888,7 +841,6 @@ states.resolve_opponent_event = {
}
}
-
states.finish_add_infl = {
inactive: 'add SPs.',
prompt () {
@@ -897,10 +849,7 @@ states.finish_add_infl = {
gen_action("end_round")
return;
}
-
view.prompt = `Add SPs: ${game.available_ops} remaining.`
-
- // Generate actions for valid spaces
for (let space_id of game.valid_spaces) {
gen_action_space(space_id)
}
@@ -910,11 +859,7 @@ states.finish_add_infl = {
},
end_round() {
push_undo()
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
-
+ do_log_summary()
end_round()
}
}
@@ -997,10 +942,7 @@ states.add_influence = {
gen_action('done')
}
} else {
-
view.prompt = `Add SPs: ${game.available_ops} remaining.`
-
- // Generate actions for valid spaces
for (let space_id of game.valid_spaces) {
gen_action_space(space_id);
}
@@ -1011,17 +953,11 @@ states.add_influence = {
},
end_round() {
push_undo()
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
end_round()
},
done() {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
reset_austria_hungary_border_reopened()
game.state = 'resolve_opponent_event'
}
@@ -1101,33 +1037,8 @@ states.tst_goddess = {
},
pass() {
log('Did not discard')
- log_h2("Action Round " + game.round)
- if (game.active === DEM) {
- next_player()
- } else {
- log_side()
- }
- if (game.persistent_events.includes(5)) {
- game.state = 'general_strike'
- } else {
- game.state = 'choose_card'
- }
+ end_goddess()
},
- done() {
-
- log_h2("Action Round " + game.round)
- if (game.active === DEM) {
- next_player()
- } else {
- log_side()
- }
- game.phase = 0
- if (game.persistent_events.includes(5)) {
- game.state = 'general_strike'
- } else {
- game.state = 'choose_card'
- }
- }
}
states.tst_goddess_draw = {
@@ -1142,23 +1053,10 @@ states.tst_goddess_draw = {
} else {
draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.democrat_hand.length, game.communist_hand.length +1)
}
- log_h2("Action Round " + game.round)
- if (game.active === DEM) {
- next_player()
- } else {
- log_side()
- }
- game.phase = 0
- if (game.persistent_events.includes(5)) {
- game.state = 'general_strike'
- } else {
- game.state = 'choose_card'
- }
+ end_goddess()
}
}
-
-
states.support_check_prep = {
inactive: 'do support checks',
prompt () {
@@ -1175,7 +1073,6 @@ states.support_check_prep = {
}
} 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) {
gen_action_space(space_id)
}
@@ -1192,7 +1089,6 @@ states.support_check_prep = {
game.state = 'austria_hungary_border_reopened_check'
return
}
-
}
}
game.state = 'do_support_check'
@@ -1285,15 +1181,15 @@ states.draw_power_cards = {
game.com_pwr_hand_limit = 0
}
// Events which affect cards drawn
- if (game.persistent_events.includes(17) && game.com_pwr_hand_limit >= 2) {
- log('Democrat receives 2 cards from Communist due to C17')
+ if (game.persistent_events.includes(C_ROUNDTABLE_TALKS) && game.com_pwr_hand_limit >= 2) {
+ log(`Democrat receives 2 cards from Communist due to C${C_ROUNDTABLE_TALKS}`)
game.dem_pwr_hand_limit += 2
game.com_pwr_hand_limit -= 2
- discard_from_table(17)
- game.persistent_events = game.persistent_events.filter(n => n !== 17)
+ discard_from_table(C_ROUNDTABLE_TALKS)
+ game.persistent_events = game.persistent_events.filter(n => n !== C_ROUNDTABLE_TALKS)
}
- if (game.persistent_events.includes(72)) {
+ if (game.persistent_events.includes(C_PEASANT_PARTIES_REVOLT)) {
let farmer_check
for (let space of spaces) {
if (space && space.country === game.pwr_struggle_in && space.socio === 3 && check_dem_control(space.space_id)) {
@@ -1301,20 +1197,20 @@ states.draw_power_cards = {
}
}
if (farmer_check && game.com_pwr_hand_limit > 0) {
- log('Democrat receives 1 cards from Communist due to C72')
+ log(`Democrat receives 1 cards from Communist due to C${C_PEASANT_PARTIES_REVOLT}`)
game.dem_pwr_hand_limit += 1
game.com_pwr_hand_limit -= 1
- permanently_remove(72)
- game.persistent_events = game.persistent_events.filter(n => n !== 72)
+ permanently_remove(C_PEASANT_PARTIES_REVOLT)
+ game.persistent_events = game.persistent_events.filter(n => n !== C_PEASANT_PARTIES_REVOLT)
}
}
- if (game.persistent_events.includes(102) && game.dem_pwr_hand_limit >=2 && (game.pwr_struggle_in === 'Romania' || game.pwr_struggle_in === 'Bulgaria')) {
- log('Communist receives 2 cards from Democrat due to C102')
+ if (game.persistent_events.includes(C_NATIONAL_SALVATION_FRONT) && game.dem_pwr_hand_limit >=2 && (game.pwr_struggle_in === 'Romania' || game.pwr_struggle_in === 'Bulgaria')) {
+ log(`Communist receives 2 cards from Democrat due to C${C_NATIONAL_SALVATION_FRONT}`)
game.dem_pwr_hand_limit -= 2
game.com_pwr_hand_limit += 2
- permanently_remove(102)
- game.persistent_events = game.persistent_events.filter(n => n !== 102)
+ permanently_remove(C_NATIONAL_SALVATION_FRONT)
+ game.persistent_events = game.persistent_events.filter(n => n !== C_NATIONAL_SALVATION_FRONT)
}
//Draw Power Cards
@@ -1330,13 +1226,13 @@ states.draw_power_cards = {
log(`Democrat: ${game.dem_pwr_hand.length} cards`)
//Check if The Crowd Turns Against Ceausescu occurs
- if (game.table_cards.includes(54) && game.pwr_struggle_in === 'Romania') {
+ if (game.table_cards.includes(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU) && game.pwr_struggle_in === 'Romania') {
if (game.active === COM) {
game.return = COM
next_player()
}
- log_h3('C54')
- game.persistent_events.push(54)
+ log_h3(`C${C_THE_CROWD_TURNS_AGAINST_CEAUSESCU}`)
+ game.persistent_events.push(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU)
game.state = 'the_crowd_turns_against_ceausescu_prep'
} else {
log_h2('Raise the Stakes')
@@ -1347,7 +1243,7 @@ states.draw_power_cards = {
states.the_crowd_turns_against_ceausescu_prep = {
get inactive() {
- return `resolve ${clean_name(cards[54].name)}.`
+ return `resolve ${clean_name(cards[C_THE_CROWD_TURNS_AGAINST_CEAUSESCU].name)}.`
},
prompt() {
view.prompt = 'The Crowd Turns Against Ceausescu: draw cards.'
@@ -1356,7 +1252,7 @@ states.the_crowd_turns_against_ceausescu_prep = {
draw() {
game.ceausescu_cards = []
draw_cards(game.power_struggle_deck, game.ceausescu_cards, game.com_pwr_hand, 15, game.com_pwr_hand.length)
- game.temp = game.ceausescu_cards.filter(card => card && card >=25 && card <= 30).length
+ game.temp = game.ceausescu_cards.filter(card => rallies.includes(card)).length
log(`Drew ${pluralize(game.temp, 'Rally in the Square')}.`)
game.vm_available_ops = game.temp * 3
log(`Democrat takes a ${game.vm_available_ops} Action Round`)
@@ -1366,7 +1262,7 @@ states.the_crowd_turns_against_ceausescu_prep = {
states.vm_the_crowd_turns_against_ceausescu = {
get inactive() {
- return `resolve ${clean_name(cards[54].name)}.`
+ return `resolve ${clean_name(cards[C_THE_CROWD_TURNS_AGAINST_CEAUSESCU].name)}.`
},
prompt() {
view.prompt = `You have ${game.vm_available_ops} operations points. Play for:`
@@ -1408,11 +1304,7 @@ states.the_crowd_turns_against_ceausescu_infl = {
vm_do_add_infl(space)
},
done() {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
-
+ do_log_summary()
if (game.return !== game.active) {
next_player()
}
@@ -1423,7 +1315,6 @@ states.the_crowd_turns_against_ceausescu_infl = {
states.raise_stakes_1 = {
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.'
@@ -1483,7 +1374,6 @@ states.raise_stakes_1 = {
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.'
@@ -1517,7 +1407,6 @@ states.raise_stakes_2 = {
game.raised_stakes++
game.valid_cards = []
}
-
},
pass() {
log('Did not raise the stakes')
@@ -1544,24 +1433,16 @@ states.power_struggle = {
}
}
if (game.phase === 1) {
+ let base_prompt = `${power_cards[game.played_power_card].name} played` + (leader_cards.includes(game.played_power_card) ? ` as a ${game.proxy_power_card}.` : ".")
if (game.valid_cards.length > 0) {
- if (leader_cards.includes(game.played_power_card)) {
- view.prompt = `${power_cards[game.played_power_card].name} played as a ${game.proxy_power_card}. You must match or concede.`
- } else {
- view.prompt = `${power_cards[game.played_power_card].name} played. You must match or concede.`
- }
- gen_action('concede')
+ view.prompt = `${base_prompt} You must match or concede.`;
for (let card of game.valid_cards) {
- gen_action_power_card(card)
- }
- } else if (game.valid_cards.length === 0) {
- if (leader_cards.includes(game.played_power_card)) {
- view.prompt = `${power_cards[game.played_power_card].name} played as a ${game.proxy_power_card}. You must concede.`
- } else {
- view.prompt = `${power_cards[game.played_power_card].name} played. You must concede.`
+ gen_action_power_card(card);
}
- gen_action('concede')
- }
+ } else {
+ view.prompt = `${base_prompt} You must concede.`;
+ }
+ gen_action('concede')
}
else if (game.phase === 2) {
view.prompt = 'You matched. Roll a die.'
@@ -1588,9 +1469,8 @@ states.power_struggle = {
game.valid_cards=[]
game.return_state = 'power_struggle'
if (game.phase === 0) {delete game.proxy_power_card}
- if (card === 52) {
- log_gap(`Played P52: P${game.played_power_card} no longer playable`)
-
+ if (card === PC_TACTIC_FAILS) {
+ log_gap(`Played P${PC_TACTIC_FAILS}: P${game.played_power_card} no longer playable`)
} else {
if (game.phase === 0 && leader_cards.includes(card)) {} /* Log nothing. Probably a better way to do this */
else if (numberless_cards.includes(card)) {
@@ -1623,7 +1503,7 @@ states.power_struggle = {
do_valid_cards()
}
} else if (game.phase === 1) {
- if (card === 52) {
+ if (card === PC_TACTIC_FAILS) {
game.tactics_fails = power_cards[game.played_power_card].name
game.phase = 0
next_player()
@@ -1694,8 +1574,8 @@ states.power_struggle = {
next_player()
do_valid_cards()
},
- done () {
- if (game.phase === 7) { /*Is this ever called anymore? */
+ /*done () {
+ if (game.phase === 7) {
game.phase = 0
log_msg_gap('Takes initiative')
do_valid_cards()
@@ -1704,81 +1584,32 @@ states.power_struggle = {
next_player()
do_valid_cards()
}
- }
+ }*/
}
states.support_loss ={
inactive: 'do Support Loss.',
prompt () {
- if (!game.persistent_events.includes(111)) {
- if (game.phase === 0) {
- view.prompt = 'You lost the Power Struggle. Roll a die for Support Loss.'
- gen_action('roll')
- } else if (game.phase === 1 && game.available_ops > 0 && game.valid_spaces.length > 0) {
- 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_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.`
- gen_action('done')
- } else if (game.phase === 1 && game.valid_spaces.length === 0) {
- view.prompt = `Power Struggle - ${country_name(game.pwr_struggle_in)}. Support Loss: no remaining SPs to remove.`
- gen_action('done')
- }
- } else {
- if (game.phase === 0) {
- view.prompt = 'You lost the Power Struggle. Roll a die for Support Loss.'
- gen_action('roll')
- } else if (game.phase === 1 && game.available_ops > 0 && game.valid_spaces.length > 0) {
- view.prompt = `New Year's Eve Party - ${country_name(game.pwr_struggle_in)}. Support Loss: remove ${pluralize(game.available_ops,'SP')}.`
+ let ps_state = game.persistent_events.includes(111) ? "New Year's Eve Party" : "Power Struggle"
+ if (game.phase === 0) {
+ view.prompt = 'You lost the Power Struggle. Roll a die for Support Loss.'
+ gen_action('roll')
+ } else if (game.phase === 1 && game.available_ops > 0 && game.valid_spaces.length > 0) {
+ view.prompt = `${ps_state} - ${country_name(game.pwr_struggle_in)}. Support Loss: remove ${pluralize(game.available_ops,'SP')}.`
- for (let space_id of game.valid_spaces) {
- 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.`
- gen_action('done')
- } else if (game.phase === 1 && game.valid_spaces.length === 0) {
- view.prompt = `New Year's Eve Party - ${country_name(game.pwr_struggle_in)}. Support Loss: no remaining SPs to remove.`
- gen_action('done')
+ for (let space_id of game.valid_spaces) {
+ gen_action_space(space_id)
}
+ } else if (game.phase === 1 && game.available_ops === 0 ) {
+ view.prompt = `${ps_state} - ${country_name(game.pwr_struggle_in)}. Support Loss: finished.`
+ gen_action('done')
+ } else if (game.phase === 1 && game.valid_spaces.length === 0) {
+ view.prompt = `${ps_state} - ${country_name(game.pwr_struggle_in)}. Support Loss: no remaining SPs to remove.`
+ gen_action('done')
}
},
roll () {
- clear_undo()
- let roll = roll_d6()
- let rally_win = 0
- let petition_win = 0
- log(`Roll: D${roll}`)
- if (rallies.includes(game.played_power_card) || game.proxy_power_card === 'Rally in the Square') { rally_win = 2}
- if (petitions.includes(game.played_power_card) || game.proxy_power_card === 'Petition') { petition_win = 2}
- let modified_roll = roll + game.raised_stakes + rally_win - petition_win
-
- // Roll modifiers
- if (game.active === COM && game.persistent_events.includes(C_YAKOVLEV_COUNSELS_GORBACHEV)) {
- log(`+1 from C${C_YAKOVLEV_COUNSELS_GORBACHEV}`)
- modified_roll ++
- }
-
- if (modified_roll < 0) {modified_roll = 0}
- else if (modified_roll > 7) {modified_roll = 7}
-
-
- if (game.raised_stakes !== 0) {
- log(`+${game.raised_stakes} from Raising the Stakes`)
- }
- if (rally_win !== 0) {
- log('+2 from winning on a P1')
- }
- if (petition_win !== 0) {
- log('-2 from winning on a P31')
- }
- if (modified_roll !== roll) {
- log(`Modified roll: ${modified_roll}`)
- }
- game.available_ops = support_loss_roll[modified_roll]
+ game.available_ops = support_loss_roll[get_aftermath_roll()]
if (game.available_ops === 0) {
log('Does not remove SPs')
}
@@ -1795,10 +1626,7 @@ states.support_loss ={
}
},
done () {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
next_player()
log_h3('Victory Point')
game.phase = 0
@@ -1809,58 +1637,20 @@ states.support_loss ={
states.vp_roll = {
inactive: 'do VP Roll.',
prompt () {
- if (!game.persistent_events.includes(111)) {
- if (game.phase === 0) {
- view.prompt = `Power Struggle - ${country_name(game.pwr_struggle_in)}: roll a die for Victory.`
- gen_action('roll')
- } else if (game.phase === 1) {
- view.prompt = `Power Struggle - ${country_name(game.pwr_struggle_in)}: take power.`
- gen_action('take')
- } else if (game.phase === 2) {
- view.prompt = `Power Struggle - ${country_name(game.pwr_struggle_in)}: proceed to scoring.`
- gen_action('scoring')
- }
- } else {
- if (game.phase === 0) {
- view.prompt = `New Year's Eve Party - ${country_name(game.pwr_struggle_in)}: roll a die for Victory.`
- gen_action('roll')
- } else if (game.phase === 1) {
- view.prompt = `New Year's Eve Party - ${country_name(game.pwr_struggle_in)}: take power.`
- gen_action('take')
- } else if (game.phase === 2) {
- view.prompt = `New Year's Eve Party - ${country_name(game.pwr_struggle_in)}: proceed to scoring.`
- gen_action('scoring')
- }
+ let ps_state = game.persistent_events.includes(111) ? "New Year's Eve Party" : "Power Struggle"
+ if (game.phase === 0) {
+ view.prompt = `${ps_state} - ${country_name(game.pwr_struggle_in)}: roll a die for Victory.`
+ gen_action('roll')
+ } else if (game.phase === 1) {
+ view.prompt = `${ps_state} - ${country_name(game.pwr_struggle_in)}: take power.`
+ gen_action('take')
+ } else if (game.phase === 2) {
+ view.prompt = `${ps_state} - ${country_name(game.pwr_struggle_in)}: proceed to scoring.`
+ gen_action('scoring')
}
},
roll () {
- let roll = roll_d6()
- log(`Roll: D${roll}`)
- let rally_win = 0
- let petition_win = 0
- if (rallies.includes(game.played_power_card) || game.proxy_power_card === 'Rally in the Square') { rally_win = 2}
- if (petitions.includes(game.played_power_card) || game.proxy_power_card === 'Petition') { petition_win = 2}
- let modified_roll = roll + game.raised_stakes + rally_win - petition_win
- if (game.active === DEM && game.persistent_events.includes(C_YAKOVLEV_COUNSELS_GORBACHEV)) {
- log(`+1 from C${C_YAKOVLEV_COUNSELS_GORBACHEV}`)
- modified_roll ++
- }
- if (modified_roll < 0) {modified_roll = 0}
- else if (modified_roll > 7) {modified_roll = 7}
-
- if (game.raised_stakes !== 0) {
- log(`+${game.raised_stakes} from Raising the Stakes`)
- }
- if (rally_win !== 0) {
- log('+2 from winning on a P1')
- }
- if (petition_win !== 0) {
- log('-2 from winning on a P31')
- }
- if (modified_roll !== roll) {
- log(`Modified roll: ${modified_roll}`)
- }
- let vp_change = vp_roll[modified_roll]
+ let vp_change = vp_roll[get_aftermath_roll()]
if (game.active === DEM) {
log(`+${vp_change} VP`)
} else {
@@ -1879,7 +1669,6 @@ states.vp_roll = {
},
take () {
push_undo()
- //Find name of scoring card
let scoring_card = scoring_cards[countries.indexOf(game.pwr_struggle_in)]
permanently_remove(scoring_card)
take_power(game.pwr_struggle_in)
@@ -1959,7 +1748,7 @@ states.the_tyrant_is_gone ={
game.return = DEM
}
log_h3(`C97`)
- game.vm_event = 97
+ game.vm_event = C_THE_TYRANT_IS_GONE
goto_vm(game.vm_event)
}
}
@@ -3247,6 +3036,37 @@ function get_end_infl_prompt() {
}
}
+function get_aftermath_roll() {
+ clear_undo()
+ let roll = roll_d6()
+ log(`Roll: D${roll}`)
+ let rally_win = 0
+ let petition_win = 0
+ if (rallies.includes(game.played_power_card) || game.proxy_power_card === 'Rally in the Square') { rally_win = 2}
+ if (petitions.includes(game.played_power_card) || game.proxy_power_card === 'Petition') { petition_win = 2}
+ let modified_roll = roll + game.raised_stakes + rally_win - petition_win
+ if (game.active === DEM && game.persistent_events.includes(C_YAKOVLEV_COUNSELS_GORBACHEV)) {
+ log(`+1 from C${C_YAKOVLEV_COUNSELS_GORBACHEV}`)
+ modified_roll ++
+ }
+ if (modified_roll < 0) {modified_roll = 0}
+ else if (modified_roll > 7) {modified_roll = 7}
+
+ if (game.raised_stakes !== 0) {
+ log(`+${game.raised_stakes} from Raising the Stakes`)
+ }
+ if (rally_win !== 0) {
+ log('+2 from winning on a P1')
+ }
+ if (petition_win !== 0) {
+ log('-2 from winning on a P31')
+ }
+ if (modified_roll !== roll) {
+ log(`Modified roll: ${modified_roll}`)
+ }
+ return modified_roll
+}
+
function permanently_remove(card) {
if (game.strategy_removed.includes(card)) {return}
remove_from_discard(card)
@@ -3313,6 +3133,20 @@ function end_stasi_choose_card() {
}
}
+function end_goddess() {
+ log_h2("Action Round " + game.round)
+ if (game.active === DEM) {
+ next_player()
+ } else {
+ log_side()
+ }
+ if (game.persistent_events.includes(5)) {
+ game.state = 'general_strike'
+ } else {
+ game.state = 'choose_card'
+ }
+}
+
function check_reformer() {
if (game.dem_tst_position !== game.com_tst_position) {
if (!game.playable_cards.includes(67)) {
@@ -3773,64 +3607,6 @@ function new_turn() {
delete game.stasi_card
delete game.stand_fast
-/* TODO: Add log for events no longer in effect */
-
- /*game.persistent_events = game.persistent_events.filter(n => n !== C_PERESTROIKA)
- game.persistent_events = game.persistent_events.filter(n => n !== C_THE_SINATRA_DOCTRINE)
- game.persistent_events = game.persistent_events.filter(n => n !== C_STASI)
- game.persistent_events = game.persistent_events.filter(n => n !== C_HONECKER)
- delete game.prudence
- delete game.stasi_card
-
- //Austria Hungary Border Reopened
- if (game.persistent_events.includes(58)) {
- game.persistent_events = game.persistent_events.filter(n => n !== 58)
- delete game.austria_hungary_border_reopened_tracker
- log(`C58 no longer in effect`)
- }
- //Elena
- if (game.persistent_events.includes(101)) {
- game.persistent_events = game.persistent_events.filter(n => n !== 101)
- log(`C101 no longer in effect`)
- }
- //GrenzTruppen
- if (game.persistent_events.includes(59)) {
- game.persistent_events = game.persistent_events.filter(n => n !== 59)
- log(`C59 no longer in effect`)
- }
- //Foreign Currency Debt Burden
- if (game.persistent_events.includes(49)) {
- game.persistent_events = game.persistent_events.filter(n => n !== 49)
- delete game.foreign_currency_debt_burden
- log(`C49 no longer in effect`)
- }
- //FRG Embassies
- if (game.persistent_events.includes(74)) {
- game.persistent_events = game.persistent_events.filter(n => n !== 74)
- log(`C74 no longer in effect`)
- discard_from_table(74)
- permanently_remove(74)
- }
- //Genscher
- if (game.persistent_events.includes(63)) {
- game.persistent_events = game.persistent_events.filter(n => n !== 63)
- log(`C63 no longer in effect`)
- discard_from_table(63)
- permanently_remove(63)
- }
- //Stasi
- if (game.persistent_events.includes(C_STASI)) {
- game.persistent_events = game.persistent_events.filter(n => n !== C_STASI)
- discard_from_table(C_STASI)
- log(`C${C_STASI} no longer in effect`)
- }
- //Stand Fast
- if (game.persistent_events.includes(100)) {
- game.persistent_events = game.persistent_events.filter(n => n !== 100)
- delete game.stand_fast
- log(`C100 no longer in effect`)
- }*/
-
if (game.samizdat_card > 0 ) {
game.democrat_hand.push(game.samizdat_card)
delete game.samizdat_card
@@ -4084,7 +3860,7 @@ function reset_power() {
game.power_struggle_discard = []
game.dem_pwr_hand = []
game.com_pwr_hand = []
- game.phase = 1
+ //game.phase = 1
game.raised_stakes_round = 0
game.raised_stakes = 0
game.played_power_card = 0
@@ -4266,24 +4042,11 @@ function pop_summary_i() {
game.summary = []
}
-function log_summary_place(p) {
- let from = piece_space(p)
- if (from !== AVAILABLE)
- log_summary("% " + piece_name(p) + " from S" + from)
- else
- log_summary("% " + piece_name(p))
-}
-
-function log_summary_move_to_from(p, to) {
- log_summary("% " + piece_name(p) + " to S" + to + " from S" + piece_space(p))
-}
-
-function log_summary_remove(p) {
- log_summary("Removed % " + piece_name(p))
-}
-
-function log_summary_activated(p) {
- log_summary("Activated % " + piece_faction_name(p))
+function do_log_summary() {
+ if (game.summary.length > 0) {
+ pop_summary()
+ log_br()
+ }
}
// ============ UNDO FUNCTIONS ==================
@@ -5627,6 +5390,7 @@ function vm_poszgay() {
function vm_power_struggle() {
game.is_pwr_struggle = true
+ game.phase = 0
game.pwr_struggle_in = countries[scoring_cards.indexOf(game.vm_event)]
log_h2(`C${game.vm_event}`)
@@ -6053,32 +5817,20 @@ states.vm_add_infl = {
vm_do_add_infl(space)
if (game.vm_available_ops === 0) {
game.valid_spaces = []
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
-
+ do_log_summary()
game.vm_event_done = true
vm_next()
}
},
done () {
push_undo()
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
-
+ do_log_summary()
game.vm_event_done = true
vm_next()
},
end_round() {
push_undo()
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
-
+ do_log_summary()
game.vm_event_done = true
vm_next()
}
@@ -6106,11 +5858,7 @@ states.vm_add_infl_free = {
vm_do_add_infl_free(space)
if (game.vm_available_ops === 0) {
game.valid_spaces = []
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
-
+ do_log_summary()
game.vm_event_done = true
vm_next()
}
@@ -6119,20 +5867,14 @@ states.vm_add_infl_free = {
push_undo()
game.valid_spaces = []
game.vm_event_done = true
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
},
end_round () {
push_undo()
game.valid_spaces = []
game.vm_event_done = true
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
}
@@ -6190,10 +5932,7 @@ states.vm_add_limited_infl = {
vm_do_add_limited_infl(space, game.vm_max_infl)
if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) {
game.valid_spaces = []
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
game.vm_event_done = true
vm_next()
}
@@ -6230,19 +5969,13 @@ states.vm_remove_infl = {
game.vm_active_country = spaces[space].country
if (game.vm_event !== C_INFLATIONARY_CURRENCY) {
if (game.vm_available_ops === 0 ) {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
}
},
done() {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
}
@@ -6296,19 +6029,13 @@ states.vm_remove_limited_infl = {
vm_do_remove_limited_infl(space, game.vm_max_infl)
if (game.vm_available_ops === 0) {
game.vm_event_done = true
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
},
done () {
game.vm_event_done = true
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
}
@@ -7624,10 +7351,7 @@ states.vm_nomenklatura_add = {
vm_do_add_infl_free(space)
if (game.vm_available_ops === 0 ) {
game.valid_spaces = []
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
},
@@ -8071,10 +7795,7 @@ states.vm_we_are_the_people_remove = {
vm_do_remove_infl(space)
},
done() {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
if (!game.vm_influence_added[S_LUTHERAN_CHURCH]) {
log('No SPs removed')
vm_next()
@@ -8099,10 +7820,7 @@ states.vm_we_are_the_people_add = {
game.vm_influence_added[S_LUTHERAN_CHURCH]--
if (game.vm_influence_added[S_LUTHERAN_CHURCH] === 0 ) {
game.valid_spaces = []
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
},
@@ -8227,18 +7945,12 @@ states.vm_tst_4 = {
space(space) {
vm_do_remove_infl(space)
if (game.vm_available_ops === 0) {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
},
done() {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
}
@@ -8382,10 +8094,7 @@ states.vm_scare_tactics = {
vm_do_remove_infl(space)
},
done() {
- if (game.summary.length > 0) {
- pop_summary()
- log_br()
- }
+ do_log_summary()
vm_next()
}
}