import { useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; const challenges = { "qr1": { question: "Jaka jest stolica Francji?", answer: "paryz" }, "qr2": { question: "2 + 2 * 2 = ?", answer: "6" }, "qr3": { question: "Jaki jest główny port HTTP?", answer: "80" }, }; export default function HackmeGame() { const [currentChallenge, setCurrentChallenge] = useState(null); const [userAnswer, setUserAnswer] = useState(""); const [score, setScore] = useState(0); const [message, setMessage] = useState(""); const handleQRScan = (code) => { if (challenges[code]) { setCurrentChallenge(challenges[code]); setMessage(""); } else { setMessage("Niepoprawny kod QR!"); } }; const checkAnswer = () => { if (userAnswer.toLowerCase() === currentChallenge.answer) { setScore(score + 1); setMessage("Poprawna odpowiedź! Szukaj następnego kodu QR."); setCurrentChallenge(null); } else { setMessage("Niepoprawna odpowiedź, spróbuj ponownie."); } setUserAnswer(""); }; return (
Skanuj kody QR i rozwiązuj zagadki!
Twoje punkty: {score}
{currentChallenge.question}
setUserAnswer(e.target.value)} />{message}
}