diff --git a/exercises/06_games/cards/cards.js b/exercises/06_games/cards/cards.js index f9b78de..4476ad2 100644 --- a/exercises/06_games/cards/cards.js +++ b/exercises/06_games/cards/cards.js @@ -1,9 +1,20 @@ + +const deck = [] + +export async function gameSetup() { + // get the card data + const deckResponse = await fetch('deck.json') + let { cards } = await deckResponse.json() + for(const card of cards) deck.push(card) // add each card to the deck + buildDeck(cards, 'game') +} + /** * Builds the deck of cards on the screen * @param {Array} cards the cards to add to the deck * @param {String} element the id of the containing div */ -export function buildDeck(cards, element) { +function buildDeck(cards, element) { const startLeft = 0.85 const top = 0.6 // const startZ = 10 @@ -14,7 +25,6 @@ export function buildDeck(cards, element) { for(const index in cards) addCard(index) // add event handler for the last card only const topCard = document.querySelector(`img[style*="z-index: ${document.getElementById('game').dataset.zindex};"]`) - // console.log(topCard.id) topCard.addEventListener('click', cardOnClick) topCard.style.cursor = 'pointer' } diff --git a/exercises/06_games/cards/game.js b/exercises/06_games/cards/game.js index 13f804e..9ba4d10 100644 --- a/exercises/06_games/cards/game.js +++ b/exercises/06_games/cards/game.js @@ -3,7 +3,7 @@ const deck = [] -let stackOrder = 10 // each card we click needs to be placed at the top +// let stackOrder = 10 // each card we click needs to be placed at the top let angle = -20 gameSetup() diff --git a/exercises/06_games/cards/index.html b/exercises/06_games/cards/index.html index b44f2b6..2c4050f 100644 --- a/exercises/06_games/cards/index.html +++ b/exercises/06_games/cards/index.html @@ -8,7 +8,6 @@ - @@ -18,5 +17,9 @@

score 0

- +