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 --- play.js | 6 ++--- rules.js | 77 ++++++++++++++++++++++++++++++++-------------------------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/play.js b/play.js index 0471007..d78cfd4 100644 --- a/play.js +++ b/play.js @@ -624,7 +624,7 @@ function layout_vp_marker() { } function layout_country(id) { - // TODO: what number to display? + // TODO: what number to display? if (view.revolutions[id]) ui.countries[id].className = "marker demInfl ctl v" + view.times_held[id] else if (view.times_held[id] > 0) @@ -992,7 +992,7 @@ function sub_icon(match) { return ICONS[match] || match } -function sub_arrow(match) { +function sub_arrow(_match) { return ' → ' } @@ -1122,7 +1122,7 @@ function on_log(text, ix) { log_event = 0 } -//Group events + // Group events // Reset group box counters (when log is rewound) if (ix <= log_event) log_event = 0 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(-) 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(-) 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 From 22f2de3e25c082aa16a8d741f6457af9cf59bb68 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 3 Jan 2025 22:44:19 +0100 Subject: put influence change in margin --- play.css | 17 ++++++++++++++++- play.js | 12 +++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/play.css b/play.css index aaf8abf..7e63f9f 100644 --- a/play.css +++ b/play.css @@ -41,6 +41,21 @@ body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } #log .h2 { background-color: wheat } #log .h3 { background-color: wheat } +#log .marginalia { + display: block; + float: right; + text-indent: 0; + margin: 0; + margin-right: 6px; + padding: 0; +} + +#log .group .marginalia { + margin-right: 0; +} + +#log > div { clear: right } + #log .h1, .h2, .h3 { font-variant-caps: small-caps; border-top: 1px solid black; @@ -538,4 +553,4 @@ body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } .card.power_50 { background-image: url(cards75/power_50.avif) } .card.power_51 { background-image: url(cards75/power_51.avif) } .card.power_52 { background-image: url(cards75/power_52.avif) } -.card.power_53 { background-image: url(cards75/power_back.avif) } \ No newline at end of file +.card.power_53 { background-image: url(cards75/power_back.avif) } diff --git a/play.js b/play.js index 12470c5..f15659e 100644 --- a/play.js +++ b/play.js @@ -848,11 +848,12 @@ function on_update() { ui.hand.appendChild(ui.cards[c]) ui.power_hand.replaceChildren() - if (view.is_pwr_struggle) + if (view.is_pwr_struggle) { ui.power_hand.appendChild(ui.power_cards[53]) if (view.power_hand.length > 0) for (let c of view.power_hand) ui.power_hand.appendChild(ui.power_cards[c]) + } ui.power_discard.replaceChildren() if (view.power_struggle_discard) @@ -993,14 +994,13 @@ function sub_icon(match) { } function sub_arrow(_match) { - return ' → ' + return " \u2192 " } function wrap_icons(match) { - return `${match}`; + return `${match.replace("(", "").replace(")", "")}` } - const ICONS = { '£CC': '', '£CU': '', @@ -1045,9 +1045,7 @@ function on_log(text, ix) { p.className = "i" } -/* - text = text.replace(/(\(£[CDU][CU]\s\.to\s£[CDU][CU]\))/g, wrap_icons) -*/ + text = text.replace(/(\(£[CDU][CU]\s\.to\s£[CDU][CU]\))/g, wrap_icons) text = text.replace(/_/g, " ") text = text.replace(/C(\d+)/g, sub_card_name) -- cgit v1.2.3 From c3bc265c7eb16cb7ededbd4d11c49fe98c82e2bd Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 3 Jan 2025 22:59:42 +0100 Subject: new log influence icons --- images/icon_com.png | Bin 0 -> 451 bytes images/icon_com.svg | 4 ++++ images/icon_dem.png | Bin 0 -> 929 bytes images/icon_dem.svg | 20 ++++++++++++++++++++ play.css | 24 +++++++++++------------- 5 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 images/icon_com.png create mode 100644 images/icon_com.svg create mode 100644 images/icon_dem.png create mode 100644 images/icon_dem.svg diff --git a/images/icon_com.png b/images/icon_com.png new file mode 100644 index 0000000..047a943 Binary files /dev/null and b/images/icon_com.png differ diff --git a/images/icon_com.svg b/images/icon_com.svg new file mode 100644 index 0000000..709c306 --- /dev/null +++ b/images/icon_com.svg @@ -0,0 +1,4 @@ + + + + diff --git a/images/icon_dem.png b/images/icon_dem.png new file mode 100644 index 0000000..01fdd51 Binary files /dev/null and b/images/icon_dem.png differ diff --git a/images/icon_dem.svg b/images/icon_dem.svg new file mode 100644 index 0000000..31654df --- /dev/null +++ b/images/icon_dem.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/play.css b/play.css index 7e63f9f..891a4bb 100644 --- a/play.css +++ b/play.css @@ -104,26 +104,24 @@ body.Communist header.your_turn { background-color: hsl(355, 70%, 75%); } #log .icon { display: inline-block; vertical-align: -2px; - width: 12px; - height: 12px; - box-shadow: none; - border: none; - background-size: contain; - background-position: center; + background-size: 10px 10px; background-repeat: no-repeat; -} - -#log .icon.number { 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);} +X#log .com_nc { background-image: url(images/icon_com.png) } +X#log .dem_nc { background-image: url(images/icon_dem.png) } + +#log .com_c { background-image: url(images/icon_com.png) } +#log .dem_c { background-image: url(images/icon_dem.png) } + +#log .com_c { background-color: hsl(358, 66%, 45%) } +#log .com_nc { background-color: hsl(358, 66%, 80%) } +#log .dem_c { background-color: #147fc0 } +#log .dem_nc { background-color: #c4e2f6 } /* MAP */ -- cgit v1.2.3