Add the Sokko TCG collectible card mini-game
Add the server-backed card game: Discord login, recharging pack openings, album, trades, gifts, stardust shop, campaign codes and its administration, stored in SQLite and disabled in production until configured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
243465720f
commit
5ce35cd7ba
193 changed files with 12159 additions and 28 deletions
48
website/src/features/cards/CardsHomePanel.jsx
Normal file
48
website/src/features/cards/CardsHomePanel.jsx
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Rôle : compose le tableau de bord d'accueil compact de Sokko TCG.
|
||||
import { useState } from "react";
|
||||
import { CardDetailModal } from "./CardDetailModal.jsx";
|
||||
import { DashboardStat } from "./CardsDashboard.jsx";
|
||||
import { readCollection } from "./collectionState.js";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
import { OpeningReserve } from "./OpeningReserve.jsx";
|
||||
import { StardustBalance } from "./ShopPanel.jsx";
|
||||
|
||||
export function CardsHomePanel({ catalog, state, runMutation, busy, content, onOpenPacks }) {
|
||||
const [detailOpen, setDetailOpen] = useState(false);
|
||||
const collectibleCards = catalog.cards.filter((card) => catalog.editions.some((edition) => edition.cardId === card.id && !edition.promotional));
|
||||
const collectibleEditions = catalog.editions.filter((edition) => !edition.promotional);
|
||||
const owned = readCollection(state);
|
||||
const discoveredCards = collectibleCards.filter((card) => owned.ownedCardIds.has(card.id)).length;
|
||||
const discoveredEditions = collectibleEditions.filter((edition) => owned.quantities.has(edition.id)).length;
|
||||
const rarest = state.rarestPull;
|
||||
const rarity = rarest && catalog.rarities.find((item) => item.id === rarest.edition.rarity);
|
||||
|
||||
return <section className="nebula-home" aria-labelledby="nebula-home-title">
|
||||
<div className="nds-section-heading nebula-home-heading">
|
||||
<div><p className="eyebrow">{content.eyebrow}</p><h2 id="nebula-home-title">{content.title}</h2></div>
|
||||
</div>
|
||||
{state.pendingOpening && <div className="nds-inline-notice nebula-home-resume" data-variant="warning"><span>{content.resume}</span><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={onOpenPacks}>{content.resumeAction}</button></div>}
|
||||
<div className="nebula-home-grid">
|
||||
<OpeningReserve recharge={state.recharge} content={content}>
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={onOpenPacks}>{content.browsePacks}</button>
|
||||
</OpeningReserve>
|
||||
<section className="nds-panel nebula-home-rarest" aria-labelledby="nebula-home-rarest-title">
|
||||
<div className="nebula-home-rarest-copy">
|
||||
<p className="eyebrow">{content.rarestEyebrow}</p>
|
||||
<h2 id="nebula-home-rarest-title">{content.rarestTitle}</h2>
|
||||
{rarest ? <><strong>{rarest.card.name}</strong><span className="nebula-home-rarity" data-rarity={rarest.edition.rarity}>{rarity?.label}</span><time dateTime={new Date(rarest.openedAt).toISOString()}>{new Date(rarest.openedAt).toLocaleDateString("fr-FR")}</time></> : <p>{content.noPull}</p>}
|
||||
</div>
|
||||
{rarest && <div className="nebula-home-rarest-card"><NebulaCard catalog={catalog} entry={rarest} size="md" onSelect={() => setDetailOpen(true)} /></div>}
|
||||
</section>
|
||||
</div>
|
||||
<section className="nebula-dashboard-stats nebula-home-stats" aria-label="Statistiques de collection">
|
||||
<DashboardStat label={content.cardsDiscovered} value={<>{discoveredCards}<small> / {collectibleCards.length}</small></>} />
|
||||
<DashboardStat label={content.editionsDiscovered} value={<>{discoveredEditions}<small> / {collectibleEditions.length}</small></>} />
|
||||
<DashboardStat label={content.ownedCopies} value={owned.totalCopies} />
|
||||
<DashboardStat label={content.packsOpened} value={state.stats?.openingsCount || 0} />
|
||||
<DashboardStat label={content.stardust} value={<StardustBalance value={state.wallet.stardust} />} />
|
||||
<DashboardStat label={content.recyclable} value={state.recycling.count} />
|
||||
</section>
|
||||
{detailOpen && rarest && <CardDetailModal catalog={catalog} state={state} entry={rarest} runMutation={runMutation} busy={busy} onClose={() => setDetailOpen(false)} />}
|
||||
</section>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue