From f321c249f5b9b4f8abc4f519a3666cdda94fad7a Mon Sep 17 00:00:00 2001 From: Frans Bongers Date: Sun, 22 Dec 2024 22:15:57 +0100 Subject: use medallions --- play.js | 70 +++++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 28 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index 1ff8d8d..fa7dcb4 100644 --- a/play.js +++ b/play.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const BONUSES_COUNT = 2; const CARD_COUNT = 109; const GLORY_COUNT = 9; -const MEDAILLONS_COUNT = 5; +const medallionS_COUNT = 9; const STANDEES_COUNT = 5; const TRACK_COUNT = 5; const TRACK_LENGTH = 11; @@ -11,6 +11,7 @@ const FACTIONS = ['a', 'c', 'm']; console.log('roles', document.getElementById('roles')); const ui = { map: document.getElementById('map'), + medallions_container: document.getElementById('medallions'), markers: document.getElementById('markers'), fronts: { a: { @@ -37,15 +38,18 @@ const ui = { glory_container: document.getElementById('glory'), hand: document.getElementById('hand'), current_events: document.getElementById('current_events'), - stats: { + roles: { a: { hero_points: document.querySelector('#role_Anarchist .role_stat'), + medallions: document.querySelector('#role_Anarchist .role_medallions'), }, c: { hero_points: document.querySelector('#role_Communist .role_stat'), + medallions: document.querySelector('#role_Communist .role_medallions'), }, m: { hero_points: document.querySelector('#role_Moderate .role_stat'), + medallions: document.querySelector('#role_Moderate .role_medallions'), }, pool: { hero_points: document.getElementById('pool_hero_points'), @@ -59,11 +63,11 @@ const ui = { tracks: document.getElementById('tracks'), hero_points: document.querySelector('#role_Anarchist .role_stat'), year: document.getElementById('year'), - blank_markers: [[], [], [], [], []], + blank_markers: [], bonuses: [], tokens_on_front: {}, glory: [], - medaillons: [], + medallions: [], spaces: [], standees: [], pieces: [], @@ -91,7 +95,7 @@ const LAYOUT_GLORY = [ [885, 771], [922, 771], ]; -const LAYOUT_MEDAILLONS = [ +const LAYOUT_medallionS = [ [364, 556], [415, 556], [466, 556], @@ -191,11 +195,10 @@ function on_init() { if (on_init_once) return; on_init_once = true; - console.log('ui', ui); - console.log('document', document); - for (let t = 0; t < 5; ++t) { - for (let bm = 0; bm < TRACK_LENGTH; ++bm) { - let e = (ui.blank_markers[t][bm] = document.createElement('div')); + for (let t = 0; t < TRACK_COUNT; ++t) { + for (let s = 0; s < TRACK_LENGTH; ++s) { + const bm = t * 11 + s; + let e = (ui.blank_markers[bm] = document.createElement('div')); e.className = 'blank_marker'; register_action(e, 'blank_marker', bm); } @@ -217,12 +220,11 @@ function on_init() { e.style.left = LAYOUT_GLORY[g][0] + 'px'; e.style.top = LAYOUT_GLORY[g][1] + 'px'; } - for (let m = 0; m < MEDAILLONS_COUNT; ++m) { - let e = (ui.medaillons[m] = document.createElement('div')); - e.className = 'medaillon'; - e.setAttribute('data-medaillon-id', '' + m); - register_action(e, 'medaillon', m); - ui.map.appendChild(ui.medaillons[m]); + for (let m = 0; m < medallionS_COUNT; ++m) { + let e = (ui.medallions[m] = document.createElement('div')); + e.className = 'medallion'; + e.setAttribute('data-medallion-id', '' + m); + register_action(e, 'medallion', m); } for (let s = 0; s < STANDEES_COUNT; ++s) { let e = (ui.standees[s] = document.createElement('div')); @@ -254,7 +256,7 @@ function on_update() { console.log('on_update', view); on_init(); for (let key of Object.keys(view.hero_points)) { - ui.stats[key].hero_points.replaceChildren(`Hero Points: ${view.hero_points[key]}`); + ui.roles[key].hero_points.replaceChildren(`Hero Points: ${view.hero_points[key]}`); } ui.current_events.replaceChildren(); for (let i = 0; i < view.current_events.length; i++) { @@ -265,12 +267,12 @@ function on_update() { ui.cards[cardId].style.top = LAYOUT_CURRENT_EVENTS[i][1] + 'px'; } ui.markers.replaceChildren(); - for (let t = 0; t < TRACK_COUNT; ++t) { - for (let bm of view.triggered_track_effects[t]) { - ui.markers.appendChild(ui.blank_markers[t][bm]); - ui.blank_markers[t][bm].style.left = LAYOUT_TRACKS[t][bm][0] + 'px'; - ui.blank_markers[t][bm].style.top = LAYOUT_TRACKS[t][bm][1] + 'px'; - } + for (let bm of view.triggered_track_effects) { + const s = bm % 11; + const t = Math.floor(bm / 11); + ui.markers.appendChild(ui.blank_markers[bm]); + ui.blank_markers[bm].style.left = LAYOUT_TRACKS[t][s][0] + 'px'; + ui.blank_markers[bm].style.top = LAYOUT_TRACKS[t][s][1] + 'px'; } for (let bonus_id of Object.keys(view.bonuses)) { ui.bonuses[bonus_id].setAttribute('data-bonus-on', view.bonuses[bonus_id] + 0); @@ -295,10 +297,19 @@ function on_update() { ui.fronts[front_id].contributions.appendChild(ui.tokens_on_front[front_id][faction_id]); } } - for (let i = 0; i < view.medaillons.length; ++i) { - if (view.medaillons[i] !== null) { - ui.medaillons[i].style.left = LAYOUT_MEDAILLONS[i][0] + 'px'; - ui.medaillons[i].style.top = LAYOUT_MEDAILLONS[i][1] + 'px'; + ui.medallions_container.replaceChildren(); + for (let i = 0; i < view.medallions.pool.length; ++i) { + if (view.medallions.pool[i] !== null) { + const id = view.medallions.pool[i]; + ui.medallions[id].style.left = LAYOUT_medallionS[i][0] + 'px'; + ui.medallions[id].style.top = LAYOUT_medallionS[i][1] + 'px'; + ui.medallions_container.appendChild(ui.medallions[id]); + } + } + for (let f of FACTIONS) { + ui.roles[f].medallions.replaceChildren(); + for (let m of view.medallions[f]) { + ui.roles[f].medallions.appendChild(ui.medallions[m]); } } for (let faction_id of FACTIONS) { @@ -339,6 +350,9 @@ function on_update() { action_button('up', 'Up'); action_button('down', 'Down'); action_button('next', 'Next'); + action_button('remove_blank_marker', 'Remove Blank marker'); + action_button('yes', 'Yes'); + action_button('no', 'No'); action_button('skip', 'Skip'); action_button('done', 'Done'); action_button('undo', 'Undo'); @@ -347,7 +361,7 @@ function on_log(text) { let p = document.createElement('div'); if (text.match(/^>>/)) { text = text.substring(2); - p.className = "ii"; + p.className = 'ii'; } if (text.match(/^>/)) { text = text.substring(1); -- cgit v1.2.3