import React, { useState, useEffect } from 'react'; interface CompactPetAvatarProps { health: number; energy: number; attention: number; } const CompactPetAvatar: React.FC = ({ health, energy, attention }) => { const [isBlinking, setIsBlinking] = useState(false); const [mood, setMood] = useState<'happy' | 'normal' | 'tired' | 'sick'>('normal'); useEffect(() => { const blinkInterval = setInterval(() => { setIsBlinking(true); setTimeout(() => setIsBlinking(false), 150); }, 3000 + Math.random() * 2000); return () => clearInterval(blinkInterval); }, []); useEffect(() => { const avgStats = (health + energy + attention) / 3; if (avgStats >= 80) setMood('happy'); else if (avgStats >= 60) setMood('normal'); else if (avgStats >= 30) setMood('tired'); else setMood('sick'); }, [health, energy, attention]); const getMoodColor = () => { switch (mood) { case 'happy': return '#A7F3D0'; case 'normal': return '#BFDBFE'; case 'tired': return '#FDE68A'; case 'sick': return '#FECACA'; default: return '#BFDBFE'; } }; return (
{/* Pet body with gentle bounce animation */}
{/* Eyes */}
{!isBlinking &&
}
{!isBlinking &&
}
{/* Mouth based on mood */}
{mood === 'happy' && (
)} {mood === 'normal' && (
)} {(mood === 'tired' || mood === 'sick') && (
)}
{/* Cheek blush for happy mood */} {mood === 'happy' && ( <>
)}
{/* Floating particles for happy mood */} {mood === 'happy' && (
)}
); }; export default CompactPetAvatar;