card cosmo ambient

This commit is contained in:
2026-02-20 21:54:38 +04:00
parent 3816b63a22
commit 9f3e5515d1
8 changed files with 6356 additions and 14 deletions

309
src/components/Card.astro Normal file
View File

@@ -0,0 +1,309 @@
---
const { frontmatter } = Astro.props;
const { birthDate, health, manifestations, date } = frontmatter;
// 1. CALCUL DU NIVEAU
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--;
// 2. VARIABLES ET COMPTAGES
const stress = health?.somatic?.stress_level ?? 2;
const hallucinations = health?.mental?.hallucinations ?? 0;
const sleepBase = health?.somatic?.sleep_avg ?? 7.5;
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
const harmonyScore =
manifestations?.reduce((acc, m) => {
if (m.type === "pos") return acc + 1;
if (m.type === "neg") return acc - 1;
return acc;
}, 0) || 0;
// 4. STATS TCG
const uniqueCercles = new Set(manifestations?.map((m) => m.cercle)).size;
const autoMotivation =
health?.mental?.motivation ?? Math.min(10, uniqueCercles * 2.5);
const harmonyAtkBonus = harmonyScore > 0 ? 1 : 0;
const harmonyDefPenalty = harmonyScore < -2 ? 2 : 0;
const autoAtk = Math.min(
10,
counts.PRO * 2 + Math.floor(autoMotivation / 4) + harmonyAtkBonus,
);
const sleepPenalty = sleepBase - (counts.PRO > 5 ? 1 : 0) < 6 ? 2 : 0;
const autoDef = Math.max(
0,
10 - stress - hallucinations - sleepPenalty - harmonyDefPenalty,
);
const autoCost = Math.max(1, Math.ceil((manifestations?.length || 0) / 2));
// 5. LOGIQUE DES BIOMES (L'ÉQUILIBRE FINAL)
let autoBiome = "SAVANE";
let biomeReason = "Équilibre par défaut";
// 1. SANTÉ (ÉTANG) - Priorité critique
if (stress > 7 || hallucinations >= 2 || harmonyScore <= -3) {
autoBiome = "ETANG";
biomeReason = "Alerte Santé / Harmonie critique";
}
// 2. ÉQUILIBRE RICHE (BELOUVE) - Priorité si diversité de vie
else if (uniqueCercles >= 3 && counts.SAN > 0) {
autoBiome = "BELOUVE";
biomeReason = "Harmonie des Cercles";
}
// 3. FLUX SOCIAL (OCEAN) - Si le social domine le pro
else if (counts.SOC > counts.PRO || counts.FLX > 2) {
autoBiome = "OCEAN";
biomeReason = "Flux Social & Émotionnel";
}
// 4. LA FORGE (FOURNAISE) - Si le pro domine OU si on a une accumulation (>= 2)
// mais qu'on n'est pas déjà tombé dans Belouve ou Ocean
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",
}));
---
<article class="tcg-card" style={`--biome-color: ${currentBiome.color}`}>
<div class="card-border">
<header class="card-header">
<span class="name">{frontmatter.name}</span>
<span class="cost">{autoCost}</span>
</header>
<div class="card-art">
<div class="biome-tag">{autoBiome}</div>
<div class="biome-label">{currentBiome.label}</div>
</div>
<div class="card-type-line">
Niveau {age} — {frontmatter.identity?.job || "PROTO"}
</div>
<div class="card-body">
{
circleSummaries.map((circle) => (
<div class="effect-line">
<span
class={`type-tag ${circle.type} ${circle.dominance}`}
>
{circle.type} <small>x{circle.count}</small>
{circle.dominance === "pos" && " +"}
{circle.dominance === "neg" && " -"}
</span>
</div>
))
}
</div>
<div class="rules-box">
<div class="mechanics-summary">
<ul>
<li><strong>Origine Biome :</strong> {biomeReason}</li>
<li>
<strong>Surcharge :</strong> PRO &gt; 5 ➔ Sommeil -1h
</li>
<li class="manual-values">
<strong>Apports :</strong> Stress {stress} • Sommeil {
sleepBase
}h • Hallu {hallucinations}
</li>
<li>
<strong>Harmonie :</strong> Score {
harmonyScore > 0 ? `+${harmonyScore}` : harmonyScore
} (Motiv. +{autoMotivation})
</li>
</ul>
</div>
</div>
<footer class="card-footer">
<div class="matchup">
<span>VS {currentBiome.strong} (+)</span>
<span>VS {currentBiome.weak} (-)</span>
</div>
<div class="stats-box">
{autoAtk} / {autoDef}
</div>
</footer>
</div>
</article>
<style>
/* Ton CSS reste identique */
.tcg-card {
width: 320px;
height: 480px;
background: var(--biome-color);
border-radius: 18px;
padding: 12px;
font-family: "Philosopher", serif;
color: #1e293b;
}
.card-border {
height: 100%;
border-radius: 10px;
display: flex;
flex-direction: column;
padding: 10px;
}
.card-header {
display: flex;
justify-content: space-between;
font-weight: bold;
}
.card-art {
flex: 1;
margin: 5px 0;
position: relative;
}
.biome-tag {
background: #333;
color: white;
padding: 2px 8px;
font-size: 0.6rem;
border-radius: 5px;
width: fit-content;
}
.biome-label {
font-size: 0.6rem;
padding: 2px 0;
}
.card-type-line {
border-bottom: 1px solid #333;
font-size: 0.75rem;
padding: 2px 5px;
margin-bottom: 5px;
font-weight: bold;
}
.card-body {
flex: 0.8;
display: flex;
gap: 5px;
flex-wrap: wrap;
}
.type-tag {
font-size: 0.7rem;
font-weight: bold;
padding: 2px 5px;
border-radius: 3px;
color: white;
background: #333;
}
.type-tag small {
font-size: 0.6rem;
opacity: 0.8;
}
.type-tag.pos {
border-left: 4px solid #4ade80;
}
.type-tag.neg {
border-left: 4px solid #f87171;
}
.PRO {
border-bottom: 3px solid #f59e0b;
}
.SAN {
border-bottom: 3px solid #3b82f6;
}
.SOC {
border-bottom: 3px solid #ec4899;
}
.FLX {
border-bottom: 3px solid #10b981;
}
.rules-box {
margin-top: auto;
padding: 6px;
background: rgba(255, 255, 255, 0.25);
border-radius: 6px;
border: 1px solid rgba(0, 0, 0, 0.1);
}
.mechanics-summary li {
font-size: 0.58rem;
list-style: none;
line-height: 1.3;
}
.manual-values {
border-top: 1px solid rgba(0, 0, 0, 0.1);
margin-top: 3px;
padding-top: 3px;
font-weight: bold;
}
.card-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 8px;
}
.stats-box {
background: #333;
color: white;
padding: 3px 8px;
border-radius: 5px;
font-size: 1.1rem;
}
.matchup {
font-size: 0.5rem;
text-transform: uppercase;
font-weight: bold;
}
</style>