From 8379a9f203f7947f70cfaaa2452bd487569b1955 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Tue, 1 Oct 2024 13:46:28 +0100 Subject: Added game.summary, reduced game object --- play.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index af7c57a..90eebb2 100644 --- a/play.js +++ b/play.js @@ -13,15 +13,7 @@ const toolbar = document.getElementById('toolbar') const vpMarker = document.getElementById('vp') const counters = document.getElementById('counters') -const countries= [ - null, - "East_Germany", - "Poland", - "Czechoslovakia", - "Hungary", - "Romania", - "Bulgaria" -] +const countries= ['Poland', 'Hungary', 'East_Germany', 'Bulgaria', 'Czechoslovakia', 'Romania'] const aside_events = [ "honecker", @@ -355,21 +347,21 @@ function on_update() { } // UPDATE COUNTRY MARKERS - for (let i = 1; i < countries.length; i++) { + for (let i = 0; i < countries.length; i++) { const country = countries[i]; const marker = document.getElementById(country) const times_held = document.getElementById(`${country}_times_held`) - - if (view.revolutions[country]) { + + if (view.revolutions[find_country_index(country)]) { marker.classList.add('revolution') marker.classList.remove('held') marker.style.display = 'block' times_held.classList.add('outlined_text') - } else if (view.times_held[country] > 0 ) { + } else if (view.times_held[find_country_index(country)] > 0 ) { //console.log('setting ', country) marker.classList.add('held') marker.style.display = 'block' - times_held.innerHTML = view.times_held[country] + times_held.innerHTML = view.times_held[find_country_index(country)] } else {marker.style.display = 'none'} } @@ -621,7 +613,7 @@ if (view.persistent_events['the_tyrant_is_gone'] > 0) { action_button("done", "Done") action_button("undo", "Undo") -console.log('view.persistent_events', view.persistent_events) +console.log('view.revolutions', view.revolutions) } // =========================== LOG FUNCTIONS ============================================== @@ -703,4 +695,8 @@ function check_com_control(demInfl, comInfl, space) { } else{ false} } +function find_country_index(country) { + return countries.indexOf(country) +} + create_ui() -- cgit v1.2.3