--- const { frontmatter, streakCount = 1 } = Astro.props; const { birthDate, health, manifestations, date, name } = frontmatter; const medicationTaken = health?.mental?.medication ?? false; // 1. CALCUL DU NIVEAU ET VARIABLES DE BASE const referenceDate = new Date(date); const birth = new Date(birthDate); let age = referenceDate.getFullYear() - birth.getFullYear(); if ( new Date(referenceDate.getFullYear(), birth.getMonth(), birth.getDate()) > referenceDate ) age--; const stress = health?.somatic?.stress_level ?? 2; const hallucinations = health?.mental?.hallucinations ?? 0; const sleepBase = health?.somatic?.sleep_avg ?? 7.5; const energy = health?.somatic?.energy_level ?? 5; const hygieneScore = health?.somatic?.hygiene_level ?? 5; // 2. RÉINTÉGRATION DES COMPTAGES const counts = { PRO: manifestations?.filter((m) => m.cercle === "PRO").length || 0, SAN: manifestations?.filter((m) => m.cercle === "SAN").length || 0, SOC: manifestations?.filter((m) => m.cercle === "SOC").length || 0, FLX: manifestations?.filter((m) => m.cercle === "FLX").length || 0, HYG: manifestations?.filter((m) => m.cercle === "HYG").length || 0, }; // 3. SCORE D'HARMONIE RAFFINÉ const rawHarmony = manifestations?.reduce((acc, m) => { if (m.type === "pos") return acc + 1; if (m.type === "neg") return acc - 1; return acc; }, 0) || 0; const uniqueCercles = new Set(manifestations?.map((m) => m.cercle)).size; const hasAllCercles = uniqueCercles === 5; const harmonyScore = rawHarmony + (hasAllCercles ? 2 : 0); // 4. SYSTÈME DE RARETÉ ET SHINY let rarity = "COMMUNE"; let isShiny = false; // Condition Shiny : Dès 3 jours de série + équilibre des cercles if (streakCount >= 3 && uniqueCercles >= 3) { isShiny = true; } // Paliers de Rareté if (streakCount >= 3) rarity = "PEU COMMUNE"; if (streakCount >= 6) rarity = "RARE"; // Ta situation actuelle if (streakCount >= 10 && harmonyScore >= 4) rarity = "LÉGENDAIRE"; if (streakCount >= 20 && hallucinations === 0) rarity = "MYTHIQUE"; // 5. STATS TCG (Avec bonus de série) const autoMotivation = health?.mental?.motivation ?? Math.min(10, uniqueCercles * 2.5); const streakBonus = Math.floor(streakCount / 7); const autoAtk = Math.min( 15, counts.PRO * 2 + Math.floor(autoMotivation / 4) + Math.floor(energy / 3) + // L'énergie booste l'attaque (harmonyScore > 0 ? 1 : 0) + streakBonus, ); const sleepPenalty = sleepBase - (counts.PRO > 5 ? 1 : 0) < 6 ? 2 : 0; const autoDef = Math.max( 0, 10 + Math.floor(hygieneScore / 2) - stress - hallucinations - sleepPenalty + streakBonus, ); const autoCost = Math.max(1, Math.ceil((manifestations?.length || 0) / 2)); // 6. LOGIQUE DES BIOMES [cite: 39, 40, 41, 42, 43, 44] let autoBiome = "SAVANE"; let biomeReason = "Équilibre par défaut"; if (stress > 7 || hallucinations >= 2 || harmonyScore <= -3) { autoBiome = "ETANG"; biomeReason = "Alerte Santé / Harmonie critique"; } else if (uniqueCercles >= 3 && counts.SAN > 0) { autoBiome = "BELOUVE"; biomeReason = "Harmonie des Cercles"; } else if (counts.SOC > counts.PRO || counts.FLX > 2) { autoBiome = "OCEAN"; biomeReason = "Flux Social & Émotionnel"; } else if (counts.PRO >= 2 && counts.PRO >= counts.SOC) { autoBiome = "FOURNAISE"; biomeReason = "Dominance Technique (PRO)"; } const biomes = { ETANG: { color: "#737e71", label: "L'Inerte", strong: "SAVANE", weak: "OCEAN", }, SAVANE: { color: "#e2d1a4", label: "La Clarté", strong: "FOURNAISE", weak: "BELOUVE", }, OCEAN: { color: "#85a9bc", label: "Le Flux", strong: "FOURNAISE", weak: "BELOUVE", }, BELOUVE: { color: "#5b8c5d", label: "La Racine", strong: "ETANG", weak: "FOURNAISE", }, FOURNAISE: { color: "#b35d4d", label: "La Forge", strong: "BELOUVE", weak: "OCEAN", }, }; const currentBiome = biomes[autoBiome] || biomes.SAVANE; const circleSummaries = Object.entries(counts) .filter(([_, count]) => count > 0) .map(([type, count]) => ({ type, count, dominance: manifestations?.find((m) => m.cercle === type && m.type)?.type || "neu", })); // LAYER AUTO : Les constantes biologiques et calculées const autoLayer = [ { label: "Sommeil", value: `${sleepBase}h`, status: sleepBase < 6 ? "critique" : "stable", }, { label: "Énergie", value: `${energy}/10`, status: energy < 3 ? "bas" : "normal", }, { label: "Hallucinations", value: hallucinations, status: hallucinations > 4 ? "alerte" : "calme", }, { label: "Stabilité", value: currentBiome.label, status: "info" }, { label: "Traitement", value: medicationTaken ? "Pris" : "Absent", status: medicationTaken ? "stable" : "critique", }, ]; // LAYER MANUEL : Les leviers d'action et ressentis const manualLayer = [ { label: "Stress ressenti", value: `${stress}/10` }, { label: "Hygiène foyer", value: `${hygieneScore}/10` }, { label: "Harmonie globale", value: harmonyScore > 0 ? `+${harmonyScore}` : harmonyScore, }, ]; ---
{name} {autoCost}
{autoBiome}
{currentBiome.label}
{rarity}
Niveau {age} — {frontmatter.identity?.job || "PROTO"}
{ medicationTaken && ( 💊 ) } streak {streakCount}
{ circleSummaries.map((circle) => (
{circle.type} x{circle.count} {circle.dominance === "pos" && " +"} {circle.dominance === "neg" && " -"}
)) }
Indicateurs Somatiques
{ autoLayer.map((stat) => (
{stat.label} {stat.value}
)) }

Ressentis & Hygiène
{ manualLayer.map((stat) => (
{stat.label} {stat.value}
)) }