Let Sokko TCG commons equip cards and add expedition synergies with a Grimoire

- Every common carries equipment spreading six points (+6, +3/+3, +2/+2/+2 or +8/−2), validated at load; every rare or better card shares a tag with at least three commons.
- Power opens up to three equipment slots; a common sharing a tag with its card adds synergy points, and a common equips one card at a time without ever leaving the collection.
- Teams earn score bonuses from destination affinity and resonances (Écho, Lignée, Étoiles sœurs), capped together with group cohesion.
- The Grimoire records lore pairs when equipping and resonances at departure for every player of the team.
- The card sheet lists equipment slots with synergy hints; previews, groups and reports show affinity and resonance badges; Administration › Guilde tunes slots, synergy points and score bonuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-15 16:40:06 +01:00
parent e0ffccd1c8
commit 6828683f1d
33 changed files with 1041 additions and 107 deletions

View file

@ -1,6 +1,7 @@
// Rôle : affiche la fiche détaillée d'une carte possédée (grand format, favori, recyclage d'un doublon).
import { Modal } from "../../components/Modal.jsx";
import { recycleDuplicates, setFavorite, upgradeCard } from "./cardsApi.js";
import { CardEquipment } from "./CardEquipment.jsx";
import { readCollection } from "./collectionState.js";
import { NebulaCard } from "./NebulaCard.jsx";
import { formatEclats } from "./expeditionFormat.js";
@ -9,7 +10,7 @@ import { formatStardust } from "./stardustFormat.js";
const STATS = [["bravoure", "Bravoure"], ["endurance", "Endurance"], ["fortune", "Fortune"], ["orientation", "Orientation"]];
// Expéditions : niveau, Puissance, stats et amélioration d'une carte rare ou mieux (Éclats, ou doublon de la même édition).
function CardProgress({ progress, eclats, busy, runMutation }) {
function CardProgress({ catalog, state, progress, eclats, busy, runMutation }) {
const atCap = progress.nextCost == null;
return <section className="nebula-card-progress" aria-labelledby="nebula-card-progress-title">
<h3 id="nebula-card-progress-title">Expéditions · niveau {progress.level} / {progress.maxLevel}</h3>
@ -20,6 +21,7 @@ function CardProgress({ progress, eclats, busy, runMutation }) {
{progress.spare > 0 && <button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={() => runMutation(() => upgradeCard(progress.editionId, "duplicate"))}>Améliorer avec un doublon</button>}
</div>}
{!atCap && <p className="nebula-form-help">Vous avez {formatEclats(eclats)} Éclats. Chaque retour d’expédition donne de l’expérience de terrain ({progress.fieldXp} % du niveau suivant).</p>}
<CardEquipment catalog={catalog} state={state} progress={progress} busy={busy} runMutation={runMutation} />
</section>;
}
@ -36,7 +38,7 @@ export function CardDetailModal({ catalog, state, entry, runMutation, busy, onCl
<div className="nebula-card-detail-layout"><NebulaCard catalog={catalog} entry={entry} size="lg" />
<div><p className="eyebrow">{catalog.rarities.find((item) => item.id === entry.edition.rarity)?.label}</p><h2 id="nebula-card-detail-title">{entry.card.name}</h2><p>{entry.card.description}</p>
<dl><div><dt>Exemplaires possédés</dt><dd>{quantity}</dd></div><div><dt>Collection</dt><dd>{catalog.collections.find((item) => item.id === entry.card.collectionId)?.name}</dd></div><div><dt>Finitions</dt><dd>{entry.edition.finishIds.map((id) => catalog.finishes.find((item) => item.id === id)?.label).join(" · ")}</dd></div></dl>
{progress && <CardProgress progress={progress} eclats={state.wallet.eclats ?? 0} busy={busy} runMutation={runMutation} />}
{progress && <CardProgress catalog={catalog} state={state} progress={progress} eclats={state.wallet.eclats ?? 0} busy={busy} runMutation={runMutation} />}
<button className="nds-button" data-variant={favorites.has(entry.edition.id) ? "primary" : "secondary"} type="button" disabled={busy} aria-pressed={favorites.has(entry.edition.id)} onClick={() => runMutation(() => setFavorite(entry.edition.id, !favorites.has(entry.edition.id)))}>{favorites.has(entry.edition.id) ? "Retirer des favoris" : "Ajouter aux favoris"}</button>
{spare > 0 && <button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={() => runMutation(() => recycleDuplicates(entry.edition.id))}>Recycler un doublon (+{formatStardust(value)})</button>}
{spare > 0 && onStartTransfer && <>

View file

@ -0,0 +1,43 @@
// Rôle : équipe une carte rare ou mieux depuis sa fiche : emplacements ouverts par la Puissance, communes à poser et leurs synergies.
import { useState } from "react";
import { equipCard } from "./cardsApi.js";
import { tagLabel } from "./expeditionFormat.js";
const STAT_SHORT = { bravoure: "Bravoure", endurance: "Endurance", fortune: "Fortune", orientation: "Orientation" };
const statsText = (stats) => Object.entries(stats).map(([stat, value]) => `${value > 0 ? "+" : "−"}${Math.abs(value)} ${STAT_SHORT[stat]}`).join(" · ");
export function CardEquipment({ catalog, state, progress, busy, runMutation }) {
const [choosing, setChoosing] = useState(null);
const nameOf = (cardId) => catalog.cards.find((card) => card.id === cardId)?.name || cardId;
const sharedTag = (item) => item.tags.find((tag) => progress.tags.includes(tag)) ?? null;
// Communes en synergie d'abord, puis les plus fortes sur leur meilleure stat.
const choices = [...(state.equipment || [])].sort((a, b) => Number(Boolean(sharedTag(b))) - Number(Boolean(sharedTag(a))) || Math.max(...Object.values(b.stats)) - Math.max(...Object.values(a.stats)));
const equip = async (slot, equipmentEditionId) => {
if (await runMutation(() => equipCard(progress.editionId, slot, equipmentEditionId))) setChoosing(null);
};
return <div className="nebula-card-equipment">
<h4>Équipements</h4>
<ul className="nebula-card-equipment-slots">{progress.slotPowers.map((power, slot) => {
const item = progress.equipment.find((entry) => entry.slot === slot);
const open = slot < progress.slots;
return <li key={slot} className="nds-list-row" data-locked={!open || undefined}>
{!open ? <span>Emplacement ouvert à Puissance {power}</span> : item ? <>
<span><strong>{item.name}</strong> {statsText(item.stats)}{item.synergyTag && <span className="nds-badge" data-variant="success">Synergie · {tagLabel(catalog, item.synergyTag)}</span>}</span>
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => equip(slot, null)}>Retirer</button>
</> : <>
<span>Emplacement libre</span>
<button className="nds-button" data-size="sm" data-variant={choosing === slot ? "primary" : "secondary"} type="button" disabled={busy || !choices.length} aria-pressed={choosing === slot} onClick={() => setChoosing(choosing === slot ? null : slot)}>Équiper</button>
</>}
</li>;
})}</ul>
{!choices.length && <p className="nebula-form-help">Les cartes communes servent d’équipement : ouvrez des paquets pour en obtenir.</p>}
{choosing != null && <ul className="nebula-card-equipment-choices" aria-label="Communes à poser">{choices.map((item) => {
const tag = sharedTag(item);
const elsewhere = item.equippedOn && item.equippedOn !== progress.editionId;
return <li key={item.editionId} className="nds-list-row">
<span><strong>{nameOf(item.cardId)}</strong> {statsText(item.stats)}{tag && <span className="nds-badge" data-variant="success">Synergie · {tagLabel(catalog, tag)}</span>}{elsewhere && <span className="nebula-form-help"> équipe déjà {nameOf(catalog.editions.find((edition) => edition.id === item.equippedOn)?.cardId)}</span>}</span>
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy} aria-label={`Poser ${nameOf(item.cardId)}`} onClick={() => equip(choosing, item.editionId)}>Poser</button>
</li>;
})}</ul>}
</div>;
}

View file

@ -1,7 +1,7 @@
// Rôle : présente un groupe en formation sur le tableau de la Guilde : membres, rôles libres, résultat attendu, et l'inscription d'une carte.
import { useState } from "react";
import { fillTemplate, formatCountdown } from "./dailyShare.js";
import { conditionText, coverEntry, dangerText, editionEntry, formatEclats } from "./expeditionFormat.js";
import { conditionText, coverEntry, dangerText, editionEntry, formatEclats, synergyLabels } from "./expeditionFormat.js";
import { NebulaCard } from "./NebulaCard.jsx";
const TIER_VARIANTS = { struggle: "neutral", success: "success", triumph: "gold" };
@ -50,6 +50,7 @@ export function ExpeditionGroupCard({ catalog, group, cards, content, now, busy,
<div className="nebula-expedition-rewards" aria-label={content.groupProjected}>
<span className="nds-badge" data-variant={TIER_VARIANTS[projected.tier]}>{content.tiers[projected.tier]}</span>
<span className="nds-badge" data-variant="neutral">{fillTemplate(content.score, { score: formatEclats(projected.scorePct) })}</span>
{synergyLabels(projected, catalog, content).map((label) => <span key={label} className="nds-badge" data-variant="success">{label}</span>)}
{projected.cohesionPct > 0 && <span className="nds-badge" data-variant="success">{fillTemplate(content.cohesion, { value: projected.cohesionPct })}</span>}
<span className="nds-badge" data-variant="gold">{fillTemplate(content.lootBonus, { value: formatEclats(projected.lootPct / 100) })}</span>
</div>

View file

@ -2,7 +2,7 @@
import { useEffect, useMemo, useState } from "react";
import { previewExpedition } from "./cardsApi.js";
import { fillTemplate } from "./dailyShare.js";
import { conditionText, coverEntry, dangerText, editionEntry, formatDecimal, formatEclats, STAT_IDS } from "./expeditionFormat.js";
import { conditionText, coverEntry, dangerText, editionEntry, formatDecimal, formatEclats, STAT_IDS, synergyLabels } from "./expeditionFormat.js";
import { NebulaCard } from "./NebulaCard.jsx";
const PREVIEW_DELAY_MS = 250;
@ -24,11 +24,12 @@ function Requirements({ catalog, option, content }) {
</div>;
}
function Preview({ preview, content }) {
function Preview({ catalog, preview, content }) {
return <div className="nebula-expedition-preview" aria-live="polite">
<div className="nebula-expedition-rewards">
<span className="nds-badge" data-variant={TIER_VARIANTS[preview.tier]}>{content.tiers[preview.tier]}</span>
<span className="nds-badge" data-variant="neutral">{fillTemplate(content.score, { score: formatEclats(preview.scorePct) })}</span>
{synergyLabels(preview, catalog, content).map((label) => <span key={label} className="nds-badge" data-variant="success">{label}</span>)}
{preview.limitedByStars && <span className="nds-badge" data-variant="warning">{fillTemplate(content.limitedByStars, { stars: preview.limitedByStars })}</span>}
</div>
<ul className="nebula-expedition-checks">{preview.requirements.map((requirement) => <li key={requirement.stat} data-met={requirement.ratioPct >= 100 || undefined}>
@ -147,7 +148,7 @@ export function ExpeditionPlanner({ catalog, view, mode = "solo", content, busy,
{!complete && <p className="nebula-form-help">{fillTemplate(content.previewEmpty, { count: slotCount })}</p>}
{group && <p className="nebula-form-help">{content.groupPreviewNote}</p>}
{shownPreview?.error && <p className="nds-inline-notice" data-variant="warning" role="status">{shownPreview.error}</p>}
{shownPreview?.value && <Preview preview={shownPreview.value} content={content} />}
{shownPreview?.value && <Preview catalog={catalog} preview={shownPreview.value} content={content} />}
<div className="nds-toolbar">
<button className="nds-button" data-variant="primary" type="button" disabled={busy || !complete} onClick={async () => { if (await onStart(body)) setSlots(slots.map(() => null)); }}>{group ? content.groupStart : content.start}</button>
</div>

View file

@ -1,6 +1,6 @@
// Rôle : présente une expédition du joueur : en route (compte à rebours), revenue (butin à récupérer), terminée ou annulée.
import { fillTemplate, formatCountdown } from "./dailyShare.js";
import { coverEntry, editionEntry, formatEclats } from "./expeditionFormat.js";
import { coverEntry, editionEntry, formatEclats, synergyLabels } from "./expeditionFormat.js";
import { NebulaCard } from "./NebulaCard.jsx";
import { formatStardust } from "./stardustFormat.js";
@ -32,6 +32,7 @@ export function ExpeditionReport({ catalog, expedition, content, now, busy, onCl
{expedition.result && <div className="nebula-expedition-rewards">
<span className="nds-badge" data-variant={TIER_VARIANTS[expedition.result.tier]}>{content.tiers[expedition.result.tier]}</span>
<span className="nds-badge" data-variant="neutral">{fillTemplate(content.score, { score: formatEclats(expedition.result.scorePct) })}</span>
{synergyLabels(expedition.result, catalog, content).map((label) => <span key={label} className="nds-badge" data-variant="success">{label}</span>)}
</div>}
{expedition.reward && <RewardBadges reward={expedition.reward} content={content} />}
{expedition.result?.players > 1 && <p className="nebula-form-help">{fillTemplate(content.reportPlayers, { count: expedition.result.players, loot: formatEclats(expedition.result.lootPct / 100) })}</p>}

View file

@ -5,7 +5,7 @@ import { fillTemplate, formatCountdown } from "./dailyShare.js";
import { ExpeditionGroupCard } from "./ExpeditionGroupCard.jsx";
import { ExpeditionPlanner } from "./ExpeditionPlanner.jsx";
import { ExpeditionReport } from "./ExpeditionReport.jsx";
import { formatEclats } from "./expeditionFormat.js";
import { formatEclats, grimoireLabel } from "./expeditionFormat.js";
import { formatStardust } from "./stardustFormat.js";
const COUNTDOWN_TICK_MS = 30_000;
@ -112,6 +112,12 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content })
: <p className="nebula-form-help">{content.groupsEmpty}</p>}
</section>}
<section className="nds-panel nebula-expedition-grimoire" aria-labelledby="nebula-expedition-grimoire-title">
<h3 id="nebula-expedition-grimoire-title">{content.grimoireTitle} <span className="nds-badge" data-variant="neutral">{fillTemplate(content.grimoireCount, { count: view.grimoire.length, s: view.grimoire.length > 1 ? "s" : "" })}</span></h3>
<p className="nebula-form-help">{content.grimoireHelp}</p>
{view.grimoire.length ? <ul className="nebula-expedition-rewards">{view.grimoire.map((entry) => <li key={entry.id} className="nds-badge" data-variant="gold">{grimoireLabel(entry.id, catalog, content)}</li>)}</ul> : <p className="nebula-form-help">{content.grimoireEmpty}</p>}
</section>
{!view.enabled ? <div className="nds-empty-state"><h3>{content.closedTitle}</h3><p>{content.closedText}</p></div>
: !expired && <>
<div className="nebula-expedition-plan-heading">

View file

@ -62,6 +62,21 @@ export const EXPEDITION_SETTING_GROUPS = [
{ path: "progression.stardustPerEclat", label: "Poussières pour 1 Éclat (pont)" }
]
},
{
id: "equipment",
title: "Équipements et synergies",
help: "Emplacements d’équipement ouverts par la Puissance, points de synergie d’une commune qui partage une étiquette avec sa carte, et bonus de score de l’Affinité et des Résonances.",
fields: [
{ path: "equipment.maxPerCard", label: "Équipements au plus par carte" },
{ path: "equipment.secondSlotPower", label: "Puissance qui ouvre le 2e emplacement" },
{ path: "equipment.thirdSlotPower", label: "Puissance qui ouvre le 3e emplacement" },
{ path: "equipment.synergyBonus", label: "Points ajoutés par une synergie d’équipement" },
{ path: "synergy.affinityPct", label: "Affinité avec la destination (% de score)" },
{ path: "synergy.resonancePct", label: "Valeur d’une Résonance (% de score)" },
{ path: "synergy.maxResonances", label: "Résonances actives au plus" },
{ path: "synergy.sistersCount", label: "Cartes d’un même thème pour les Étoiles sœurs" }
]
},
{
id: "requirements",
title: "Exigences",

View file

@ -213,3 +213,8 @@ export function upgradeCard(editionId, method) {
export function convertStardust(eclats) {
return request("/eclats/convert", { method: "POST", body: JSON.stringify({ eclats }) });
}
// Pose une commune sur un emplacement d'une carte, ou le vide avec `equipmentEditionId` nul.
export function equipCard(editionId, slot, equipmentEditionId) {
return request("/equipment", { method: "PUT", body: JSON.stringify({ editionId, slot, equipmentEditionId }) });
}

View file

@ -44,3 +44,19 @@ export function editionEntry(catalog, editionId) {
const card = edition && catalog.cards.find((item) => item.id === edition.cardId);
return card ? { editionId, edition, card } : null;
}
// Badges des bonus de score d'un résultat : Affinité avec la destination, puis chaque Résonance.
export function synergyLabels(result, catalog, content) {
const labels = [];
if (result?.affinity) labels.push(fillTemplate(content.affinity, { tag: tagLabel(catalog, result.affinity) }));
for (const resonance of result?.resonances || []) labels.push(fillTemplate(content.resonance, { type: content.resonanceTypes[resonance.type], tag: tagLabel(catalog, resonance.key) }));
return labels;
}
// Une découverte du Grimoire : « pair:<étiquette> » ou « resonance:<sorte>:<étiquette> ».
export function grimoireLabel(entryId, catalog, content) {
const [kind, ...rest] = entryId.split(":");
if (kind === "pair") return fillTemplate(content.grimoirePair, { tag: tagLabel(catalog, rest.join(":")) });
const [type, ...tag] = rest;
return fillTemplate(content.resonance, { type: content.resonanceTypes[type] || type, tag: tagLabel(catalog, tag.join(":")) });
}