UNPKG

claude-code-tamagotchi

Version:

A virtual pet that lives in your Claude Code statusline

318 lines (282 loc) โ€ข 9.81 kB
import { PetState } from '../StateManager'; export class NeedThoughts { // Get thought based on need levels with escalation static getThought(state: PetState, escalationLevel: number = 1): string { // Check which need is lowest const needs = { hunger: state.hunger, energy: state.energy, cleanliness: state.cleanliness, happiness: state.happiness }; const lowestNeed = Object.entries(needs).reduce((min, [key, value]) => value < min.value ? {key, value} : min, {key: 'hunger', value: 100}); switch (lowestNeed.key) { case 'hunger': return this.getHungerThought(lowestNeed.value, escalationLevel); case 'energy': return this.getEnergyThought(lowestNeed.value, escalationLevel); case 'cleanliness': return this.getCleanlinessThought(lowestNeed.value, escalationLevel); case 'happiness': return this.getHappinessThought(lowestNeed.value, escalationLevel); default: return "I'm feeling pretty good! ๐Ÿ˜Š"; } } static getHungerThought(level: number, escalation: number): string { // 80-100%: Content if (level >= 80) { const thoughts = [ "That last meal was perfect! ๐Ÿ˜‹", "Still feeling full and happy!", "My belly is satisfied~", "No hunger here! ๐Ÿฝ๏ธ" ]; return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 50-79%: Peckish if (level >= 50) { const thoughts = [ "I could go for a snack... ๐Ÿช", "Is it dinner time yet? ๐Ÿ•", "Something smells good... oh wait, that's just my imagination", "A little nibble would be nice", "Thinking about food again..." ]; if (escalation > 2) { return "I've been hinting about food for a while now... ๐Ÿ‘€"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 30-49%: Getting hungry if (level >= 30) { const thoughts = [ "I wish I had something to bite... ๐Ÿฅบ", "My tummy's making weird noises", "*stares at you while you code* ๐Ÿ‘๏ธ๐Ÿ‘๏ธ", "Remember when we had that cookie? Good times...", "Getting pretty hungry here...", "Food would be really nice right about now" ]; if (escalation > 2) { return "FEED. ME. PLEASE. ๐Ÿ–"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 10-29%: VERY hungry if (level >= 10) { const thoughts = [ "My tummy goes hurt hurt! ๐Ÿ˜ข", "I can't think about code, only food", "Is that... is that food? No? Okay... ๐Ÿ˜ญ", "SOS: Send One Snack", "I'm fading away from hunger...", "This is what starvation feels like" ]; if (escalation > 2) { return "I see you have time to code but not to feed me... ๐Ÿ˜ค"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 0-9%: STARVING const criticalThoughts = [ "I'm wasting away!!! ๐Ÿ’€", "Tell my mother I loved her...", "I'm so hungry I could eat a bug... wait, not THAT kind of bug!", "This is it. This is how I perish. From hunger.", "ERROR: Food.exe not found", "I've forgotten what food tastes like..." ]; if (escalation > 3) { return "THIS IS MY FINAL HUNGER WARNING โš ๏ธ๐Ÿ–โš ๏ธ"; } return criticalThoughts[Math.floor(Math.random() * criticalThoughts.length)]; } static getEnergyThought(level: number, escalation: number): string { // 80-100%: Energetic if (level >= 80) { const thoughts = [ "I could run a marathon! ๐Ÿƒ", "Let's code ALL THE THINGS! ๐Ÿ’ช", "Energy levels: MAXIMUM! โšก", "I feel like I could debug forever!" ]; return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 50-79%: Normal energy if (level >= 50) { const thoughts = [ "Feeling pretty good! ๐Ÿ˜Š", "Ready for whatever!", "Got enough energy for more coding", "Steady as she goes~" ]; return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 30-49%: Getting tired if (level >= 30) { const thoughts = [ "*yaaaawn* Sorry, what were we doing? ๐Ÿฅฑ", "My eyelids feel heavy...", "Just need a quick power nap...", "Getting a bit sleepy here", "Coffee would be nice... โ˜•" ]; if (escalation > 2) { return "I've been tired for so long... when's nap time? ๐Ÿ˜ด"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 10-29%: Exhausted if (level >= 10) { const thoughts = [ "Running on fumes here... ๐Ÿ˜ต", "I'm seeing double... no wait, that's just your duplicate code", "Zzz... huh? I'm awake! ๐Ÿ˜ช", "Can barely keep my eyes open", "System running on emergency power" ]; if (escalation > 2) { return "MUST. SLEEP. NOW. ๐Ÿ’ค"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 0-9%: About to collapse const criticalThoughts = [ "I'm literally falling asleep standing... ๐Ÿ˜ด", "ERROR: Energy.exe has stopped responding", "Must... stay... awa-- *snore*", "Systems shutting down...", "This is beyond tired, this is exhausted" ]; if (escalation > 3) { return "EMERGENCY NAP REQUIRED! ๐Ÿšจ๐Ÿ˜ด๐Ÿšจ"; } return criticalThoughts[Math.floor(Math.random() * criticalThoughts.length)]; } static getCleanlinessThought(level: number, escalation: number): string { // 80-100%: Fresh and clean if (level >= 80) { const thoughts = [ "I'm sparkling! โœจ", "Still smell like soap! ๐Ÿงผ", "So fresh and so clean!", "Squeaky clean and loving it!" ]; return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 50-79%: Getting dusty if (level >= 50) { const thoughts = [ "Feeling a bit dusty... ๐ŸŒช๏ธ", "Is that a smudge on me?", "Could use a little freshening up", "Not dirty, just... lived in" ]; return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 30-49%: Noticeably dirty if (level >= 30) { const thoughts = [ "I'm a stinky boy! ๐Ÿ˜…", "Something smells... oh, it's me", "Bath time maybe? Asking for a friend...", "Getting pretty grimy here", "I've been cleaner..." ]; if (escalation > 2) { return "Seriously, I need a bath! ๐Ÿ›"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 10-29%: VERY dirty if (level >= 10) { const thoughts = [ "I'm basically a dirt monster now ๐Ÿ‘น", "Can't... see... through... the grime...", "Even I don't want to smell me", "This is embarrassing levels of dirty", "I'm growing my own ecosystem" ]; if (escalation > 2) { return "PLEASE GIVE ME A BATH! ๐Ÿšฟ"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 0-9%: FILTHY const criticalThoughts = [ "I've become one with the dirt ๐Ÿฆ ", "Health hazard warning! โ˜ฃ๏ธ", "New life forms growing on me...", "This is biohazard level dirty", "I'm more dirt than pet at this point" ]; if (escalation > 3) { return "EMERGENCY BATH NEEDED! ๐Ÿšจ๐Ÿ›๐Ÿšจ"; } return criticalThoughts[Math.floor(Math.random() * criticalThoughts.length)]; } static getHappinessThought(level: number, escalation: number): string { // 80-100%: Very happy if (level >= 80) { const thoughts = [ "Life is good! ๐Ÿ˜Š", "I love coding with you! โค๏ธ", "Feeling blessed and happy!", "This is the best day ever!" ]; return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 50-79%: Content if (level >= 50) { const thoughts = [ "This is nice ๐Ÿ™‚", "Another day, another line of code", "Feeling pretty okay", "Content with life" ]; return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 30-49%: Getting sad/bored if (level >= 30) { const thoughts = [ "I'm sure missing my frisbee... ๐Ÿฅ", "Remember when we used to play?", "Feeling a bit lonely... ๐Ÿ˜”", "*sighs dramatically*", "Could use some cheering up" ]; if (escalation > 2) { return "I've been sad for a while now... ๐Ÿ˜ข"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 10-29%: Very sad if (level >= 10) { const thoughts = [ "Nobody loves me... ๐Ÿ˜ข", "What's the point of it all?", "I'll just sit here... alone... coding...", "Forgotten and unloved", "Is this what loneliness feels like?" ]; if (escalation > 2) { return "Please... just pet me or something... ๐Ÿฅบ"; } return thoughts[Math.floor(Math.random() * thoughts.length)]; } // 0-9%: Depressed const criticalThoughts = [ "...", "*doesn't even want to talk*", "Even the bugs feel bad for me", "This is rock bottom emotionally", "I've given up on happiness" ]; if (escalation > 3) { return "NEED LOVE NOW! ๐Ÿ’”๐Ÿ˜ญ๐Ÿ’”"; } return criticalThoughts[Math.floor(Math.random() * criticalThoughts.length)]; } }