diff options
author | iainp5 <iain.pearce.ip@gmail.com> | 2025-01-11 17:37:50 +0000 |
---|---|---|
committer | iainp5 <iain.pearce.ip@gmail.com> | 2025-01-11 17:37:50 +0000 |
commit | d7d9f6890eaf1af9d3a1da2bac6e9f977daa7cc6 (patch) | |
tree | 83ff83683bbb625de3e09d686c47217f210a3670 | |
parent | 0f72001ae4f2c9bfc3d72a1e6d17a9830c55facb (diff) | |
download | 1989-dawn-of-freedom-d7d9f6890eaf1af9d3a1da2bac6e9f977daa7cc6.tar.gz |
Tidy up code
-rw-r--r-- | play.js | 46 |
1 files changed, 0 insertions, 46 deletions
@@ -404,22 +404,6 @@ function create_country(id, name) { ui.countries[id] = e document.getElementById("markers").appendChild(e) } -/* -function create_score_box(id, name) { - let [ x, y, w, h ] = LAYOUT[name] - let xc = Math.round(x + w / 2) - let yc = Math.round(y + h / 2) - - //Create dynamic scoring box - let b = document.createElement("div") - b.className = "box" - b.style.left = xc - 110 + "px" - b.style.top = yc - 76 + "px" - b.id = name - ui.score_box[id] = b - - document.getElementById("markers").appendChild(b) -}*/ const INF_DX = 33 const INF_DY = 10 @@ -536,12 +520,6 @@ function create_ui() { create_country(3, "country_bulgaria") create_country(4, "country_czechoslovakia") create_country(5, "country_romania") - /*create_score_box(0, "box_poland") - create_score_box(1, "box_hungary") - create_score_box(2, "box_east_germany") - create_score_box(3, "box_bulgaria") - create_score_box(4, "box_czechoslovakia") - create_score_box(5, "box_romania")*/ } function layout_turn_marker() { @@ -624,7 +602,6 @@ function layout_vp_marker() { } function layout_country(id) { - // 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) @@ -675,17 +652,13 @@ function layout_inf_markers(cn, one, two, three, v, ctl) { function check_presence(country) { - let dem_spaces = 0 let com_spaces = 0 let dem_battlegrounds = 0 let com_battlegrounds = 0 - //console.log('checking country', country) for (let i = 0; i < spaces.length; i++) { let space = spaces[i] - //console.log('checking space', space.ascii_name, 'space.country', space.country.toLowerCase) if (space.country.toLowerCase() === country) { - //console.log('space', space.ascii_name, 'is in', country) if (check_dem_control(i)) { dem_spaces++ if (space.battleground === 1) @@ -698,12 +671,8 @@ function check_presence(country) { } } } - - // Determine domination let dem_domination = dem_battlegrounds > com_battlegrounds && dem_spaces > com_spaces && dem_spaces - dem_battlegrounds > 0 let com_domination = com_battlegrounds > dem_battlegrounds && com_spaces > dem_spaces && com_spaces - com_battlegrounds > 0 - - // Determine control let total_battlegrounds = battlegrounds(country) let dem_control = dem_battlegrounds === total_battlegrounds && dem_spaces > com_spaces let com_control = com_battlegrounds === total_battlegrounds && com_spaces > dem_spaces @@ -751,7 +720,6 @@ function on_update() { create_ui() // UPDATE PLAYER INFO - if (view.is_pwr_struggle) { roles.Democrat.stat.textContent = `${pluralize(view.democrat_power_hand, 'Power card')}` roles.Communist.stat.textContent = `${pluralize(view.communist_power_hand, 'Power card')}` @@ -763,7 +731,6 @@ function on_update() { ui.turn_info.innerText = `Strategy deck: ${pluralize(view.strategy_deck, 'card')}` // UPDATE TRACK MARKERS - layout_turn_marker() layout_round_marker() layout_stability_marker() @@ -772,7 +739,6 @@ function on_update() { layout_tst_marker(ui.com_tst, view.com_tst, 1) // UPDATE EVENT MARKERS ON THE BOARD - if (view.persistent_events.includes(C_SOLIDARITY_LEGALIZED)) ui.events[C_SOLIDARITY_LEGALIZED].style.display = "block" else @@ -800,14 +766,12 @@ function on_update() { } // EVENT REMINDER LIST - ui.event_reminder_list.replaceChildren() for (let id of box_events) if (view.persistent_events.includes(id)) ui.event_reminder_list.appendChild(ui.events[id]) // UPDATE INFLUENCE VALUES - for (let s = 0; s <= last_space; ++s) { const demInfl = view.demInfl[s] const comInfl = view.comInfl[s] @@ -830,14 +794,11 @@ function on_update() { } // UPDATE COUNTRY MARKERS - for (let i = 0; i < 6; ++i) { layout_country(i) - /*layout_score_box(i)*/ } // UPDATE CARD DISPLAYS - ui.samizdat_card.replaceChildren() if (view.samizdat > 0) ui.samizdat_card.appendChild(ui.cards[view.samizdat]) @@ -919,7 +880,6 @@ function on_update() { action_button("hungary", "Hungary") action_button("romania", "Romania") action_button("bulgaria", "Bulgaria") - action_button("yes", "Yes") action_button("no", "No") action_button("start", "Start") @@ -952,7 +912,6 @@ function on_update() { action_button("opp_event", "Opponent's Event") action_button("influence", "Support Points") action_button("support_check", "Support Checks") - //action_button("tst", "Tiananmen Square Attempt") action_button("tst", "Tiananmen Attempt") action_button("roll", "Roll") action_button("done", "Done") @@ -1027,8 +986,6 @@ const die = { function on_log(text, ix) { let p = document.createElement("div") - - //console.log('text', text) let event_string = text.match(/^C(\d+)/) if (event_string) event_n = parseInt(event_string[1]) @@ -1135,16 +1092,13 @@ function on_log(text, ix) { event_side = "both" text = text.replace(".N", "") } - if (log_event && text === "") { log_event = 0 event_side = null } - if (log_event) p.classList.add("group", "event", event_side) } - p.innerHTML = text return p } |