diff options
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) { |