/** * سه‌یار: سیگما (Σ)، دلتا (Δ) و پی (π) — ماسکوت‌های اپ. * * هر سه از دلِ یک دفترچه‌ی بی‌نهایت آمده‌اند و هر کدام از جنسِ یک نمادِ ریاضی‌اند: * سیگما → راهنمای درس و آزمون دلتا → هم‌تیمیِ تمرینِ سریع پی → دستیار و همراهِ دلگرمی * * خروجی رشته‌ی SVG است (نه JSX) تا هر سه با یک موتورِ چهره ساخته شوند. * ورودی‌ها همه از همین فایل‌اند و هیچ متنِ کاربر واردِ SVG نمی‌شود. */ export type SeyarChar = 'sigma' | 'delta' | 'pi'; export type SeyarMood = 'idle' | 'happy' | 'excited' | 'sad' | 'angry' | 'depressed'; const PALETTE: Record> = { sigma: { body: "#4C5FD5", inner: "#7A8CFF", belly: "#EAF0FF", ink: "#232355", cheek: "#FFB2C0", mouth: "#FF6B6B", tear: "#8EC9FF", badge: "#FFD23F" }, delta: { body: "#FF7A3D", inner: "#FFB25E", belly: "#FFE7C7", ink: "#6E2A12", cheek: "#FF8FA3", mouth: "#D6402A", tear: "#8EC9FF", spike: "#FFEB3B" }, pi: { body: "#9B7BFF", inner: "#C6B3FF", belly: "#F1ECFF", ink: "#3B2B66", cheek: "#FFC2D1", mouth: "#FF6F91", tear: "#5EC8E8" }, }; const Y_SHIFT: Record = { idle: 0, happy: 0, excited: -4, sad: 3, angry: 0, depressed: 9 }; const ARM_DELTA: Record = { idle: 0, happy: 2, excited: 46, sad: -4, angry: -8, depressed: -10 }; function face(mood: SeyarMood, ex: number, ey: number, mx: number, my: number, ink: string, mouthC: string, tearC: string, cheekC: string, spread: number) { const lx = ex, rx = ex + spread; let eyes = "", mouth = "", cheeks = "", extra = ""; if (mood === "idle") { eyes = `` + ``; mouth = ``; } else if (mood === "happy") { eyes = `` + ``; mouth = ``; cheeks = ``; } else if (mood === "excited") { eyes = `` + `` + ``; mouth = ``; cheeks = ``; extra = ``; } else if (mood === "sad") { eyes = `` + `` + ``; mouth = ``; extra = ``; } else if (mood === "angry") { eyes = `` + `` + ``; mouth = ``; cheeks = ``; extra = ``; } else if (mood === "depressed") { eyes = `` + ``; mouth = ``; extra = `` + `` + `` + `` + `` + `` + ``; } return { eyes, mouth, cheeks, extra }; } function seyarSigmaSVG(mood: SeyarMood): string { const C = PALETTE.sigma; const f = face(mood, 80, 86, 100, 114, C.ink, C.mouth, C.tear, C.cheek, 40); const a = 12 + ARM_DELTA[mood], dy = Y_SHIFT[mood]; return ` ${f.extra}${f.eyes}${f.cheeks}${f.mouth} Σ `; } function seyarDeltaSVG(mood: SeyarMood): string { const C = PALETTE.delta; const f = face(mood, 84, 108, 100, 128, C.ink, C.mouth, C.tear, C.cheek, 32); const a = 16 + ARM_DELTA[mood], dy = Y_SHIFT[mood]; return ` ${f.extra}${f.eyes}${f.cheeks}${f.mouth} `; } function seyarPiSVG(mood: SeyarMood): string { const C = PALETTE.pi; const f = face(mood, 80, 112, 100, 138, C.ink, C.mouth, C.tear, C.cheek, 40); const a = 18 + ARM_DELTA[mood], dy = Y_SHIFT[mood]; return ` ${f.extra}${f.eyes}${f.cheeks}${f.mouth} `; } export const SEYAR_SVG: Record string> = { sigma: seyarSigmaSVG, delta: seyarDeltaSVG, pi: seyarPiSVG, }; export const SEYAR_INFO: Record = { sigma: { name: "سیگما", symbol: "Σ", role: "راهنمای آزمون و کوییز" }, delta: { name: "دلتا", symbol: "Δ", role: "هم‌تیمیِ تمرین‌های سریع" }, pi: { name: "پی", symbol: "π", role: "همراهِ دلگرمی" }, }; /** slugِ کاراکترِ سرور (sigma/delta/pi) را به یکی از سه‌یار نگاشت می‌کند. */ export function seyarFromSlug(slug: string | null | undefined): SeyarChar | null { const s = (slug ?? '').toLowerCase(); if (s === 'sigma' || s === 'delta' || s === 'pi') return s; return null; } /** حالتِ ماسکوت که سرور می‌دهد («happy»، «encourage»، …) را به حالتِ سه‌یار نگاشت می‌کند. */ export function moodFromServer(server: string | null | undefined): SeyarMood { const s = (server ?? '').toLowerCase(); if (s.includes('excited') || s.includes('celebrat')) return 'excited'; if (s.includes('happy') || s.includes('encourage')) return 'happy'; if (s.includes('sad')) return 'sad'; if (s.includes('angry')) return 'angry'; if (s.includes('depress') || s.includes('tired')) return 'depressed'; return 'idle'; }