import { useState, useEffect } from 'react'; import { Shuffle, RefreshCw, Award, ChevronRight } from 'lucide-react'; export default function WutheringWavesQuoteGame() { // Game state const [currentQuote, setCurrentQuote] = useState(null); const [options, setOptions] = useState([]); const [selectedCharacter, setSelectedCharacter] = useState(null); const [score, setScore] = useState(0); const [totalQuestions, setTotalQuestions] = useState(0); const [gameStatus, setGameStatus] = useState('playing'); // 'playing', 'correct', 'incorrect' const [quoteHistory, setQuoteHistory] = useState([]); const [isLoading, setIsLoading] = useState(true); // Database of quotes and characters const quoteDatabase = [ { quote: "The world is a vast place. I want to see it all.", character: "Rover", image: "https://i.imgur.com/JQpTbLM.png" }, { quote: "I'm not interested in the past. Only in what lies ahead.", character: "Yinlin", image: "https://i.imgur.com/8Xt3Ygj.png" }, { quote: "The Union's authority is absolute. Remember that.", character: "Jianxin", image: "https://i.imgur.com/QXnHrZA.png" }, { quote: "My research is all that matters. Don't get in my way.", character: "Chixia", image: "https://i.imgur.com/0Ht9Yvl.png" }, { quote: "The shadows hide many secrets. I've learned to embrace them.", character: "Baizhi", image: "https://i.imgur.com/JlCGXwG.png" }, { quote: "Every performance should touch the heart. That's my belief.", character: "Lingyang", image: "https://i.imgur.com/Yk9YVGM.png" }, { quote: "The sea calls to me. I can hear its whispers.", character: "Jiyan", image: "https://i.imgur.com/pVLCgzP.png" }, { quote: "My blade is the last thing my enemies see.", character: "Herta", image: "https://i.imgur.com/1XZdXzA.png" }, { quote: "The stars hold the answers we seek.", character: "Yuanwu", image: "https://i.imgur.com/dNzjnSB.png" }, { quote: "I fight for those who cannot fight for themselves.", character: "Aalto", image: "https://i.imgur.com/KXcLnVG.png" }, { quote: "The path of justice is often paved with difficult choices.", character: "Mortefi", image: "https://i.imgur.com/8Xt3Ygj.png" }, { quote: "My loyalty is to the people, not to any organization.", character: "Verina", image: "https://i.imgur.com/JQpTbLM.png" }, { quote: "Knowledge is power. I seek to understand everything.", character: "Chixia", image: "https://i.imgur.com/0Ht9Yvl.png" }, { quote: "The echoes of the past guide my steps forward.", character: "Yuanwu", image: "https://i.imgur.com/dNzjnSB.png" }, { quote: "In the dance of blades, I find my purpose.", character: "Baizhi", image: "https://i.imgur.com/JlCGXwG.png" } ]; const characters = [...new Set(quoteDatabase.map(item => item.character))]; // Initialize game useEffect(() => { loadNewQuote(); setIsLoading(false); }, []); // Load a new random quote const loadNewQuote = () => { setSelectedCharacter(null); setGameStatus('playing'); // Filter out quotes that have already been used const unusedQuotes = quoteDatabase.filter( quote => !quoteHistory.includes(quote.quote) ); // If all quotes have been used, reset history if (unusedQuotes.length === 0) { setQuoteHistory([]); const randomQuote = quoteDatabase[Math.floor(Math.random() * quoteDatabase.length)]; setCurrentQuote(randomQuote); setQuoteHistory([randomQuote.quote]); } else { // Select a random unused quote const randomQuote = unusedQuotes[Math.floor(Math.random() * unusedQuotes.length)]; setCurrentQuote(randomQuote); setQuoteHistory([...quoteHistory, randomQuote.quote]); } // Generate options (1 correct, 3 random) generateOptions(); }; // Generate 4 options including the correct answer const generateOptions = () => { if (!quoteDatabase.length) return; // Get a random quote if currentQuote is not set yet const quote = currentQuote || quoteDatabase[Math.floor(Math.random() * quoteDatabase.length)]; // Create a copy of characters array without the correct answer const otherCharacters = characters.filter(char => char !== quote.character); // Shuffle the array const shuffledCharacters = otherCharacters.sort(() => 0.5 - Math.random()); // Take 3 random characters const randomOptions = shuffledCharacters.slice(0, 3); // Add the correct answer const allOptions = [...randomOptions, quote.character]; // Shuffle again to randomize position setOptions(allOptions.sort(() => 0.5 - Math.random())); }; // Handle character selection const handleSelect = (character) => { if (gameStatus !== 'playing') return; setSelectedCharacter(character); if (character === currentQuote.character) { setScore(score + 1); setGameStatus('correct'); } else { setGameStatus('incorrect'); } setTotalQuestions(totalQuestions + 1); }; // Handle next question const handleNext = () => { loadNewQuote(); }; // Reset the game const resetGame = () => { setScore(0); setTotalQuestions(0); setQuoteHistory([]); loadNewQuote(); }; if (isLoading) { return (
Can you guess which character said these quotes?
"{currentQuote?.quote}"{/* Decorative elements */}
{gameStatus === 'correct' ? 'Correct!' : 'Incorrect!'}
"{currentQuote?.quote}" was said by {currentQuote?.character}
Test your knowledge of Wuthering Waves characters and their memorable quotes!