diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 214 |
1 files changed, 159 insertions, 55 deletions
@@ -21,7 +21,7 @@ const countries = ['Poland', 'Hungary', 'East_Germany', 'Bulgaria', 'Czechoslova const elite_spaces = [12, 15, 27, 43, 51, 69]
const all_power_cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 ]
const numberless_cards = [25, 26, 27, 28, 29, 30, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52]
-const auto_resolve_events = [5, 8, 9, 13, 17, 25, 26, 30, 35, 50, 53, 58, 59, 62, 63, 65, 70, 72, 74, 99, 102, 108]
+const auto_resolve_events = [5, 8, 9, 13, 17, 25, 26, 30, 35, 50, 53, 54, 58, 59, 62, 63, 65, 70, 72, 74, 99, 102, 108]
const switch_events = [6, 20, 71]
exports.scenarios = [ "Standard" ]
@@ -467,7 +467,9 @@ states.choose_card = { if (game.active === DEM && game.persistent_events['ligachev'] && card !== 14) {
log('-3 VP from C99')
game.vp -= 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
game.persistent_events['ligachev'] = false
}
game.state = 'play_card'
@@ -507,9 +509,14 @@ states.play_card ={ gen_action('tst_8')
}
- // Special check for Reformer Rehabilitated
- if ((game.active === DEM && game.playable_cards[game.played_card] === 2 && (game.dem_tst_position > game.com_tst_position)) || (game.active === COM && game.playable_cards[game.played_card].playable === 2 && (game.dem_tst_position < game.com_tst_position))) {
- gen_action('event')
+ // Check for Reformer Rehabilitated
+ if (game.played_card === 67){
+ if (game.active === DEM && game.playable_cards[67].playable === DEM) {
+ gen_action('event')
+ }
+ if (game.active === COM && game.playable_cards[67].playable === COM) {
+ gen_action('event')
+ }
}
//Continue with normal logic
@@ -557,11 +564,15 @@ states.play_card ={ if (game.active === DEM) {
game.vp --
log('-1 VP')
- check_vp()
+ if (check_vp()) {
+ return
+ }
} else {
game.vp ++
log('+1 VP')
- check_vp()
+ if (check_vp()) {
+ return
+ }
}
}
// Check if card is opponent card with event that needs to be resolved
@@ -998,7 +1009,6 @@ states.draw_power_cards = { game.com_pwr_hand_limit = 0
}
// Events which affect cards drawn
- console.log('test')
if (game.persistent_events['roundtable_talks'] && game.com_pwr_hand_limit >= 2) {
log('Democrat receives 2 cards from Communist due to C17')
game.dem_pwr_hand_limit += 2
@@ -1007,6 +1017,14 @@ states.draw_power_cards = { game.persistent_events['roundtable_talks'] = false
}
+ if (game.persistent_events['peasant_parties_revolt'] && game.com_pwr_hand_limit >=1) {
+ log('Democrat receives 1 cards from Communist due to C72')
+ game.dem_pwr_hand_limit += 1
+ game.com_pwr_hand_limit -= 1
+ discard_from_table(72)
+ game.persistent_events['peasant_parties_revolt'] = false
+ }
+
if (game.persistent_events['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 C102')
game.dem_pwr_hand_limit -= 2
@@ -1055,7 +1073,7 @@ states.the_crowd_turns_against_ceausescu_prep = { console.log('game.ceausescu_cards', game.ceausescu_cards)
game.temp = game.ceausescu_cards.filter(card => card && card >=25 && card <= 30).length
log(`Drew ${pluralize(game.temp, 'Rally in the Square')}.`)
- game.temp = game.temp * 3
+ game.vm_available_ops = game.temp * 3
game.state = 'the_crowd_turns_against_ceausescu'
}
}
@@ -1065,7 +1083,7 @@ states.the_crowd_turns_against_ceausescu = { return `resolve ${cards[54].name}.`
},
prompt() {
- view.prompt = `You have ${game.temp} operations points. Play for:`
+ view.prompt = `You have ${game.vm_available_ops} operations points. Play for:`
gen_action('influence')
gen_action('support_check')
},
@@ -1087,21 +1105,20 @@ states.the_crowd_turns_against_ceausescu = { states.the_crowd_turns_against_ceausescu_infl = {
inactive: 'add influence.',
prompt () {
- if (game.temp === 0)
+ if (game.vm_available_ops === 0)
{
view.prompt = 'Place influence: done.';
gen_action("done");
return;
}
- view.prompt = `Add influence: ${game.temp} remaining`
+ view.prompt = `Add influence: ${game.vm_available_ops} remaining`
for (let space of game.valid_spaces) {
gen_action_infl(spaces[space].name_unique)
}
},
infl(space) {
- add_infl(space)
- game.temp --
+ vm_do_add_infl(space)
},
done() {
if (game.return !== game.active) {
@@ -1421,7 +1438,7 @@ states.support_loss ={ view.prompt = 'Support Loss: finished.'
gen_action('done')
} else if (game.phase === 1 && game.valid_spaces.length === 0) {
- view.prompt = 'No remaining influence to remove.'
+ view.prompt = 'Support Loss: no remaining influence to remove.'
gen_action('done')
}
},
@@ -1457,6 +1474,9 @@ states.support_loss ={ log(`Modified roll: ${modified_roll}`)
}
game.available_ops = support_loss_roll[modified_roll]
+ if (game.available_ops === 0) {
+ log('Does not remove influence')
+ }
game.phase++
valid_spaces_support_loss()
},
@@ -1632,7 +1652,9 @@ states.finish_scoring ={ game.state = 'new_years_eve_party'
return
}
- check_vp()
+ if (check_vp()) {
+ return
+ }
reset_power()
end_round()
}
@@ -2130,7 +2152,9 @@ function do_sc(space) { if (game.active === COM && game.persistent_events['helsinki_final_act'] && (spaces[clicked_space].socio === 5 || spaces[clicked_space].socio === 6) ) {
log('+1 VP from C26')
game.vp ++
- check_vp()
+ if (check_vp()) {
+ return
+ }
}
// Continue with Support Check Logic
@@ -2292,7 +2316,9 @@ function do_sc(space) { if (game.active === COM && game.persistent_events['eco_glasnost'] && spaces[clicked_space].space_id === 66) {
log_msg_gap('+1 VP from Eco Glasnost')
game.vp++
- check_vp()
+ if (check_vp()) {
+ return
+ }
}
// If Austria-Hungary Border Reopened used, all future support checks must be in East Germany
@@ -2618,8 +2644,14 @@ function do_tst_attempt() { }
}
// Check whether The Reformer is playable:
- if ((game.dem_tst_position !== game.com_tst_position)) {
- game.playable_cards[67].playable = 2
+ if (game.dem_tst_position > game.com_tst_position) {
+ game.playable_cards[67].playable = DEM
+ }
+ if (game.dem_tst_position < game.com_tst_position) {
+ game.playable_cards[67].playable = COM
+ }
+ if (game.dem_tst_position === game.com_tst_position) {
+ game.playable_cards[67].playable = ''
}
}
@@ -2871,9 +2903,12 @@ function permanently_remove(card) { function check_vp() {
if (game.vp >= 20) {
goto_game_over(DEM, `${DEM} won an Automatic Victory!`)
+ return true
} else if(game.vp <= -20) {
goto_game_over(COM, `${COM} won an Automatic Victory!`)
+ return true
}
+ return false
}
function game_over() {
@@ -2889,7 +2924,7 @@ function goto_game_over(result, victory) { game.victory = victory
log_h1("Game Over")
log(game.victory)
- //return true
+ return
}
@@ -3645,9 +3680,10 @@ function vm_endif() { function vm_goto_step(step) {
console.log('vm_goto_step called, target:', step)
- console.log('game.vp.ip', game.vp.ip)
- for (let i = game.vp.ip; i < CODE[game.vm.fp].length; i++) {
- console.log('game.vp.ip', game.vp.ip)
+ console.log('game.vm.ip', game.vp.ip)
+ for (let i = game.vm.ip; i < CODE[game.vm.fp].length; i++) {
+ console.log('i', i)
+ console.log('step', CODE[game.vm.fp][i][0])
if (CODE[game.vm.fp][i][0] === step) {
game.vm.ip = i;
vm_exec();
@@ -4005,6 +4041,7 @@ function vm_active_country () { function vm_take_control_prep() {
game.vm_available_ops = vm_operand(1)
game.state = 'vm_take_control'
+ console.log('in vm_take_control_prep game.state', game.state)
}
function vm_take_control(space) {
@@ -4419,7 +4456,9 @@ function vm_40th_anniversary_celebration() { function vm_40th_anniversary_celebration_vp() {
game.vp --
log('-1VP')
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
}
@@ -4453,7 +4492,9 @@ function vm_breakaway_baltic_republics() { log('+5 VP')
game.vp += 5
game.stability++
- check_vp()
+ if (check_vp()) {
+ return
+ }
game.playable_cards[109].playable = 1
game.playable_cards[14].playable = 0
if (game.pieces[56].demCtrl === 0 && game.persistent_events['systematization'] !== 56) {game.valid_spaces.push(56)}
@@ -4474,7 +4515,9 @@ function vm_bulgarian_turks_expelled(){ game.remove_opponent_infl = true
game.vp -= 2
log('-2VP')
- check_vp()
+ if (check_vp()) {
+ return
+ }
if (game.pieces[70].demInfl > 0) {game.valid_spaces = [70]}
vm_next()
}
@@ -4503,7 +4546,9 @@ function vm_central_committee_reshuffle() { function vm_civic_forum() {
log('+1 VP')
game.vp++
- check_vp()
+ if (check_vp()) {
+ return
+ }
game.persistent_events['civic_forum'] = true
if (game.pieces[31].demCtrl === 1) {
vm_next()
@@ -4609,12 +4654,15 @@ function vm_eliminate(space_id) { // Clear the adjacency list of the clicked space
game.pieces[space_id].adjacent = [];
- // Eliminate the democrat influence and move the communist influence to Bucharesti
+ // Eliminate the democrat influence and move the communist influence to Bucuresti
game.pieces[space_id].demInfl = 0
game.pieces[61].comInfl += game.pieces[space_id].comInfl
- log(`${game.pieces[space_id].comInfl} Communist influence relocated to Bucharesti`)
+ log(`${game.pieces[space_id].comInfl} Communist influence relocated to Bucuresti`)
game.pieces[space_id].comInfl = 0
+
+ //Update control in the eliminated space and in Bucuresti
check_control_change(space_id)
+ check_control_change(61)
}
@@ -4625,7 +4673,9 @@ function vm_exit_visas() { function vm_foreign_currency_debt_burden() {
log('+1VP')
game.vp++
- check_vp()
+ if (check_vp()) {
+ return
+ }
game.table_cards.push(49)
game.state = 'vm_foreign_currency_debt_burden'
}
@@ -4705,7 +4755,9 @@ function vm_heal_our_bleeding_wounds() { else change_vp = 3
log(`${change_vp} VP`)
game.vp += change_vp
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
}
@@ -4764,7 +4816,9 @@ function vm_klaus_and_komarek() { function vm_kohl_proposes_reunification() {
log('+2 VP')
game.vp += 2
- check_vp()
+ if (check_vp()) {
+ return
+ }
if (game.persistent_events['the_wall_must_go']) {
game.vm_event = 87
game.state = 'vm_common_european_home'
@@ -4778,7 +4832,9 @@ function vm_kohl_proposes_reunification() { function vm_kremlin_coup() {
log('-3 VP')
game.vp -= 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
elite_spaces.forEach(space => {
if (!game.revolutions[spaces[space].country]) {
@@ -4954,12 +5010,24 @@ function vm_roundtable_talks() { vm_next()
}
+function vm_sajudis_check() {
+ if (spaces[56].demCtrl !== 1) {
+ game.valid_spaces.push(56)
+ }
+ if (spaces[70].demCtrl !== 1) {
+ game.valid_spaces.push(70)
+ }
+ vm_next()
+}
+
function vm_sajudis() {
game.playable_cards[81].playable = 1
game.stability++
log('+1 VP')
game.vp++
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
}
@@ -5034,7 +5102,10 @@ function vm_the_baltic_way() { if (game.pieces[70].demCtrl === 0 && game.persistent_events['systematization'] !== 70) {game.valid_spaces.push(70)}
log('+3 VP')
game.vp += 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
+ console.log('game.state', game.state)
vm_next()
}
@@ -5821,7 +5892,9 @@ states.vm_dash_for_the_west = { log(`More than the ${com_control} Communist controlled spaces in East Germany`)
log('+1 VP')
game.vp++
- check_vp()
+ if (check_vp()) {
+ return
+ }
game.discard = true
game.state = 'vm_play_event_from_discard'
} else {
@@ -5842,10 +5915,11 @@ states.vm_play_event_from_discard = { prompt() {
if (game.valid_cards.length === 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: no valid cards in discard.`
- gen_action('done')
+ gen_action('pass')
} else if (game.temp === 0) {
view.prompt = `${event_prompt()}.`
for (let card of game.valid_cards) {
+ gen_action('pass')
gen_action_card(card)
}
} else {
@@ -5864,6 +5938,15 @@ states.vm_play_event_from_discard = { if (switch_events.includes(card)) {next_player()}
goto_vm(card)
},
+ pass(){
+ push_undo()
+ if (game.valid_cards.length === 0) {
+ log('No valid cards to choose')
+ } else{
+ log('Did not choose a card')
+ }
+ vm_next()
+ },
done(){
game.discard = false
vm_next()
@@ -6434,12 +6517,15 @@ states.vm_malta_summit = { log(`Rolled a ${roll}`)
if (game.stability > 0) {
log(`+${game.stability} from USSR Stability Track`)
+ log(`Modified roll: ${roll + game.stability}`)
}
if (roll + game.stability > 3) {
log('Summit successful')
game.vp += 3
log('+3 VP')
- check_vp()
+ if (check_vp()) {
+ return
+ }
if (game.pieces[12].comInfl > 0 ) {game.valid_spaces.push(12)}
if (game.pieces[15].comInfl > 0 ) {game.valid_spaces.push(15)}
if (game.pieces[27].comInfl > 0 ) {game.valid_spaces.push(27)}
@@ -6451,7 +6537,7 @@ states.vm_malta_summit = { vm_next()
}
else {
- log('Summit failed')
+ log('Summit failed. Required 4 or more')
//game.phase++
vm_goto_step(vm_permanently_remove)
}
@@ -6539,7 +6625,9 @@ states.vm_new_years_eve_party = { log(`Communist holds power in ${power} countries. +3 VP`)
game.vp += 3
}
- check_vp()
+ if (check_vp()) {
+ return
+ }
game.table_cards.push(104)
vm_next()
},
@@ -6817,25 +6905,26 @@ states.vm_systematization = { return `resolve ${cards[game.played_card].name}.`
},
prompt() {
- if (game.persistent_events['systematization'] === 0) {
+ /*if (game.persistent_events['systematization'] === 0) { */
view.prompt = 'Systematization: eliminate a space in Romania.'
for (let space_id of game.valid_spaces) {
gen_action_infl(spaces[space_id].name_unique);
}
- } else {
+ /*} else {
view.prompt = 'Systematization: done.'
gen_action('done')
- }
+ }*/
},
infl(space) {
push_undo()
vm_eliminate(find_space_index(space))
game.valid_spaces = []
game.persistent_events['systematization'] = find_space_index(space)
+ vm_next()
},
- done() {
+/* done() {
vm_next()
- }
+ } */
}
states.vm_the_chinese_solution = {
@@ -6858,7 +6947,9 @@ states.vm_the_chinese_solution = { log(`Chose ${country_name(game.vm_active_country)}`)
log('+3 VP')
game.vp += 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
},
poland() {
@@ -6867,7 +6958,9 @@ states.vm_the_chinese_solution = { log(`Chose ${country_name(game.vm_active_country)}`)
log('+3 VP')
game.vp += 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
},
czechoslovakia() {
@@ -6876,7 +6969,9 @@ states.vm_the_chinese_solution = { log(`Chose ${country_name(game.vm_active_country)}`)
log('+3 VP')
game.vp += 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
},
hungary() {
@@ -6885,7 +6980,9 @@ states.vm_the_chinese_solution = { log(`Chose ${country_name(game.vm_active_country)}`)
log('+3 VP')
game.vp += 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
},
romania() {
@@ -6894,7 +6991,9 @@ states.vm_the_chinese_solution = { log(`Chose ${country_name(game.vm_active_country)}`)
log('+3 VP')
game.vp += 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
},
bulgaria () {
@@ -6903,7 +7002,9 @@ states.vm_the_chinese_solution = { log(`Chose ${country_name(game.vm_active_country)}`)
log('+3 VP')
game.vp += 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
vm_next()
},
pass() {
@@ -7011,7 +7112,9 @@ states.vm_the_wall_must_go = { game.persistent_events['the_wall_must_go'] = true
log('+3 VP')
game.vp += 3
- check_vp()
+ if (check_vp()) {
+ return
+ }
for (let space of game.pieces) {
if (space) {console.log('space.space_id', space.space_id)}
if (space && spaces[space.space_id].country === 'East_Germany' && space.comInfl > 0){
@@ -7032,7 +7135,7 @@ states.vm_warsaw_pact_summit = { return `resolve ${cards[game.played_card].name}.`
},
prompt() {
- view.prompt = 'Choose to play for support checks or influence.'
+ view.prompt = 'Choose to play for support checks or place SPs.'
gen_action('influence')
gen_action('support_check')
},
@@ -7669,7 +7772,7 @@ CODE[32] = [ // Peasant Parties* ]
CODE[33] = [ // Sajudis*
- [ vm_valid_spaces, 56, 70 ],
+ [ vm_sajudis_check ],
[ vm_prompt, 'any Minorities space' ],
[ vm_take_control_prep, 1 ],
[ vm_sajudis ],
@@ -7693,6 +7796,7 @@ CODE[35] = [ // Heal our Bleeding Wounds* CODE[36] = [ // Dash for the West*
[ vm_permanently_remove ],
+ [ vm_prompt, 'select any Democratic event with an asterix(*) from the discard pile. Event occurs immediately.'],
[ vm_dash_for_the_west ],
[ vm_return ],
]
|