import React, { useState, useEffect } from 'react'; import { Volume2, Star, Heart, Award } from 'lucide-react'; const ThreeLevelsQuiz = () => { const [currentQuestion, setCurrentQuestion] = useState(0); const [score, setScore] = useState(0); const [selectedAnswer, setSelectedAnswer] = useState(null); const [showExplanation, setShowExplanation] = useState(false); const [gameComplete, setGameComplete] = useState(false); const [shuffledQuestions, setShuffledQuestions] = useState([]); // בנק השאלות עם ערבוב אסטרטגי const questions = [ { id: 1, text: "ליהנות מאוכל טעים", correctAnswer: "cat", explanation: "כל יצור חי נהנה מטעם טוב - זה צורך בסיסי של החיים!", level: "בסיסי" }, { id: 2, text: "להתרגש כשבעל הבית חוזר", correctAnswer: "dog", explanation: "כלבים יוצרים קשר רגשי עמוק, בעוד שחתולים יותר עצמאיים ולא תמיד מתרגשים מחזרה.", level: "רגשי" }, { id: 3, text: "להבין בדיחה ולהתפוצץ מצחוק", correctAnswer: "human", explanation: "הומור דורש הבנת משמעויות כפולות ואירוניה - זה ייחודי לנשמה האנושית!", level: "נשמתי" }, { id: 4, text: "לישון במקום נוח וחם", correctAnswer: "cat", explanation: "זה צורך בסיסי של כל בעל חיים - גם החתול הכי פשוט מחפש מקום נוח לישון.", level: "בסיסי" }, { id: 5, text: "להרגיש עצוב כשנעזבים לבד", correctAnswer: "dog", explanation: "כלבים הם חיות להקה שזקוקות לחברה, בעוד שחתולים הרבה יותר עצמאיים.", level: "רגשי" }, { id: 6, text: "להתרגש מסיפור או ספר", correctAnswer: "human", explanation: "דמיון ויכולת להיכנס לעולמות לא קיימים - זה כוח מיוחד של הנשמה האנושית!", level: "נשמתי" }, { id: 7, text: "ליהנות מליטוף עדין", correctAnswer: "cat", explanation: "חתולים אוהבים מגע נעים (כשהם במצב רוח...) - זה הנאה חושית בסיסית.", level: "בסיסי" }, { id: 8, text: "לשמח מישהו שעצוב", correctAnswer: "dog", explanation: "כלבים מרגישים רגשות של אחרים ומגיבים באמפתיה טבעית.", level: "רגשי" }, { id: 9, text: "לחלום על העתיד ולתכנן", correctAnswer: "human", explanation: "רק אנחנו חיים בעתיד ולא רק בהווה - זה כוח מיוחד של הנשמה!", level: "נשמתי" }, { id: 10, text: "להרגיש בטוח במקום מוכר", correctAnswer: "cat", explanation: "גם חתול מרגיש יותר רגוע בטריטוריה שלו - זה צורך בסיסי של בטחון.", level: "בסיסי" }, { id: 11, text: "ללמוד להביא חפץ ולהיות גאה על זה", correctAnswer: "dog", explanation: "כלבים אוהבים לרצות ומרגישים הצלחה כשעושים משהו נכון.", level: "רגשי" }, { id: 12, text: "להכיר בטעות ולהתנצל מהלב", correctAnswer: "human", explanation: "הכרה מוסרית והחלטה לשנות - זה דורש נשמה עם מצפון!", level: "נשמתי" }, { id: 13, text: "ליהנות מחום השמש", correctAnswer: "cat", explanation: "תראו איך חתולים מחפשים את כתם השמש בבית - זה הנאה טבעית!", level: "בסיסי" }, { id: 14, text: "להזדהות עם כאב של האדם", correctAnswer: "dog", explanation: "כלבים מפתחים אמפתיה אמיתית ומרגישים כשהבעלים שלהם כואבים.", level: "רגשי" }, { id: 15, text: "ליצור משהו יפה שלא היה קיים", correctAnswer: "human", explanation: "יצירתיות מקורית ורצון ליופי - זה כוח אלוהי שיש רק לנשמה האנושית!", level: "נשמתי" } ]; // ערבוב השאלות באופן אסטרטגי useEffect(() => { const basicQuestions = questions.filter(q => q.level === "בסיסי"); const emotionalQuestions = questions.filter(q => q.level === "רגשי"); const soulQuestions = questions.filter(q => q.level === "נשמתי"); // ערבוב בתוך כל קטגוריה const shuffleArray = (array) => { const shuffled = [...array]; for (let i = shuffled.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]; } return shuffled; }; const shuffledBasic = shuffleArray(basicQuestions); const shuffledEmotional = shuffleArray(emotionalQuestions); const shuffledSoul = shuffleArray(soulQuestions); // חלוקה מעורבבת: בסיסי, רגשי, נשמתי, בסיסי, רגשי, נשמתי... const mixed = []; const maxLength = Math.max(shuffledBasic.length, shuffledEmotional.length, shuffledSoul.length); for (let i = 0; i < maxLength; i++) { if (shuffledBasic[i]) mixed.push(shuffledBasic[i]); if (shuffledEmotional[i]) mixed.push(shuffledEmotional[i]); if (shuffledSoul[i]) mixed.push(shuffledSoul[i]); } setShuffledQuestions(mixed); }, []); // אפקט קולי const playSound = (isCorrect) => { // יצירת צליל פשוט עם Web Audio API const audioContext = new (window.AudioContext || window.webkitAudioContext)(); const oscillator = audioContext.createOscillator(); const gainNode = audioContext.createGain(); oscillator.connect(gainNode); gainNode.connect(audioContext.destination); if (isCorrect) { // צליל נכון - נעים וחיובי oscillator.frequency.setValueAtTime(523.25, audioContext.currentTime); // C5 oscillator.frequency.setValueAtTime(659.25, audioContext.currentTime + 0.1); // E5 oscillator.frequency.setValueAtTime(783.99, audioContext.currentTime + 0.2); // G5 } else { // צליל שגוי - נמוך יותר oscillator.frequency.setValueAtTime(220, audioContext.currentTime); // A3 oscillator.frequency.setValueAtTime(196, audioContext.currentTime + 0.15); // G3 } oscillator.type = 'sine'; gainNode.gain.setValueAtTime(0.1, audioContext.currentTime); gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.3); oscillator.start(audioContext.currentTime); oscillator.stop(audioContext.currentTime + 0.3); }; const handleAnswer = (answer) => { if (selectedAnswer !== null) return; setSelectedAnswer(answer); const isCorrect = answer === shuffledQuestions[currentQuestion]?.correctAnswer; playSound(isCorrect); if (isCorrect) { setScore(score + 1); } setShowExplanation(true); }; const nextQuestion = () => { if (currentQuestion < shuffledQuestions.length - 1) { setCurrentQuestion(currentQuestion + 1); setSelectedAnswer(null); setShowExplanation(false); } else { setGameComplete(true); } }; const resetQuiz = () => { setCurrentQuestion(0); setScore(0); setSelectedAnswer(null); setShowExplanation(false); setGameComplete(false); // ערבוב חדש של השאלות window.location.reload(); }; const getAnswerColor = (answer) => { if (!showExplanation) return 'bg-white hover:bg-gray-50'; const correct = shuffledQuestions[currentQuestion]?.correctAnswer; if (answer === correct) return 'bg-green-200 border-green-500'; if (answer === selectedAnswer && answer !== correct) return 'bg-red-200 border-red-500'; return 'bg-gray-100'; }; const getProgressMessage = () => { const progress = ((currentQuestion + 1) / shuffledQuestions.length) * 100; if (progress <= 33) return "מתחילות לגלות את המיוחדות שלנו! 🌱"; if (progress <= 66) return "מבינות יותר ויותר כמה אנחנו מיוחדות! ✨"; return "כמעט גילינו את כל הסוד של הנשמה שלנו! 💎"; }; if (shuffledQuestions.length === 0) { return (
מכינה את השאלות המיוחדות...
{message}
יש לנו 15 הנאות מיוחדות שאף יצור אחר בעולם לא יכול לחוות! זה בגלל שיש לנו נשמה אלוהית שנותנת לנו לחוות את החיים ברמה עמוקה ומשמעותית. ✨
מי יכול להרגיש מה?
{getProgressMessage()}
{currentQ?.text}
{currentQ?.explanation}
{/* הודעת עידוד */}{selectedAnswer === currentQ?.correctAnswer ? "🎉 כל הכבוד! המשיכי לגלות כמה את מיוחדת!" : "💭 זה בסדר! כל שאלה עוזרת לנו להבין יותר על עצמנו!"}