From 5f8f49869a62ce92baf91a75723227ee7afca7d9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 2 Jan 2025 17:39:48 +0100 Subject: fix indentation and semicolons --- rules.js | 77 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 064c108..8a06fbb 100644 --- a/rules.js +++ b/rules.js @@ -2204,10 +2204,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() @@ -4326,7 +4326,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() { @@ -4436,74 +4436,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() { @@ -8383,7 +8384,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 && -- cgit v1.2.3 From 754be4bf07ba910b3e5417db6729d4e1a6e84925 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 2 Jan 2025 17:40:13 +0100 Subject: remove trailing whitespace --- rules.js | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 8a06fbb..b78c137 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() { @@ -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 @@ -4292,7 +4291,7 @@ function log(msg) { function log_ops_banner() { if (game.active === DEM) log('.O.d') - else + else log('.O.c') finish_select_card() } @@ -4300,7 +4299,7 @@ function log_ops_banner() { function log_event_banner() { if (game.active === DEM) log('.V.d') - else + else log('.V.c') } @@ -4314,10 +4313,10 @@ function log_struggle_banner(n) { function log_tst_8_banner() { if (game.active === DEM) log('.T.d') - else + else log('.T.c') finish_select_card() -} +} function log_event(n) { log_br() @@ -4378,7 +4377,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}`) @@ -4506,7 +4505,6 @@ function pop_summary_i() { game.summary = [] } - function do_log_summary() { if (game.summary.length > 0) { pop_summary_i() @@ -4703,7 +4701,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() } @@ -4957,7 +4955,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) +'.') } @@ -4992,7 +4990,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' @@ -5001,7 +4999,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 { @@ -5351,7 +5349,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 } @@ -6438,7 +6436,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) { @@ -6898,7 +6896,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' @@ -8192,7 +8190,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() -- cgit v1.2.3 From d25d7e33e2ff1260a607c49a7e0a0ffaf3e03221 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 2 Jan 2025 20:30:46 +0100 Subject: tweak logging --- play.css | 38 ++++++++++++++++++-------------------- play.js | 2 +- rules.js | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 21 deletions(-) (limited to 'rules.js') diff --git a/play.css b/play.css index afee2c4..aaf8abf 100644 --- a/play.css +++ b/play.css @@ -37,39 +37,38 @@ body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } #log .h5 { text-decoration: underline; } #log { background-color: floralwhite } -#log .h1 { background-color: tan ;} +#log .h1 { background-color: tan } #log .h2 { background-color: wheat } #log .h3 { background-color: wheat } -#log .h1, .h2:not(.group), .h3 { - text-transform: uppercase; +#log .h1, .h2, .h3 { + font-variant-caps: small-caps; border-top: 1px solid black; border-bottom: 1px solid black; - font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; } -#log .h2:not(.group).dem { - font-size: 10px; - background-color: hsl(206, 85%, 80%); border-top: 1px solid hsl(206, 85%, 25%); border-bottom: 1px solid hsl(206, 85%, 25%);} -#log .h2:not(.group).com { - font-size: 10px; - background-color: hsl(355, 70%, 80%); - border-top: 1px solid hsl(355, 70%, 25%); +#log .h2.dem { + background-color: hsl(206, 85%, 80%); + border-top: 1px solid hsl(206, 85%, 25%); + border-bottom: 1px solid hsl(206, 85%, 25%); +} +#log .h2.com { + background-color: hsl(355, 70%, 80%); + border-top: 1px solid hsl(355, 70%, 25%); border-bottom: 1px solid hsl(355, 70%, 25%); } #log .group.dem { background-color: hsl(206, 85%, 90%); } #log .group.com { background-color: hsl(355, 70%, 90%); } #log .group.both { background-color: gainsboro; } -#log .h1, #log .h2, #log .h3 { margin: 6px 0; } - -#log .group {margin: 0 6px} +#log .group { margin: 0 6px; } +#log .header.group.dem { background-color: hsl(206, 85%, 85%); } +#log .header.group.com { background-color: hsl(355, 70%, 85%); } #log div { padding-left: 20px; text-indent: -12px; } #log div.i { padding-left: 32px; text-indent: -12px; } #log div.ii { padding-left: 44px; text-indent: -12px; } #log .card_name { font-style: italic; } -#log div.h2 .card_name { font-style: normal; } #log .card_name:hover { text-decoration: underline; } #log .space_tip:hover { cursor: pointer; text-decoration: underline; } @@ -100,18 +99,17 @@ body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } } #log .icon.number { - background-color: white; + background-color: white; border: 1px solid #444; width: 10px; height: 10px; -} +} #log .com_nc { background-image: url(images/SVd_blank.gif);} #log .com_c {background-image: url(images/SV_blank.gif);} #log .dem_nc { background-image: url(images/USd_blank.gif);} #log .dem_c {background-image: url(images/favicon_dem.svg);} - /* MAP */ #mapwrap { @@ -179,7 +177,7 @@ body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } height: 15px; width: 100px; } - + .box.d_pres { background: linear-gradient(to right, rgba(0, 0, 255, 0.75) 0%, rgba(0, 0, 255, 0.75) 20%, transparent 20%, transparent 100%); } .box.c_pres { background: linear-gradient(to right, transparent 0%, transparent 80%,rgba(255, 0, 0, 0.75) 80%, rgba(255, 0, 0, 0.75) 100%); } @@ -197,7 +195,7 @@ body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } .box.c_pres.c_dom { background: linear-gradient(to right, transparent 50%, rgba(255, 0, 0, 0.75) 50%, rgba(255, 0, 0, 0.75) 100%); } .box.d_pres.c_pres.c_dom { background: linear-gradient(to right, rgba(0, 0, 255, 0.75) 0%, rgba(0, 0, 255, 0.75) 20%, transparent 20%, transparent 50%, rgba(255, 0, 0, 0.75) 50%, rgba(255, 0, 0, 0.75) 100%); } - + .box.c_pres.c_ctrl { background: linear-gradient(to right, transparent 20%, rgba(255, 0, 0, 0.75) 20%, rgba(255, 0, 0, 0.75) 100%); } .box.d_pres.c_pres.c_ctrl { background: linear-gradient(to right, rgba(0, 0, 255, 0.75) 0%, rgba(0, 0, 255, 0.75) 20%, transparent 20%, rgba(255, 0, 0, 0.75) 20%, rgba(255, 0, 0, 0.75) 100%); } diff --git a/play.js b/play.js index d78cfd4..12470c5 100644 --- a/play.js +++ b/play.js @@ -1128,7 +1128,7 @@ function on_log(text, ix) { if (!scoring_cards.includes(event_n)) { if (text.match(/^.E:/)) { - p.classList.add("h2") + p.classList.add("header") log_event = ix text = text.replace(".E:", "") } diff --git a/rules.js b/rules.js index b78c137..095008b 100644 --- a/rules.js +++ b/rules.js @@ -4289,32 +4289,40 @@ function log(msg) { } function log_ops_banner() { + log_br() if (game.active === DEM) log('.O.d') else log('.O.c') + log_br() finish_select_card() } function log_event_banner() { + log_br() if (game.active === DEM) log('.V.d') 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 log('.T.c') + log_br() finish_select_card() } @@ -4343,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) { -- cgit v1.2.3