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>;
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
// Rôle : équipe une carte rare ou mieux depuis sa fiche : emplacements ouverts par la Puissance, communes à poser et leurs synergies.
|
||||
import { useState } from "react";
|
||||
import { engraveEquipment, equipCard } from "./cardsApi.js";
|
||||
import { equipmentEffect, tagLabel } from "./expeditionFormat.js";
|
||||
|
||||
const itemText = equipmentEffect;
|
||||
|
||||
export function CardEquipment({ catalog, state, progress, busy, runMutation }) {
|
||||
const [choosing, setChoosing] = useState(null);
|
||||
const [engraving, setEngraving] = useState(null);
|
||||
const burins = state.items?.engraving ?? 0;
|
||||
const nameOf = (cardId) => catalog.cards.find((card) => card.id === cardId)?.name || cardId;
|
||||
const sharedTag = (item) => item.tags.find((tag) => progress.tags.includes(tag)) ?? null;
|
||||
// Communes en synergie d'abord, puis les plus fortes sur leur meilleure stat.
|
||||
const best = (item) => Math.max(0, ...Object.values(item.stats || {}));
|
||||
const choices = [...(state.equipment || [])].sort((a, b) => Number(Boolean(sharedTag(b))) - Number(Boolean(sharedTag(a))) || best(b) - best(a));
|
||||
const equip = async (slot, equipmentEditionId) => {
|
||||
if (await runMutation(() => equipCard(progress.editionId, slot, equipmentEditionId))) setChoosing(null);
|
||||
};
|
||||
return <div className="nebula-card-equipment">
|
||||
<h4>Équipements</h4>
|
||||
<ul className="nebula-card-equipment-slots">{progress.slotPowers.map((power, slot) => {
|
||||
const item = progress.equipment.find((entry) => entry.slot === slot);
|
||||
const open = slot < progress.slots;
|
||||
return <li key={slot} className="nds-list-row" data-locked={!open || undefined}>
|
||||
{!open ? <span>Emplacement ouvert à Puissance {power}</span> : item ? <>
|
||||
<span><strong>{item.name}</strong> {itemText(item)}{item.synergyTag && <span className="nds-badge" data-variant="success">Synergie · {tagLabel(catalog, item.synergyTag)}</span>}{item.engraved && <span className="nds-badge" data-variant="gold">Gravée · {tagLabel(catalog, item.engraved)}</span>}</span>
|
||||
{!item.engraved && !item.synergyTag && burins > 0 && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} aria-pressed={engraving === item.editionId} onClick={() => setEngraving(engraving === item.editionId ? null : item.editionId)}>Graver</button>}
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => equip(slot, null)}>Retirer</button>
|
||||
{engraving === item.editionId && <div className="nebula-card-equipment-engrave" role="group" aria-label={`Étiquette à graver sur ${item.name}`}>
|
||||
<span className="nebula-form-help">Un burin grave une étiquette de cette carte sur la commune, pour toujours ({burins} burin{burins > 1 ? "s" : ""}) :</span>
|
||||
{progress.tags.map((tag) => <button key={tag} className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={async () => { if (await runMutation(() => engraveEquipment(item.editionId, tag))) setEngraving(null); }}>{tagLabel(catalog, tag)}</button>)}
|
||||
</div>}
|
||||
</> : <>
|
||||
<span>Emplacement libre</span>
|
||||
<button className="nds-button" data-size="sm" data-variant={choosing === slot ? "primary" : "secondary"} type="button" disabled={busy || !choices.length} aria-pressed={choosing === slot} onClick={() => setChoosing(choosing === slot ? null : slot)}>Équiper</button>
|
||||
</>}
|
||||
</li>;
|
||||
})}</ul>
|
||||
{!choices.length && <p className="nebula-form-help">Les cartes communes servent d’équipement : ouvrez des paquets pour en obtenir.</p>}
|
||||
{choosing != null && <ul className="nebula-card-equipment-choices" aria-label="Communes à poser">{choices.map((item) => {
|
||||
const tag = sharedTag(item);
|
||||
const elsewhere = item.equippedOn && item.equippedOn !== progress.editionId;
|
||||
return <li key={item.editionId} className="nds-list-row">
|
||||
<span><strong>{nameOf(item.cardId)}</strong> {itemText(item)}{tag && <span className="nds-badge" data-variant="success">Synergie · {tagLabel(catalog, tag)}</span>}{elsewhere && <span className="nebula-form-help"> équipe déjà {nameOf(catalog.editions.find((edition) => edition.id === item.equippedOn)?.cardId)}</span>}</span>
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy} aria-label={`Poser ${nameOf(item.cardId)}`} onClick={() => equip(choosing, item.editionId)}>Poser</button>
|
||||
</li>;
|
||||
})}</ul>}
|
||||
</div>;
|
||||
}
|
||||
|
|
@ -1,78 +1,115 @@
|
|||
// Rôle : plan de progression d'une carte depuis sa fiche : ses points de niveau suivent sa collection, une vocation (une stat privilégiée)
|
||||
// ou la répartition du joueur. Aperçu des stats avant de valider ; le premier choix est gratuit, les changements suivants coûtent
|
||||
// un Parchemin d'oubli (ajouter des points en libre reste gratuit).
|
||||
// Rôle : répartition des statistiques d'une carte depuis sa fiche : ses points de niveau suivent sa collection (« Par défaut »), un
|
||||
// profil (une stat privilégiée ; une étoile marque celui qui lui donne la stat la plus haute) ou la répartition du joueur
|
||||
// (« Personnalisé »). Le choix en cours s'affiche dans le récapitulatif de la fiche (`onPreview`) avant de valider. Le premier choix
|
||||
// est gratuit ; ensuite, la répartition se verrouille : la réinitialiser coûte un Parchemin d'oubli et remet la carte en
|
||||
// « Personnalisé », sans point placé, d'où un nouveau choix gratuit (un profil répartit tout seul). Ajouter des points en
|
||||
// « Personnalisé » reste gratuit.
|
||||
import { useState } from "react";
|
||||
import { setCardPlan } from "./cardsApi.js";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
|
||||
const STATS = [["bravoure", "Bravoure"], ["endurance", "Endurance"], ["fortune", "Fortune"], ["orientation", "Orientation"]];
|
||||
const PLANS = [
|
||||
{ id: "collection", label: "Sa collection", help: "Les points suivent le profil de la collection de la carte." },
|
||||
const PROFILES = [
|
||||
{ id: "leader", stat: "bravoure", label: "Meneur", help: "Surtout de la Bravoure, pour les destinations qui en demandent beaucoup." },
|
||||
{ id: "guardian", stat: "endurance", label: "Gardien", help: "Surtout de l’Endurance, pour les destinations qui en demandent beaucoup." },
|
||||
{ id: "seeker", stat: "fortune", label: "Chercheur", help: "Surtout de la Fortune, pour les destinations qui en demandent beaucoup." },
|
||||
{ id: "navigator", stat: "orientation", label: "Navigateur", help: "Surtout de l’Orientation, pour les destinations qui en demandent beaucoup." },
|
||||
{ id: "free", label: "Libre", help: "Vous placez vous-même chaque point." }
|
||||
{ id: "navigator", stat: "orientation", label: "Navigateur", help: "Surtout de l’Orientation, pour les destinations qui en demandent beaucoup." }
|
||||
];
|
||||
const HELP = { collection: "Les points suivent le profil de la collection de la carte.", free: "Vous placez vous-même chaque point." };
|
||||
const ZERO = Object.fromEntries(STATS.map(([stat]) => [stat, 0]));
|
||||
const total = (stats) => Object.values(stats).reduce((sum, value) => sum + value, 0);
|
||||
const toDraft = (allocation) => Object.fromEntries(STATS.map(([stat]) => [stat, String(allocation?.[stat] ?? 0)]));
|
||||
const toAllocation = (draft) => Object.fromEntries(STATS.map(([stat]) => [stat, Math.max(0, Number.parseInt(draft[stat], 10) || 0)]));
|
||||
|
||||
function StatPreview({ before, after }) {
|
||||
return <ul className="nebula-card-plan-preview" aria-label="Stats de la carte avec ce plan, hors équipement">{STATS.map(([stat, label]) => {
|
||||
const delta = after[stat] - before[stat];
|
||||
return <li key={stat} data-trend={delta > 0 ? "up" : delta < 0 ? "down" : undefined}>
|
||||
<span><MaskIcon name={stat} />{label}</span>
|
||||
<strong>{delta ? <>{before[stat]} → {after[stat]}</> : after[stat]}</strong>
|
||||
</li>;
|
||||
})}</ul>;
|
||||
}
|
||||
|
||||
// `locked` : la carte est en expédition, son plan ne change pas avant son retour.
|
||||
export function CardPlan({ progress, oblivions, locked = false, busy, runMutation }) {
|
||||
// `locked` : la carte est en expédition, sa répartition ne change pas avant son retour.
|
||||
export function CardPlan({ progress, oblivions, locked = false, busy, runMutation, onPreview = () => {} }) {
|
||||
const plan = progress.plan;
|
||||
// Choix encore ouvert : premier choix, ou après une réinitialisation.
|
||||
const open = !plan.paid;
|
||||
const placed = plan.allocation || ZERO;
|
||||
const [choice, setChoice] = useState(plan.id);
|
||||
const [draft, setDraft] = useState(() => toDraft(plan.allocation));
|
||||
const free = choice === "free";
|
||||
const allocation = Object.fromEntries(STATS.map(([stat]) => [stat, Math.max(0, Number.parseInt(draft[stat], 10) || 0)]));
|
||||
const profile = PROFILES.find((item) => item.id === choice) || null;
|
||||
const allocation = toAllocation(draft);
|
||||
const left = plan.points - total(allocation);
|
||||
const placed = plan.allocation || toDraft(null);
|
||||
const unchanged = choice === plan.id && (!free || STATS.every(([stat]) => allocation[stat] === Number(placed[stat])));
|
||||
const onlyAdds = free && plan.id === "free" && STATS.every(([stat]) => allocation[stat] >= Number(placed[stat]));
|
||||
const paid = plan.paid && !onlyAdds;
|
||||
const preview = free ? Object.fromEntries(STATS.map(([stat]) => [stat, plan.levelBase[stat] + allocation[stat]])) : plan.previews[choice];
|
||||
const chosen = PLANS.find((item) => item.id === choice);
|
||||
// Un point de plus ne dépasse ni le plafond d'une stat, ni les points restants.
|
||||
const statsFor = (id, points) => (id === "free" ? Object.fromEntries(STATS.map(([stat]) => [stat, plan.levelBase[stat] + points[stat]])) : plan.previews[id]);
|
||||
const unchangedFor = (id, points) => id === plan.id && (id !== "free" || STATS.every(([stat]) => points[stat] === placed[stat]));
|
||||
const unchanged = unchangedFor(choice, allocation);
|
||||
// Le profil qui donne à la carte sa stat la plus haute.
|
||||
const best = PROFILES.reduce((top, item) => (plan.previews[item.id][item.stat] > plan.previews[top.id][top.stat] ? item : top), PROFILES[0]).id;
|
||||
const report = (id, points) => onPreview(unchangedFor(id, points) ? null : statsFor(id, points));
|
||||
const choose = (id) => {
|
||||
setChoice(id);
|
||||
report(id, allocation);
|
||||
};
|
||||
// Un point de plus ne dépasse ni le plafond d'une stat, ni les points restants ; sans réinitialisation, on ne retire pas un point placé.
|
||||
const setPoints = (stat, raw) => {
|
||||
const limit = Math.min(plan.maxStatPoints, allocation[stat] + left);
|
||||
setDraft((current) => ({ ...current, [stat]: raw !== "" && Number(raw) > limit ? String(limit) : raw }));
|
||||
const next = { ...draft, [stat]: raw !== "" && Number(raw) > limit ? String(limit) : raw };
|
||||
setDraft(next);
|
||||
report("free", toAllocation(next));
|
||||
};
|
||||
const cancel = () => {
|
||||
setChoice(plan.id);
|
||||
setDraft(toDraft(plan.allocation));
|
||||
onPreview(null);
|
||||
};
|
||||
const save = async () => {
|
||||
if (await runMutation(() => setCardPlan(progress.editionId, choice, free ? allocation : null))) onPreview(null);
|
||||
};
|
||||
const reset = async () => {
|
||||
if (await runMutation(() => setCardPlan(progress.editionId, "free", ZERO))) onPreview(null);
|
||||
};
|
||||
const removesPoints = free && plan.id === "free" && STATS.some(([stat]) => allocation[stat] < placed[stat]);
|
||||
const editable = !locked && (open || plan.id === "free");
|
||||
const option = (id, label, stat = null) => <button key={id} type="button" className="nds-button" data-size="sm" data-variant={id === choice ? "primary" : "secondary"} aria-pressed={id === choice}
|
||||
disabled={busy || locked || (!open && id !== choice)} onClick={() => choose(id)}>
|
||||
{stat && <MaskIcon name={stat} />}{label}{id === best && <span className="nebula-card-plan-best" aria-label="(le plus adapté à cette carte)" title="Le plus adapté à cette carte">★</span>}
|
||||
</button>;
|
||||
|
||||
// « Valider » et « Annuler » dans le cadre du choix en cours, sous ce qui a changé.
|
||||
const actions = !unchanged && <div className="nebula-card-plan-actions">
|
||||
{plan.id === "collection" && !free && <p className="nebula-form-help">Premier choix gratuit : ensuite, le changer demandera de réinitialiser la répartition avec un Parchemin d’oubli.</p>}
|
||||
{removesPoints && <p className="nebula-form-help">Pour retirer des points déjà placés, réinitialisez la répartition.</p>}
|
||||
<div className="nds-toolbar">
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || locked || removesPoints} onClick={save}>Valider</button>
|
||||
<button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={cancel}>Annuler</button>
|
||||
</div>
|
||||
</div>;
|
||||
|
||||
return <section className="nebula-card-plan" aria-labelledby="nebula-card-plan-title">
|
||||
<h4 id="nebula-card-plan-title">Plan de progression</h4>
|
||||
<h3 id="nebula-card-plan-title">Répartition des statistiques</h3>
|
||||
<p className="nebula-form-help">{plan.points
|
||||
? `Ses ${plan.points} points de niveau se répartissent selon ce plan, au plus ${plan.maxStatPoints} dans une même stat.`
|
||||
: "Chaque amélioration donne des points de stats, répartis selon ce plan."}</p>
|
||||
<div role="group" aria-label="Plan de progression" className="nds-toolbar nebula-card-plan-choices">{PLANS.map((item) => <button key={item.id} type="button" className="nds-button" data-size="sm"
|
||||
data-variant={item.id === choice ? "primary" : "secondary"} aria-pressed={item.id === choice} disabled={busy} onClick={() => setChoice(item.id)}>
|
||||
{item.stat && <MaskIcon name={item.stat} />}{item.label}
|
||||
</button>)}</div>
|
||||
<p className="nebula-form-help">{chosen.help}</p>
|
||||
{free && <div className="nebula-card-plan-points">
|
||||
{STATS.map(([stat, label]) => <label key={stat}><span><MaskIcon name={stat} />{label}</span>
|
||||
<input className="nds-input" type="number" inputMode="numeric" min="0" max={plan.maxStatPoints} step="1" value={draft[stat]} disabled={busy || !plan.points}
|
||||
onChange={(event) => setPoints(stat, event.target.value)} onBlur={() => { if (draft[stat] === "") setDraft((current) => ({ ...current, [stat]: "0" })); }} />
|
||||
</label>)}
|
||||
<p className="nebula-form-help" role="status">{!plan.points ? "Aucun point à placer pour l’instant : améliorez la carte." : left > 0 ? `${left} point${left > 1 ? "s" : ""} à placer.` : "Tous les points sont placés."}</p>
|
||||
</div>}
|
||||
<StatPreview before={progress.baseStats} after={preview} />
|
||||
{!unchanged && <p className="nebula-form-help">{paid
|
||||
? `Coûte 1 Parchemin d’oubli : vous en avez ${oblivions}.${oblivions < 1 ? " Ils s’achètent dans la Boutique." : ""}`
|
||||
: plan.id === "collection" ? "Premier choix gratuit : ensuite, changer de plan coûtera un Parchemin d’oubli." : "Placer de nouveaux points est gratuit."}</p>}
|
||||
{locked && <p className="nebula-form-help">Cette carte est en expédition : son plan pourra changer à son retour.</p>}
|
||||
<div className="nds-toolbar">
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || locked || unchanged || (paid && oblivions < 1)}
|
||||
onClick={() => runMutation(() => setCardPlan(progress.editionId, choice, free ? allocation : null))}>{free ? "Valider les points" : "Choisir ce plan"}</button>
|
||||
{!unchanged && <button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={() => { setChoice(plan.id); setDraft(toDraft(plan.allocation)); }}>Annuler</button>}
|
||||
? `${plan.points} point${plan.points > 1 ? "s" : ""} gagné${plan.points > 1 ? "s" : ""} en améliorant la carte.`
|
||||
: "Chaque amélioration donne des points de stats, répartis selon ce choix."}</p>
|
||||
{/* Deux cadres : « Par défaut » ou « Personnalisé » (et ses points juste dessous), puis les profils ; le cadre du choix en cours
|
||||
est souligné d'or. */}
|
||||
<div role="group" aria-label="Par défaut ou personnalisé" className="nebula-card-plan-frame" data-active={!profile || undefined}>
|
||||
<div className="nds-toolbar">{option("collection", "Par défaut")}{option("free", "Personnalisé")}</div>
|
||||
{!profile && <p className="nebula-form-help">{HELP[choice]}</p>}
|
||||
{free && <div className="nebula-card-plan-points">
|
||||
<p className="nebula-card-plan-left" role="status">{!plan.points ? "Aucun point à répartir pour l’instant : améliorez la carte." : <>
|
||||
{left > 0 ? `${left} point${left > 1 ? "s" : ""} à répartir` : "Tous les points sont répartis."}
|
||||
<small>{`Au plus ${plan.maxStatPoints} dans une même stat.`}</small>
|
||||
</>}</p>
|
||||
{STATS.map(([stat, label]) => <label key={stat}><span><MaskIcon name={stat} />{label}</span>
|
||||
<input className="nds-input" type="number" inputMode="numeric" min={open ? 0 : placed[stat]} max={plan.maxStatPoints} step="1" value={draft[stat]} disabled={busy || !editable || !plan.points}
|
||||
onChange={(event) => setPoints(stat, event.target.value)} onBlur={() => { if (draft[stat] === "") setDraft((current) => ({ ...current, [stat]: "0" })); }} />
|
||||
</label>)}
|
||||
</div>}
|
||||
{!profile && actions}
|
||||
</div>
|
||||
<div role="group" aria-labelledby="nebula-card-plan-profiles" className="nebula-card-plan-frame" data-active={profile ? true : undefined}>
|
||||
<h4 id="nebula-card-plan-profiles">Répartition automatique par profil</h4>
|
||||
<div className="nds-toolbar">{PROFILES.map((item) => option(item.id, item.label, item.stat))}</div>
|
||||
{profile && <p className="nebula-form-help">{profile.help}</p>}
|
||||
{profile && actions}
|
||||
</div>
|
||||
{locked && <p className="nebula-form-help">Cette carte est en expédition : sa répartition pourra changer à son retour.</p>}
|
||||
{!open && !locked && <div className="nebula-card-plan-reset">
|
||||
<button className="nds-button" data-variant="secondary" type="button" disabled={busy || oblivions < 1} onClick={reset}>Réinitialiser la répartition · 1 Parchemin d’oubli</button>
|
||||
<p className="nebula-form-help">{`Vous en avez ${oblivions}.${oblivions < 1 ? " Ils s’achètent dans la Boutique." : " La carte repasse en « Personnalisé », tous ses points à répartir : un profil les répartit tout seul."}`}</p>
|
||||
</div>}
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
90
website/src/features/cards/ExpeditionAtelier.jsx
Normal file
90
website/src/features/cards/ExpeditionAtelier.jsx
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
// Rôle : atelier du Plan d'atelier, en fenêtre. Le joueur pose 3 doublons de communes (en cartes illustrées) dans sa sélection,
|
||||
// avec leurs doublons libres en pastille sur la carte, puis fabrique : le plan et les doublons ne sont consommés qu'à ce moment, et « Annuler » ferme sans rien utiliser. Une fois
|
||||
// fabriquée, la commune de pouvoir obtenue s'affiche à la place du choix, avec sa description, son pouvoir et ses effets chiffrés.
|
||||
import { useState } from "react";
|
||||
import { Modal } from "../../components/Modal.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { editionEntry, POWER_TEXT, powerDetails } from "./expeditionFormat.js";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
|
||||
const RECIPE_SIZE = 3;
|
||||
|
||||
// Commune obtenue : la carte, puis son nom, sa description, son pouvoir, ce qu'il fait et ses effets chiffrés (`powerValues`).
|
||||
function CraftedCard({ catalog, entry, content, powerValues }) {
|
||||
const power = entry.card.expedition?.equipment?.power;
|
||||
return <div className="nebula-atelier-result">
|
||||
<NebulaCard catalog={catalog} entry={entry} size="md" />
|
||||
<div className="nebula-atelier-result-text">
|
||||
<h3>{entry.card.name}</h3>
|
||||
{entry.card.description && <p className="nebula-atelier-description">{entry.card.description}</p>}
|
||||
{power && <section className="nebula-atelier-power" aria-label={content.atelierPower}>
|
||||
<h4><MaskIcon name="power" />{content.powers[power] || power}</h4>
|
||||
<p>{POWER_TEXT[power]}</p>
|
||||
{powerDetails(power, powerValues).length > 0 && <ul>{powerDetails(power, powerValues).map((line) => <li key={line}>{line}</li>)}</ul>}
|
||||
</section>}
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
export function ExpeditionAtelier({ catalog, state, content, busy, powerValues, onCraft, onClose }) {
|
||||
const [chosen, setChosen] = useState([]);
|
||||
const [crafted, setCrafted] = useState(null);
|
||||
const [error, setError] = useState("");
|
||||
const commons = state.collection.filter((entry) => entry.spare > 0 && entry.edition?.rarity === "common");
|
||||
const used = (editionId) => chosen.filter((id) => id === editionId).length;
|
||||
const nameOf = (editionId) => editionEntry(catalog, editionId)?.card.name || "";
|
||||
const add = (entry) => {
|
||||
if (chosen.length < RECIPE_SIZE && used(entry.editionId) < entry.spare) setChosen([...chosen, entry.editionId]);
|
||||
};
|
||||
const craft = async () => {
|
||||
setError("");
|
||||
const result = await onCraft(chosen);
|
||||
if (result?.crafted) setCrafted(result.crafted);
|
||||
else setError(result?.error || "");
|
||||
};
|
||||
const result = crafted && editionEntry(catalog, crafted);
|
||||
|
||||
return <Modal dialogClassName="confirm-modal nds-modal nebula-expedition-picker nebula-atelier" labelledBy="nebula-atelier-title" onRequestClose={onClose} canClose={!busy}>
|
||||
<h2 id="nebula-atelier-title">{content.atelierTitle}</h2>
|
||||
{result ? <>
|
||||
<p className="nebula-form-help" role="status">{fillTemplate(content.crafted, { card: result.card.name })}</p>
|
||||
<CraftedCard catalog={catalog} entry={result} content={content} powerValues={powerValues} />
|
||||
<div className="nds-toolbar nebula-expedition-picker-actions">
|
||||
<button className="nds-button" data-variant="primary" type="button" onClick={onClose}>{content.atelierClose}</button>
|
||||
</div>
|
||||
</> : <>
|
||||
<p className="nebula-form-help">{content.atelierHelp}</p>
|
||||
{error && <p className="nds-inline-notice" data-variant="warning" role="alert">{error}</p>}
|
||||
{/* Sélection : trois places ; une carte posée se retire d'un clic. */}
|
||||
<section className="nebula-atelier-selection" aria-labelledby="nebula-atelier-selection-title">
|
||||
<h3 id="nebula-atelier-selection-title">{fillTemplate(content.atelierSelection, { count: chosen.length })}</h3>
|
||||
<ol>{Array.from({ length: RECIPE_SIZE }, (_, index) => {
|
||||
const editionId = chosen[index];
|
||||
const entry = editionId && editionEntry(catalog, editionId);
|
||||
return <li key={index} data-empty={!entry || undefined}>
|
||||
{entry ? <NebulaCard catalog={catalog} entry={entry} size="sm" onSelect={busy ? undefined : () => setChosen(chosen.filter((_, position) => position !== index))}
|
||||
selectLabel={fillTemplate(content.atelierRemove, { card: entry.card.name })} /> : <span aria-hidden="true" />}
|
||||
</li>;
|
||||
})}</ol>
|
||||
</section>
|
||||
{commons.length ? <ul className="nebula-equipment-choices-grid" aria-label={content.atelierCommons}>{commons.map((entry) => {
|
||||
const card = editionEntry(catalog, entry.editionId);
|
||||
if (!card) return null;
|
||||
const left = entry.spare - used(entry.editionId);
|
||||
const full = chosen.length >= RECIPE_SIZE || left <= 0;
|
||||
return <li key={entry.editionId} data-equipped={used(entry.editionId) > 0 || undefined} data-unavailable={(full && !used(entry.editionId)) || undefined}>
|
||||
<span className="nebula-equipment-choice">
|
||||
<NebulaCard catalog={catalog} entry={card} size="sm" quantity={left} disabled={busy || full} onSelect={() => add(entry)}
|
||||
selectLabel={fillTemplate(content.atelierAdd, { card: nameOf(entry.editionId) })} />
|
||||
</span>
|
||||
<strong>{card.card.name}</strong>
|
||||
</li>;
|
||||
})}</ul> : <p className="nebula-form-help">{content.atelierNoCommons}</p>}
|
||||
<div className="nds-toolbar nebula-expedition-picker-actions">
|
||||
<button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={onClose}>{content.atelierCancel}</button>
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || chosen.length !== RECIPE_SIZE} onClick={craft}>{content.atelierAction}</button>
|
||||
</div>
|
||||
</>}
|
||||
</Modal>;
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ export function PowerTooltipContent({ power, values }) {
|
|||
</span>;
|
||||
}
|
||||
|
||||
function EquipmentStats({ item, content, color, powerValues }) {
|
||||
export function EquipmentStats({ item, content, color, powerValues }) {
|
||||
// Une commune de pouvoir n'a pas de stats ; posée en synergie, son bonus va à la première stat, et s'affiche sous le pouvoir.
|
||||
if (item.power) return <span className="nebula-equipment-stats">
|
||||
<Tooltip className="nebula-equipment-power" tooltipClassName="nebula-power-tooltip" content={<PowerTooltipContent power={item.power} values={powerValues} />}
|
||||
|
|
@ -52,7 +52,9 @@ function EquipmentStats({ item, content, color, powerValues }) {
|
|||
}
|
||||
|
||||
// Les emplacements d'équipement ; sans carte choisie (`progress` absent), trois emplacements inactifs.
|
||||
export function EquipmentSlots({ catalog, progress, content, busy, runMutation, onOpen, powerValues }) {
|
||||
// `onEngrave` (avec au moins un Burin) : une commune posée ni gravée ni en synergie propose « Graver », qui ouvre l'atelier de
|
||||
// gravure sur elle et sur la carte.
|
||||
export function EquipmentSlots({ catalog, progress, content, busy, runMutation, onOpen, powerValues, onEngrave = null }) {
|
||||
const remove = (slot) => runMutation(() => equipCard(progress.editionId, slot, null));
|
||||
if (!progress) return <ul className="nebula-equipment-slots" aria-label={content.equipmentTitle}>{PLACEHOLDER_SLOTS.map((slot) => <li key={slot}>
|
||||
<span className="nebula-equipment-slot" data-locked><span aria-hidden="true">+</span></span>
|
||||
|
|
@ -73,6 +75,10 @@ export function EquipmentSlots({ catalog, progress, content, busy, runMutation,
|
|||
</span>
|
||||
<EquipmentStats item={item} content={content} powerValues={powerValues} color={tagColor(progress.tags, item.synergyTag)} />
|
||||
{item.synergyTag && <SynergyBadge catalog={catalog} tag={item.synergyTag} tags={progress.tags} content={content} />}
|
||||
{onEngrave && !item.synergyTag && !item.engraved && <button className="nds-button nebula-equipment-engrave" data-size="sm" data-variant="secondary" type="button" disabled={busy}
|
||||
aria-label={fillTemplate(content.engraveButtonLabel, { card: entry.card.name })} onClick={() => onEngrave(item.editionId)}>
|
||||
<MaskIcon name="tag" />{content.engraveButton}
|
||||
</button>}
|
||||
</li>;
|
||||
})}</ul>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ function InviteLink({ groupId, content }) {
|
|||
}
|
||||
|
||||
// `invited` : le joueur arrive par le lien d'invitation de cette expédition : elle est mise en vue, son inscription dépliée.
|
||||
export function ExpeditionGroupCard({ catalog, group, cards, content, now, busy, limitReached, onJoin, onLeave, onDepart, invited = false }) {
|
||||
export function ExpeditionGroupCard({ catalog, group, cards, content, now, busy, limitReached, onJoin, onLeave, onDepart, onTestPlayer = null, invited = false }) {
|
||||
const [joining, setJoining] = useState(invited && group.canJoin && !limitReached);
|
||||
const articleRef = useRef(null);
|
||||
useEffect(() => { if (invited) articleRef.current?.scrollIntoView({ block: "center" }); }, [invited]);
|
||||
|
|
@ -119,12 +119,13 @@ export function ExpeditionGroupCard({ catalog, group, cards, content, now, busy,
|
|||
})}
|
||||
{Array.from({ length: group.freeSlots }, (_, index) => <li key={`free-${index}`}><span className="nebula-expedition-group-free">{content.groupFreeRole}</span></li>)}
|
||||
</ul>
|
||||
{group.freeSlots > 0 && <p className="nebula-form-help">{group.members.length > 1 ? content.groupKeeper : content.soloKeeper}</p>}
|
||||
{group.freeSlots > 0 && <p className="nebula-form-help">{content.groupScaling}</p>}
|
||||
</section>
|
||||
<div className="nds-toolbar nebula-expedition-group-actions">
|
||||
{group.canJoin && !joining && <button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || limitReached} onClick={() => setJoining(true)}>{content.join}</button>}
|
||||
{group.isCreator && <button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || !group.canDepart} onClick={() => onDepart(group.id)}>{content.depart}</button>}
|
||||
{group.isMember && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => onLeave(group.id)}>{group.isCreator ? content.dissolve : content.leave}</button>}
|
||||
{onTestPlayer && group.isMember && group.freeSlots > 0 && <button className="nds-button" data-size="sm" data-variant="ghost" type="button" disabled={busy} onClick={() => onTestPlayer(group.id)}>{content.testPlayer}</button>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="nebula-group-main">
|
||||
|
|
|
|||
229
website/src/features/cards/ExpeditionImprove.jsx
Normal file
229
website/src/features/cards/ExpeditionImprove.jsx
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
// Rôle : 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 ; `ImproveCardPicker` montre les cartes jouables en
|
||||
// illustrations pour le Parchemin, puis ouvre la fiche de celle qu'on choisit sur sa répartition.
|
||||
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>;
|
||||
}
|
||||
|
||||
export function CardSheet({ catalog, state, editionId, focus = null, busy, runMutation, onClose }) {
|
||||
const entry = editionEntry(catalog, editionId);
|
||||
if (!entry) return null;
|
||||
return <CardDetailModal catalog={catalog} state={state} entry={entry} focus={focus} initialTab="improve" runMutation={runMutation} busy={busy} onClose={onClose} />;
|
||||
}
|
||||
|
||||
export function ImproveCardPicker({ catalog, state, view, item, content, busy, runMutation, onClose }) {
|
||||
const [chosen, setChosen] = useState(null);
|
||||
const filters = useCardFilters();
|
||||
const cards = applyCardFilters([...view.cards].sort((a, b) => b.power - a.power), filters, { entryOf: (card) => editionEntry(catalog, card.editionId), statOf: (card, stat) => card.stats[stat], mode: "sort" });
|
||||
if (chosen) return <CardSheet catalog={catalog} state={state} editionId={chosen} focus="plan" busy={busy} runMutation={runMutation} onClose={onClose} />;
|
||||
return <Modal dialogClassName="confirm-modal nds-modal nebula-expedition-picker" labelledBy="nebula-improve-picker-title" onRequestClose={onClose}>
|
||||
<h2 id="nebula-improve-picker-title">{content.items[item]}</h2>
|
||||
<p className="nebula-form-help">{content.improvePickerHelp[item]}</p>
|
||||
<CardFilters catalog={catalog} filters={filters} entries={view.cards.map((card) => editionEntry(catalog, card.editionId))} content={content} />
|
||||
{cards.length ? <ul className="nebula-expedition-cards" aria-label={content.cardsLabel}>{cards.map((card) => <ExpeditionCardTile key={card.editionId} catalog={catalog} card={card}
|
||||
destination={null} content={content} selected={false} onSelect={() => setChosen(card.editionId)} />)}</ul>
|
||||
: <p className="nds-inline-notice" data-variant="info">{view.cards.length ? content.filterEmpty : content.improvePickerEmpty[item]}</p>}
|
||||
<div className="nds-toolbar nebula-expedition-picker-actions">
|
||||
<button className="nds-button" data-variant="secondary" type="button" onClick={onClose}>{content.cancel}</button>
|
||||
</div>
|
||||
</Modal>;
|
||||
}
|
||||
|
|
@ -1,9 +1,44 @@
|
|||
// Rôle : suivi d'une expédition en route : le paysage de la destination défile derrière les cartes parties, qui avancent sur le
|
||||
// sentier, au-dessus d'une barre de progression et du compte à rebours du retour.
|
||||
// Rôle : suivi d'une expédition en route : devant le paysage fixe de la destination, un décor de ciel (nuages, îlots flottants,
|
||||
// éclats de roche, étincelles, brume) dérive pendant que les cartes parties avancent, au-dessus d'une barre de progression et du
|
||||
// compte à rebours du retour.
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { coverEntry, editionEntry } from "./expeditionFormat.js";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
|
||||
// Silhouettes du décor (cadre 100 × 100).
|
||||
const SPRITE_PATHS = {
|
||||
cloud: "M10 80 C2 80 0 66 10 62 C10 50 24 44 34 50 C38 36 58 32 66 46 C76 40 90 48 88 60 C98 62 98 80 88 80 Z",
|
||||
isle: "M4 38 C10 28 22 32 28 26 C36 20 46 28 54 24 C64 18 76 28 84 26 C92 26 98 32 96 38 L80 50 L66 68 L52 96 L42 72 L26 58 Z",
|
||||
shard: "M20 30 L48 12 L80 24 L92 52 L72 84 L36 88 L10 62 Z",
|
||||
sparkle: "M50 0 C54 36 64 46 100 50 C64 54 54 64 50 100 C46 64 36 54 0 50 C36 46 46 36 50 0 Z"
|
||||
};
|
||||
|
||||
// Décor du ciel : au fond, nuages et îlots ; devant, éclats, étincelles et une nappe de brume au ras du sentier. `offset` place
|
||||
// chaque élément dans son cycle (de 0 à 1), `y` sa hauteur depuis le bas (%) ; `x` est sa place fixe quand les animations sont
|
||||
// réduites.
|
||||
const SCENERY = [
|
||||
{ kind: "cloud", layer: "back", offset: 0, scale: 1.2, y: 58, x: 10 },
|
||||
{ kind: "isle", layer: "back", offset: 0.16, scale: 0.9, y: 34, x: 30 },
|
||||
{ kind: "cloud", layer: "back", offset: 0.34, scale: 0.8, y: 74, x: 52 },
|
||||
{ kind: "isle", layer: "back", offset: 0.55, scale: 0.65, y: 50, x: 70 },
|
||||
{ kind: "cloud", layer: "back", offset: 0.75, scale: 1, y: 40, x: 88 },
|
||||
{ kind: "isle", layer: "back", offset: 0.9, scale: 1.1, y: 22, x: 4 },
|
||||
{ kind: "shard", layer: "front", offset: 0.05, scale: 1, y: 30, x: 18 },
|
||||
{ kind: "sparkle", layer: "front", offset: 0.2, scale: 1, y: 66, x: 40 },
|
||||
{ kind: "cloud", layer: "front", offset: 0.3, scale: 1.6, y: -6, x: 60 },
|
||||
{ kind: "shard", layer: "front", offset: 0.48, scale: 0.6, y: 52, x: 76 },
|
||||
{ kind: "sparkle", layer: "front", offset: 0.62, scale: 0.7, y: 84, x: 92 },
|
||||
{ kind: "cloud", layer: "front", offset: 0.8, scale: 1.3, y: -8, x: 26 },
|
||||
{ kind: "sparkle", layer: "front", offset: 0.92, scale: 0.85, y: 44, x: 8 }
|
||||
];
|
||||
|
||||
function TrailScenery() {
|
||||
return <div className="nebula-trail-scenery" aria-hidden="true">{SCENERY.map((item) => <span key={`${item.layer}-${item.offset}`} className="nebula-trail-sprite"
|
||||
data-kind={item.kind} data-layer={item.layer} style={{ "--nebula-sprite-offset": item.offset, "--nebula-sprite-scale": item.scale, "--nebula-sprite-y": `${item.y}%`, "--nebula-sprite-x": `${item.x}%` }}>
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none" focusable="false"><path d={SPRITE_PATHS[item.kind]} /></svg>
|
||||
</span>)}</div>;
|
||||
}
|
||||
|
||||
export function ExpeditionJourney({ catalog, expedition, content, now, busy, anchors = 0, onRecall = null }) {
|
||||
const span = Math.max(1, expedition.returnsAt - expedition.departsAt);
|
||||
const pct = Math.round(Math.min(1, Math.max(0, (now - expedition.departsAt) / span)) * 100);
|
||||
|
|
@ -15,11 +50,10 @@ export function ExpeditionJourney({ catalog, expedition, content, now, busy, anc
|
|||
<p className="eyebrow">{fillTemplate(content.journeyMeta, { stars: "★".repeat(expedition.stars), hours: expedition.hours, mode })}</p>
|
||||
<h3 id={`nebula-journey-${expedition.id}`}>{expedition.destination.name}</h3>
|
||||
<div className="nebula-expedition-trail" style={backdrop ? { "--nebula-trail-image": `url("${backdrop}")` } : undefined}>
|
||||
<TrailScenery />
|
||||
<ul className="nebula-expedition-caravan" aria-label={content.journeyCards}>{expedition.slots.map((slot, index) => {
|
||||
const entry = slot.editionId && editionEntry(catalog, slot.editionId);
|
||||
return <li key={slot.position} style={{ "--nebula-step-delay": `${index * -0.35}s` }}>
|
||||
{entry ? <NebulaCard catalog={catalog} entry={entry} size="sm" /> : <span className="nebula-expedition-keeper">{content.keeper}</span>}
|
||||
</li>;
|
||||
return entry ? <li key={slot.position} style={{ "--nebula-step-delay": `${index * -0.35}s` }}><NebulaCard catalog={catalog} entry={entry} size="sm" /></li> : null;
|
||||
})}</ul>
|
||||
</div>
|
||||
<div className="nds-progress" role="progressbar" aria-label={content.journeyProgress} aria-valuemin={0} aria-valuemax={100} aria-valuenow={pct}><span style={{ width: `${pct}%` }} /></div>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
// Rôle : étape « Votre carte » de la préparation d'une expédition. Un cadre réunit l'emplacement de la carte envoyée (en `lg`, un
|
||||
// « + » tant qu'aucune n'est choisie), ses stats pour l'expédition et ses trois emplacements d'équipement (en `md`). Un clic sur
|
||||
// l'emplacement de la carte ouvre la liste des cartes jouables (tris, étiquettes utiles à la destination) ; un clic sur un
|
||||
// emplacement d'équipement ouvre le choix des communes.
|
||||
// emplacement d'équipement ouvre le choix des communes, « Graver » sous une commune sa gravure (avec un Burin) ; « Améliorer la
|
||||
// carte » ouvre sa fiche (niveau, plan de progression).
|
||||
import { useMemo, useState } from "react";
|
||||
import { Modal } from "../../components/Modal.jsx";
|
||||
import { Tooltip } from "../../components/Tooltip.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { ExpeditionCardTile } from "./ExpeditionCardTile.jsx";
|
||||
import { EquipmentPicker, EquipmentSlots, PowerTooltipContent } from "./ExpeditionEquipmentSlots.jsx";
|
||||
import { CardSheet, EngraveModal } from "./ExpeditionImprove.jsx";
|
||||
import { editionEntry, formatDecimal, helpScore, POWER_TEXT, powerDetails, STAT_IDS, tagColor, tagLabel } from "./expeditionFormat.js";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
|
|
@ -73,13 +75,18 @@ export function ExpeditionLoadout({ catalog, state, view, destination, card, onC
|
|||
{entry ? <NebulaCard catalog={catalog} entry={entry} size="lg" onSelect={() => setPicker("card")} selectLabel={fillTemplate(content.changeCard, { card: entry.card.name })} />
|
||||
: <button className="nebula-loadout-empty" type="button" onClick={() => setPicker("card")}><span aria-hidden="true">+</span><strong>{content.chooseCardSlot}</strong></button>}
|
||||
{card?.tags?.length > 0 && <ul className="nebula-loadout-tags" aria-label={content.tagsTitle}>{card.tags.map((tag) => <li key={tag} className="nebula-tag-chip" data-tag-color={tagColor(card.tags, tag)}>{tagLabel(catalog, tag)}</li>)}</ul>}
|
||||
{/* La fiche de la carte, sans quitter les Expéditions : niveau, plan de progression, équipement et gravure. */}
|
||||
{entry && <button className="nds-button nebula-loadout-improve" data-size="sm" data-variant="secondary" type="button" onClick={() => setPicker("sheet")}>
|
||||
<MaskIcon name="power" />{content.improveCard}
|
||||
</button>}
|
||||
</div>
|
||||
<div className="nebula-loadout-body">
|
||||
{card ? <h4>{entry?.card.name}</h4> : <p className="nebula-form-help">{content.loadoutEmpty}</p>}
|
||||
<div className="nebula-loadout-columns">
|
||||
<section className="nebula-loadout-equipment" aria-label={content.equipmentTitle}>
|
||||
<h5>{content.equipmentTitle}</h5>
|
||||
<EquipmentSlots catalog={catalog} progress={progress} content={content} busy={busy} runMutation={runMutation} onOpen={setPicker} powerValues={view.powers} />
|
||||
<EquipmentSlots catalog={catalog} progress={progress} content={content} busy={busy} runMutation={runMutation} onOpen={setPicker} powerValues={view.powers}
|
||||
onEngrave={(state.items?.engraving ?? 0) > 0 ? (equipmentId) => setPicker({ engrave: equipmentId }) : null} />
|
||||
</section>
|
||||
{card && <section className="nebula-loadout-stats" aria-label={content.chosenStats}>
|
||||
<h5>{content.chosenStatsTitle}</h5>
|
||||
|
|
@ -100,6 +107,8 @@ export function ExpeditionLoadout({ catalog, state, view, destination, card, onC
|
|||
</section>}
|
||||
</div>
|
||||
</div>
|
||||
{picker?.engrave && progress && <EngraveModal catalog={catalog} state={state} view={view} equipmentId={picker.engrave} characterId={progress.editionId} content={content} busy={busy} runMutation={runMutation} onClose={() => setPicker(null)} />}
|
||||
{picker === "sheet" && card && <CardSheet catalog={catalog} state={state} editionId={card.editionId} busy={busy} runMutation={runMutation} onClose={() => setPicker(null)} />}
|
||||
{picker === "card" && <CardPicker catalog={catalog} view={view} destination={destination} selectedId={card?.editionId} content={content} onChoose={onChooseCard} onClose={() => setPicker(null)} />}
|
||||
{typeof picker === "number" && progress && <EquipmentPicker catalog={catalog} state={state} progress={progress} cardName={entry?.card.name || ""} slot={picker} content={content}
|
||||
busy={busy} runMutation={runMutation} onClose={() => setPicker(null)} powerValues={view.powers} />}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { useEffect, useMemo, useState } from "react";
|
|||
import { Tooltip } from "../../components/Tooltip.jsx";
|
||||
import { previewExpedition } from "./cardsApi.js";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { conditionText, coverEntry, dangerText, editionEntry, formatDecimal, formatEclats, synergyLabels, tagLabel } from "./expeditionFormat.js";
|
||||
import { conditionText, coverEntry, dangerText, editionEntry, formatDecimal, formatEclats, ITEM_ART, synergyLabels, tagLabel } from "./expeditionFormat.js";
|
||||
import { MainStatMark, MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { ExpeditionLoadout } from "./ExpeditionLoadout.jsx";
|
||||
import { ExpectedLootTile, PowerName, TierTile } from "./ExpeditionOutcome.jsx";
|
||||
|
|
@ -159,7 +159,7 @@ function DestinationOption({ catalog, item, selected, card, view, content, onSel
|
|||
</button>;
|
||||
}
|
||||
|
||||
export function ExpeditionPlanner({ catalog, state, view, content, busy, onStart, runMutation }) {
|
||||
export function ExpeditionPlanner({ catalog, state, view, content, busy, onStart, onReroll, runMutation }) {
|
||||
// Destinations de la plus facile à la plus difficile.
|
||||
const destinations = useMemo(() => [...view.destinations].sort((a, b) => (a.level ?? 0) - (b.level ?? 0)), [view.destinations]);
|
||||
const [destinationId, setDestinationId] = useState(destinations[0]?.id || "");
|
||||
|
|
@ -195,7 +195,13 @@ export function ExpeditionPlanner({ catalog, state, view, content, busy, onStart
|
|||
const start = async (departNow) => { if (await onStart({ ...body, departNow })) setEditionId(null); };
|
||||
return <div className="nebula-expedition-planner">
|
||||
<section className="nds-panel nebula-expedition-step" aria-labelledby="nebula-expedition-destinations-title">
|
||||
<h3 id="nebula-expedition-destinations-title">{content.destinationsTitle}</h3>
|
||||
{/* La Rose des vents se joue ici, à côté des destinations qu'elle remplace, tant que le joueur en a. */}
|
||||
<div className="nebula-expedition-step-heading">
|
||||
<h3 id="nebula-expedition-destinations-title">{content.destinationsTitle}</h3>
|
||||
{view.enabled && view.items?.windRose > 0 && <button className="nds-button nebula-wind-rose-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={onReroll}>
|
||||
<img src={ITEM_ART.windRose} alt="" />{fillTemplate(content.useWindRose, { count: view.items.windRose })}
|
||||
</button>}
|
||||
</div>
|
||||
{view.unlocked && view.unlocked.count < view.unlocked.total && <p className="nebula-form-help">{fillTemplate(content.unlockedDestinations, view.unlocked)}</p>}
|
||||
<p className="nebula-form-help">{card ? fillTemplate(content.requirementsHelpCard, { card: editionEntry(catalog, card.editionId)?.card.name || "" }) : content.requirementsHelp}</p>
|
||||
<div className="nebula-expedition-destinations">{destinations.map((item) => <DestinationOption key={item.id} catalog={catalog} item={item} selected={item.id === destination.id} card={card}
|
||||
|
|
@ -211,7 +217,8 @@ export function ExpeditionPlanner({ catalog, state, view, content, busy, onStart
|
|||
<section className="nds-panel nebula-expedition-step" aria-labelledby="nebula-expedition-settings-title">
|
||||
<h3 id="nebula-expedition-settings-title">{content.difficultyTitle}</h3>
|
||||
<div className="nebula-expedition-choices">
|
||||
<div role="group" aria-label={content.durationLabel} className="nds-toolbar">{view.durations.map((value) => <button key={value} type="button" className="nds-button" data-size="sm" data-variant={value === hours ? "primary" : "secondary"} aria-pressed={value === hours} onClick={() => setHours(value)}>{fillTemplate(content.hours, { hours: value })}</button>)}</div>
|
||||
{/* En local, une durée de test en plus (`view.testDuration`), aux règles de la plus courte. */}
|
||||
<div role="group" aria-label={content.durationLabel} className="nds-toolbar">{[...view.durations, ...(view.testDuration ? [view.testDuration] : [])].map((value) => <button key={value} type="button" className="nds-button" data-size="sm" data-variant={value === hours ? "primary" : "secondary"} aria-pressed={value === hours} onClick={() => setHours(value)}>{value === view.testDuration ? content.testDuration : fillTemplate(content.hours, { hours: value })}</button>)}</div>
|
||||
</div>
|
||||
{!complete && <p className="nebula-form-help">{content.previewEmpty}</p>}
|
||||
{shownPreview?.error && <p className="nds-inline-notice" data-variant="warning" role="status">{shownPreview.error}</p>}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ export function ExpeditionReport({ catalog, expedition, content, now, busy, onCl
|
|||
{expedition.result?.players > 1 && <p className="nebula-form-help">{fillTemplate(content.reportPlayers, { count: expedition.result.players, loot: formatEclats(expedition.result.lootPct / 100) })}</p>}
|
||||
<ul className="nebula-expedition-report-team" aria-label={content.teamTitle}>{expedition.slots.map((slot) => {
|
||||
const entry = slot.editionId && editionEntry(catalog, slot.editionId);
|
||||
// Place du Veilleur de la Guilde : sans carte.
|
||||
if (!entry) return <li key={slot.position} className="nebula-expedition-group-free"><span>{content.keeper}</span></li>;
|
||||
if (!entry) return null;
|
||||
return <li key={slot.position}><NebulaCard catalog={catalog} entry={entry} size="sm" />{expedition.mode === "group" && <span>{slot.own ? content.you : slot.playerName}</span>}</li>;
|
||||
})}</ul>
|
||||
{status === "running" && expedition.mode === "solo" && anchors > 0 && onRecall && <div className="nds-card-actions">
|
||||
|
|
|
|||
63
website/src/features/cards/ExpeditionReturn.jsx
Normal file
63
website/src/features/cards/ExpeditionReturn.jsx
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
// Rôle : retour d'une expédition du joueur, sur toute la largeur et en deux colonnes comme l'expédition en préparation : le paysage
|
||||
// et l'équipe à gauche ; à droite, seulement ce que le joueur reçoit, visible dès le retour, et le bouton dessous. Un clic récupère le
|
||||
// butin : l'expédition passe au Journal et la carte disparaît.
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { editionEntry, formatEclats } from "./expeditionFormat.js";
|
||||
import { DestinationArt, MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
// Une ligne du butin : une icône, puis le gain.
|
||||
function LootLine({ icon, children, variant }) {
|
||||
return <li data-variant={variant}><MaskIcon name={icon} /><span>{children}</span></li>;
|
||||
}
|
||||
|
||||
// Butin rapporté : Éclats, poussière, paquets et objets en colonne à gauche ; à côté, les cartes trouvées en cartes `sm`, leur
|
||||
// nom dessous.
|
||||
function ReturnLoot({ catalog, reward, content }) {
|
||||
const items = Object.entries((reward.items || []).reduce((counts, item) => ({ ...counts, [item]: (counts[item] || 0) + 1 }), {}));
|
||||
const cards = (reward.cards || []).map((editionId) => editionEntry(catalog, editionId)).filter(Boolean);
|
||||
return <section className="nebula-return-loot" aria-label={content.claimedTitle}>
|
||||
<h5>{content.claimedTitle}</h5>
|
||||
<div className="nebula-return-loot-body">
|
||||
<ul className="nebula-return-loot-list">
|
||||
<LootLine icon="eclats" variant="gold">{fillTemplate(content.rewardEclats, { value: formatEclats(reward.eclats) })}</LootLine>
|
||||
{reward.stardust > 0 && <LootLine icon="stardust">{fillTemplate(content.rewardStardust, { value: formatStardust(reward.stardust) })}</LootLine>}
|
||||
{reward.packs.length > 0 && <LootLine icon="cards">{fillTemplate(content.rewardPacks, { count: reward.packs.length, s: reward.packs.length > 1 ? "s" : "" })}</LootLine>}
|
||||
{items.map(([item, count]) => <LootLine key={item} icon="items">{count > 1 ? `${content.items[item]} ×${count}` : content.items[item]}</LootLine>)}
|
||||
{reward.recalledPct != null && <LootLine icon="items" variant="warning">{fillTemplate(content.recalledShare, { pct: reward.recalledPct })}</LootLine>}
|
||||
</ul>
|
||||
{cards.length > 0 && <ul className="nebula-return-cards" aria-label={content.returnCards}>{cards.map((entry, index) => <li key={`${entry.edition.id}-${index}`}>
|
||||
<NebulaCard catalog={catalog} entry={entry} size="sm" /><strong>{entry.card.name}</strong>
|
||||
</li>)}</ul>}
|
||||
</div>
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function ExpeditionReturn({ catalog, expedition, content, busy, onClaim }) {
|
||||
const { reward } = expedition;
|
||||
const team = expedition.slots.filter((slot) => slot.editionId);
|
||||
return <article className="nds-card nebula-expedition-group nebula-expedition-return" aria-labelledby={`nebula-return-${expedition.id}`}>
|
||||
<div className="nebula-group-side">
|
||||
<DestinationArt catalog={catalog} destination={expedition.destination} />
|
||||
<section className="nebula-group-team" aria-label={content.returnTeam}>
|
||||
<h5>{content.returnTeam}</h5>
|
||||
<ul className="nebula-expedition-group-members">{team.map((slot) => {
|
||||
const entry = editionEntry(catalog, slot.editionId);
|
||||
return <li key={slot.position}>{entry && <NebulaCard catalog={catalog} entry={entry} size="sm" />}<strong>{slot.own ? content.you : slot.playerName}</strong></li>;
|
||||
})}</ul>
|
||||
</section>
|
||||
</div>
|
||||
<div className="nebula-group-main">
|
||||
<div className="nebula-group-heading">
|
||||
<p className="eyebrow">{fillTemplate(content.reportMeta, { stars: "★".repeat(expedition.stars), hours: expedition.hours })}</p>
|
||||
<h4 id={`nebula-return-${expedition.id}`}>{expedition.destination.name}</h4>
|
||||
<p className="nebula-return-status">{content.returned}</p>
|
||||
</div>
|
||||
{reward && <ReturnLoot catalog={catalog} reward={reward} content={content} />}
|
||||
<div className="nds-toolbar nebula-expedition-group-actions">
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy} onClick={() => onClaim(expedition.id)}>{content.claim}</button>
|
||||
</div>
|
||||
</div>
|
||||
</article>;
|
||||
}
|
||||
|
|
@ -1,18 +1,22 @@
|
|||
// Rôle : présente les Expéditions, quête de la Guilde, en deux onglets. « Préparer » suit le parcours du joueur : la carte de
|
||||
// destination offerte à sa première visite, puis son expédition (à récupérer, en route, ou ouverte au groupe) ou, s'il n'en a pas,
|
||||
// les expéditions à rejoindre et la préparation. « Journal » garde les expéditions terminées et leur butin.
|
||||
// les expéditions à rejoindre et la préparation. Une expédition revenue montre son résultat et son butin sur place ; récupéré, il reste
|
||||
// affiché jusqu'à « Préparer la suivante ». « Journal » garde les expéditions terminées et leur butin.
|
||||
import { useEffect, useState } from "react";
|
||||
import { Modal } from "../../components/Modal.jsx";
|
||||
import { Tabs } from "../../components/Tabs.jsx";
|
||||
import { addBonusDestination, claimExpedition, craftPowerCommon, recallExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, markStarterSeen, rerollDestinations, startExpedition } from "./cardsApi.js";
|
||||
import { addBonusDestination, addTestPlayer, claimExpedition, craftPowerCommon, recallExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, markStarterSeen, rerollDestinations, startExpedition } from "./cardsApi.js";
|
||||
import { CurrencyAmount } from "./Currency.jsx";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { ExpeditionAtelier } from "./ExpeditionAtelier.jsx";
|
||||
import { ExpeditionGroupCard } from "./ExpeditionGroupCard.jsx";
|
||||
import { EngraveModal, ImproveCardPicker } from "./ExpeditionImprove.jsx";
|
||||
import { ExpeditionJourney } from "./ExpeditionJourney.jsx";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { ExpeditionPlanner } from "./ExpeditionPlanner.jsx";
|
||||
import { ExpeditionReport } from "./ExpeditionReport.jsx";
|
||||
import { ExpeditionReturn } from "./ExpeditionReturn.jsx";
|
||||
import { ExpeditionStarter } from "./ExpeditionStarter.jsx";
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
import { formatEclats, ITEM_ART } from "./expeditionFormat.js";
|
||||
|
||||
const COUNTDOWN_TICK_MS = 30_000;
|
||||
|
||||
|
|
@ -27,43 +31,48 @@ const expeditionCall = (call) => async () => {
|
|||
};
|
||||
|
||||
// Sac du Veilleur : objets rapportés ; les destinations bonus s'ouvrent ici, l'ancre et le burin depuis l'expédition et la fiche de carte.
|
||||
// Atelier : 3 doublons de communes (une même commune peut compter autant de fois qu'elle a de doublons libres).
|
||||
function Atelier({ catalog, state, content, busy, onCraft }) {
|
||||
const [chosen, setChosen] = useState([]);
|
||||
const commons = state.collection.filter((entry) => entry.spare > 0 && entry.edition?.rarity === "common");
|
||||
const count = (editionId) => chosen.filter((id) => id === editionId).length;
|
||||
return <div className="nebula-expedition-atelier">
|
||||
<p className="nebula-form-help">{fillTemplate(content.atelierHelp, { count: chosen.length })}</p>
|
||||
{commons.length ? <ul>{commons.map((entry) => <li key={entry.editionId}>
|
||||
<button className="nds-button" data-size="sm" data-variant={count(entry.editionId) ? "primary" : "secondary"} type="button" disabled={busy || (chosen.length >= 3 && !count(entry.editionId))}
|
||||
onClick={() => setChosen(count(entry.editionId) < entry.spare && chosen.length < 3 ? [...chosen, entry.editionId] : chosen.filter((id) => id !== entry.editionId))}>
|
||||
{entry.card?.name || catalog.cards.find((card) => card.id === entry.edition?.cardId)?.name}{count(entry.editionId) ? ` ×${count(entry.editionId)}` : ""}
|
||||
</button>
|
||||
</li>)}</ul> : <p className="nebula-form-help">{content.atelierNoCommons}</p>}
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || chosen.length !== 3} onClick={async () => { if (await onCraft(chosen)) setChosen([]); }}>{content.atelierAction}</button>
|
||||
</div>;
|
||||
// Sac du Veilleur en grille de cartes : l'illustration de chaque objet (sans illustration, l'icône générique des objets) et sa
|
||||
// quantité, son nom, son aide, puis son action. La Rose des vents s'utilise depuis les destinations du jour ; le plan ouvre
|
||||
// l'atelier en fenêtre.
|
||||
const BAG_ORDER = ["guideStar", "skyChart", "fragment", "windRose", "anchor", "engraving", "plan", "oblivion"];
|
||||
|
||||
function ItemArt({ id, count }) {
|
||||
return <span className="nebula-bag-art">
|
||||
{ITEM_ART[id] ? <img src={ITEM_ART[id]} alt="" loading="lazy" decoding="async" /> : <MaskIcon name="items" />}
|
||||
<span className="nebula-bag-count">×{count}</span>
|
||||
</span>;
|
||||
}
|
||||
|
||||
function ItemBag({ catalog, state, view, content, busy, onBonus, onReroll, onCraft }) {
|
||||
function ItemBag({ catalog, state, view, content, busy, onBonus, onCraft, onAtelierClosed, runMutation }) {
|
||||
const [crafting, setCrafting] = useState(false);
|
||||
// Burin ou Parchemin : la fenêtre des cartes ouverte pour cet objet, puis la fiche de la carte choisie.
|
||||
const [improving, setImproving] = useState(null);
|
||||
const { items } = view;
|
||||
const used = new Set(view.destinations.map((destination) => destination.bonusSlot).filter(Boolean));
|
||||
const actions = { guideStar: ["5", content.useGuideStar, 1], skyChart: ["6", content.useSkyChart, 1], fragment: ["hidden", content.useFragments, view.fragmentsForMap] };
|
||||
const owned = Object.entries(items).filter(([, count]) => count > 0);
|
||||
// Objets de destination : la place de la destination ajoutée et le nombre d'exemplaires qu'il faut.
|
||||
const actions = { guideStar: ["5", 1], skyChart: ["6", 1], fragment: ["hidden", view.fragmentsForMap] };
|
||||
// Les objets de destination d'abord, du plus simple au plus riche ; puis les autres.
|
||||
const owned = Object.entries(items).filter(([, count]) => count > 0)
|
||||
.sort(([a], [b]) => BAG_ORDER.indexOf(a) - BAG_ORDER.indexOf(b));
|
||||
// Sans objet, pas de Sac du Veilleur.
|
||||
if (!owned.length) return null;
|
||||
return <section className="nds-panel nebula-expedition-bag" aria-labelledby="nebula-expedition-bag-title">
|
||||
<h3 id="nebula-expedition-bag-title">{content.bagTitle}</h3>
|
||||
<ul>{owned.map(([id, count]) => {
|
||||
const action = actions[id];
|
||||
return <li key={id} className="nds-list-row">
|
||||
<span><strong>{content.items[id]}</strong> ×{count}<span className="nebula-form-help">{content.itemHelp[id]}</span></span>
|
||||
{action && view.enabled && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy || count < action[2] || used.has(action[0])} onClick={() => onBonus(id)}>{action[1]}</button>}
|
||||
{id === "windRose" && view.enabled && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy || view.rerolledToday} onClick={onReroll}>{view.rerolledToday ? content.windRoseUsed : content.useWindRose}</button>}
|
||||
{id === "plan" && view.atelierAvailable && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" aria-pressed={crafting} disabled={busy} onClick={() => setCrafting(!crafting)}>{content.atelierOpen}</button>}
|
||||
{id === "plan" && crafting && <Atelier catalog={catalog} state={state} content={content} busy={busy} onCraft={async (ids) => { const done = await onCraft(ids); if (done) setCrafting(false); return done; }} />}
|
||||
return <li key={id} className="nds-card nebula-bag-item">
|
||||
<ItemArt id={id} count={count} />
|
||||
<span className="nebula-bag-text"><strong>{content.items[id]}</strong><span className="nebula-form-help">{fillTemplate(content.itemHelp[id], { count: view.fragmentsForMap })}</span></span>
|
||||
{/* Les fragments n'ont de bouton qu'une fois assez nombreux pour une carte au trésor. */}
|
||||
{action && view.enabled && count >= action[1] && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy || used.has(action[0])} aria-label={fillTemplate(content.useItemLabel, { item: content.items[id] })} onClick={() => onBonus(id)}>{content.useItem}</button>}
|
||||
{(id === "engraving" || id === "oblivion") && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy}
|
||||
aria-label={fillTemplate(content.useItemLabel, { item: content.items[id] })} onClick={() => setImproving(id)}>{content.useItem}</button>}
|
||||
{id === "plan" && view.atelierAvailable && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => setCrafting(true)}>{content.atelierOpen}</button>}
|
||||
</li>;
|
||||
})}</ul>
|
||||
{improving === "engraving" && <EngraveModal catalog={catalog} state={state} view={view} content={content} busy={busy} runMutation={runMutation} onClose={() => setImproving(null)} />}
|
||||
{improving === "oblivion" && <ImproveCardPicker catalog={catalog} state={state} view={view} item={improving} content={content} busy={busy} runMutation={runMutation} onClose={() => setImproving(null)} />}
|
||||
{crafting && <ExpeditionAtelier catalog={catalog} state={state} content={content} busy={busy} powerValues={view.powers} onCraft={onCraft} onClose={() => { setCrafting(false); onAtelierClosed(); }} />}
|
||||
</section>;
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +83,6 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
const [reloadKey, setReloadKey] = useState(0);
|
||||
const [notice, setNotice] = useState(null);
|
||||
const [tab, setTab] = useState("prepare");
|
||||
const [claimed, setClaimed] = useState(null);
|
||||
const [starterClosed, setStarterClosed] = useState(false);
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
|
||||
|
|
@ -91,6 +99,15 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
// Une expédition revient pendant que la page est ouverte : la vue est relue à son heure de retour pour obtenir son résultat et
|
||||
// son butin.
|
||||
useEffect(() => {
|
||||
const returns = (view?.expeditions || []).filter((expedition) => expedition.status === "running" && !expedition.result).map((expedition) => expedition.returnsAt);
|
||||
if (!returns.length) return undefined;
|
||||
const timer = setTimeout(() => setReloadKey((key) => key + 1), Math.max(0, Math.min(...returns) - Date.now()) + 500);
|
||||
return () => clearTimeout(timer);
|
||||
}, [view]);
|
||||
|
||||
if (loadError) return <section className="nds-empty-state" role="alert"><h2>{content.title}</h2><p>{loadError}</p></section>;
|
||||
if (!view) return <section className="nds-empty-state" aria-busy="true"><h2>{content.title}</h2></section>;
|
||||
|
||||
|
|
@ -107,19 +124,23 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
return false;
|
||||
};
|
||||
const start = async (body) => handle(await runMutation(expeditionCall(() => startExpedition(body))), body.departNow ? content.departedSolo : content.groupOpened);
|
||||
const claim = async (id) => {
|
||||
const result = await runMutation(expeditionCall(() => claimExpedition(id)));
|
||||
if (handle(result, null) && result.expedition) setClaimed(result.expedition);
|
||||
};
|
||||
const claim = async (id) => handle(await runMutation(expeditionCall(() => claimExpedition(id))), content.claimedNotice);
|
||||
const join = async (id, choice) => handle(await runMutation(expeditionCall(() => joinExpedition(id, choice))), content.joined);
|
||||
const leave = async (id) => handle(await runMutation(expeditionCall(() => leaveExpedition(id))), content.left);
|
||||
// Serveur Vite local : un joueur de test rejoint une expédition ouverte au groupe.
|
||||
const testPlayer = view.testPlayers ? async (id) => handle(await runMutation(expeditionCall(() => addTestPlayer(id))), content.testPlayerAdded) : null;
|
||||
const bonus = async (item) => handle(await runMutation(expeditionCall(() => addBonusDestination(item))), content.bonusAdded);
|
||||
const reroll = async () => handle(await runMutation(expeditionCall(() => rerollDestinations())), content.rerolled);
|
||||
// Atelier : l'erreur s'affiche dans sa fenêtre ; à sa fermeture, la vue est relue pour le compte des plans.
|
||||
const craft = async (editionIds) => {
|
||||
const result = await runMutation(expeditionCall(() => craftPowerCommon(editionIds)));
|
||||
if (result?.crafted) setNotice({ variant: "success", text: fillTemplate(content.crafted, { card: catalog.cards.find((card) => card.id === catalog.editions.find((edition) => edition.id === result.crafted)?.cardId)?.name || "" }) });
|
||||
else if (result?.expeditionError) setNotice({ variant: "warning", text: result.expeditionError.message });
|
||||
return Boolean(result?.crafted);
|
||||
const result = await runMutation(async () => {
|
||||
try {
|
||||
return await craftPowerCommon(editionIds);
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
});
|
||||
return result?.crafted ? { crafted: result.crafted } : { error: result?.error || "" };
|
||||
};
|
||||
const recall = async (id) => handle(await runMutation(expeditionCall(() => recallExpedition(id))), content.recalled);
|
||||
const depart = async (id) => handle(await runMutation(expeditionCall(() => departExpedition(id))), content.departed);
|
||||
|
|
@ -145,10 +166,10 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
{joinId && !invited && view.enabled && <p className="nds-inline-notice" data-variant="info">{content.joinMissing}</p>}
|
||||
{view.expeditions.map((expedition) => (expedition.status === "running" && expedition.returnsAt > now
|
||||
? <ExpeditionJourney key={expedition.id} catalog={catalog} expedition={expedition} content={content} now={now} busy={busy} anchors={view.items.anchor} onRecall={recall} />
|
||||
: <ExpeditionReport key={expedition.id} catalog={catalog} expedition={expedition} content={content} now={now} busy={busy} onClaim={claim} />))}
|
||||
: <ExpeditionReturn key={expedition.id} catalog={catalog} expedition={expedition} content={content} busy={busy} onClaim={claim} />))}
|
||||
{mine.length > 0 && <section className="nebula-expedition-active" aria-labelledby="nebula-expedition-mine-title">
|
||||
<h3 id="nebula-expedition-mine-title">{content.mineTitle}</h3>
|
||||
<div className="nebula-expedition-reports">{mine.map((group) => <ExpeditionGroupCard key={group.id} catalog={catalog} group={group} cards={view.cards} content={content} now={now} busy={busy} limitReached={limitReached} onJoin={join} onLeave={leave} onDepart={depart} />)}</div>
|
||||
<div className="nebula-expedition-reports">{mine.map((group) => <ExpeditionGroupCard key={group.id} catalog={catalog} group={group} cards={view.cards} content={content} now={now} busy={busy} limitReached={limitReached} onJoin={join} onLeave={leave} onDepart={depart} onTestPlayer={testPlayer} />)}</div>
|
||||
</section>}
|
||||
{!view.enabled ? <div className="nds-empty-state"><h3>{content.closedTitle}</h3><p>{content.closedText}</p></div>
|
||||
: !expired && !limitReached && <>
|
||||
|
|
@ -160,8 +181,8 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
<h3>{content.planTitle}</h3>
|
||||
<span className="nebula-form-help">{fillTemplate(content.nextDay, { time: formatCountdown(view.nextDayAt - now) })}</span>
|
||||
</div>
|
||||
<ItemBag catalog={catalog} state={state} view={view} content={content} busy={busy} onBonus={bonus} onReroll={reroll} onCraft={craft} />
|
||||
<ExpeditionPlanner key={view.day} catalog={catalog} state={state} view={view} content={content} busy={busy} onStart={start} runMutation={equipAndRefresh} />
|
||||
<ItemBag catalog={catalog} state={state} view={view} content={content} busy={busy} onBonus={bonus} onCraft={craft} onAtelierClosed={reload} runMutation={equipAndRefresh} />
|
||||
<ExpeditionPlanner key={view.day} catalog={catalog} state={state} view={view} content={content} busy={busy} onStart={start} onReroll={reroll} runMutation={equipAndRefresh} />
|
||||
</>}
|
||||
{view.enabled && limitReached && invited && !invited.isMember && <p className="nds-inline-notice" data-variant="info">{content.groupLimit}</p>}
|
||||
</>;
|
||||
|
|
@ -187,10 +208,5 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
{expired && <div className="nds-inline-notice nebula-daily-expired" data-variant="warning" role="status"><span>{content.expired}</span><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={reload}>{content.reload}</button></div>}
|
||||
{tab === "prepare" ? prepare : journal}
|
||||
{view.starterCard && !starterClosed && <ExpeditionStarter catalog={catalog} editionId={view.starterCard} content={content} onClose={closeStarter} />}
|
||||
{claimed && <Modal dialogClassName="confirm-modal nds-modal nebula-expedition-claimed" labelledBy="nebula-expedition-claimed-title" onRequestClose={() => setClaimed(null)}>
|
||||
<h2 id="nebula-expedition-claimed-title">{content.claimedTitle}</h2>
|
||||
<ExpeditionReport catalog={catalog} expedition={claimed} content={content} now={now} busy={busy} onClaim={claim} />
|
||||
<div className="nds-toolbar"><button className="nds-button" data-variant="primary" type="button" onClick={() => setClaimed(null)}>{content.claimedClose}</button></div>
|
||||
</Modal>}
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ function CardFace({ entry, quantity, visual, size }) {
|
|||
<p>{card.description}</p>
|
||||
{edition.rarity === "mythic" && <span className="nebula-card-finish">{visual.finishLabel}</span>}
|
||||
</div>}
|
||||
{size === "md" && quantity > 0 && <span className="nebula-card-quantity" aria-label={`${quantity} exemplaires`}>×{quantity}</span>}
|
||||
{(size === "md" || size === "sm") && quantity > 0 && <span className="nebula-card-quantity" aria-label={`${quantity} exemplaires`}>×{quantity}</span>}
|
||||
<RaritySymbol rarity={edition.rarity} label={edition.rarity} />
|
||||
{visual.effectPreset && <>
|
||||
<span className="nebula-card-holo-layer nebula-card-holo-primary" aria-hidden="true" />
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ function ArticlesForm({ catalog, setting, articles, busy, save, saveExpeditionPr
|
|||
{!articles.open && <span className="nds-badge" data-variant="neutral">Fermé aux joueurs</span>}
|
||||
<label><span>Prix</span><input className="nds-input" aria-label="Prix d’un Parchemin d’oubli" type="number" inputMode="numeric" min={oblivion.min} max={oblivion.max} step="1" {...field("oblivionPrice")} /></label>
|
||||
{oblivionValid
|
||||
? <p className="nebula-form-help">Change le plan de progression d’une carte. Le premier choix de plan est gratuit.</p>
|
||||
? <p className="nebula-form-help">Réinitialise la répartition des stats d’une carte personnage. Le premier choix de plan est gratuit.</p>
|
||||
: <p className="nebula-form-help" role="alert">Prix d’un Parchemin : entier de {oblivion.min} à {oblivion.max.toLocaleString("fr-FR")}.</p>}
|
||||
</div>
|
||||
</article>}
|
||||
|
|
@ -125,7 +125,7 @@ function ArticlesForm({ catalog, setting, articles, busy, save, saveExpeditionPr
|
|||
{!articles.open && <span className="nds-badge" data-variant="neutral">Fermé aux joueurs</span>}
|
||||
<label><span>Prix</span><input className="nds-input" aria-label="Prix d’une Rose des vents" type="number" inputMode="numeric" min={windRose.min} max={windRose.max} step="1" {...field("windRosePrice")} /></label>
|
||||
{windRoseValid
|
||||
? <p className="nebula-form-help">Tire de nouvelles destinations pour la journée, une fois par jour. Elle sort aussi rarement du butin (poids réglé dans Guilde › Expéditions).</p>
|
||||
? <p className="nebula-form-help">Tire de nouvelles destinations pour la journée, autant de fois qu’on a de Roses. Elle sort aussi rarement du butin (poids réglé dans Guilde › Expéditions).</p>
|
||||
: <p className="nebula-form-help" role="alert">Prix d’une Rose des vents : entier de {windRose.min} à {windRose.max.toLocaleString("fr-FR")}.</p>}
|
||||
</div>
|
||||
</article>}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
{ path: "group.slots", label: "Places par groupe" },
|
||||
{ path: "group.recruitHours", label: "Période d’inscription maximale", unit: "h" },
|
||||
{ path: "group.lootPct", label: "Multiplicateur de butin selon les joueurs", unit: "%", items: ["2 joueurs", "3 joueurs", "4 joueurs"] },
|
||||
{ path: "group.npcStat", label: "Stats du Veilleur de la Guilde (chacune)" },
|
||||
{ path: "group.cohesionPct", label: "Bonus de cohésion, collections toutes différentes", unit: "%" }
|
||||
]
|
||||
},
|
||||
|
|
@ -83,7 +82,7 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
{ path: "progression.costFactor", label: "Éclats par point de Puissance au-dessus du décalage" },
|
||||
{ path: "progression.costOffset", label: "Décalage du coût (Puissance)" },
|
||||
{ path: "progression.duplicateLevels", label: "Niveaux donnés par un doublon" },
|
||||
{ path: "progression.fieldXpPct", label: "Expérience de terrain par retour, en part d’un niveau", unit: "%" },
|
||||
{ path: "progression.fieldXpPct", label: "Expérience par retour, en part d’un niveau", unit: "%" },
|
||||
{ path: "plans.maxStatPct", label: "Part maximale des points de niveau dans une stat", unit: "%" }
|
||||
]
|
||||
},
|
||||
|
|
@ -139,8 +138,8 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
{ path: "items.weights.engraving", label: "Poids : burin de graveur" },
|
||||
{ path: "items.weights.plan", label: "Poids : plan d’atelier" },
|
||||
{ path: "items.weights.anchor", label: "Poids : ancre des Veilleurs" },
|
||||
{ path: "items.weights.guideStar", label: "Poids : étoile guide (5e destination)" },
|
||||
{ path: "items.weights.skyChart", label: "Poids : carte céleste (6e destination)" },
|
||||
{ path: "items.weights.guideStar", label: "Poids : étoile guide (destination bonus)" },
|
||||
{ path: "items.weights.skyChart", label: "Poids : carte céleste (destination bonus au butin plus riche)" },
|
||||
{ path: "items.weights.windRose", label: "Poids : rose des vents (nouvelles destinations du jour)" },
|
||||
{ path: "items.weights.oblivion", label: "Poids : parchemin d’oubli (changer le plan d’une carte)" }
|
||||
]
|
||||
|
|
@ -187,7 +186,7 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
{ path: "loot.tierPct", label: "Multiplicateur du palier", unit: "%", items: ["Retour difficile", "Réussite", "Triomphe"] },
|
||||
{ path: "loot.fortunePerPointPct", label: "Bonus de carte par point de Fortune par place", unit: "%" },
|
||||
{ path: "loot.fortuneCapPct", label: "Bonus de Fortune maximal", unit: "%" },
|
||||
{ path: "loot.bonusSlotPct", label: "Multiplicateur des destinations bonus", unit: "%", items: ["5e destination", "6e destination"] },
|
||||
{ path: "loot.bonusSlotPct", label: "Multiplicateur des destinations bonus", unit: "%", items: ["Étoile guide", "Carte céleste"] },
|
||||
{ path: "specialty.boostPct", label: "Spécialité simple : la récompense favorisée", unit: "%" },
|
||||
{ path: "specialty.otherPct", label: "Spécialité simple : les trois autres récompenses", unit: "%" },
|
||||
{ path: "specialty.pairBoostPct", label: "Spécialité double : les deux récompenses favorisées", unit: "%" },
|
||||
|
|
|
|||
|
|
@ -205,6 +205,11 @@ export function joinExpedition(expeditionId, { editionId, role }) {
|
|||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/join`, { method: "POST", body: JSON.stringify({ editionId, role }) });
|
||||
}
|
||||
|
||||
// Serveur Vite local uniquement : un joueur de test rejoint l'expédition.
|
||||
export function addTestPlayer(expeditionId) {
|
||||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/test-player`, { method: "POST" });
|
||||
}
|
||||
|
||||
export function leaveExpedition(expeditionId) {
|
||||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/leave`, { method: "POST" });
|
||||
}
|
||||
|
|
@ -228,7 +233,7 @@ export function buyShopItem(item, count) {
|
|||
return request("/shop/items", { method: "POST", body: JSON.stringify({ item, count }) });
|
||||
}
|
||||
|
||||
// Rose des vents : de nouvelles destinations pour la journée (une fois par jour).
|
||||
// Rose des vents : de nouvelles destinations pour la journée.
|
||||
export function rerollDestinations() {
|
||||
return request("/expeditions/reroll", { method: "POST" });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,3 +116,15 @@ export function tagColor(tags, tag) {
|
|||
const index = (tags || []).indexOf(tag);
|
||||
return index < 0 ? undefined : (index % TAG_COLORS) + 1;
|
||||
}
|
||||
|
||||
// Illustration de chaque objet des Expéditions : découpe transparente 6:5, comme les articles de la boutique.
|
||||
export const ITEM_ART = Object.freeze({
|
||||
fragment: "/static/img/expeditions/items/fragment.webp",
|
||||
engraving: "/static/img/expeditions/items/engraving.webp",
|
||||
plan: "/static/img/expeditions/items/plan.webp",
|
||||
anchor: "/static/img/expeditions/items/anchor.webp",
|
||||
guideStar: "/static/img/expeditions/items/guide-star.webp",
|
||||
skyChart: "/static/img/expeditions/items/sky-chart.webp",
|
||||
oblivion: "/static/img/cards/shop/oblivion.webp",
|
||||
windRose: "/static/img/cards/shop/wind-rose.webp"
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue