Rework the expedition screens: in-place return, illustrated bag and workshop, card sheet tabs and an engraving workshop
Expeditions - The journey keeps the destination landscape still while a sky scenery (clouds, floating isles, shards, sparkles) drifts behind the cards. - A returned expedition shows only what the player receives, in place and without a window; claiming it removes the card and confirms with a notice, and the page reloads by itself when an expedition comes back. - The Guild Keeper slots are gone: group requirements scale with the players. - Local development adds a 20-second test duration, a test player for groups and keeps the dev account stocked with every item. - The Wind Rose has no daily limit and is used from the destinations step. - The Guide Star opens a destination one level below the player's highest daily level, the Sky Chart one at that level; bonus destinations are badged with the item that opened them. Bag and workshop - The Watcher's bag is a grid of illustrated item cards, ordered from the destination items, with a short "Utiliser" button; the six missing item illustrations are added. - The workshop opens in a window with illustrated commons, spare counts on the cards, cancel without spending anything, and shows the crafted card with its description and power. - The engraving workshop picks a common first, then a tag from a chosen character card (in its tag colours) or from every tag, filtered by name and family; card lists filter by name, collection and stat. Card sheet - Two tabs: the card and its lore (default from the collection), and its improvement (default from the expeditions) with a summary of power, level, experience and stats. - "Répartition des statistiques" offers Par défaut, Personnalisé and profiles, previews the change in the summary, and a Parchemin d'oubli resets it to Personnalisé so the next choice is free again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7a0d19da75
commit
30413de036
48 changed files with 1506 additions and 433 deletions
|
|
@ -1,34 +1,76 @@
|
|||
// Rôle : affiche la fiche détaillée d'une carte possédée (grand format, favori, recyclage d'un doublon, progression d'expédition).
|
||||
// Rôle : affiche la fiche détaillée d'une carte possédée : à gauche la carte en grand, à droite son nom et, pour une carte des
|
||||
// Expéditions, deux onglets. « La carte » (par défaut depuis la collection) : son lore, ses informations (exemplaires, collection,
|
||||
// finitions) et les actions (favori, recyclage d'un doublon, don, échange). « Amélioration » (par défaut depuis les Expéditions,
|
||||
// `initialTab`) : un récapitulatif (Puissance, niveau et expérience, les quatre stats et celles que donnerait la répartition en
|
||||
// cours de choix), l'amélioration et la répartition des statistiques. L'équipement se règle depuis les Expéditions.
|
||||
// `focus` (« plan ») ouvre « Amélioration » et fait défiler la fiche jusqu'à cette section, depuis un objet du Sac.
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Modal } from "../../components/Modal.jsx";
|
||||
import { Tabs } from "../../components/Tabs.jsx";
|
||||
import { recycleDuplicates, setFavorite, upgradeCard } from "./cardsApi.js";
|
||||
import { CardEquipment } from "./CardEquipment.jsx";
|
||||
import { CardPlan } from "./CardPlan.jsx";
|
||||
import { CurrencyAmount } from "./Currency.jsx";
|
||||
import { readCollection } from "./collectionState.js";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
const STATS = [["bravoure", "Bravoure"], ["endurance", "Endurance"], ["fortune", "Fortune"], ["orientation", "Orientation"]];
|
||||
const FOCUS_SELECTORS = { plan: ".nebula-card-plan" };
|
||||
const TABS = [{ id: "card", label: "La carte" }, { id: "improve", label: "Amélioration" }];
|
||||
|
||||
// Expéditions : niveau, Puissance, stats et amélioration d'une carte rare ou mieux (Éclats, ou doublon de la même édition).
|
||||
function CardProgress({ catalog, state, progress, eclats, locked, busy, runMutation }) {
|
||||
// Récapitulatif d'une carte des Expéditions : Puissance, niveau et expérience, puis ses quatre stats (équipement compris ; la part
|
||||
// de l'équipement en petit dessous). `preview` : stats sans équipement de la répartition en cours de choix, montrées « 15 → 18 ».
|
||||
function CardSummary({ progress, preview }) {
|
||||
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>
|
||||
<p><strong>Puissance {progress.power}</strong> · {STATS.map(([stat, label]) => `${label} ${progress.stats[stat]}`).join(" · ")}</p>
|
||||
{!atCap && <div className="nds-progress" data-size="sm" role="progressbar" aria-label="Expérience de terrain" aria-valuemin={0} aria-valuemax={100} aria-valuenow={progress.fieldXp}><span style={{ width: `${progress.fieldXp}%` }} /></div>}
|
||||
{atCap ? <p className="nebula-form-help">Puissance maximale atteinte.</p> : <div className="nds-toolbar">
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || eclats < progress.nextCost} onClick={() => runMutation(() => upgradeCard(progress.editionId, "eclats"))}>Améliorer · <CurrencyAmount kind="eclats">{formatEclats(progress.nextCost)} Éclats</CurrencyAmount></button>
|
||||
{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>}
|
||||
<CardPlan key={`${progress.plan.id}-${progress.plan.points}-${JSON.stringify(progress.plan.allocation)}`} progress={progress} oblivions={state.items?.oblivion ?? 0} locked={locked} busy={busy} runMutation={runMutation} />
|
||||
<CardEquipment catalog={catalog} state={state} progress={progress} busy={busy} runMutation={runMutation} />
|
||||
return <section className="nebula-card-summary" aria-label="Récapitulatif pour les Expéditions">
|
||||
<div className="nebula-card-summary-head">
|
||||
<div className="nebula-card-summary-power"><span>Puissance</span><strong>{progress.power}</strong></div>
|
||||
<div className="nebula-card-summary-level">
|
||||
<span>Niveau <strong>{progress.level}</strong> / {progress.maxLevel}</span>
|
||||
{atCap ? <small>Puissance maximale atteinte</small> : <>
|
||||
<div className="nds-progress" data-size="sm" role="progressbar" aria-label="Expérience" aria-valuemin={0} aria-valuemax={100} aria-valuenow={progress.fieldXp}><span style={{ width: `${progress.fieldXp}%` }} /></div>
|
||||
<small>Expérience : {progress.fieldXp} / 100</small>
|
||||
</>}
|
||||
</div>
|
||||
</div>
|
||||
<ul className="nebula-card-summary-stats" aria-label="Stats">{STATS.map(([stat, label]) => {
|
||||
const base = progress.baseStats?.[stat] ?? progress.stats[stat];
|
||||
const gear = progress.stats[stat] - base;
|
||||
const next = preview ? progress.stats[stat] + preview[stat] - base : progress.stats[stat];
|
||||
return <li key={stat} data-trend={next > progress.stats[stat] ? "up" : next < progress.stats[stat] ? "down" : undefined}>
|
||||
<span><MaskIcon name={stat} />{label}</span>
|
||||
<strong>{next !== progress.stats[stat] ? <>{progress.stats[stat]} <span aria-hidden="true">→</span><span className="sr-only"> deviendrait </span>{next}</> : progress.stats[stat]}</strong>
|
||||
{gear !== 0 && <small data-sign={gear > 0 ? "up" : "down"}>{gear > 0 ? "+" : "−"}{Math.abs(gear)} équipement</small>}
|
||||
</li>;
|
||||
})}</ul>
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function CardDetailModal({ catalog, state, entry, runMutation, busy, onClose, onStartTransfer = null }) {
|
||||
// Amélioration d'une carte rare ou mieux : Éclats, ou doublon de la même édition ; puis la répartition de ses statistiques.
|
||||
function CardProgress({ state, progress, eclats, locked, busy, runMutation, onPreview }) {
|
||||
const atCap = progress.nextCost == null;
|
||||
return <>
|
||||
{!atCap && <section className="nebula-card-upgrade" aria-labelledby="nebula-card-upgrade-title">
|
||||
<h3 id="nebula-card-upgrade-title">Améliorer</h3>
|
||||
<div className="nds-toolbar">
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || eclats < progress.nextCost} onClick={() => runMutation(() => upgradeCard(progress.editionId, "eclats"))}>Améliorer · <CurrencyAmount kind="eclats">{formatEclats(progress.nextCost)} Éclats</CurrencyAmount></button>
|
||||
{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>
|
||||
<p className="nebula-form-help">Vous avez {formatEclats(eclats)} Éclats. Chaque retour d’expédition donne aussi de l’expérience.</p>
|
||||
</section>}
|
||||
<CardPlan key={`${progress.plan.id}-${progress.plan.points}-${JSON.stringify(progress.plan.allocation)}`} progress={progress} oblivions={state.items?.oblivion ?? 0} locked={locked} busy={busy} runMutation={runMutation} onPreview={onPreview} />
|
||||
</>;
|
||||
}
|
||||
|
||||
export function CardDetailModal({ catalog, state, entry, runMutation, busy, onClose, onStartTransfer = null, focus = null, initialTab = "card" }) {
|
||||
const dialogRef = useRef(null);
|
||||
useEffect(() => {
|
||||
if (!focus) return undefined;
|
||||
const frame = requestAnimationFrame(() => dialogRef.current?.querySelector(FOCUS_SELECTORS[focus])?.scrollIntoView({ block: "start", behavior: "smooth" }));
|
||||
return () => cancelAnimationFrame(frame);
|
||||
}, [focus]);
|
||||
const owned = readCollection(state).entries.get(entry.edition.id);
|
||||
const quantity = owned?.quantity || 0;
|
||||
const spare = owned?.spare || 0;
|
||||
|
|
@ -36,21 +78,47 @@ export function CardDetailModal({ catalog, state, entry, runMutation, busy, onCl
|
|||
const favorites = new Set(state.favorites);
|
||||
const expedition = state.expeditions?.busyEditions?.find((item) => item.editionId === entry.edition.id);
|
||||
const progress = state.cardProgress?.find((item) => item.editionId === entry.edition.id);
|
||||
// Aperçu de la répartition en cours de choix, lié à la répartition enregistrée : il disparaît dès qu'elle change.
|
||||
const planKey = progress && `${progress.plan.id}-${progress.plan.points}-${JSON.stringify(progress.plan.allocation)}`;
|
||||
const [preview, setPreview] = useState({ key: null, stats: null });
|
||||
const previewStats = preview.key === planKey ? preview.stats : null;
|
||||
const [tab, setTab] = useState(focus ? "improve" : initialTab);
|
||||
// Sans progression (commune, destination), seulement la carte.
|
||||
const activeTab = progress ? tab : "card";
|
||||
|
||||
return <Modal dialogClassName="confirm-modal nds-modal nebula-card-detail" labelledBy="nebula-card-detail-title" onRequestClose={onClose}>
|
||||
<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 catalog={catalog} state={state} progress={progress} eclats={state.wallet.eclats ?? 0} locked={Boolean(expedition)} 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 && <>
|
||||
<button className="nds-button" data-variant="secondary" type="button" onClick={() => onStartTransfer("gift", entry.edition.id)}>Donner</button>
|
||||
<button className="nds-button" data-variant="secondary" type="button" onClick={() => onStartTransfer("trade", entry.edition.id)}>Échanger</button>
|
||||
</>}
|
||||
<button className="nds-button" data-variant="secondary" type="button" onClick={onClose}>Fermer</button>
|
||||
{expedition && <p className="nebula-form-help">En expédition jusqu’à {new Date(expedition.returnsAt).toLocaleString("fr-FR", { weekday: "long", hour: "2-digit", minute: "2-digit" })}.</p>}
|
||||
{quantity > 1 && !spare && <p className="nebula-form-help">Les doublons de cette carte sont réservés par une proposition d’échange en cours.</p>}
|
||||
const info = <>
|
||||
{entry.card.description && <p className="nebula-card-detail-lore">{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>
|
||||
<div className="nds-toolbar nebula-card-detail-actions">
|
||||
<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 && <>
|
||||
<button className="nds-button" data-variant="secondary" type="button" onClick={() => onStartTransfer("gift", entry.edition.id)}>Donner</button>
|
||||
<button className="nds-button" data-variant="secondary" type="button" onClick={() => onStartTransfer("trade", entry.edition.id)}>Échanger</button>
|
||||
</>}
|
||||
</div>
|
||||
{quantity > 1 && !spare && <p className="nebula-form-help">Les doublons de cette carte sont réservés par une proposition d’échange en cours.</p>}
|
||||
</>;
|
||||
const improve = progress && <>
|
||||
<CardSummary progress={progress} preview={previewStats} />
|
||||
<CardProgress state={state} progress={progress} eclats={state.wallet.eclats ?? 0} locked={Boolean(expedition)} busy={busy} runMutation={runMutation}
|
||||
onPreview={(stats) => setPreview({ key: planKey, stats })} />
|
||||
</>;
|
||||
|
||||
return <Modal dialogClassName="confirm-modal nds-modal nebula-card-detail" labelledBy="nebula-card-detail-title" onRequestClose={onClose} dialogRef={dialogRef}>
|
||||
<div className="nebula-card-detail-layout">
|
||||
<div className="nebula-card-detail-side"><NebulaCard catalog={catalog} entry={entry} size="lg" /></div>
|
||||
<div className="nebula-card-detail-main">
|
||||
<header><p className="eyebrow">{catalog.rarities.find((item) => item.id === entry.edition.rarity)?.label}</p><h2 id="nebula-card-detail-title">{entry.card.name}</h2></header>
|
||||
{expedition && <p className="nds-inline-notice" data-variant="info">En expédition jusqu’à {new Date(expedition.returnsAt).toLocaleString("fr-FR", { weekday: "long", hour: "2-digit", minute: "2-digit" })}.</p>}
|
||||
{/* Une carte des Expéditions a deux onglets : la carte et son lore, puis son amélioration. */}
|
||||
{progress && <Tabs className="nebula-card-detail-tabs" tabs={TABS} activeTab={activeTab} onChange={setTab} />}
|
||||
<div className="nebula-card-detail-panel" role={progress ? "tabpanel" : undefined} aria-label={progress ? TABS.find((item) => item.id === activeTab).label : undefined}>
|
||||
{activeTab === "improve" ? improve : info}
|
||||
</div>
|
||||
<div className="nds-toolbar nebula-card-detail-close">
|
||||
<button className="nds-button" data-variant="secondary" type="button" onClick={onClose}>Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue