summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-09-29 13:26:50 +0100
committeriainp5 <iain.pearce.ip@gmail.com>2024-09-29 13:26:50 +0100
commit794f1b8e6d6cb7d58c3036241e2bd355bc55ece6 (patch)
tree02e989bf8803295e607d2952d466f7d4ac7ca3a1 /rules.js
parentd8046647bc35ee2007df85111bccb240ddd00032 (diff)
download1989-dawn-of-freedom-794f1b8e6d6cb7d58c3036241e2bd355bc55ece6.tar.gz
Changes to reduce size of game object
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js495
1 files changed, 272 insertions, 223 deletions
diff --git a/rules.js b/rules.js
index 1abdf84..1b8b52a 100644
--- a/rules.js
+++ b/rules.js
@@ -23,6 +23,7 @@ const all_power_cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
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, 54, 58, 59, 62, 63, 65, 70, 72, 74, 99, 102, 108]
const switch_events = [6, 20, 71]
+const variable_events = [3, 14, 15, 21, 61, 67, 70, 81, 84, 96, 97, 107, 109]
exports.scenarios = [ "Standard" ]
@@ -131,22 +132,15 @@ function start_game() {
console.log('card numbers: ', card_numbers) */
game.strategy_deck = draw_deck(cards)
reset_power()
- game.playable_cards = cards.map(card => {
- if (card === null) return null
- return {
- number: card.number,
- playable: card.playable
- }})
+
+ // Set cards were event playable status changes during the game
+
+ game.playable_cards = [false, true, true, true, false, '', true, false, false, false, false, false, false ]
+
//console.log('game.strategy_deck: ', game.strategy_deck[1])
draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit)
//.log('game.strategy_deck: ', game.strategy_deck[1], 'democrat_hand:', game.democrat_hand)
- spaces.forEach((space, index) => {
- if(index === 0 ) return
- game.pieces.push({
- demInfl: space.demInfl,
- comInfl: space.comInfl
- });
- });
+
game.valid_spaces = valid_spaces_setup()
game.available_ops = 2
game.phase = 0
@@ -169,7 +163,8 @@ exports.view = function(state, player) {
valid_spaces: game.valid_spaces,
valid_cards: game.valid_cards,
- pieces: game.pieces,
+ demInfl: spaces.demInfl,
+ comInfl: spaces.comInfl,
turn: game.turn,
round: game.round,
round_player: game.round_player,
@@ -482,22 +477,38 @@ states.play_card ={
}
// Check for Reformer Rehabilitated
- console.log('game.active', game.active, 'game.playable_cards[67].playable', game.playable_cards[67].playable)
+
+ //console.log('game.active', game.active, 'game.playable_cards[67].playable', game.playable_cards[67].playable)
+
+
if (game.played_card === 67){
- if (game.active === DEM && game.playable_cards[67].playable === DEM) {
+ if (game.active === DEM && game.playable_cards[find_event(67)] === DEM) {
gen_action('event')
}
- if (game.active === COM && game.playable_cards[67].playable === COM) {
+ if (game.active === COM && game.playable_cards[find_event(67)] === COM) {
gen_action('event')
}
}
//Continue with normal logic
+
+ //Check if it is a card with an event which is always playable
+
+ if (!variable_events.includes(game.played_card)) {
+ get_events(game.played_card)
+ }
+
+ // Resolve cards with variable events
+
+ if (variable_events.includes(game.played_card) && game.playable_cards[find_event(game.played_card)]) {
+ get_events(game.played_card)
+ } /*
if ((game.active === DEM && cards[game.played_card].side === 'D' && game.playable_cards[game.played_card].playable === 1) || (game.active === COM && cards[game.played_card].side === 'C' && game.playable_cards[game.played_card].playable ===1) || (cards[game.played_card].side === 'N'&& game.playable_cards[game.played_card].playable ===1)) {
gen_action('event')
} else if ((game.active === DEM && (cards[game.played_card].side === 'C' && game.playable_cards[game.played_card].playable ===1)) || game.active === COM && (cards[game.played_card].side === 'D' && game.playable_cards[game.played_card].playable ===1)) {
gen_action('opp_event')
- }
+ } */
+
gen_action('influence')
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')
@@ -549,10 +560,13 @@ states.play_card ={
}
}
// Check if card is opponent card with event that needs to be resolved
- if ((game.active === DEM && cards[game.played_card].side === "C" && game.playable_cards[game.played_card].playable === 1) || (game.active === COM && cards[game.played_card].side === "D" && game.playable_cards[game.played_card].playable === 1 )) {
- game.phase = 1 /*Do I need this? */
- game.vm_event_to_do = true
- }
+
+ if (!variable_events.includes(game.played_card)|| game.playable_cards[find_event(game.played_card)]) {
+ if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) {
+ //game.phase = 1 /*Do I need this? */
+ game.vm_event_to_do = true
+ }
+ }
// Set AHBR tracker to true
game.austria_hungary_border_reopened_tracker = true
@@ -569,9 +583,18 @@ states.play_card ={
log_gap(`Played C${cards[game.played_card].number} for support checks`)
// Check if card is opponent card with event that needs to be resolved
- if (game.phase === 0 && game.active === DEM && cards[game.played_card].side === "C" && game.playable_cards[game.played_card].playable === 1 || game.phase === 0 && game.active === COM && cards[game.played_card].side === "D" && game.playable_cards[game.played_card].playable === 1 ) {
+ /*if (game.phase === 0 && game.active === DEM && cards[game.played_card].side === "C" && game.playable_cards[game.played_card].playable === 1 || game.phase === 0 && game.active === COM && cards[game.played_card].side === "D" && game.playable_cards[game.played_card].playable === 1 ) {
game.vm_event_to_do = true
+ }*/
+
+ if (!variable_events.includes(game.played_card)|| game.playable_cards[find_event(game.played_card)]) {
+ if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) {
+ game.vm_event_to_do = true
+ }
}
+
+
+
game.available_ops = 2
game.state='support_check_prep'
valid_spaces_sc()
@@ -1962,7 +1985,7 @@ states.stasi_confirm = {
}
},
done() {
- game.playable_cards[21].playable = 0
+ game.playable_cards[find_event(21)] = false
end_stasi_choose_card()
}
}
@@ -2079,9 +2102,9 @@ function add_infl(space) {
// Update influence values
if (game.active === COM) {
- game.pieces[clicked_space].comInfl++
+ game.comInfl[clicked_space].comInfl++
} else {
- game.pieces[clicked_space].demInfl++
+ game.demInfl[clicked_space].demInfl++
}
// Check whether spaces are controlled
@@ -2128,13 +2151,13 @@ function remove_infl(space) {
if (game.remove_opponent_infl === true) {
if (game.active === COM) {
- game.pieces[clicked_space].demInfl--
- if (game.pieces[clicked_space].demInfl === 0) {
+ game.demInfl[clicked_space]--
+ if (game.demInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space);
}
} else {
- game.pieces[clicked_space].comInfl--
- if (game.pieces[clicked_space].comInfl === 0) {
+ game.comInfl[clicked_space]--
+ if (game.comInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space);
}
}
@@ -2142,13 +2165,13 @@ function remove_infl(space) {
} else {
if (game.active === COM) {
- game.pieces[clicked_space].comInfl--
- if (game.pieces[clicked_space].comInfl === 0) {
+ game.comInfl[clicked_space]--
+ if (game.comInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space);
}
} else {
- game.pieces[clicked_space].demInfl--
- if (game.pieces[clicked_space].demInfl === 0) {
+ game.demInfl[clicked_space]--
+ if (game.demInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space);
}
}
@@ -2319,25 +2342,25 @@ function do_sc(space) {
log_msg_gap(`${change_infl} point swing`)
let clicked_space = find_space_index(space)
if(game.active === DEM) {
- if (change_infl > game.pieces[clicked_space].comInfl) {
- const residual = change_infl - game.pieces[clicked_space].comInfl
- game.pieces[clicked_space].comInfl = 0
- game.pieces[clicked_space].demInfl += residual
+ if (change_infl > game.comInfl[clicked_space]) {
+ const residual = change_infl - game.comInfl[clicked_space]
+ game.comInfl[clicked_space] = 0
+ game.demInfl[clicked_space] += residual
} else {
- game.pieces[clicked_space].comInfl -= change_infl
+ game.comInfl[clicked_space] -= change_infl
}
- if (game.pieces[clicked_space].comInfl === 0) {
+ if (game.comInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space)
}
} else {
- if (change_infl > game.pieces[clicked_space].demInfl) {
- const residual = change_infl - game.pieces[clicked_space].demInfl
- game.pieces[clicked_space].demInfl = 0
- game.pieces[clicked_space].comInfl += residual
+ if (change_infl > game.demInfl[clicked_space]) {
+ const residual = change_infl - game.demInfl[clicked_space]
+ game.demInfl[clicked_space] = 0
+ game.comInfl[clicked_space] += residual
} else {
- game.pieces[clicked_space].demInfl -= change_infl
+ game.demInfl[clicked_space] -= change_infl
}
- if (game.pieces[clicked_space].demInfl === 0) {
+ if (game.demInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space)
}
}
@@ -2367,17 +2390,18 @@ function valid_spaces_setup() {
game.valid_spaces = []
let valid_spaces_set = new Set();
console.log('in vs setup, state', game.state)
- for (let i =1 ; i < game.pieces.length; i++) {
- piece = game.pieces[i]
+ for (let i =1 ; i < 75 ; i++) {
space = spaces[i]
if (game.state === 'com_init') {
+ infl = game.demInfl[i]
- if (piece.demInfl === 0) {
+ if (infl === 0) {
valid_spaces_set.add(space.space_id);
}
} else if (game.state === 'dem_init') {
- if (piece.comInfl === 0) {
+ infl = game.comInfl[i]
+ if (infl === 0) {
valid_spaces_set.add(space.space_id);
}
}
@@ -2390,16 +2414,17 @@ function valid_spaces_setup() {
function valid_spaces_sc() {
let valid_spaces_set = new Set();
- for (let i = 1 ; i < game.pieces.length; i++) {
- piece = game.pieces[i]
+ for (let i = 1 ; i < 75; i++) {
space = spaces[i]
if (game.active === DEM) {
- if (piece.comInfl !== 0 ) {
+ infl = game.comInfl[i]
+ if (infl !== 0 ) {
valid_spaces_set.add(space.space_id);
}
- } else {
- if (piece.demInfl !== 0 ) {
+ } else {
+ infl = game.demInfl[i]
+ if (infl !== 0 ) {
if (game.persistent_events['solidarity_legalised']) {
if (space.space_id === 14) {continue}
}
@@ -2436,16 +2461,17 @@ function valid_spaces_sc() {
function valid_spaces_support_loss() {
let valid_spaces_set = new Set();
- for (let i = 1; i < game.pieces.length; i++) {
- console.log('game.pieces.length', game.pieces.length, 'i', i)
- piece = game.pieces[i]
+ for (let i = 1; i < game.demInfl.length; i++) {
+ console.log('spaces.length', game.demInfl.length, 'i', i)
space = spaces[i]
if (game.active === DEM) {
- if (piece.demInfl > 0 && space.country === game.pwr_struggle_in) {
+ infl = game.demInfl[i]
+ if (infl > 0 && space.country === game.pwr_struggle_in) {
valid_spaces_set.add(space.space_id);
}
} else {
- if (piece.comInfl > 0 && space.country === game.pwr_struggle_in) {
+ infl = game.demInfl[i]
+ if (infl > 0 && space.country === game.pwr_struggle_in) {
valid_spaces_set.add(space.space_id);
}
}
@@ -2492,11 +2518,11 @@ function valid_spaces_infl() {
let valid_spaces_set = new Set();
// Iterate over all spaces to find the ones with the player's influence
- for (let i = 1; i < game.pieces.length; i++) {
- piece = game.pieces[i]
+ for (let i = 1; i < game.demInfl.length; i++) {
+ //piece = game.pieces[i]
space = spaces[i]
// console.log('checking piece:', space.name_unique)
- let player_influence = game.active === COM ? piece.comInfl : piece.demInfl;
+ let player_influence = game.active === COM ? game.comInfl[i] : game.demInfl[i];
// If the piece has the player's influence, add it and its adjacent spaces to the set
if (player_influence > 0) {
@@ -2627,9 +2653,9 @@ function count_adj(name_unique) {
function check_control(space_id) {
console.log('in check control, space', spaces[space_id].name_unique)
- if (game.active === COM && ((game.pieces[space_id].comInfl - game.pieces[space_id].demInfl) >= spaces[space_id].stability)) {
+ if (game.active === COM && ((game.comInfl[space_id] - game.demInfl[space_id]) >= spaces[space_id].stability)) {
return true;
- } else if (game.active === DEM && ((game.pieces[space_id].demInfl - game.pieces[space_id].comInfl) >= spaces[space_id].stability)) {
+ } else if (game.active === DEM && ((game.demInfl[space_id] - game.comInfl[space_id]) >= spaces[space_id].stability)) {
console.log('true')
return true;
} else {
@@ -2640,9 +2666,9 @@ function check_control(space_id) {
function check_opp_control(space_id) {
console.log('in check control, space', spaces[space_id].name_unique)
- if (game.active === DEM && ((game.pieces[space_id].comInfl - game.pieces[space_id].demInfl) >= spaces[space_id].stability)) {
+ if (game.active === DEM && ((game.comInfl[space_id] - game.demInfl[space_id]) >= spaces[space_id].stability)) {
return true;
- } else if (game.active === COM && ((game.pieces[space_id].demInfl - game.pieces[space_id].comInfl) >= spaces[space_id].stability)) {
+ } else if (game.active === COM && ((game.demInfl[space_id] - game.comInfl[space_id]) >= spaces[space_id].stability)) {
console.log('true')
return true;
} else {
@@ -2652,7 +2678,7 @@ function check_opp_control(space_id) {
}
function check_dem_control(space_id) {
- if ((game.pieces[space_id].demInfl - game.pieces[space_id].comInfl) >= spaces[space_id].stability) {
+ if ((game.demInfl[space_id] - game.comInfl[space_id]) >= spaces[space_id].stability) {
return true;
} else {
return false;
@@ -2660,7 +2686,7 @@ function check_dem_control(space_id) {
}
function check_com_control(space_id) {
- if ((game.pieces[space_id].comInfl - game.pieces[space_id].demInfl) >= spaces[space_id].stability) {
+ if ((game.comInfl[space_id] - game.demInfl[space_id]) >= spaces[space_id].stability) {
return true;
} else {
return false;
@@ -2742,7 +2768,6 @@ function check_presence(country) {
for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
- let piece = game.pieces[i]
if (space.country === country) {
if (check_dem_control(i)) {
@@ -3032,20 +3057,20 @@ function check_reformer() {
console.log('reformer check, dem pos:', game.dem_tst_position, 'com:', game.com_tst_position)
if (game.dem_tst_position > game.com_tst_position) {
console.log('reformer set to DEM')
- game.playable_cards[67].playable = DEM
+ game.playable_cards[find_event(67)] = DEM
}
if (game.dem_tst_position < game.com_tst_position) {
- console.log('reformer set to COM')
- console.log('game.playable_cards[66].playable before', game.playable_cards[66].playable)
- console.log('game.playable_cards[67].playable before', game.playable_cards[67].playable)
- game.playable_cards[67].playable = COM
- console.log('game.playable_cards[67].playable after', game.playable_cards[67].playable)
+ //console.log('reformer set to COM')
+ //console.log('game.playable_cards[66].playable before', game.playable_cards[66].playable)
+ //console.log('game.playable_cards[67].playable before', game.playable_cards[67].playable)
+ game.playable_cards[find_event(67)] = COM
+ //console.log('game.playable_cards[67].playable after', game.playable_cards[67].playable)
}
if (game.dem_tst_position === game.com_tst_position) {
- console.log(`reformer set to ''`)
- game.playable_cards[67].playable = ''
+ //console.log(`reformer set to ''`)
+ game.playable_cards[find_event(67)] = ''
}
- console.log('game.playable_cards[67].playable', game.playable_cards[67].playable)
+ //console.log('game.playable_cards[67].playable', game.playable_cards[67].playable)
}
function count_scoring_cards() {
@@ -3126,6 +3151,23 @@ function select_card(card){
console.log('game.state', game.state)
}
+function find_event(card) {
+ return variable_events.findIndex(card)
+}
+
+function get_events(card){
+ if (cards[card].side === 'D') {
+ if (game.active === DEM) {gen_action('event')}
+ if (game.active === COM) {gen_action('opp_event')}
+ }
+ else if (cards[card].side === 'C') {
+ if (game.active === COM) {gen_action('event')}
+ if (game.active === DEM) {gen_action('opp_event')}
+ } else {
+ gen_action('event')
+ }
+}
+
// =========== MOVING THROUGH TURNS ============
function end_round() {
@@ -3156,7 +3198,7 @@ function end_round() {
game.return = ''
game.valid_cards = []
game.valid_spaces = []
- game.playable_cards[21].playable = 1
+ game.playable_cards[find_event(21)] = true
reset_austria_hungary_border_reopened() /*This should be redundant! */
@@ -3653,10 +3695,10 @@ function check_control_change(space_id) {
/*game.pieces[space_id].demCtrl = 0
game.pieces[space_id].comCtrl = 0
- if ((game.pieces[space_id].demInfl - game.pieces[space_id].comInfl) >= game.pieces[space_id].stability) {
+ if ((game.demInfl[space_id] - game.comInfl[space_id]) >= game.pieces[space_id].stability) {
game.pieces[space_id].demCtrl = 1
}
- if ((game.pieces[space_id].comInfl - game.pieces[space_id].demInfl) >= game.pieces[space_id].stability) {
+ if ((game.comInfl[space_id] - game.demInfl[space_id]) >= game.pieces[space_id].stability) {
game.pieces[space_id].comCtrl = 1
}*/
@@ -4057,16 +4099,17 @@ function vm_valid_spaces() {
function vm_valid_spaces_opponent () {
let valid_spaces = []
- for (let i = 1; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
if (game.active === DEM) {
- if (piece.comInfl > 0) {
+ let infl = game.comInfl[i]
+ if (infl > 0) {
valid_spaces.push(space.space_id)
}
- } else {
- if (piece.demInfl > 0) {
+ } else {
+ infl = game.demInfl[i]
+ if (infl > 0) {
valid_spaces.push(space.space_id)
}
}
@@ -4078,7 +4121,7 @@ function vm_valid_spaces_opponent () {
function vm_valid_spaces_socio () {
let valid_spaces = []
- for (let i = 1; i < game.pieces.length; i++) {
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
if (space.socio === vm_operand(1)) {
@@ -4096,16 +4139,17 @@ function vm_valid_spaces_socio () {
function vm_valid_spaces_opponent_socio () {
let valid_spaces = []
- for (let i = 1; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
- if (game.active === DEM) {
- if (piece.comInfl > 0 && space.socio === vm_operand(1)) {
+ if (game.active === DEM) {
+ let infl = game.demInfl[i]
+ if (infl > 0 && space.socio === vm_operand(1)) {
valid_spaces.push(space.space_id)
}
} else {
- if (piece.demInfl > 0 && space.socio === vm_operand(1)) {
+ let infl = game.comInfl[i]
+ if (infl > 0 && space.socio === vm_operand(1)) {
valid_spaces.push(space.space_id)
}
}
@@ -4152,11 +4196,11 @@ function vm_valid_spaces_country_opp () {
for (let space of spaces) {
if (!space) continue
if (game.active === DEM) {
- if (space.country === country && game.pieces[space.space_id].comInfl >0) {
+ if (space.country === country && game.comInfl[space.space_id] >0) {
game.valid_spaces.push(space.space_id);
}
} else {
- if (space.country === country && game.pieces[space.space_id].demInfl >0) {
+ if (space.country === country && game.demInfl[space.space_id]>0) {
game.valid_spaces.push(space.space_id);
}
}
@@ -4176,11 +4220,11 @@ function vm_valid_spaces_country_sc () {
for (let space of spaces) {
if (!space) continue
if (game.active === DEM) {
- if (space.country === country && game.pieces[space.space_id].comInfl >0) {
+ if (space.country === country && game.comInfl[space.space_id] >0) {
valid_spaces.push(space.space_id);
}
} else {
- if (space.country === country && game.pieces[space.space_id].demInfl >0) {
+ if (space.country === country && game.demInfl[space.space_id] >0) {
if (game.persistent_events['solidarity_legalised'] && space.space_id === 14) {continue}
if (game.persistent_events['civic_forum'] && space.space_id === 30) {continue}
if (game.persistent_events['we_are_the_people'] && space.space_id === 9) {continue}
@@ -4225,7 +4269,7 @@ function vm_valid_spaces_region_opp() {
for (let space of spaces) {
if (!space) continue
let s = space.space_id
- if ((game.active === DEM && space.region === vm_operand(1) && game.pieces[s].comInfl > 0 ) || (game.active === COM && space.region === vm_operand(1) && game.pieces[s].demInfl > 0 )) {
+ if ((game.active === DEM && space.region === vm_operand(1) && game.comInfl[s] > 0 ) || (game.active === COM && space.region === vm_operand(1) && game.demInfl[s] > 0 )) {
valid_spaces.push(space.space_id);
}
}
@@ -4235,7 +4279,7 @@ function vm_valid_spaces_region_opp() {
function vm_valid_spaces_solidarity_legalised() {
let valid_spaces = []
- for (let i = 1; i < game.pieces.length; i++) {
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
let uncontrolled = (!check_control(i) && !check_opp_control(i))
if ((space.country === 'Poland' && uncontrolled && space.socio === 3) || (space.country === 'Poland' && uncontrolled && space.socio === 4)) {
@@ -4263,22 +4307,22 @@ function vm_take_control_prep() {
function vm_take_control(space) {
let clicked_space = find_space_index(space)
if (game.active === DEM) {
- let current_infl = game.pieces[clicked_space].demInfl
- let opponent_infl = game.pieces[clicked_space].comInfl
+ let current_infl = game.demInfl[clicked_space]
+ let opponent_infl = game.comInfl[clicked_space]
let stability = spaces[clicked_space].stability
if ((current_infl - opponent_infl) < stability) {
- game.pieces[clicked_space].demInfl += stability - current_infl + opponent_infl
+ game.demInfl[clicked_space] += stability - current_infl + opponent_infl
//game.pieces[clicked_space].demCtrl = 1
//game.pieces[clicked_space].comCtrl = 0
}
} else if (game.active === COM) {
- let current_infl = game.pieces[clicked_space].comInfl
- let opponent_infl = game.pieces[clicked_space].demInfl
+ let current_infl = game.comInfl[clicked_space]
+ let opponent_infl = game.demInfl[clicked_space]
let stability = spaces[clicked_space].stability
if ((current_infl - opponent_infl) < stability) {
- game.pieces[clicked_space].comInfl += stability - current_infl + opponent_infl
+ game.comInfl[clicked_space] += stability - current_infl + opponent_infl
//game.pieces[clicked_space].comCtrl = 1
//game.pieces[clicked_space].demCtrl = 0
}
@@ -4314,9 +4358,9 @@ function vm_do_add_infl(space) {
// Update influence values
if (game.active === COM) {
- game.pieces[clicked_space].comInfl++
+ game.comInfl[clicked_space]++
} else {
- game.pieces[clicked_space].demInfl++
+ game.demInfl[clicked_space]++
}
// Check whether spaces are controlled
@@ -4362,9 +4406,9 @@ function vm_do_add_infl_free(space) {
// Update influence values
if (game.active === COM) {
- game.pieces[clicked_space].comInfl++
+ game.comInfl[clicked_space]++
} else {
- game.pieces[clicked_space].demInfl++
+ game.demInfl[clicked_space]++
}
game.vm_available_ops--
// Check whether spaces are controlled
@@ -4396,9 +4440,9 @@ function vm_do_add_x_infl(space) {
if (game.active === COM) {
- game.pieces[clicked_space].comInfl += game.vm_available_ops
+ game.comInfl[clicked_space] += game.vm_available_ops
} else {
- game.pieces[clicked_space].demInfl += game.vm_available_ops
+ game.demInfl[clicked_space] += game.vm_available_ops
}
check_control_change(clicked_space)
game.vm_available_ops = 0
@@ -4426,9 +4470,9 @@ function vm_do_add_limited_infl(space, max_infl) {
}
if (game.active === COM) {
- game.pieces[clicked_space].comInfl ++
+ game.comInfl[clicked_space] ++
} else {
- game.pieces[clicked_space].demInfl ++
+ game.demInfl[clicked_space] ++
}
game.vm_influence_added[clicked_space] ++
@@ -4474,13 +4518,13 @@ function vm_do_remove_infl(space) {
}
if (game.remove_opponent_infl === true) {
if (game.active === COM) {
- game.pieces[clicked_space].demInfl--
- if (game.pieces[clicked_space].demInfl === 0) {
+ game.demInfl[clicked_space]--
+ if (game.demInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space);
}
} else {
- game.pieces[clicked_space].comInfl--
- if (game.pieces[clicked_space].comInfl === 0) {
+ game.comInfl[clicked_space]--
+ if (game.comInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space);
}
}
@@ -4488,13 +4532,13 @@ function vm_do_remove_infl(space) {
} else {
if (game.active === COM) {
- game.pieces[clicked_space].comInfl--
- if (game.pieces[clicked_space].comInfl === 0) {
+ game.comInfl[clicked_space]--
+ if (game.comInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space);
}
} else {
- game.pieces[clicked_space].demInfl--
- if (game.pieces[clicked_space].demInfl === 0) {
+ game.demInfl[clicked_space]--
+ if (game.demInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space);
}
}
@@ -4511,34 +4555,34 @@ function vm_do_remove_x_infl(space) {
if (game.remove_opponent_infl) {
if (game.active === COM) {
- if (game.pieces[clicked_space].demInfl >= game.vm_available_ops) {
- game.pieces[clicked_space].demInfl -= game.vm_available_ops
+ if (game.demInfl[clicked_space] >= game.vm_available_ops) {
+ game.demInfl[clicked_space] -= game.vm_available_ops
} else {
- game.vm_available_ops = game.pieces[clicked_space].demInfl
- game.pieces[clicked_space].demInfl -= game.vm_available_ops
+ game.vm_available_ops = game.demInfl[clicked_space]
+ game.demInfl[clicked_space] -= game.vm_available_ops
}
} else {
- if (game.pieces[clicked_space].comInfl >= game.vm_available_ops) {
- game.pieces[clicked_space].comInfl -= game.vm_available_ops
+ if (game.comInfl[clicked_space] >= game.vm_available_ops) {
+ game.comInfl[clicked_space] -= game.vm_available_ops
} else {
- game.vm_available_ops = game.pieces[clicked_space].comInfl
- game.pieces[clicked_space].comInfl -= game.vm_available_ops
+ game.vm_available_ops = game.comInfl[clicked_space]
+ game.comInfl[clicked_space] -= game.vm_available_ops
}
}
} else {
if (game.active === COM) {
- if (game.pieces[clicked_space].comInfl >= game.vm_available_ops) {
- game.pieces[clicked_space].comInfl -= game.vm_available_ops
+ if (game.comInfl[clicked_space] >= game.vm_available_ops) {
+ game.comInfl[clicked_space] -= game.vm_available_ops
} else {
- game.vm_available_ops = game.pieces[clicked_space].comInfl
- game.pieces[clicked_space].comInfl -= game.vm_available_ops
+ game.vm_available_ops = game.comInfl[clicked_space]
+ game.comInfl[clicked_space] -= game.vm_available_ops
}
} else {
- if (game.pieces[clicked_space].demInfl >= game.vm_available_ops) {
- game.pieces[clicked_space].demInfl -= game.vm_available_ops
+ if (game.demInfl[clicked_space] >= game.vm_available_ops) {
+ game.demInfl[clicked_space] -= game.vm_available_ops
} else {
- game.vm_available_ops = game.pieces[clicked_space].demInfl
- game.pieces[clicked_space].demInfl -= game.vm_available_ops
+ game.vm_available_ops = game.demInfl[clicked_space]
+ game.demInfl[clicked_space] -= game.vm_available_ops
}
}
}
@@ -4573,13 +4617,13 @@ function vm_do_remove_limited_infl(space, max_infl) {
}
if (game.active === COM) {
- game.pieces[clicked_space].demInfl --
- if (game.pieces[clicked_space].demInfl === 0) {
+ game.demInfl[clicked_space] --
+ if (game.demInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space)
}
} else {
- game.pieces[clicked_space].comInfl --
- if (game.pieces[clicked_space].comInfl === 0) {
+ game.comInfl[clicked_space] --
+ if (game.comInfl[clicked_space] === 0) {
game.valid_spaces = game.valid_spaces.filter(id => id !== clicked_space)
}
}
@@ -4606,17 +4650,17 @@ function vm_do_remove_all_infl(space) {
if (game.remove_opponent_infl === true) {
if (game.active === COM) {
- game.pieces[clicked_space].demInfl = 0
+ game.demInfl[clicked_space] = 0
} else {
- game.pieces[clicked_space].comInfl = 0
+ game.comInfl[clicked_space] = 0
}
check_control_change(clicked_space)
} else {
if (game.active === COM) {
- game.pieces[clicked_space].comInfl = 0
+ game.comInfl[clicked_space] = 0
} else {
- game.pieces[clicked_space].demInfl = 0
+ game.demInfl[clicked_space] = 0
}
check_control_change(clicked_space)
}
@@ -4626,11 +4670,11 @@ function vm_do_remove_all_infl(space) {
function vm_replace_all_infl(space_id) {
if (game.active === DEM) {
- game.pieces[space_id].demInfl += game.pieces[space_id].comInfl
- game.pieces[space_id].comInfl = 0
+ game.demInfl[space_id] += game.comInfl[space_id]
+ game.comInfl[space_id] = 0
} else {
- game.pieces[space_id].comInfl += game.pieces[space_id].demInfl
- game.pieces[space_id].demInfl = 0
+ game.comInfl[space_id] += game.demInfl[space_id]
+ game.demInfl[space_id] = 0
}
check_control_change(space_id)
}
@@ -4654,8 +4698,8 @@ function vm_support_check_modified() {
function vm_switch_infl(space){
push_undo()
let clicked_space = find_space_index(space)
- game.pieces[clicked_space].demInfl -= game.vm_available_ops
- game.pieces[clicked_space].comInfl += game.vm_available_ops
+ game.demInfl[clicked_space] -= game.vm_available_ops
+ game.comInfl[clicked_space] += game.vm_available_ops
log(`Replaced ${game.vm_available_ops} influence in ${spaces[clicked_space].name_unique}`)
game.vm_available_ops = 0
check_control_change(clicked_space)
@@ -4687,7 +4731,7 @@ function vm_army_backs_revolution() {
permanently_remove(70)
}*/
game.persistent_events['securitate'] = false
- game.playable_cards[70].playable = 0
+ game.playable_cards[find_event(70)] = false
/*if (game.table_cards.includes(70)) {
permanently_remove(70)
}*/
@@ -4703,9 +4747,9 @@ function vm_austria_hungary_border_reopened() {
}
function vm_betrayal() {
- if (game.pieces[58].demInfl > 0 ) { game.valid_spaces.push(58) }
- if (game.pieces[65].demInfl >0 ) { game.valid_spaces.push(65) }
- game.vm_available_ops = Math.max(game.pieces[58].demInfl, game.pieces[65].demInfl)
+ if (game.demInfl[58] > 0 ) { game.valid_spaces.push(58) }
+ if (game.demInfl[65] >0 ) { game.valid_spaces.push(65) }
+ game.vm_available_ops = Math.max(game.demInfl[58], game.demInfl[65])
game.state = 'vm_switch_infl'
}
@@ -4716,8 +4760,8 @@ function vm_breakaway_baltic_republics() {
if (check_vp()) {
return
}
- game.playable_cards[109].playable = 1
- game.playable_cards[14].playable = 0
+ game.playable_cards[find_event(109)] = true
+ game.playable_cards[find_event(14)] = false
if (!check_dem_control(56) && game.persistent_events['systematization'] !== 56) {game.valid_spaces.push(56)}
if (!check_dem_control(70)) {game.valid_spaces.push(70)}
vm_next()
@@ -4739,18 +4783,18 @@ function vm_bulgarian_turks_expelled(){
if (check_vp()) {
return
}
- if (game.pieces[70].demInfl > 0) {game.valid_spaces = [70]}
+ if (game.demInfl[70] > 0) {game.valid_spaces = [70]}
vm_next()
}
function vm_ceausescu() {
let adj_cluj = false
- if (game.pieces[50].demInfl > 0 ) {adj_cluj = true}
- if (game.pieces[54].demInfl > 0 ) {adj_cluj = true}
- if (game.pieces[58].demInfl > 0 ) {adj_cluj = true}
- if (game.pieces[61].demInfl > 0 ) {adj_cluj = true}
+ if (game.demInfl[50] > 0 ) {adj_cluj = true}
+ if (game.demInfl[54] > 0 ) {adj_cluj = true}
+ if (game.demInfl[58] > 0 ) {adj_cluj = true}
+ if (game.demInfl[61] > 0 ) {adj_cluj = true}
- if (adj_cluj && game.pieces[61].comInfl>0) {
+ if (adj_cluj && game.comInfl[61]>0) {
game.valid_spaces = [61]
game.vm_available_ops = 1
//next_player()
@@ -4800,7 +4844,7 @@ function vm_common_european_home() {
function vm_dash_for_the_west() {
game.valid_cards = []
for (let c of game.strategy_discard) {
- if (cards[c].side === 'D' && cards[c].remove === 1 && game.playable_cards[c].playable === 1) {
+ if (cards[c].side === 'D' && cards[c].remove === 1 && (!variable_events.includes(c) || game.playable_cards[find_event(c)])) {
game.valid_cards.push(c)
}
}
@@ -4851,16 +4895,18 @@ function vm_eliminate(space_id) {
log(`Eliminated %${space_id}`)
const adjacent_spaces = spaces[space_id].adjacent.filter(Number.isInteger);
- console.log('adjacency before: Iasi', game.pieces[53].adjacent, 'Ploesti:', game.pieces[59].adjacent, 'Bucharesti:', game.pieces[61].adjacent)
+ //console.log('adjacency before: Iasi', game.pieces[53].adjacent, 'Ploesti:', game.pieces[59].adjacent, 'Bucharesti:', game.pieces[61].adjacent)
// Remove clicked_space from the adjacency lists of its adjacent spaces
adjacent_spaces.forEach(s => {
game.pieces[s].adjacent = spaces[s].adjacent.filter(id => id !== space_id);
});
- console.log('adjacency after: Iasi', game.pieces[53].adjacent, 'Ploesti:', game.pieces[59].adjacent, 'Bucharesti:', game.pieces[61].adjacent)
+ //console.log('adjacency after: Iasi', game.pieces[53].adjacent, 'Ploesti:', game.pieces[59].adjacent, 'Bucharesti:', game.pieces[61].adjacent)
// Connect adjacent spaces to each other
+ // No longer used - spaces done dynamically
+/*
for (let i = 0; i < adjacent_spaces.length; i++) {
for (let j = i + 1; j < adjacent_spaces.length; j++) {
console.log(' checking i,', spaces[adjacent_spaces[i]].name, 'j', spaces[adjacent_spaces[j]].name)
@@ -4876,14 +4922,14 @@ function vm_eliminate(space_id) {
console.log('adjacency after addition: Iasi', game.pieces[53].adjacent, 'Ploesti:', game.pieces[59].adjacent, 'Bucharesti:', game.pieces[61].adjacent)
// Clear the adjacency list of the clicked space
game.pieces[space_id].adjacent = [];
-
+*/
// 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
- if (game.pieces[space_id].comInfl > 0 ) {
- log(`${game.pieces[space_id].comInfl} Communist SP relocated to Bucuresti`)
+ game.demInfl[space_id] = 0
+ game.comInfl[61] += game.comInfl[space_id]
+ if (game.comInfl[space_id] > 0 ) {
+ log(`${game.comInfl[space_id]} Communist SP relocated to Bucuresti`)
}
- game.pieces[space_id].comInfl = 0
+ game.comInfl[space_id] = 0
//Update control in the eliminated space and in Bucuresti
check_control_change(space_id)
@@ -4931,10 +4977,9 @@ function vm_foreign_currency_debt_burden() {
}
function vm_foreign_television() {
- for (let i = 1 ; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1 ; i < spaces.length; i++) {
if (i === 12) {continue} /*Does not apply to Dresden*/
- if (piece.comInfl > 0 ) {
+ if (game.comInfl[i] > 0 ) {
game.valid_spaces.push(i)
}
}
@@ -4976,7 +5021,7 @@ function vm_goodbye_lenin() {
}
//Check if these cards are playabl
for (let card of game.communist_hand_red) {
- if (game.playable_cards[card].playable === 1) {
+ if (!variable_events.includes(card) || game.playable_cards[find_event(card)]) {
game.valid_cards.push(card)
}
}
@@ -4985,10 +5030,9 @@ function vm_goodbye_lenin() {
}
function vm_government_resigns() {
- for (let i = 1; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
- if (space.socio === 1 && piece.comInfl > 0 && !check_control(i)) {
+ if (space.socio === 1 && game.comInfl[i] > 0 && !check_control(i)) {
game.valid_spaces.push(i)
}
}
@@ -5066,7 +5110,7 @@ function vm_kiss_of_death() {
}
function vm_klaus_and_komarek() {
- if (game.pieces[29].comInfl > 0 ) {game.valid_spaces = [29]}
+ if (game.comInfl[29] > 0 ) {game.valid_spaces = [29]}
vm_next()
}
@@ -5107,7 +5151,7 @@ function vm_kremlin_coup() {
function vm_laszlo_tokes() {
game.persistent_events['laszlo_tokes'] = true
- game.playable_cards[107].playable = 1
+ game.playable_cards[find_event(107)] = true
game.state = 'vm_laszlo_tokes'
}
@@ -5117,7 +5161,7 @@ function vm_legacy_of_martial_law() {
}
function vm_legacy_of_1968() {
- for (let i = 1; i < game.pieces.length; i++) {
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
if ((!check_com_control(i) && space.country === 'Czechoslovakia')) {
game.valid_spaces.push(space.space_id);
@@ -5148,7 +5192,7 @@ function vm_massacre_in_timisoara() {
}
function vm_modrow() {
- game.playable_cards[15].playable = 0
+ game.playable_cards[find_event(15)] = false
game.state = 'vm_modrow'
}
@@ -5172,8 +5216,8 @@ function vm_nomenklatura() {
}
function vm_normalisation() {
- if (game.pieces[27].demInfl >0) {game.valid_spaces.push(27)}
- if (game.pieces[29].demInfl > 0) {game.valid_spaces.push(29)}
+ if (game.demInfl[27] >0) {game.valid_spaces.push(27)}
+ if (game.demInfl[29] > 0) {game.valid_spaces.push(29)}
game.remove_opponent_infl = true
vm_next()
}
@@ -5254,7 +5298,7 @@ function vm_prudence() {
function vm_public_against_violence() {
game.valid_spaces = []
- if (game.pieces[34].comInfl > 0 ) {game.valid_spaces.push(34)}
+ if (game.comInfl[34] > 0 ) {game.valid_spaces.push(34)}
vm_next()
}
@@ -5290,7 +5334,7 @@ function vm_sajudis_check() {
}
function vm_sajudis() {
- game.playable_cards[81].playable = 1
+ game.playable_cards[find_event(81)] = true
game.stability++
log('+1 VP')
game.vp++
@@ -5321,14 +5365,14 @@ function vm_social_democratic_platform_adopted() {
function vm_solidarity_legalised() {
log_msg_gap(`C2 in effect`)
- game.playable_cards[3].playable = 1
+ game.playable_cards[find_event(3)] = true
game.persistent_events['solidarity_legalised'] = true
vm_next()
}
function vm_st_nicholas_church () {
game.persistent_events['st_nicholas_church'] = true
- game.playable_cards[61].playable = 1
+ game.playable_cards[find_event(61)] = true
permanently_remove(24)
vm_next()
}
@@ -5371,7 +5415,7 @@ function vm_tear_gas () {
}
function vm_the_baltic_way() {
- game.playable_cards[84].playable = 1
+ game.playable_cards[find_event(84)] =true
game.stability++
if (!check_dem_control(56) && game.persistent_events['systematization'] !== 56) {game.valid_spaces.push(56)}
if (!check_dem_control(70) && game.persistent_events['systematization'] !== 70) {game.valid_spaces.push(70)}
@@ -5392,7 +5436,7 @@ function vm_the_crowd_turns_against_ceausescu() {
//game.persistent_events['the_crowd_turns_against_ceausescu'] = true
game.table_cards.push(54)
remove_from_discard(54)
- game.playable_cards[97].playable = 1
+ game.playable_cards[find_event(97)] = true
vm_next()
}
@@ -5415,18 +5459,17 @@ function vm_the_third_way() {
function vm_the_tyrant_is_gone() {
game.valid_spaces = []
- for (let i = 1; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
- if (piece.demInfl === 0 && space.country === 'Romania') {
+ if (game.demInfl[i] === 0 && space.country === 'Romania') {
if (space.space_id === game.persistent_events['systematization']) {continue}
game.valid_spaces.push(space.space_id)
}
}
- game.playable_cards[10].playable = 0
+ /*game.playable_cards[10].playable = 0
game.playable_cards[41].playable = 0
game.playable_cards[101].playable = 0
- game.playable_cards[107].playable = 0
+ game.playable_cards[107].playable = 0*/
console.log('game.vm_event', game.vm_event, 'game.played_card', game.played_card)
game.state = 'vm_the_tyrant_is_gone'
}
@@ -5461,7 +5504,7 @@ function vm_warsaw_pact_summit() {
}
function vm_we_are_the_people() {
- if (game.pieces[6].demInfl > 0) {game.valid_spaces = [6]}
+ if (game.demInfl[6] > 0) {game.valid_spaces = [6]}
game.persistent_events['we_are_the_people'] = true
game.vm_influence_added[6] = 0
game.vm_available_ops = 4
@@ -5473,7 +5516,7 @@ function vm_workers_revolt() {
for (let space of spaces) {
if (!space) continue
let country = space.country
- if (!game.revolutions[`${country}`] && game.pieces[space.space_id].comInfl > 0 && space.socio === 4) {
+ if (!game.revolutions[`${country}`] && game.comInfl[space.space_id] > 0 && space.socio === 4) {
game.valid_spaces.push(space.space_id);
}
}
@@ -5481,7 +5524,7 @@ function vm_workers_revolt() {
for (let space of spaces) {
if (!space) continue
let country = space.country
- if (game.revolutions[`${country}`] && game.pieces[space.space_id].demInfl > 0 && space.socio === 4) {
+ if (game.revolutions[`${country}`] && game.demInfl[space.space_id] > 0 && space.socio === 4) {
game.valid_spaces.push(space.space_id);
}
}
@@ -6021,7 +6064,7 @@ states.vm_brought_in_for_questioning = {
discard() {
game.vm_event = discard_card(game.democrat_hand)
game.phase = 1
- if (cards[game.vm_event].side === 'C' && game.playable_cards[game.vm_event].playable === 1) {
+ if (cards[game.vm_event].side === 'C' && (!variable_events.includes(game.event) || game.playable_cards[find_event(game.vm_event)])) {
game.return = game.active
if (!auto_resolve_events.includes(game.vm_event) && !switch_events.includes(game.vm_event)) {
next_player()
@@ -6252,7 +6295,7 @@ states.vm_deutsche_marks = {
return `resolve ${cards[20].name}.`
},
prompt() {
- if(cards[game.vm_event].side === 'C' && game.playable_cards[game.vm_event].playable === 1) {
+ if(cards[game.vm_event].side === 'C' && (!variable_events.includes(game.vm_event) || game.playable_cards[find_event(game.vm_event)])) {
view.prompt = `Deutsche Marks: you must play ${clean_name(cards[this_card()].name)} for the event.`
gen_action('event')
} else {
@@ -6864,12 +6907,12 @@ states.vm_malta_summit = {
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)}
- if (game.pieces[43].comInfl > 0 ) {game.valid_spaces.push(43)}
- if (game.pieces[51].comInfl > 0 ) {game.valid_spaces.push(51)}
- if (game.pieces[69].comInfl > 0 ) {game.valid_spaces.push(69)}
+ if (game.comInfl[12] > 0 ) {game.valid_spaces.push(12)}
+ if (game.comInfl[15] > 0 ) {game.valid_spaces.push(15)}
+ if (game.comInfl[27] > 0 ) {game.valid_spaces.push(27)}
+ if (game.comInfl[43] > 0 ) {game.valid_spaces.push(43)}
+ if (game.comInfl[51] > 0 ) {game.valid_spaces.push(51)}
+ if (game.comInfl[69] > 0 ) {game.valid_spaces.push(69)}
//game.vm_available_ops = 5
game.remove_opponent_infl = true
vm_next()
@@ -6990,11 +7033,10 @@ states.vm_nomenklatura = {
remove() {
push_undo()
game.valid_spaces = []
- for (let i = 1; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
- if (space.socio === 1 && piece.demInfl > 0) {
+ if (space.socio === 1 && game.demInfl[i] > 0) {
game.valid_spaces.push(space.space_id)
}
}
@@ -7458,10 +7500,9 @@ states.vm_the_wall_must_go = {
if (check_vp()) {
return
}
- for (let i = 1; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
- if (space.country === 'East_Germany' && piece.comInfl > 0){
+ if (space.country === 'East_Germany' && game.comInfl[i] > 0){
game.valid_spaces.push(space.space_id)
}
}
@@ -7485,10 +7526,9 @@ states.vm_warsaw_pact_summit = {
},
influence(){
push_undo()
- for (let i = 1; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
- if (piece.demInfl === 0) {
+ if (game.demInfl[i] === 0) {
game.valid_spaces.push(space.space_id);
}
}
@@ -7499,10 +7539,9 @@ states.vm_warsaw_pact_summit = {
},
support_check(){
push_undo()
- for (let i = 1; i < game.pieces.length; i++) {
- let piece = game.pieces[i]
+ for (let i = 1; i < spaces.length; i++) {
let space = spaces[i]
- if (piece.demInfl > 0 && (space.socio === 5 || space.socio === 6)) {
+ if (game.demInfl[i] > 0 && (space.socio === 5 || space.socio === 6)) {
game.valid_spaces.push(space.space_id)
}
}
@@ -7518,7 +7557,7 @@ states.vm_we_are_the_people_remove = {
return `resolve ${cards[game.played_card].name}.`
},
prompt() {
- if (game.pieces[6].demInfl === 0) {
+ if (game.demInfl[6] === 0) {
view.prompt = '"We are the People!": no influence to remove.'
gen_action('done')
} else if (game.vm_available_ops > 0 ) {
@@ -7929,9 +7968,11 @@ CODE[9] = [ // The Wall*
]
CODE[10] = [ // Cult of Personality
+ [ vm_if, ()=>!game.persistent_events['the_tyrant_is_gone'] ],
[ vm_valid_spaces_country_socio_2, 'Romania', 3, 4 ],
[ vm_prompt, 'Worker or Farmer spaces in Romania, no more than 2 per space' ],
[ vm_add_limited_infl, 4, 2 ],
+ [ vm_endif ],
[ vm_permanently_remove ],
[ vm_return ],
]
@@ -8110,7 +8151,7 @@ CODE[35] = [ // Heal our Bleeding Wounds*
CODE[36] = [ // Dash for the West*
[ vm_permanently_remove ],
- [ vm_prompt, 'Dash for the West: select any Democratic event with an asterix(*) from the discard pile. Event occurs immediately.' ],
+ [ vm_prompt, 'Dash for the West: select any Democratic event with an asterix(*) from the discard pile. Event occurs immediately' ],
[ vm_dash_for_the_west ],
[ vm_return ],
]
@@ -8154,6 +8195,7 @@ CODE[40] = [ // Hungarian Democratic Forum
]
CODE[41] = [ // Ceausescu*
+ [ vm_if, ()=>!game.persistent_events['the_tyrant_is_gone'] ],
[ vm_valid_spaces_country_sc, 'Romania' ],
[ vm_prompt, ' from Romania' ],
[ vm_remove_opp_infl, 3 ],
@@ -8162,6 +8204,7 @@ CODE[41] = [ // Ceausescu*
[ vm_1_support_check ],
[ vm_prompt, ' from Bucharesti' ],
[ vm_ceausescu ],
+ [ vm_endif ],
[ vm_permanently_remove ],
[ vm_return ],
]
@@ -8621,9 +8664,11 @@ CODE[100] = [ // Stand Fast*
]
CODE[101] = [ // Elena*
+ [ vm_if, ()=>!game.persistent_events['the_tyrant_is_gone'] ],
[ vm_valid_spaces, 51 ],
[ vm_prompt, 'the Romania Elite Space' ],
[ vm_add_x_infl, 2 ],
+ [ vm_endif ],
[ vm_elena ],
[ vm_return ],
]
@@ -8662,6 +8707,7 @@ CODE[105] = [ // Public Against Violence*
CODE[106] = [ // Social Democratic Platform Adopted*
[ vm_social_democratic_platform_adopted ],
[ vm_valid_spaces_country ],
+ [ vm_prompt, ()=>`${country_name(game.vm_active_country)}` ],
[ vm_add_infl_free, 2 ],
[ vm_valid_spaces_country_sc ],
[ vm_prompt, ()=>`make a Support Check in ${country_name(game.vm_active_country)}` ],
@@ -8671,10 +8717,12 @@ CODE[106] = [ // Social Democratic Platform Adopted*
]
CODE[107] = [ // Massacre in Timisoara*
+ [ vm_if, ()=>!game.persistent_events['the_tyrant_is_gone'] ],
[ vm_massacre_in_timisoara ],
[ vm_valid_spaces_country_sc, 'Romania' ],
[ vm_prompt, 'Make Support Checks in Romania' ],
[ vm_support_check_modified, 2, 2 ],
+ [ vm_endif ],
[ vm_permanently_remove ],
[ vm_return ],
]
@@ -8687,8 +8735,8 @@ CODE[108] = [ // Army Backs Revolution*
CODE[109] = [ // Kremlin Coup*
[ vm_kremlin_coup ],
- //[ vm_prompt, 'Elite spaces in all countries where the Communist retains Power' ],
- //[ vm_take_control_prep, 6 ],
+ [ vm_prompt, 'Elite spaces in all countries where the Communist retains Power' ],
+ [ vm_take_control_prep, 6 ],
[ vm_permanently_remove ],
[ vm_return ],
]
@@ -8710,6 +8758,7 @@ CODE[110] = [ // Malta Summit*
+
// ============= TIANANMEN SQUARE TRACK AWARDS ====================
CODE[203] = [//Tiananmen Square space 3 award
[vm_tst_3],