--- const { frontmatter, streakCount = 1 } = Astro.props; const { birthDate, health, manifestations, date, name } = frontmatter; // 1. CALCUL DU NIVEAU ET VARIABLES DE BASE [cite: 25, 26, 27] 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; // 2. RÉINTÉGRATION DES COMPTAGES (Le fix pour l'erreur) [cite: 28, 29, 30, 31] 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, }; // 3. SCORE D'HARMONIE RAFFINÉ [cite: 32, 33] 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 === 4; 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( 12, counts.PRO * 2 + Math.floor(autoMotivation / 4) + (harmonyScore > 0 ? 1 : 0) + streakBonus, ); const sleepPenalty = sleepBase - (counts.PRO > 5 ? 1 : 0) < 6 ? 2 : 0; const autoDef = Math.max( 0, 10 - 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", })); ---
{name} {autoCost}
{autoBiome}
{currentBiome.label}
{rarity}
Niveau {age} — {frontmatter.identity?.job || "PROTO"} streak {streakCount}
{ circleSummaries.map((circle) => (
{circle.type} x{circle.count} {circle.dominance === "pos" && " +"} {circle.dominance === "neg" && " -"}
)) }
  • Origine : {biomeReason}
  • Série : Bonus +{streakBonus} ATK/DEF
  • Stress {stress} • Sommeil {sleepBase}h • Harmonie { harmonyScore > 0 ? `+${harmonyScore}` : harmonyScore }