- Each owned rare or better edition keeps a level and field experience; a level costs Éclats by current power, so every rarity reaches the same cap and a rare pays the longer road. - A duplicate of the same edition gives a whole level; every claimed expedition grants field experience to the cards it sent. - A one-way bridge turns stardust into Éclats at an admin-tuned rate. - The card sheet shows level, power, stats and experience with upgrade buttons; expeditions use the upgraded power. - Administration › Guilde tunes the cost formula, duplicate levels, field experience and the bridge rate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
6.2 KiB
JavaScript
80 lines
6.2 KiB
JavaScript
// Rôle : présente le journal personnel des ouvertures et de leurs cartes, des transferts, récompenses et achats en boutique.
|
||
import { formatStardust } from "./stardustFormat.js";
|
||
const EVENT_LABELS = {
|
||
pack_opened: "Paquet ouvert",
|
||
trade_created: "Échange proposé",
|
||
trade_received: "Proposition d’échange reçue",
|
||
trade_declined: "Échange refusé",
|
||
trade_joined: "Échange rejoint",
|
||
trade_completed: "Échange terminé",
|
||
trade_cancelled: "Échange annulé",
|
||
gift_created: "Don créé",
|
||
gift_joined: "Don rejoint",
|
||
gift_completed: "Don terminé",
|
||
gift_cancelled: "Don annulé",
|
||
campaign_claimed: "Code utilisé",
|
||
gift_pack_opened: "Paquet offert ouvert",
|
||
cards_recycled: "Doublons recyclés",
|
||
opening_purchased: "Ouverture achetée",
|
||
daily_won: "Carte du jour trouvée",
|
||
expedition_completed: "Expédition terminée",
|
||
expedition_cancelled_by_guild: "Expédition annulée par la Guilde",
|
||
expedition_dissolved: "Groupe d’expédition dissous",
|
||
card_upgraded: "Carte améliorée",
|
||
eclats_converted: "Éclats d’étoile obtenus"
|
||
};
|
||
|
||
// Le journal garde la quantité réellement offerte : les comptes plus anciens n'ont reçu qu'une ouverture.
|
||
function eventLabel(entry) {
|
||
if (entry.type !== "welcome_opening") return EVENT_LABELS[entry.type];
|
||
const amount = entry.details.amount ?? 1;
|
||
return amount > 1 ? `${amount} ouvertures de paquets de bienvenue offertes` : "1 ouverture de paquet de bienvenue offerte";
|
||
}
|
||
|
||
// Simple référence textuelle : le journal garde l'identifiant si la carte a depuis quitté le catalogue.
|
||
function cardReference(editionId, catalog) {
|
||
const edition = catalog.editions.find((item) => item.id === editionId);
|
||
const card = edition && catalog.cards.find((item) => item.id === edition.cardId);
|
||
if (!card) return editionId;
|
||
const finishes = edition.finishIds.filter((id) => id !== "standard").map((id) => catalog.finishes.find((item) => item.id === id)?.label);
|
||
return [card.name, ...finishes].filter(Boolean).join(" · ");
|
||
}
|
||
|
||
function OpenedCards({ entry, catalog, pendingOpeningId, content }) {
|
||
const editionIds = entry.details.cards;
|
||
if (!editionIds?.length) return null;
|
||
// L'entrée existe dès l'attribution du paquet : les cartes restent cachées tant qu'elles n'ont pas été révélées.
|
||
if (entry.entityId === pendingOpeningId) return <span>{content.pendingCards}</span>;
|
||
return <ul className="nebula-history-cards" aria-label="Cartes obtenues">{editionIds.map((editionId, index) => {
|
||
const rarityId = catalog.editions.find((item) => item.id === editionId)?.rarity;
|
||
const rarity = catalog.rarities.find((item) => item.id === rarityId)?.label;
|
||
return <li key={`${editionId}-${index}`} data-rarity={rarityId}><span className="nds-badge" data-variant="neutral"><i className="nebula-history-rarity" {...(rarity ? { role: "img", "aria-label": rarity, title: rarity } : { "aria-hidden": true })} />{cardReference(editionId, catalog)}</span></li>;
|
||
})}</ul>;
|
||
}
|
||
|
||
function HistoryDetail({ entry, catalog }) {
|
||
const { details } = entry;
|
||
if (details.sent || details.received) return <span>{[details.sent && `Donnée : ${cardReference(details.sent, catalog)}`, details.received && `Reçue : ${cardReference(details.received, catalog)}`].filter(Boolean).join(" · ")}</span>;
|
||
if (entry.type === "cards_recycled") return <span>{details.count} exemplaire{details.count > 1 ? "s" : ""} · +{formatStardust(details.stardust)} d’étoiles</span>;
|
||
if (entry.type === "daily_won") return <span>{`Défi n° ${details.number} · ${details.guesses}/6`}{details.stardust > 0 && ` · +${formatStardust(details.stardust)} d’étoiles`}</span>;
|
||
if (entry.type === "expedition_completed") {
|
||
const tier = { struggle: "Retour difficile", success: "Réussite", triumph: "Triomphe" }[details.tier];
|
||
const gains = [`+${details.eclats} Éclats`, details.stardust > 0 && `+${formatStardust(details.stardust)} d’étoiles`, details.packs > 0 && `${details.packs} paquet${details.packs > 1 ? "s" : ""} offert${details.packs > 1 ? "s" : ""}`].filter(Boolean);
|
||
return <span>{[`${details.destinationName} · ${"★".repeat(details.difficulty)} · ${details.hours} h`, tier, ...gains].filter(Boolean).join(" · ")}</span>;
|
||
}
|
||
if (entry.type === "expedition_cancelled_by_guild") return <span>{details.destinationName} · cartes libérées, sans butin</span>;
|
||
if (entry.type === "expedition_dissolved") return <span>{details.destinationName} · {details.reason === "creator_left" ? "dissous par son créateur" : "pas assez de joueurs"} · cartes libérées</span>;
|
||
if (entry.type === "card_upgraded") return <span>{[cardReference(entry.entityId, catalog), `niveau ${details.level}`, `Puissance ${details.power}`, details.method === "duplicate" ? "un doublon utilisé" : `−${details.eclats} Éclats`].join(" · ")}</span>;
|
||
if (entry.type === "eclats_converted") return <span>+{details.eclats} Éclats · −{formatStardust(details.stardust)} d’étoiles</span>;
|
||
if (entry.type === "opening_purchased") return <span>−{formatStardust(details.price)} d’étoiles</span>;
|
||
if (!details.collectionId) return null;
|
||
const name = catalog.collections.find((item) => item.id === details.collectionId)?.name;
|
||
if (details.price) return <span>{name} · −{formatStardust(details.price)}</span>;
|
||
return <span>{details.purchased ? `${name} · ouverture achetée` : name}</span>;
|
||
}
|
||
|
||
export function HistoryPanel({ state, catalog, content }) {
|
||
return <section aria-labelledby="nebula-history-title"><div className="nds-section-heading nebula-section-heading"><div><p className="eyebrow">Journal du compte</p><h2 id="nebula-history-title">Historique</h2></div></div>
|
||
{state.history.length ? <ol className="nebula-history-list">{state.history.map((entry, index) => <li key={`${entry.entityId}-${entry.createdAt}-${index}`} className="nds-list-row"><span className="nebula-history-mark" aria-hidden="true" /><div><strong>{eventLabel(entry) || entry.type}</strong><HistoryDetail entry={entry} catalog={catalog} /><OpenedCards entry={entry} catalog={catalog} pendingOpeningId={state.pendingOpening?.id} content={content} /></div><time dateTime={new Date(entry.createdAt).toISOString()}>{new Date(entry.createdAt).toLocaleString("fr-FR")}</time></li>)}</ol> : <div className="nds-empty-state"><p>Vos premières actions apparaîtront ici.</p></div>}
|
||
</section>;
|
||
}
|