diff options
author | Florrie <towerofnix@gmail.com> | 2019-01-17 12:16:16 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-01-17 12:16:16 -0400 |
commit | 39bb19de91169cc22a3ce9c4f273e614e9c601f6 (patch) | |
tree | 8e93c1f6b54cc458c4f6826786dc4fd66d617174 /main.js | |
parent | 5d6fb747d811e20f690c951f88ed303915fe69ee (diff) |
Dummy mode picker
No actual game modes yet.
Diffstat (limited to 'main.js')
-rw-r--r-- | main.js | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/main.js b/main.js index dc5d398..62eb5b0 100644 --- a/main.js +++ b/main.js @@ -9,6 +9,9 @@ * * - pick __ HARD __ selections of choices, not just totally random ones * + * - time trial - guess as many as you can in 30 seconds; options show up + * instantly + * */ // initializy stuff --------------------------------------------------------ooo @@ -285,10 +288,6 @@ function markScorekeeper(cls, character) { async function mainLol() { const testChar = 'Noellef'; - await loadResources(); - - document.body.classList.add('resources-loaded'); - document.body.addEventListener('keydown', evt => { const choiceContainer = document.getElementById('choice-container'); if (!choiceContainer.classList.contains('hide')) { @@ -301,6 +300,8 @@ async function mainLol() { } } else if (event.key === 'ArrowRight') { const el = document.activeElement; + // TODO: don't be specific to choiceContainer, just find the + // next sibling that is an <a> element if (el.parentElement === choiceContainer && el.nextSibling) { el.nextSibling.focus(); } @@ -319,10 +320,39 @@ async function mainLol() { } }); + // pre-game ------------------------------------------------------------... + + let mode; + + const modeLinks = document.querySelectorAll('#mode-picker a[data-mode]'); + const modeParas = document.querySelectorAll('#mode-descriptions p[data-mode]'); + + const pickMode = function(a) { + mode = a.dataset.mode; + for (const el of [...modeLinks, ...modeParas]) { + if (el.dataset.mode === mode) { + el.classList.add('selected'); + } else { + el.classList.remove('selected'); + } + } + }; + + for (const el of modeLinks) { + el.addEventListener('click', evt => pickMode(evt.target)); + } + + pickMode(modeLinks[0]); + modeLinks[0].focus(); + + // you can pick game options before resources are loaded + await loadResources(); + + document.body.classList.add('resources-loaded'); + const gameEl = document.getElementById('game'); const playLink = document.getElementById('play-link'); - playLink.focus(); await waitForEvent(playLink, 'click'); document.body.classList.add('game'); @@ -332,6 +362,8 @@ async function mainLol() { const characterDeck = gameData.characters.filter(chr => chr.games.some(g => deckGames.includes(g))); + // game loop -----------------------------------------------------------nym + setupScorekeeper(characterDeck.length); while (characterDeck.length) { |