sokko-g/website/src/features/cards/ExpeditionLoadout.jsx
Shinuwa 30413de036 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>
2026-11-18 13:36:01 +01:00

116 lines
9.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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, « 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";
// Tris des cartes jouables : utiles à la destination (condition, dangers, Affinité), Puissance ou une stat.
const SORTS = ["useful", "power", ...STAT_IDS];
// Total d'une stat de la carte pour l'expédition, et au survol son détail : la valeur de la carte et l'apport de chaque commune
// (synergie comprise).
function StatTotal({ card, stat, content }) {
const sign = (value) => `${value > 0 ? "+" : "−"}${formatDecimal(Math.abs(value))}`;
const base = card.baseStats?.[stat] ?? card.stats[stat];
const lines = [
fillTemplate(content.statBase, { value: formatDecimal(base) }),
...(card.equipment || []).map((item) => {
const value = (item.stats?.[stat] || 0) + (item.synergyStat === stat ? item.synergyBonus || 0 : 0);
return value ? fillTemplate(content.bonusFrom, { card: item.name, value: sign(value) }) : null;
}).filter(Boolean)
];
return <Tooltip className="nebula-loadout-stat-total" content={<span className="nebula-tooltip-lines">{lines.map((line) => <span key={line}>{line}</span>)}</span>}
aria-label={`${content.stats[stat]} : ${formatDecimal(card.stats[stat])}. ${lines.join(" ; ")}`} tabIndex={0}>
<strong aria-hidden="true">{formatDecimal(card.stats[stat])}</strong>
</Tooltip>;
}
// Liste des cartes jouables, dans une fenêtre : un clic choisit la carte et la ferme.
function CardPicker({ catalog, view, destination, selectedId, content, onChoose, onClose }) {
const mainStat = destination?.stats[0];
// Tri par défaut : la stat principale de la destination.
const [sort, setSort] = useState(null);
const sortKey = sort || mainStat;
// La carte déjà choisie en tête, puis les cartes libres avant celles en expédition, dans l'ordre du tri.
const cards = useMemo(() => [...view.cards].sort((a, b) => Number(b.editionId === selectedId) - Number(a.editionId === selectedId) || Number(a.busy) - Number(b.busy)
|| (sortKey === "useful" ? helpScore(b, destination) - helpScore(a, destination) || (b.stats[mainStat] ?? 0) - (a.stats[mainStat] ?? 0)
: sortKey === "power" ? b.power - a.power : (b.stats[sortKey] ?? 0) - (a.stats[sortKey] ?? 0) || b.power - a.power)), [view.cards, sortKey, destination, mainStat, selectedId]);
return <Modal dialogClassName="confirm-modal nds-modal nebula-expedition-picker" labelledBy="nebula-card-picker-title" onRequestClose={onClose}>
<h2 id="nebula-card-picker-title">{content.cardPickerTitle}</h2>
<p className="nebula-form-help">{fillTemplate(content.cardPickerHelp, { destination: destination?.name || "" })}</p>
<div className="nebula-expedition-sort" role="group" aria-label={content.sortLabel}>
<span className="nebula-form-help">{content.sortLabel}</span>
{SORTS.map((id) => <button key={id} type="button" className="nds-button" data-size="sm" data-variant={id === sortKey ? "primary" : "secondary"} aria-pressed={id === sortKey} onClick={() => setSort(id)}>
{id === "useful" ? content.sortUseful : id === "power" ? content.sortPower : <><MaskIcon name={id} />{content.stats[id]}</>}
</button>)}
</div>
{cards.length ? <ul className="nebula-expedition-cards" aria-label={content.cardsLabel}>{cards.map((item) => <ExpeditionCardTile key={item.editionId} catalog={catalog} card={item}
destination={destination} content={content} selected={item.editionId === selectedId} sortKey={sortKey} onSelect={() => { onChoose(item.editionId); onClose(); }} />)}</ul>
: <p className="nds-inline-notice" data-variant="info">{content.noCards}</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>;
}
export function ExpeditionLoadout({ catalog, state, view, destination, card, onChooseCard, content, busy, runMutation }) {
// Fenêtre ouverte : « card » (choix de la carte) ou le numéro de l'emplacement d'équipement.
const [picker, setPicker] = useState(null);
// Exigences de la destination choisie pour une carte seule : elles ne donnent que la couleur des totaux.
const requirements = destination?.requirements || [];
const entry = card && editionEntry(catalog, card.editionId);
const progress = card && state.cardProgress?.find((item) => item.editionId === card.editionId);
return <div className="nebula-expedition-loadout">
<div className="nebula-loadout-card">
{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}
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>
<ul className="nebula-expedition-chosen-stats">{STAT_IDS.map((stat) => {
const requirement = requirements.find((item) => item.stat === stat);
const met = requirement ? card.stats[stat] >= requirement.value : null;
return <li key={stat} data-met={met == null ? undefined : String(met)}>
<span className="nebula-loadout-stat-name"><MaskIcon name={stat} />{content.stats[stat]}</span>
<StatTotal card={card} stat={stat} content={content} />
</li>;
})}</ul>
{card.powers?.length > 0 && <ul className="nebula-expedition-chosen-powers" aria-label={content.chosenPowers}>{card.powers.map((power) => <li key={power}>
<Tooltip className="nebula-equipment-power" tooltipClassName="nebula-power-tooltip" content={<PowerTooltipContent power={power} values={view.powers} />}
aria-label={[`${content.powers[power]} : ${POWER_TEXT[power]}`, ...powerDetails(power, view.powers)].join(" ; ")} tabIndex={0}>
<MaskIcon name="power" /><span aria-hidden="true">{content.powers[power]}</span>
</Tooltip> {POWER_TEXT[power]}
</li>)}</ul>}
</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} />}
</div>;
}