summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2025-01-04 07:10:09 +0000
committeriainp5 <iain.pearce.ip@gmail.com>2025-01-04 07:10:09 +0000
commit2a924526251c6aba437fcb83005947891f02a685 (patch)
treeb773228521ad81e613a6bca09520d096984bab48 /rules.js
parentc9c84bb1b37e23f91959ac10bc4160011d24fdb5 (diff)
parentc3bc265c7eb16cb7ededbd4d11c49fe98c82e2bd (diff)
download1989-dawn-of-freedom-2a924526251c6aba437fcb83005947891f02a685.tar.gz
Tor updates
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js143
1 files changed, 78 insertions, 65 deletions
diff --git a/rules.js b/rules.js
index 064c108..095008b 100644
--- a/rules.js
+++ b/rules.js
@@ -679,7 +679,7 @@ states.play_card = {
view.actions.event = 0
}
}
-
+
// Special 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)) {
@@ -1969,7 +1969,6 @@ states.general_strike_roll = {
},
}
-
states.honecker = {
inactive: 'resolve Honecker',
prompt() {
@@ -2204,10 +2203,10 @@ states.stasi_play_ceh = {
return `play ${quoted_card_name[game.played_card]}`
},
prompt() {
- view.prompt = "Play " + quoted_card_name[game.played_card]
- gen_action('influence')
- gen_action('support_check')
- },
+ view.prompt = 'Play ' + quoted_card_name[game.played_card]
+ gen_action('influence')
+ gen_action('support_check')
+ },
influence() {
push_undo()
log_ops_banner()
@@ -2272,7 +2271,7 @@ function add_infl(space, ops) {
game.demInfl[space]++
}
- let end_control = check_control(space)
+ let end_control = check_control(space)
log_summary('£ in %' + space + get_icons(starting_control,end_control))
check_tyrant()
@@ -2777,7 +2776,7 @@ function check_control(space) {
return 'd_ahead'
else if (game.comInfl[space] > game.demInfl[space])
return 'c_ahead'
- else
+ else
return "none"
}
@@ -2814,9 +2813,9 @@ function get_icons(starting_control, end_control) {
return ' (£UU .to £DC)'
else if (starting_control === 'none' && end_control === COM)
return ' (£UU .to £CC)'
- else
+ else
return ''
- }
+ }
else
return ''
}
@@ -3094,7 +3093,7 @@ function score_country(country) {
if (presence.com_battlegrounds > 0) {
logi(`${presence.com_battlegrounds} VP for Battlegrounds`)
com_vp -= presence.com_battlegrounds
- }
+ }
} else {
logi('0 VP')
}
@@ -3105,7 +3104,7 @@ function score_country(country) {
if (presence.dem_battlegrounds > 0) {
logi(`${presence.dem_battlegrounds} VP for Battlegrounds`)
dem_vp += presence.dem_battlegrounds
- }
+ }
} else {
logi('0 VP')
}
@@ -3242,7 +3241,7 @@ function end_stasi_choose_card() {
if (game.stasi_card === C_COMMON_EUROPEAN_HOME) {
game.state = 'stasi_confirm'
} else {
- end_stasi()
+ end_stasi()
}
}
@@ -3265,7 +3264,7 @@ function end_goddess() {
log_h2("Action Round " + game.round)
if (game.active === DEM) {
change_player()
- }
+ }
if (game.persistent_events.includes(C_GENERAL_STRIKE)) {
game.state = 'general_strike'
} else {
@@ -3875,7 +3874,7 @@ function end_round() {
game.round_player = DEM
if (game.active !== DEM) {
change_player()
- }
+ }
if (game.democrat_hand.includes(game.stasi_card)) {
game.state = 'stasi_play_card'
} else {
@@ -4011,7 +4010,7 @@ function new_turn() {
}
if (game.active === DEM)
log('Democrat:')
- else
+ else
log('Communist:')
game.state = 'tst_goddess'
} else {
@@ -4254,7 +4253,7 @@ function check_systematization() {
if (game.systematization > 0) {
game.valid_spaces = game.valid_spaces.filter(n => n !== game.systematization)
}
-}
+}
function this_card() {
return game.vm_event > 0 ? game.vm_event : game.played_card
@@ -4290,34 +4289,42 @@ function log(msg) {
}
function log_ops_banner() {
+ log_br()
if (game.active === DEM)
log('.O.d')
- else
+ else
log('.O.c')
+ log_br()
finish_select_card()
}
function log_event_banner() {
+ log_br()
if (game.active === DEM)
log('.V.d')
- else
+ else
log('.V.c')
+ log_br()
}
function log_struggle_banner(n) {
+ log_br()
if (game.active === DEM)
log('.S.dC' + n)
else
log('.S.cC' + n)
+ log_br()
}
function log_tst_8_banner() {
+ log_br()
if (game.active === DEM)
log('.T.d')
- else
+ else
log('.T.c')
+ log_br()
finish_select_card()
-}
+}
function log_event(n) {
log_br()
@@ -4326,7 +4333,7 @@ function log_event(n) {
else if (cards[n].side === "D")
game.log.push(".E:C" + n + ".D")
else
- game.log.push(".E:C" + n + ".N")
+ game.log.push(".E:C" + n + ".N")
}
function log_br() {
@@ -4344,15 +4351,21 @@ function logii(msg) {
}
function log_h1(msg) {
+ log_br()
log(".h1 " + msg)
+ log_br()
}
function log_h2(msg) {
+ log_br()
log(".h2 " + msg)
+ log_br()
}
function log_h3(msg) {
+ log_br()
log(".h3 " + msg)
+ log_br()
}
function log_h4(msg) {
@@ -4378,7 +4391,7 @@ function log_msg_gap(msg) {
function logi_msg_gap(msg) {
game.log.push(">" + msg)
log_br()
-}
+}
function log_round() {
log_h2(`Action Round ${game.round}`)
@@ -4436,75 +4449,75 @@ function pop_summary_i() {
function pop_summary_i() {
if (game.summary.length > 0) {
// Create a map to group by space and track totals and details
- let grouped_summary = new Map();
- let c63_logged = false;
- let deferred_logs = [];
+ let grouped_summary = new Map()
+ let c63_logged = false
+ let deferred_logs = []
- for (let [n, msg] of game.summary) {
+ for (let [ n, msg ] of game.summary) {
// Special case: Log C63 only once
- if (msg === "(-1 Op due to C63)") {
+ if (msg === '(-1 Op due to C63)') {
if (!c63_logged) {
- logi(msg);
- c63_logged = true;
+ logi(msg)
+ c63_logged = true
}
- continue;
+ continue
}
// Direct log for messages like C50, C123
if (!/^£/.test(msg)) {
if (msg.includes('VP')) {
- deferred_logs.push(msg);
- } else {
- logi(msg);
- }
+ deferred_logs.push(msg)
+ } else {
+ logi(msg)
+ }
}
// Extract the space identifier (e.g., %33) and type (e.g., "in" or "from")
- let space_match = msg.match(/(in|from) (%\d+)/);
- if (!space_match) continue; // Skip if no valid match
+ let space_match = msg.match(/(in|from) (%\d+)/)
+ if (!space_match)
+ continue // Skip if no valid match
- let type = space_match[1];
- let space = space_match[2];
+ let type = space_match[1]
+ let space = space_match[2]
// Extract additional details (e.g., £DC .to £UU)
- let details_match = msg.match(/\((.*?)\)$/);
- let details = details_match ? details_match[1] : "";
+ let details_match = msg.match(/\((.*?)\)$/)
+ let details = details_match ? details_match[1] : ''
// Split the details into "start" and "end" parts
- let [start, end] = details.split(" .to ");
+ let [ start, end ] = details.split(' .to ')
// Group by type and space
- let key = `${type} ${space}`;
+ let key = `${type} ${space}`
if (!grouped_summary.has(key)) {
- grouped_summary.set(key, { total: 0, start: "", end: "" });
+ grouped_summary.set(key, { total: 0, start: '', end: '' })
}
- let entry = grouped_summary.get(key);
- entry.total += n;
+ let entry = grouped_summary.get(key)
+ entry.total += n
// Update the start only if it's not already set
if (start && !entry.start) {
- entry.start = start;
+ entry.start = start
}
// Always update the end with the most recent value
if (end) {
- entry.end = end;
+ entry.end = end
}
}
// Log the grouped results
- for (let [key, { total, start, end }] of grouped_summary) {
- let details = start && end ? ` (${start} .to ${end})` : "";
- logi(`${total} ${key}${details}`);
+ for (let [ key, { total, start, end } ] of grouped_summary) {
+ let details = start && end ? ` (${start} .to ${end})` : ''
+ logi(`${total} ${key}${details}`)
}
for (let msg of deferred_logs) {
- logi(msg);
- }
+ logi(msg)
+ }
}
- game.summary = [];
-}
-
+ game.summary = []
+}
function do_log_summary() {
if (game.summary.length > 0) {
@@ -4702,7 +4715,7 @@ function vm_return() {
delete game.vm_max_infl
delete game.vm_influence_added
delete game.communist_hand_red
- game.vm_event = 0
+ game.vm_event = 0
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
reset_austria_hungary_border_reopened()
}
@@ -4956,7 +4969,7 @@ function vm_take_control(space) {
let end_control = check_control(space)
if (game.state === 'vm_kremlin_coup_take_control')
logi('Took control of %' + space + get_icons(starting_control, end_control) +'.')
- else
+ else
log('Took control of %' + space + get_icons(starting_control, end_control) +'.')
}
@@ -4991,7 +5004,7 @@ function vm_add_infl_free() {
function vm_add_x_infl() {
game.vm_available_ops = vm_operand(1)
- if (!(game.vm_event === C_PUBLIC_AGAINST_VIOLENCE &&
+ if (!(game.vm_event === C_PUBLIC_AGAINST_VIOLENCE &&
event_prompt() === 'Presov'))
log('Placed SP:')
game.state = 'vm_add_x_infl'
@@ -5000,7 +5013,7 @@ function vm_add_x_infl() {
function vm_do_add_x_infl(space) {
push_undo()
let starting_control = check_control(space)
-
+
if (game.active === COM) {
game.comInfl[space] += game.vm_available_ops
} else {
@@ -5350,7 +5363,7 @@ function vm_ceausescu_prep() {
function vm_ceausescu() {
game.persistent_events = game.persistent_events.filter(n => n!== C_CEAUSESCU)
let adj_cluj = false
-
+
if (game.demInfl[S_TIMISOARA] > 0) {
adj_cluj = true
}
@@ -6437,7 +6450,7 @@ states.vm_remove_infl = {
else {
if (game.vm_event === C_CEAUSESCU)
prompt_event(`${event_prompt()}.`)
- else
+ else
prompt_event(`Remove ${pluralize(game.vm_available_ops,'SP')}${event_prompt()}.`)
}
for (let space_id of game.valid_spaces) {
@@ -6897,7 +6910,7 @@ states.vm_common_european_home_play = {
game.state = 'vm_ceh_support_check_prep'
valid_spaces_sc()
},
- tst() {
+ tst() {
push_undo()
log_gap(`Played C${game.vm_event} to the Tiananmen Square Track`)
game.state = 'vm_tiananmen_square_attempt'
@@ -8191,7 +8204,7 @@ states.vm_we_are_the_people_remove = {
space(space) {
remove_infl(space, 'vm_available_ops')
if (game.vm_influence_added[S_LUTHERAN_CHURCH] === 4 ||
- game.valid_spaces.length === 0
+ game.valid_spaces.length === 0
) {
do_log_summary()
finish_we_are_the_people()
@@ -8383,7 +8396,7 @@ states.vm_tst_6 = {
if (game.active === DEM)
log('Democrat free 2 Ops support check.')
else
- log('Communist free 2 Ops support check.')
+ log('Communist free 2 Ops support check.')
game.selected_space = space
if (
game.active === DEM &&