<script>
import SingleCard from './SingleCard.svelte'
let imgCover = 'https://raw.githubusercontent.com/iamshaunjp/React-Firebase/lesson-58/magic-memory/public/img/cover.png'
let imgHelmet = 'https://raw.githubusercontent.com/iamshaunjp/React-Firebase/lesson-58/magic-memory/public/img/helmet-1.png'
let imgPotion = 'https://raw.githubusercontent.com/iamshaunjp/React-Firebase/lesson-58/magic-memory/public/img/potion-1.png'
let imgRing = 'https://raw.githubusercontent.com/iamshaunjp/React-Firebase/lesson-58/magic-memory/public/img/ring-1.png'
let imgScroll = 'https://raw.githubusercontent.com/iamshaunjp/React-Firebase/lesson-58/magic-memory/public/img/scroll-1.png'
let imgShield = 'https://raw.githubusercontent.com/iamshaunjp/React-Firebase/lesson-58/magic-memory/public/img/shield-1.png'
let imgSword = 'https://raw.githubusercontent.com/iamshaunjp/React-Firebase/lesson-58/magic-memory/public/img/sword-1.png'
const cardImages = [
{ src: imgHelmet, matched: false },
{ src: imgPotion, matched: false },
{ src: imgRing, matched: false },
{ src: imgScroll, matched: false },
{ src: imgShield, matched: false },
{ src: imgSword, matched: false },
]
let cards = []
let turns = 0
let choiceOne = null
let choiceTwo = null
let disabled = false
// shuffle cards
const shuffledCards = () => {
const shuffledCards = [...cardImages, ...cardImages]
.sort(() => Math.random() - 0.5)
.map((card) => ({ ...card, id: Math.random()}))
cards = shuffledCards
turns = 0
}
// handle a choice