import * as vscode from 'vscode'; import { TamagotchiState } from './tamagotchi'; export interface PetColors { primary: string; secondary: string; accent: string; blush: string; } // Color presets for quick customization export const COLOR_PRESETS: Record = { sakura: { primary: '#ffb7c5', secondary: '#ff69b4', accent: '#ffd700', blush: '#ffe4e9', }, ocean: { primary: '#00bcd4', secondary: '#0077be', accent: '#7fdbff', blush: '#b3e5fc', }, sunset: { primary: '#ff6b35', secondary: '#f72585', accent: '#ffd23f', blush: '#ffaa85', }, forest: { primary: '#4caf50', secondary: '#2e7d32', accent: '#8bc34a', blush: '#a5d6a7', }, galaxy: { primary: '#9c27b0', secondary: '#673ab7', accent: '#e040fb', blush: '#ce93d8', }, candy: { primary: '#f48fb1', secondary: '#81d4fa', accent: '#fff176', blush: '#f8bbd9', }, monochrome: { primary: '#9e9e9e', secondary: '#616161', accent: '#e0e0e0', blush: '#bdbdbd', }, }; const THEMES = { classic: { bg: 'linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%)', cardBg: 'rgba(255, 255, 255, 0.05)', accent: '#e94560', accentSecondary: '#ff6b6b', text: '#eee', textMuted: '#aaa', statBar: '#e94560', buttonBg: 'linear-gradient(135deg, #e94560 0%, #ff6b6b 100%)', buttonHover: 'linear-gradient(135deg, #ff6b6b 0%, #e94560 100%)', }, neon: { bg: 'linear-gradient(135deg, #0d0d0d 0%, #1a0a2e 50%, #0d0d0d 100%)', cardBg: 'rgba(0, 255, 255, 0.05)', accent: '#00ffff', accentSecondary: '#ff00ff', text: '#fff', textMuted: '#888', statBar: '#00ffff', buttonBg: 'linear-gradient(135deg, #00ffff 0%, #ff00ff 100%)', buttonHover: 'linear-gradient(135deg, #ff00ff 0%, #00ffff 100%)', }, pastel: { bg: 'linear-gradient(135deg, #ffecd2 0%, #fcb69f 50%, #ffecd2 100%)', cardBg: 'rgba(255, 255, 255, 0.6)', accent: '#ff9a9e', accentSecondary: '#fecfef', text: '#5c5c5c', textMuted: '#888', statBar: '#ff9a9e', buttonBg: 'linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%)', buttonHover: 'linear-gradient(135deg, #fecfef 0%, #ff9a9e 100%)', }, dark: { bg: 'linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #0a0a0a 100%)', cardBg: 'rgba(255, 255, 255, 0.03)', accent: '#7c3aed', accentSecondary: '#a78bfa', text: '#e5e5e5', textMuted: '#737373', statBar: '#7c3aed', buttonBg: 'linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%)', buttonHover: 'linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%)', }, }; // SVG Sprites with CSS variable support const SVG_SPRITES = { egg: ` `, baby: ` `, child: ` `, teen: ` `, adult: ` `, sleeping: ` Z Z z `, sick: ` `, dead: ` `, dirty: ` `, }; // Emoji fallbacks const EMOJI_SPRITES = { egg: { idle: '🥚', happy: '🥚', neutral: '🥚', sad: '🥚', sleeping: '🥚', sick: '🥚', dead: '💔' }, baby: { idle: '🐣', happy: '🐥', neutral: '🐣', sad: '😢', sleeping: '😴', sick: '🤒', dead: '💀', eating: '😋', playing: '🎉', cleaning: '🛁' }, child: { idle: '🐱', happy: '😺', neutral: '🐱', sad: '😿', sleeping: '😴', sick: '🤒', dead: '💀', eating: '😋', playing: '🎮', cleaning: '🧼' }, teen: { idle: '🐯', happy: '😸', neutral: '🐯', sad: '😿', sleeping: '😴', sick: '🤕', dead: '💀', eating: '🍖', playing: '⚽', cleaning: '🚿' }, adult: { idle: '🦁', happy: '🦁', neutral: '🦁', sad: '😢', sleeping: '😴', sick: '🤒', dead: '💀', eating: '🍗', playing: '🏆', cleaning: '✨' }, }; function getSvgSprite(state: TamagotchiState): string { const { mood, stats, currentAction } = state; if (!stats.isAlive) {return SVG_SPRITES.dead;} if (currentAction === 'sleeping' || mood === 'sleeping') {return SVG_SPRITES.sleeping;} if (mood === 'sick') {return SVG_SPRITES.sick;} // Show dirty sprite when cleanliness drops below 30% if (stats.cleanliness < 30) {return SVG_SPRITES.dirty;} return SVG_SPRITES[stats.stage as keyof typeof SVG_SPRITES] || SVG_SPRITES.baby; } function getEmojiSprite(state: TamagotchiState): string { const { mood, stats, currentAction } = state; const sprites = EMOJI_SPRITES[stats.stage as keyof typeof EMOJI_SPRITES] || EMOJI_SPRITES.baby; if (currentAction !== 'idle' && sprites[currentAction as keyof typeof sprites]) { return sprites[currentAction as keyof typeof sprites]; } return sprites[mood as keyof typeof sprites] || sprites.idle; } export function getWebviewContent( webview: vscode.Webview, extensionUri: vscode.Uri, state: TamagotchiState, themeName: string = 'classic', useCustomSprites: boolean = true, petColors: PetColors = { primary: '#ff6b9d', secondary: '#c44cff', accent: '#ffe14c', blush: '#ffb3d9' } ): string { const theme = THEMES[themeName as keyof typeof THEMES] || THEMES.classic; const nonce = getNonce(); const spriteContent = useCustomSprites ? getSvgSprite(state) : ''; const emojiContent = getEmojiSprite(state); return ` Tamagotchi
${state.name}
${state.stats.stage}
${useCustomSprites ? spriteContent : emojiContent}
Feeling ${state.mood}
🍖 Hunger ${Math.round(state.stats.hunger)}%
😊 Happiness ${Math.round(state.stats.happiness)}%
⚡ Energy ${Math.round(state.stats.energy)}%
🧼 Cleanliness ${Math.round(state.stats.cleanliness)}%
❤️ Health ${Math.round(state.stats.health)}%
${!state.stats.isAlive ? '💔 Your Tamagotchi has passed away...' : 'Take care of your Tamagotchi!'}
Age: ${state.stats.age} ticks
`; } function getNonce(): string { let text = ''; const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; for (let i = 0; i < 32; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); } return text; }