diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 132 |
1 files changed, 89 insertions, 43 deletions
@@ -144,8 +144,7 @@ function start_game() { if(index === 0 ) return
game.pieces.push({
demInfl: space.demInfl,
- comInfl: space.comInfl,
- adjacent: space.adjacent
+ comInfl: space.comInfl
});
});
game.valid_spaces = valid_spaces_setup()
@@ -453,22 +452,28 @@ states.choose_card = { console.log('prudence:', game.persistent_events['prudence'])
if ((game.active === DEM && game.persistent_events['prudence'].DEM !== 0)) {
- if (game.available_ops > 1) {
- log(`${pluralize(game.persistent_events['prudence'].DEM,' op')} from C8`)
- game.available_ops += game.persistent_events['prudence'].DEM
- if (game.available_ops < 1) {
- game.available_ops = 1
+ if (game.available_ops > 2) {
+ log(`${pluralize(game.persistent_events['prudence'].DEM,'op')} from C8`)
+ } else {
+ if (game.available_ops > 1) {
+ log(`-1 op from C8`)
}
}
+ game.available_ops += game.persistent_events['prudence'].DEM
+ if (game.available_ops < 1) {
+ game.available_ops = 1
+ }
}
if (game.active === COM && game.persistent_events['prudence'].COM !== 0) {
- if (game.available_ops > 1) {
- log(`${pluralize(game.persistent_events['prudence'].COM,' op')} from C8`)
- game.available_ops += game.persistent_events['prudence'].COM
- if (game.available_ops < 1) {
- game.available_ops = 1
- }
+ if (game.available_ops > 2) {
+ log(`${pluralize(game.persistent_events['prudence'].COM,'op')} from C8`)
+ } else if (game.available_ops > 1) {
+ log(`-1 op from C8`)
+ }
+ game.available_ops += game.persistent_events['prudence'].COM
+ if (game.available_ops < 1) {
+ game.available_ops = 1
}
}
@@ -1352,6 +1357,7 @@ states.power_struggle = { }
},
concede () {
+ push_undo()
log('Conceded')
log_h2('Aftermath')
log_h3('Support Loss')
@@ -2047,11 +2053,11 @@ states.stasi_play_card = { end_round()
},
done () {
+ game.stasi_card = 0
if (game.democrat_hand.includes(21)) {
game.state = 'stasi_resolve_common_european_home'
} else {
game.state = 'play_card'
- game.stasi_card = 0
}
}
}
@@ -2072,7 +2078,6 @@ states.stasi_resolve_common_european_home = { },
no() {
game.state = 'play_card'
- game.stasi_card = 0
}
}
@@ -2119,7 +2124,7 @@ function add_infl(space) { // Check Austria Hungary Border Reopened is true and condition has been met
if (game.available_ops === 0 && game.active === DEM && game.persistent_events['austria_hungary_border_reopened'] && game.austria_hungary_border_reopened_tracker) {
game.available_ops ++
- log('+1 influence from C58')
+ log('+1 op from C58')
game.austria_hungary_border_reopened_tracker = false
game.valid_spaces = game.valid_spaces.filter(n => spaces[n].country === 'East_Germany')
}
@@ -2303,6 +2308,7 @@ function do_sc(space) { // Events which affect adjacency - The Wall
const adj = count_adj(space)
+ console.log('adj', adj)
if (game.active === COM && game.persistent_events['the_wall'] && spaces[clicked_space].country === 'East_Germany') {
log('No adjacency for Democrats due to C9')
log('C9 no longer in effect')
@@ -2394,7 +2400,7 @@ function do_sc(space) { function valid_spaces_setup() {
game.valid_spaces = []
let valid_spaces_set = new Set();
- console.log('in vs setup')
+ console.log('in vs setup, state', game.state)
for (let i =1 ; i < game.pieces.length; i++) {
piece = game.pieces[i]
space = spaces[i]
@@ -2405,7 +2411,7 @@ function valid_spaces_setup() { valid_spaces_set.add(space.space_id);
}
} else if (game.state === 'dem_init') {
- if (space && space.comInfl === 0) {
+ if (piece.comInfl === 0) {
valid_spaces_set.add(space.space_id);
}
}
@@ -2523,21 +2529,23 @@ function valid_spaces_infl() { for (let i = 1; i < game.pieces.length; i++) {
piece = game.pieces[i]
space = spaces[i]
- //console.log('checking piece:', piece)
+ console.log('checking piece:', space.name_unique)
let player_influence = game.active === COM ? piece.comInfl : piece.demInfl;
// If the piece has the player's influence, add it and its adjacent spaces to the set
if (player_influence > 0) {
- //console.log(piece, 'added to set')
+ console.log(space.name_unique, 'added to set')
valid_spaces_set.add(space.space_id);
// Check adjacency information
- for (let adj_space_id of space.adjacent) {
+ let adjacent_spaces = get_adjusted_adjacency(space.space_id)
+
+ for (let adj_space_id of adjacent_spaces) {
console.log('adj_space_id', adj_space_id)
if (adj_space_id) {
console.log('checking adjacent space', spaces[adj_space_id].name_unique)
const adj_piece = spaces[adj_space_id];
- console.log('adjacent piece', adj_piece)
+ console.log('adjacent piece name', adj_piece.name_unique)
// Check if the adjacent space is controlled by the opponent
const opponent_control = check_opp_control(adj_piece.space_id)
@@ -2546,13 +2554,13 @@ function valid_spaces_infl() { //Check for Genscher. Can always place in East Germany even with 1 op
if (game.active === DEM && adj_piece.country === 'East_Germany' && game.persistent_events['genscher']){
- //console.log('space added with genscher')
+ console.log('space added with genscher')
valid_spaces_set.add(adj_piece.space_id)
}
// Otherwise, only add the adjacent space if the available_ops >= 2 or the space is not controlled by the opponent
if (ops >= 2 || !opponent_control) {
- //console.log('space added normally')
+ console.log('space added normally')
valid_spaces_set.add(adj_piece.space_id)
}
}
@@ -2601,18 +2609,23 @@ function do_valid_cards() { }
function count_adj(name_unique) {
- const space = game.pieces[find_space_index(name_unique)]
+ const space = spaces[find_space_index(name_unique)]
let dem_adj = 0
let com_adj = 0
- for (let adj_space_id of space.adjacent) {
+ let adjacent_spaces = get_adjusted_adjacency(space.space_id)
+
+ for (let adj_space_id of adjacent_spaces) {
if (adj_space_id) {
- const adj_piece = game.pieces.find(piece => piece && piece.space_id === adj_space_id);
- if (adj_piece) {
- if (adj_piece.demCtrl === 1) {
+ const adj_piece = spaces.find(piece => piece && piece.space_id === adj_space_id);
+ console.log('adj_piece.space_id', adj_piece.space_id, 'space', space)
+ if (adj_piece && adj_piece.space_id !== space.space_id) {
+ if (check_dem_control(adj_piece.space_id)) {
+ console.log('added DEM space', spaces[adj_piece.space_id].name)
dem_adj++
}
- if (adj_piece.comCtrl === 1) {
+ if (check_com_control(adj_piece.space_id)) {
+ console.log('added COM space', spaces[adj_piece.space_id].name)
com_adj++
}
}
@@ -3327,7 +3340,7 @@ function new_turn() { if (game.persistent_events['presidential_visit']) {
game.com_hand_limit = 7
log('Communist draws 7 cards due to Presidential Visit')
- permanently_remove(65)
+ //permanently_remove(65)
game.persistent_events['presidential_visit'] = false
}
console.log('deck', game.strategy_deck)
@@ -3591,8 +3604,8 @@ function check_control_change(space_id) { }
}
-function check_systematisation() {
- // Check for Systematisation - may not use this space
+function check_systematization() {
+ // Check for Systematization - may not use this space
if (game.persistent_events['systematization'] > 0) {
game.valid_spaces = game.valid_spaces.filter(n => n !== game.persistent_events['systematization'])
}
@@ -3969,8 +3982,8 @@ function vm_valid_spaces() { game.valid_spaces = [space_1, space_2, space_3, space_4, space_5, space_6]
game.valid_spaces = game.valid_spaces.filter( n => n )
- // Check for Systematisation - may not use this space
- check_systematisation()
+ // Check for Systematization - may not use this space
+ check_systematization()
vm_next()
}
@@ -4007,7 +4020,7 @@ function vm_valid_spaces_socio () { }
game.valid_spaces = valid_spaces
- // Check for Systematisation - may not use this space
+ // Check for Systematization - may not use this space
if (game.persistent_events['systematization'] > 0) {
game.valid_spaces = game.valid_spaces.filter(n => n !== game.persistent_events['systematization'])
}
@@ -4031,7 +4044,7 @@ function vm_valid_spaces_opponent_socio () { }
}
game.valid_spaces = valid_spaces
- // Check for Systematisation - may not use this space
+ // Check for Systematization - may not use this space
if (game.persistent_events['systematization'] > 0) {
game.valid_spaces = game.valid_spaces.filter(n => n !== game.persistent_events['systematization'])
}
@@ -4048,7 +4061,7 @@ function vm_valid_spaces_country () { game.valid_spaces.push(space.space_id);
}
}
- // Check for Systematisation - may not use this space
+ // Check for Systematization - may not use this space
if (game.persistent_events['systematization'] > 0) {
game.valid_spaces = game.valid_spaces.filter(n => n !== game.persistent_events['systematization'])
}
@@ -4800,14 +4813,40 @@ function vm_eliminate(space_id) { // 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 Bucuresti`)
+ if (game.pieces[space_id].comInfl > 0 ) {
+ log(`${game.pieces[space_id].comInfl} Communist SP 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)
+}
+
+function get_adjusted_adjacency(space_id) {
+ let adjacent_spaces = spaces[space_id].adjacent;
+ if (adjacent_spaces.includes(game.persistent_events['systematization'])) {
+ console.log('in get adjusted adjacency, systemization',game.persistent_events['systematization'])
+ console.log('adjacent_spaces', adjacent_spaces)
}
+ if (game.persistent_events['systematization'] !== 0) {
+ console.log('in systematization check')
+ let eliminated_space_id = game.persistent_events['systematization'];
+
+ return adjacent_spaces.map(adj_space_id => {
+ if (adj_space_id === eliminated_space_id) {
+ // Replace the eliminated space with its adjacencies
+ console.log('in map check, return', spaces[eliminated_space_id].adjacent)
+ return spaces[eliminated_space_id].adjacent;
+ }
+ console.log('2nd check, return', adj_space_id)
+ return adj_space_id;
+ }).flat(); // Flatten in case the eliminated space has multiple adjacencies
+ }
+ console.log('final adjacent spaces', adjacent_spaces)
+ return adjacent_spaces;
+}
function vm_exit_visas() {
game.state = 'vm_exit_visas'
@@ -5134,8 +5173,10 @@ function vm_presidential_visit() { function vm_prudence() {
if (game.active === DEM) {
game.persistent_events['prudence'].COM --
- } else {game.persistent_events['prudence'].DEM --}
- log_msg_gap('C8 in effect')
+ log(`${game.persistent_events['prudence'].COM} to Communist ops this turn`)
+ } else {
+ game.persistent_events['prudence'].DEM --
+ log(`${game.persistent_events['prudence'].DEM} to Democrat ops this turn`)}
vm_next()
}
@@ -5594,7 +5635,12 @@ states.vm_remove_infl = { inactive: 'remove influence.',
prompt () {
// Keep this so that there is an undo option in, e.g., Scare Tactics
- if (game.vm_available_ops === 0 || game.valid_spaces.length === 0) {
+ if (game.valid_spaces.length === 0 && game.vm_available_ops > 0) {
+ view.prompt = `${clean_name(cards[this_card()].name)}: no further influence to remove.`
+ gen_action('done')
+ return
+ }
+ if (game.vm_available_ops === 0 ) {
view.prompt = `${clean_name(cards[this_card()].name)}. Remove influence: done.`
gen_action('done')
return
@@ -5782,7 +5828,7 @@ states.vm_1_support_check_prep = { view.prompt = `${clean_name(cards[this_card()].name)}. Support check: done.`
gen_action('done')
} else if (game.valid_spaces.length === 0) {
- view.prompt = `${clean_name(cards[this_card()].name)}.No valid targets for support check.`
+ view.prompt = `${clean_name(cards[this_card()].name)}: no valid targets for support check.`
gen_action('done')
} else {
view.prompt = `${clean_name(cards[this_card()].name)}: ${event_prompt()}.`
|