claude-code-tamagotchi
Version:
A virtual pet that lives in your Claude Code statusline
318 lines (282 loc) โข 9.81 kB
text/typescript
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)];
}
}