import React, { useState, useEffect, useCallback } from 'react'; import './PharaohsTrivia.css'; // For professional styling
// Assuming image imports are correctly configured: import Coin20 from './images/enhanced_1762428323273.jpg'; import Coin50 from './images/enhanced_1762430071978.jpg'; import Coin100 from './images/unnamed (9).jpg';
// --- Game Data: Questions and Levels Configuration --- const QUIZ_DATA = [ // Level 1: Easy Questions (Reward: 20 EGP) { question: "What is the capital city of Egypt?", options: ["Alexandria", "Luxor", "Cairo", "Aswan"], answer: "Cairo" }, { question: "Which river is often called the 'Lifeblood' of Egypt?", options: ["Tigris", "Euphrates", "Nile", "Jordan"], answer: "Nile" }, ];
const LEVEL_CONFIG = [ { levelId: 1, minScore: 1, // Need at least 1 correct answer to pass Level 1 reward: { value: 20, image: Coin20, message: "Abu Simbel's Treasure!" } }, { levelId: 2, minScore: 2, // Need at least 2 correct answers to pass Level 2 reward: { value: 50, image: Coin50, message: "Giza Pyramids' Wealth!" } }, { levelId: 3, minScore: 3, reward: { value: 100, image: Coin100, message: "Grand Museum's Gold!" } }, ];
// Handles the player selecting an answer const handleAnswerSelect = useCallback((option) => { if (isAnswerSelected) return;
setIsAnswerSelected(true); setSelectedOption(option); // Check if the answer is correct if (option === QUIZ_DATA[currentQuestion].answer) { setScore(prevScore => prevScore + 1); }
}, [currentQuestion, isAnswerSelected]);
// Handles moving to the next question or checking level completion const handleNext = useCallback(() => { if (!isAnswerSelected) return; // Must select an answer first
const nextQuestion = currentQuestion + 1;
if (nextQuestion < totalQuestions) { // Go to next question setCurrentQuestion(nextQuestion); setIsAnswerSelected(false); setSelectedOption(null); } else { // All questions for the current level answered if (score >= currentLevelConfig.minScore) { setGameState('levelComplete'); } else { setGameState('lost'); // Implement a specific loss state if needed } } }, [currentQuestion, totalQuestions, score, currentLevelConfig, isAnswerSelected]);
// Handles moving to the next level const handleNextLevel = useCallback(() => { const nextLevelIndex = levelIndex + 1;
if (nextLevelIndex < LEVEL_CONFIG.length) { // Reset and advance to the next level setLevelIndex(nextLevelIndex); setCurrentQuestion(0); setScore(0); setGameState('playing'); setIsAnswerSelected(false); setSelectedOption(null); } else { // Game over, all levels finished setGameState('finished'); } }, [levelIndex]);
// Helper function for styling options const getOptionStyle = (option) => { if (!isAnswerSelected || selectedOption !== option) { return {}; // Default style } // Once an answer is selected if (option === QUIZ_DATA[currentQuestion].answer) { return styles.correctOption; } else { return styles.incorrectOption; } };
A ver a ver, ¿hay gente real aquí? Lo poco que llevo en #tangled solo he visto imágenes hechas con #000 inteligenciaartificial . ¿A ustedes también les sale solo esas imágenes o solo a mi? 😐