summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js81
1 files changed, 62 insertions, 19 deletions
diff --git a/rules.js b/rules.js
index a023604..3d03d97 100644
--- a/rules.js
+++ b/rules.js
@@ -46,16 +46,12 @@ exports.setup = function (seed, scenario, options) {
played_card: 0,
table_cards: [],
- temp: 0,
available_ops: 0,
vm_available_ops: 0,
- starting_infl: {
- com_starting_infl: 0,
- dem_starting_infl: 0
- },
valid_spaces: [],
valid_cards: [],
+ vp: 0,
turn: 0,
round: 0,
round_player: COM,
@@ -65,10 +61,7 @@ exports.setup = function (seed, scenario, options) {
dem_tst_attempted: 0,
com_tst_attempted: 0,
dem_tst_attempted_this_turn: 0,
- com_tst_attempted_this_turn:0,
- tst_7: false,
- tst_8: false,
- vp: 0,
+ com_tst_attempted_this_turn: 0,
demInfl: [],
comInfl: [],
@@ -85,7 +78,6 @@ exports.setup = function (seed, scenario, options) {
com_hand_limit: 8,
democrat_hand: [],
communist_hand: [],
- communist_hand_red: [],
pwr_struggle_in: [],
is_pwr_struggle: false,
@@ -93,7 +85,6 @@ exports.setup = function (seed, scenario, options) {
com_pwr_hand_limit: 0,
dem_pwr_hand: [],
com_pwr_hand: [],
- ceausescu_cards: [],
raised_stakes_discard: 0,
raised_stakes: 0,
raised_stakes_round: 0,
@@ -129,6 +120,12 @@ function start_game() {
}
})
+ //Set starting placement ops
+ game.starting_infl = {
+ com_starting_infl: 0,
+ dem_starting_infl: 0
+ },
+
// Set variable event cards where event is playable at start of game
game.playable_cards = [14, 15, 21, 70]
@@ -173,7 +170,7 @@ exports.view = function(state, player) {
the_tyrant_is_gone: game.the_tyrant_is_gone,
strategy_deck: game.strategy_deck.length,
- strategy_discard: game.strategy_discard,
+ //strategy_discard: game.strategy_discard,
discard: game.discard,
show_opp_hand: game.view_opp_hand,
@@ -193,6 +190,12 @@ exports.view = function(state, player) {
}
+ if (game.is_pwr_struggle) {
+ view.strategy_discard = game.power_struggle_discard
+ } else {
+ view.strategy_discard = game.strategy_discard
+ }
+
if (player === game.active && game.vm && game.vm.draw)
view.drawn = game.vm.draw
@@ -214,7 +217,9 @@ exports.view = function(state, player) {
if (player === DEM) {
view.hand = game.democrat_hand
- view.opp_hand = game.communist_hand_red
+ if (game.communist_hand_red) {
+ view.opp_hand = game.communist_hand_red
+ }
view.set_aside = game.democrat_set_aside /*Is this being used? */
view.power_hand = game.dem_pwr_hand.sort((a, b) => a - b)
@@ -1126,6 +1131,7 @@ states.the_crowd_turns_against_ceausescu_prep = {
gen_action('draw')
},
draw() {
+ game.ceausescu_cards = []
draw_cards(game.power_struggle_deck, game.ceausescu_cards, game.com_pwr_hand, 15, game.com_pwr_hand.length)
console.log('game.ceausescu_cards', game.ceausescu_cards)
game.temp = game.ceausescu_cards.filter(card => card && card >=25 && card <= 30).length
@@ -1146,14 +1152,14 @@ states.vm_the_crowd_turns_against_ceausescu = {
},
influence() {
push_undo()
- game.ceausescu_cards = []
+ delete game.ceausescu_cards
valid_spaces_infl()
game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'Romania')
game.state = 'the_crowd_turns_against_ceausescu_infl' /* Send this to add_infl. Add check at end of add_infl similar to valid_spaces*/
},
support_check() {
push_undo()
- game.ceausescu_cards = []
+ delete game.ceausescu_cards
valid_spaces_sc()
game.available_ops = 2
game.state = 'support_check_prep'
@@ -2846,9 +2852,26 @@ function do_tst_attempt() {
game.dem_tst_attempted_this_turn = 1
if (roll >= dem_tst_req[game.dem_tst_position]) {
log(`${dem_tst_req[game.dem_tst_position]} required: success`)
- game.tst_success = true
game.dem_tst_position++
game.dem_tst_attempted = 0
+
+ //Check if they have reached box 7 or 8 first
+ if (game.dem_tst_position === 7 && game.com_tst_position < 7) {
+ game.tst_7 = false
+ }
+ if (game.dem_tst_position === 8 && game.com_tst_position < 8) {
+ game.tst_8 = false
+ }
+
+ //Check if they have caught up to box 7 or 8
+ if (game.dem_tst_position >= 7 && game.com_tst_position >= 7) {
+ delete game.tst_7
+ }
+ if (game.dem_tst_position >= 8 && game.com_tst_position >= 8) {
+ delete game.tst_8
+ }
+
+ //Check if TST events occur
if (game.dem_tst_position === 3 && game.com_tst_position < 3) {goto_vm(203)}
else if (game.dem_tst_position === 4 && game.com_tst_position < 4) {goto_vm(204)}
else {game.state = 'tiananmen_square_attempt_success'}
@@ -2863,6 +2886,24 @@ function do_tst_attempt() {
log(`${com_tst_req[game.com_tst_position]} required: success`)
game.com_tst_position++
game.com_tst_attempted = 0
+
+ //Check if they have reached box 7 or 8 first
+ if (game.dem_tst_position === 7 && game.com_tst_position < 7) {
+ game.tst_7 = false
+ }
+ if (game.dem_tst_position === 8 && game.com_tst_position < 8) {
+ game.tst_8 = false
+ }
+
+ //Check if they have caught up to box 7 or 8
+ if (game.dem_tst_position >= 7 && game.com_tst_position >= 7) {
+ delete game.tst_7
+ }
+ if (game.dem_tst_position >= 8 && game.com_tst_position >= 8) {
+ delete game.tst_8
+ }
+
+ //Check if TST events occur
if (game.com_tst_position === 3 && game.dem_tst_position < 3) {goto_vm(203)}
else if (game.com_tst_position === 4 && game.dem_tst_position < 4) {goto_vm(204)}
else {game.state = 'tiananmen_square_attempt_success'}
@@ -3179,6 +3220,7 @@ function check_reformer() {
} else {
game.playable_cards = game.playable_cards.filter(n => n !== 67)
}
+
}
function count_scoring_cards() {
@@ -3498,8 +3540,8 @@ function new_turn() {
game.round_player = COM
game.dem_tst_attempted_this_turn = 0
game.com_tst_attempted_this_turn = 0
- game.tst_7 = false
- game.tst_8 = false
+ if (game.tst_7) {game.tst_7 = false}
+ if (game.tst_8) {game.tst_8 = false}
//Remove events that only last one turn
game.persistent_events = game.persistent_events.filter(n => n !== 25) /*Perestroika*/
@@ -4250,6 +4292,7 @@ function vm_return() {
delete game.support_check_modifier
delete game.vm_max_infl
delete game.vm_influence_added
+ delete game.communist_hand_red
game.vm_event = 0 /*Reset to 0 now that event has been completed. Hopefully this doesn't cause issues! */
if (game.persistent_events.includes(58)) {
@@ -5231,13 +5274,13 @@ function vm_genscher() {
function vm_goodbye_lenin() {
game.view_opp_hand = true
+ game.communist_hand_red = []
// Select Red cards to show
for (let card of game.communist_hand) {
console.log('checking card ', card, 'red', cards[card].red)
if (cards[card].red) {
game.communist_hand_red.push(card)
}
- console.log('game.communist_hand_red', game.communist_hand_red)
}
//Check if these cards are playabl
for (let card of game.communist_hand_red) {