Group Sokko TCG's interface files by Guild quest and card rendering

The 48 files of the Daily Card, Expeditions, Daily Team and race, Broken
Mirror and card rendering move to daily/, expeditions/, team/, mirror/ and
rendering/ under website/src/features/cards, with every relative import
rewritten. The root keeps the page, server calls, cache and the player
sections outside the Guild. The cards README, the quest recipe and the
current docs follow the new paths; dated audits and plans keep theirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-12-01 11:35:18 +01:00
parent 863050437f
commit 88c7bf8317
74 changed files with 165 additions and 161 deletions

View file

@ -1,214 +0,0 @@
/**
* @file Depuis les Expéditions, améliorer ses cartes sans passer par la collection. `CardSheet` ouvre la
* fiche d'une carte sur son amélioration ; `EngraveModal` est l'atelier de gravure du Burin.
*/
import { useState } from "react";
import { Modal } from "../../components/Modal.jsx";
import { CardDetailModal } from "./CardDetailModal.jsx";
import { engraveEquipment } from "./cardsApi.js";
import { fillTemplate } from "./dailyShare.js";
import { ExpeditionCardTile } from "./ExpeditionCardTile.jsx";
import { CardsFilterMenu } from "./CardsFilterMenu.jsx";
import { EquipmentStats } from "./ExpeditionEquipmentSlots.jsx";
import { editionEntry, STAT_IDS, tagColor, tagLabel } from "./expeditionFormat.js";
import { MaskIcon } from "./ExpeditionLabels.jsx";
import { NebulaCard } from "./NebulaCard.jsx";
// Filtres d'une liste de cartes : recherche par nom, collections, et une stat. `mode` « filter » ne garde que les cartes qui
// apportent la stat (les communes), « sort » trie toutes les cartes par cette stat (les cartes personnage) ; dans les deux cas,
// la plus forte d'abord.
function useCardFilters() {
const [search, setSearch] = useState("");
const [collectionIds, setCollectionIds] = useState([]);
const [stat, setStat] = useState(null);
return { search, setSearch, collectionIds, setCollectionIds, stat, setStat };
}
function applyCardFilters(items, filters, { entryOf, statOf, mode }) {
const query = filters.search.trim().toLocaleLowerCase("fr");
const kept = items.filter((item) => {
const entry = entryOf(item);
if (!entry) return false;
if (query && !entry.card.name.toLocaleLowerCase("fr").includes(query)) return false;
if (filters.collectionIds.length && !filters.collectionIds.includes(entry.card.collectionId)) return false;
return !(filters.stat && mode === "filter" && !(statOf(item, filters.stat) > 0));
});
return filters.stat ? [...kept].sort((a, b) => (statOf(b, filters.stat) || 0) - (statOf(a, filters.stat) || 0)) : kept;
}
function CardFilters({ catalog, filters, entries, content }) {
const present = new Set(entries.map((entry) => entry?.card.collectionId).filter(Boolean));
const options = catalog.collections.filter((collection) => present.has(collection.id)).map((collection) => ({ value: collection.id, label: collection.name }));
return <div className="filter-panel nds-filter-panel nebula-card-filters" data-variant="horizontal-menu" role="group" aria-label={content.filtersLabel}>
<label className="nds-filter-search"><span className="sr-only">{content.filterSearch}</span>
<input className="nds-input" data-size="sm" type="search" value={filters.search} placeholder={content.filterSearch} onChange={(event) => filters.setSearch(event.target.value)} />
</label>
{options.length > 1 && <CardsFilterMenu label={content.filterCollection} options={options} selected={filters.collectionIds} onChange={filters.setCollectionIds} />}
<div className="nds-toolbar nebula-card-filters-stats" role="group" aria-label={content.filterStats}>{STAT_IDS.map((stat) => <button key={stat} type="button" className="nds-button" data-size="sm"
data-variant={filters.stat === stat ? "primary" : "secondary"} aria-pressed={filters.stat === stat} onClick={() => filters.setStat(filters.stat === stat ? null : stat)}>
<MaskIcon name={stat} />{content.stats[stat]}
</button>)}</div>
</div>;
}
// Familles d'étiquettes, dans l'ordre de l'atelier ; une étiquette se range selon le préfixe de son identifiant.
const TAG_GROUPS = ["personnage", "lieu", "theme", "objet"];
// Une étiquette à graver. Celle de la carte personnage choisie prend sa couleur, comme ses pastilles dans les Expéditions
// (`color`) ; le lecteur d'écran l'annonce en synergie.
function TagChoice({ catalog, tag, selected, color, content, disabled, onSelect }) {
const label = tagLabel(catalog, tag);
return <button type="button" className="nds-button nebula-engrave-tag" data-size="sm" data-variant={selected ? "primary" : "secondary"} data-tag-color={color} aria-pressed={selected}
aria-label={color ? fillTemplate(content.engraveSynergyLabel, { tag: label }) : undefined} disabled={disabled} onClick={onSelect}>
{color && <MaskIcon name="link" />}{label}
</button>;
}
// Atelier de gravure, en deux pages. 1. La commune, parmi celles qui ne sont pas encore gravées (posées ou non) ; une commune posée
// sur une carte présélectionne cette carte personnage à la page suivante. 2. L'étiquette à
// graver : celles d'une carte personnage qu'on choisit (la commune ne les a pas encore ; les graver crée une synergie ; dans sa
// couleur, avec l'icône de lien), ou toutes,
// par famille ; puis la confirmation, car la gravure est définitive. Depuis « Graver » sous un emplacement, la commune et la carte
// sont déjà choisies (`equipmentId`, `characterId`). Un Burin par gravure.
export function EngraveModal({ catalog, state, view, content, busy, runMutation, onClose, equipmentId = null, characterId = null }) {
const commons = (state.equipment || []).filter((item) => !item.engraved)
.map((item) => ({ item, entry: editionEntry(catalog, item.editionId) })).filter(({ entry }) => entry)
.sort((a, b) => Number(Boolean(b.item.equippedOn)) - Number(Boolean(a.item.equippedOn)) || a.entry.card.name.localeCompare(b.entry.card.name, "fr"));
const [chosen, setChosen] = useState(equipmentId);
const [character, setCharacter] = useState(characterId);
const commonFilters = useCardFilters();
const cardFilters = useCardFilters();
const [pickingCard, setPickingCard] = useState(false);
const [tag, setTag] = useState(null);
// Filtres de « Toutes les étiquettes » : nom, familles cochées (aucune : toutes), et seulement celles de la carte choisie.
const [tagSearch, setTagSearch] = useState("");
const [tagGroups, setTagGroups] = useState([]);
const [onlyCharacter, setOnlyCharacter] = useState(false);
const [error, setError] = useState("");
const burins = state.items?.engraving ?? 0;
const common = commons.find(({ item }) => item.editionId === chosen) || null;
const owned = new Set(common?.item.tags || []);
const characterCard = character && view.cards.find((card) => card.editionId === character);
const characterTags = (characterCard?.tags || []).filter((id) => !owned.has(id));
// Couleur d'une étiquette de la carte choisie, à sa place parmi les étiquettes de la carte (comme sous la carte des Expéditions).
const colorOf = (id) => (characterTags.includes(id) ? tagColor(characterCard.tags, id) : undefined);
const nameOf = (editionId) => editionEntry(catalog, editionId)?.card.name || "";
const engrave = async () => {
setError("");
const done = await runMutation(async () => {
try {
return await engraveEquipment(common.item.editionId, tag);
} catch (mutationError) {
setError(mutationError.message);
return null;
}
});
if (done) onClose();
};
const header = <>
<h2 id="nebula-engrave-title">{content.engraveTitle}</h2>
<p className="nebula-form-help">{fillTemplate(content.engraveHelp, { count: burins, s: burins > 1 ? "s" : "" })}</p>
{error && <p className="nds-inline-notice" data-variant="warning" role="alert">{error}</p>}
</>;
const footer = (back) => <div className="nds-toolbar nebula-expedition-picker-actions">
{back && <button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={back}>{content.engraveBack}</button>}
<button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={onClose}>{content.cancel}</button>
</div>;
let body;
if (!common) {
// Page 1 : la commune, filtrée.
const shownCommons = applyCardFilters(commons, commonFilters, { entryOf: ({ entry }) => entry, statOf: ({ item }, stat) => item.stats?.[stat], mode: "filter" });
body = <>
<h3 className="nebula-engrave-heading">{content.engraveCommon}</h3>
{commons.length > 0 && <CardFilters catalog={catalog} filters={commonFilters} entries={commons.map(({ entry }) => entry)} content={content} />}
{!commons.length ? <p className="nds-inline-notice" data-variant="info">{content.engraveNoCommons}</p>
: !shownCommons.length ? <p className="nds-inline-notice" data-variant="info">{content.filterEmpty}</p>
: <ul className="nebula-equipment-choices-grid">{shownCommons.map(({ item, entry }) => <li key={item.editionId}>
<span className="nebula-equipment-choice"><NebulaCard catalog={catalog} entry={entry} size="sm" onSelect={busy ? undefined : () => { setChosen(item.editionId); setTag(null); if (item.equippedOn && view.cards.some((card) => card.editionId === item.equippedOn)) setCharacter(item.equippedOn); }}
selectLabel={fillTemplate(content.engraveChoose, { card: entry.card.name })} /></span>
<strong>{entry.card.name}</strong>
<EquipmentStats item={item} content={content} powerValues={view.powers} />
</li>)}</ul>}
{footer(null)}
</>;
} else if (pickingCard) {
// Choix de la carte personnage dont on veut les étiquettes.
body = <>
<h3 className="nebula-engrave-heading">{content.engravePickCardTitle}</h3>
<CardFilters catalog={catalog} filters={cardFilters} entries={view.cards.map((card) => editionEntry(catalog, card.editionId))} content={content} />
<ul className="nebula-expedition-cards" aria-label={content.cardsLabel}>{applyCardFilters([...view.cards].sort((a, b) => b.power - a.power), cardFilters, { entryOf: (card) => editionEntry(catalog, card.editionId), statOf: (card, stat) => card.stats[stat], mode: "sort" }).map((card) => <ExpeditionCardTile key={card.editionId} catalog={catalog} card={{ ...card, busy: false }}
destination={null} content={content} selected={card.editionId === character} onSelect={() => { setCharacter(card.editionId); setTag(null); setPickingCard(false); }} />)}</ul>
{footer(() => setPickingCard(false))}
</>;
} else {
// Page 2 : l'étiquette, pour une carte personnage ou parmi toutes.
const query = tagSearch.trim().toLocaleLowerCase("fr");
const shown = (id) => !owned.has(id) && (!query || tagLabel(catalog, id).toLocaleLowerCase("fr").includes(query)) && (!onlyCharacter || characterTags.includes(id));
const groups = TAG_GROUPS.filter((group) => !tagGroups.length || tagGroups.includes(group))
.map((group) => ({ group, tags: (catalog.expeditionTags || []).map((item) => item.id).filter((id) => id.startsWith(`${group}:`) && shown(id)) })).filter(({ tags }) => tags.length);
const toggleGroup = (group) => setTagGroups(tagGroups.includes(group) ? tagGroups.filter((item) => item !== group) : [...tagGroups, group]);
body = <>
<div className="nebula-engrave-common">
<span className="nebula-engrave-common-card"><NebulaCard catalog={catalog} entry={common.entry} size="sm" /></span>
<div>
<strong>{common.entry.card.name}</strong>
<EquipmentStats item={common.item} content={content} powerValues={view.powers} />
<span className="nebula-form-help">{content.engraveCommonTags}</span>
<ul className="nebula-engrave-own-tags">{common.item.tags.map((id) => <li key={id} className="nebula-tag-chip">{tagLabel(catalog, id)}</li>)}</ul>
{!equipmentId && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => { setChosen(null); setTag(null); }}>{content.engraveChange}</button>}
</div>
</div>
<section className="nebula-engrave-frame" aria-labelledby="nebula-engrave-for-card">
<h3 id="nebula-engrave-for-card">{content.engraveForCard}</h3>
{characterCard ? <>
<div className="nebula-engrave-character">
<span className="nebula-engrave-character-card"><NebulaCard catalog={catalog} entry={editionEntry(catalog, characterCard.editionId)} size="sm" onSelect={busy ? undefined : () => setPickingCard(true)}
selectLabel={content.engraveChangeCard} /></span>
<div>
<strong>{nameOf(characterCard.editionId)}</strong>
<p className="nebula-form-help">{characterTags.length ? content.engraveForCardHelp : content.engraveCardFull}</p>
<div className="nds-toolbar">{characterTags.map((id) => <TagChoice key={id} catalog={catalog} tag={id} selected={id === tag} color={colorOf(id)} content={content} disabled={busy} onSelect={() => setTag(id)} />)}</div>
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => setPickingCard(true)}>{content.engraveChangeCard}</button>
</div>
</div>
</> : <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => setPickingCard(true)}>{content.engravePickCard}</button>}
</section>
<section className="nebula-engrave-frame" aria-labelledby="nebula-engrave-all">
<h3 id="nebula-engrave-all">{content.engraveAllTags}</h3>
<div className="filter-panel nds-filter-panel nebula-card-filters" data-variant="horizontal-menu" role="group" aria-label={content.tagFiltersLabel}>
<label className="nds-filter-search"><span className="sr-only">{content.tagSearch}</span>
<input className="nds-input" data-size="sm" type="search" value={tagSearch} placeholder={content.tagSearch} onChange={(event) => setTagSearch(event.target.value)} />
</label>
<div className="nds-toolbar" role="group" aria-label={content.tagFamilies}>{TAG_GROUPS.map((group) => <button key={group} type="button" className="nds-button" data-size="sm"
data-variant={tagGroups.includes(group) ? "primary" : "secondary"} aria-pressed={tagGroups.includes(group)} onClick={() => toggleGroup(group)}>{content.engraveTagGroups[group]}</button>)}</div>
{characterTags.length > 0 && <button type="button" className="nds-button nebula-engrave-tag" data-size="sm" data-variant={onlyCharacter ? "primary" : "secondary"} aria-pressed={onlyCharacter}
onClick={() => setOnlyCharacter(!onlyCharacter)}><MaskIcon name="link" />{content.tagOnlyCharacter}</button>}
</div>
{!groups.length && <p className="nds-inline-notice" data-variant="info">{content.tagEmpty}</p>}
{groups.map(({ group, tags }) => <div key={group} className="nebula-engrave-group" role="group" aria-label={content.engraveTagGroups[group]}>
<h4>{content.engraveTagGroups[group]}</h4>
<div className="nds-toolbar">{tags.map((id) => <TagChoice key={id} catalog={catalog} tag={id} selected={id === tag} color={colorOf(id)} content={content} disabled={busy} onSelect={() => setTag(id)} />)}</div>
</div>)}
</section>
{tag && <div className="nebula-engrave-confirm" role="group" aria-label={content.engraveButton}>
<p className="nebula-form-help">{content.engraveForever}</p>
<button className="nds-button" data-variant="primary" type="button" disabled={busy || burins < 1} onClick={engrave}>
{fillTemplate(content.engraveConfirm, { tag: tagLabel(catalog, tag), card: common.entry.card.name })}
</button>
</div>}
{footer(null)}
</>;
}
return <Modal dialogClassName="confirm-modal nds-modal nebula-expedition-picker nebula-engrave" labelledBy="nebula-engrave-title" onRequestClose={onClose} canClose={!busy}>
{header}
{body}
</Modal>;
}
// `content` : textes cards.cardSheet.
export function CardSheet({ catalog, state, editionId, content, focus = null, busy, runMutation, onClose }) {
const entry = editionEntry(catalog, editionId);
if (!entry) return null;
return <CardDetailModal catalog={catalog} state={state} entry={entry} content={content} focus={focus} initialTab="improve" runMutation={runMutation} busy={busy} onClose={onClose} />;
}