E Rekenaargeletterdheidvasvrae en -speletjies

Digital Literacy Go Fish

♠ Digital Literacy Go Fish ♥

A classic card game with a smart-tech twist

🧑 Your books: 0 🤖 Computer books: 0 🃏 Cards left: 52
🤖 Computer’s hand (7 cards)
✦
Draw pile
38 cards
Lumi the learning lamp
Your hand (7 cards) — choose a rank to ask for
Welcome! Select a card in your hand, then ask the computer for that rank. First, answer a digital literacy question correctly!

How to play: Collect four cards of the same rank to make a book. On your turn, select a rank you hold. Lumi asks a digital literacy question; answer correctly to make your request. If the computer has that rank, you get its cards and another turn. If not, go fish! The computer takes its turn after yours.

Digital Literacy Go Fish · Learn a little with every turn
'; let s=suits[card.suit]; return `
${card.rank}
${s.s}
${s.s} ${card.rank}
${s.s}
`; } function render() { $('cpuHand').innerHTML=cpu.map(()=>cardHTML(null,true)).join(''); $('playerHand').innerHTML=player.map((c,i)=>{ let s=suits[c.suit]; return `
${c.rank}
${s.s}
${s.s} ${c.rank}
${s.s}
`; }).join(''); $('yourCount').textContent=`(${player.length} cards)`; $('cpuCount').textContent=`(${cpu.length} cards)`; $('yourBooks').textContent=books.player; $('cpuBooks').textContent=books.cpu; $('deckCount').textContent=deck.length; $('remaining').textContent=deck.length+player.length+cpu.length; $('askBtn').disabled=!selected||turn!=='player'||gameOver; } function deal() { deck=shuffle( suits.flatMap((suit,si)=> ranks.map(rank=>({rank,suit:si})) ) ); player=deck.splice(0,7); cpu=deck.splice(0,7); books={player:0,cpu:0}; selected=null; turn='player'; gameOver=false; checkBooks('player'); checkBooks('cpu'); render(); $('message').innerHTML= 'Your turn! Choose a rank from your hand. Lumi will quiz you before you ask the computer.'; } function checkBooks(who) { let hand=who==='player'?player:cpu; for(let r of ranks) { let matching=hand.filter(c=>c.rank===r); if(matching.length===4) { if(who==='player') player=hand.filter(c=>c.rank!==r); else cpu=hand.filter(c=>c.rank!==r); books[who]++; $('message').innerHTML= `${who==='player'?'You':'The computer'} made a book of ${rankName(r)}! Great collecting!`; } } } function ask() { if(!selected||turn!=='player'||gameOver) return; let rank=selected; selected=null; quizQuestion=questions[Math.floor(Math.random()*questions.length)]; afterQuiz=()=>makeRequest(rank); showQuiz(); render(); } function showQuiz() { let q=quizQuestion; $('qCategory').textContent=q[0].toUpperCase(); $('qText').textContent=q[1]; $('answers').innerHTML=q[2].map((a,i)=> `` ).join(''); $('feedback').textContent='Choose the best answer to earn your turn.'; $('continueBtn').classList.add('hidden'); $('quizModal').classList.add('show'); $('answers').querySelectorAll('button').forEach(b=>{ b.onclick=()=>answerQuiz(+b.dataset.answer); }); } function answerQuiz(i) { let q=quizQuestion; let correct=i===q[3]; $('answers').querySelectorAll('button').forEach((b,j)=>{ b.disabled=true; if(j===q[3]) b.classList.add('correct'); if(j===i&&!correct) b.classList.add('wrong'); }); $('feedback').textContent= (correct?'Correct! ':'Not quite. ')+q[4]; $('continueBtn').classList.remove('hidden'); $('continueBtn').onclick=()=>{ $('quizModal').classList.remove('show'); if(correct) { afterQuiz(); } else { $('message').innerHTML= 'Good learning! Your request is skipped this turn. The computer will play now.'; setTimeout(computerTurn,700); } }; } function makeRequest(rank) { let found=cpu.filter(c=>c.rank===rank); if(found.length) { cpu=cpu.filter(c=>c.rank!==rank); player.push(...found); $('message').innerHTML= `Yes! The computer had ${rankName(rank)}. You collected ${found.length} card(s). Ask again!`; checkBooks('player'); selected=null; render(); if(!gameOver) setTimeout(()=>{ if(player.length===0&&deck.length) draw('player'); },400); } else { $('message').innerHTML= `Go fish! The computer has no ${rankName(rank)}. Draw a card.`; draw('player'); if(!gameOver) setTimeout(computerTurn,850); } render(); checkEnd(); } function draw(who) { if(!deck.length) return; let c=deck.pop(); (who==='player'?player:cpu).push(c); if(who==='player') $('message').innerHTML+=' You drew a card.'; checkBooks(who); render(); } function computerTurn() { if(gameOver||turn==='cpu') return; turn='cpu'; if(!cpu.length&&deck.length) draw('cpu'); if(!cpu.length) { turn='player'; checkEnd(); return; } let rank=cpu[Math.floor(Math.random()*cpu.length)].rank; let found=player.filter(c=>c.rank===rank); if(found.length) { player=player.filter(c=>c.rank!==rank); cpu.push(...found); $('message').innerHTML= `Computer asks: Do you have any ${rankName(rank)}? You did — the computer collected ${found.length} card(s).`; checkBooks('cpu'); render(); turn='player'; if(!gameOver) setTimeout(computerTurn,1200); } else { $('message').innerHTML= `Computer asks for ${rankName(rank)}. You don't have any, so the computer goes fishing.`; if(deck.length) { cpu.push(deck.pop()); checkBooks('cpu'); } render(); turn='player'; checkEnd(); } } function checkEnd() { if(gameOver) return; let total=books.player+books.cpu; if(total===13||(!deck.length&&!player.length&&!cpu.length)) { gameOver=true; let result= books.player>books.cpu?'You win!': books.playerGame over — ${result} Final books: You ${books.player}, Computer ${books.cpu}. Press New game to play again.`; render(); } } $('playerHand').addEventListener('click',e=>{ let el=e.target.closest('[data-index]'); if(!el||turn!=='player'||gameOver) return; let c=player[+el.dataset.index]; selected=selected===c.rank?null:c.rank; render(); $('message').innerHTML=selected ? `${rankName(selected)} selected. Press “Ask for selected rank” to take your digital literacy challenge.` : 'Choose a card rank to ask for.'; }); $('askBtn').onclick=ask; $('newBtn').onclick=deal; deal();