The Guild administration now has a tab per quest. The expedition settings sit behind a status band (open or close, today's activity) and four themed tabs, with units inside the fields, the default value shown, and one sticky apply bar that lists every change before confirming. The Pont des Veilleurs leaves the expedition page and becomes the « Éclats d’étoile » shop item, priced from Administration › Boutique. Openings and Éclats are bought by quantity: a number field capped by the stardust the player actually has, and a full-width button that shows the total cost. Stardust and Éclats get their own SVG icons, aligned with the text around them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
7 KiB
JavaScript
87 lines
7 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",
|
||
item_used: "Objet utilisé"
|
||
};
|
||
|
||
// 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 === "item_used") {
|
||
const name = { anchor: "Ancre des Veilleurs", guideStar: "Étoile guide", skyChart: "Carte céleste", fragment: "Carte au trésor", engraving: "Burin de graveur", plan: "Plan d’atelier" }[details.item] || details.item;
|
||
if (details.item === "plan") return <span>{name} · {cardReference(details.editionId, catalog)} fabriquée</span>;
|
||
const detail = details.destinationName ? `${details.destinationName}${details.recalledPct != null ? ` · rappel à ${details.recalledPct} %` : ""}` : details.tag ? `${cardReference(details.editionId, catalog)} · étiquette gravée` : "";
|
||
return <span>{[name, detail].filter(Boolean).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>{details.count > 1 && `${details.count} ouvertures · `}−{formatStardust(details.stardust ?? 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>;
|
||
}
|