Let players compare card stats in the collection, rebalance card profiles with a full refunded reset of upgrades, and fix best boosts that sometimes fired in the previous zone
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4a44306e30
commit
3590df5e1e
31 changed files with 1515 additions and 211 deletions
|
|
@ -1,5 +1,11 @@
|
|||
/**
|
||||
* @file Affiche l'album, ses progressions, ses filtres, le recyclage des doublons et le détail des éditions.
|
||||
* @file Affiche la collection du joueur : l'album (progressions par collection, filtres, recyclage des doublons, détail des
|
||||
* éditions) ou l'affichage « Stats » des cartes possédées des Expéditions, pour comparer leurs profils et classer un build.
|
||||
*
|
||||
* Utilisé par : CardsPage.jsx (section « collection »), en version complète et en mode mobile.
|
||||
* Attention : les filtres Recherche, Collection et Rareté valent pour les deux affichages ; Possession n'existe que dans l'album
|
||||
* (l'affichage Stats ne montre que des cartes possédées), Profil que dans l'affichage Stats.
|
||||
* @see website/src/features/cards/cardStats.js
|
||||
*/
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
|
|
@ -8,8 +14,11 @@ import { SelectDropdown } from "../../components/SelectDropdown.jsx";
|
|||
import { Tooltip } from "../../components/Tooltip.jsx";
|
||||
import { ActiveFilterBadges } from "../games/ActiveFilterBadges.jsx";
|
||||
import { ConfirmModal } from "../../components/ToolboxModals.jsx";
|
||||
import { Tabs } from "../../components/Tabs.jsx";
|
||||
import { CardDetailModal } from "./CardDetailModal.jsx";
|
||||
import { CardsFilterMenu } from "./CardsFilterMenu.jsx";
|
||||
import { PROFILE_SHAPES, rankRows, statRows } from "./cardStats.js";
|
||||
import { CollectionStats } from "./CollectionStats.jsx";
|
||||
import { DashboardAside } from "./CardsDashboard.jsx";
|
||||
import { recycleDuplicates } from "./cardsApi.js";
|
||||
import { readCollection, visibleCollections } from "./collectionState.js";
|
||||
|
|
@ -21,6 +30,7 @@ import { frenchList, rarityAdjective } from "./rarityWords.js";
|
|||
import { useCardsHref } from "./useCardsHref.js";
|
||||
|
||||
const OWNERSHIP_OPTIONS = [{ value: "owned", label: "Possédées" }, { value: "missing", label: "Manquantes" }, { value: "duplicates", label: "Doublons" }];
|
||||
const VIEWS = ["album", "stats"];
|
||||
const countDuplicates = (count) => `${count} doublon${count > 1 ? "s" : ""}`;
|
||||
|
||||
export function CollectionPanel({ catalog, state, runMutation, busy, headingContent, recyclingContent: content, cardSheetContent, onStartTransfer }) {
|
||||
|
|
@ -29,6 +39,11 @@ export function CollectionPanel({ catalog, state, runMutation, busy, headingCont
|
|||
const [collectionIds, setCollectionIds] = useState([]);
|
||||
const [rarities, setRarities] = useState([]);
|
||||
const [ownership, setOwnership] = useState([]);
|
||||
const [view, setView] = useState("album");
|
||||
const [statMode, setStatMode] = useState("profile");
|
||||
const [targets, setTargets] = useState([]);
|
||||
const [shapes, setShapes] = useState([]);
|
||||
// Fiche ouverte : la carte et son onglet (« Amélioration » depuis l'affichage Stats).
|
||||
const [selected, setSelected] = useState(null);
|
||||
const [confirmingRecycle, setConfirmingRecycle] = useState(false);
|
||||
const [recycleNotice, setRecycleNotice] = useState("");
|
||||
|
|
@ -41,15 +56,22 @@ export function CollectionPanel({ catalog, state, runMutation, busy, headingCont
|
|||
const normalizedSearch = search.trim().toLocaleLowerCase("fr");
|
||||
const collections = visibleCollections(catalog, owned.ownedCardIds);
|
||||
const visibleCollectionIds = new Set(collections.map((collection) => collection.id));
|
||||
// Recherche, collection et rareté : communes aux deux affichages. Une carte inconnue ne se cherche que par son nom : sa
|
||||
// description, cachée, est un indice de la Carte du jour.
|
||||
const matchesCommon = (card, edition, quantity) => visibleCollectionIds.has(card.collectionId)
|
||||
&& (!normalizedSearch || `${card.name} ${quantity > 0 ? card.description : ""}`.toLocaleLowerCase("fr").includes(normalizedSearch))
|
||||
&& (!collectionIds.length || collectionIds.includes(card.collectionId))
|
||||
&& (!rarities.length || rarities.includes(edition.rarity));
|
||||
const editions = catalog.editions.filter((edition) => {
|
||||
const card = cards.get(edition.cardId);
|
||||
const quantity = quantities.get(edition.id) || 0;
|
||||
// Une carte inconnue ne se cherche que par son nom : sa description, cachée, est un indice de la Carte du jour.
|
||||
return visibleCollectionIds.has(card.collectionId) && (!normalizedSearch || `${card.name} ${quantity > 0 ? card.description : ""}`.toLocaleLowerCase("fr").includes(normalizedSearch))
|
||||
&& (!collectionIds.length || collectionIds.includes(card.collectionId))
|
||||
&& (!rarities.length || rarities.includes(edition.rarity))
|
||||
return matchesCommon(cards.get(edition.cardId), edition, quantity)
|
||||
&& (!ownership.length || ownership.includes("owned") && quantity > 0 || ownership.includes("missing") && quantity === 0 || ownership.includes("duplicates") && quantity > 1);
|
||||
});
|
||||
const allStatRows = useMemo(() => statRows(catalog, state), [catalog, state]);
|
||||
const shownStatRows = rankRows(allStatRows.filter((row) => matchesCommon(row.card, row.edition, 1) && (!shapes.length || shapes.includes(row.shape))), targets, statMode);
|
||||
const hasCurrent = allStatRows.some((row) => row.current);
|
||||
const currentMax = Math.max(0, ...allStatRows.flatMap((row) => (row.current ? Object.values(row.current) : [])));
|
||||
const statsContent = headingContent.stats;
|
||||
|
||||
/** Éditions hors promotion d'une collection, décomptées dans les titres de l'album. */
|
||||
function collectionEditionsOf(collection) {
|
||||
|
|
@ -61,6 +83,7 @@ export function CollectionPanel({ catalog, state, runMutation, busy, headingCont
|
|||
setCollectionIds([]);
|
||||
setRarities([]);
|
||||
setOwnership([]);
|
||||
setShapes([]);
|
||||
}
|
||||
|
||||
async function recycleAll() {
|
||||
|
|
@ -82,15 +105,22 @@ export function CollectionPanel({ catalog, state, runMutation, busy, headingCont
|
|||
const showingDuplicates = ownership.includes("duplicates");
|
||||
const collectionOptions = collections.map((item) => ({ value: item.id, label: item.name }));
|
||||
const rarityOptions = catalog.rarities.map((item) => ({ value: item.id, label: item.label }));
|
||||
const shapeOptions = PROFILE_SHAPES.map((id) => ({ value: id, label: statsContent.shapes[id] }));
|
||||
const activeFilters = [
|
||||
...(search.trim() ? [{ id: "search", label: `Recherche : ${search.trim()}`, onRemove: () => setSearch("") }] : []),
|
||||
...collectionOptions.filter((option) => collectionIds.includes(option.value)).map((option) => ({ id: `collection-${option.value}`, label: `Collection : ${option.label}`, onRemove: () => setCollectionIds(collectionIds.filter((value) => value !== option.value)) })),
|
||||
...rarityOptions.filter((option) => rarities.includes(option.value)).map((option) => ({ id: `rarity-${option.value}`, label: `Rareté : ${option.label}`, onRemove: () => setRarities(rarities.filter((value) => value !== option.value)) })),
|
||||
...OWNERSHIP_OPTIONS.filter((option) => ownership.includes(option.value)).map((option) => ({ id: `ownership-${option.value}`, label: `Possession : ${option.label}`, onRemove: () => setOwnership(ownership.filter((value) => value !== option.value)) }))
|
||||
...(view === "album" ? OWNERSHIP_OPTIONS : []).filter((option) => ownership.includes(option.value)).map((option) => ({ id: `ownership-${option.value}`, label: `Possession : ${option.label}`, onRemove: () => setOwnership(ownership.filter((value) => value !== option.value)) })),
|
||||
...(view === "stats" ? shapeOptions : []).filter((option) => shapes.includes(option.value)).map((option) => ({ id: `shape-${option.value}`, label: `${statsContent.shapeFilter} : ${option.label}`, onRemove: () => setShapes(shapes.filter((value) => value !== option.value)) }))
|
||||
];
|
||||
|
||||
return <>
|
||||
<div className="nds-section-heading nebula-section-heading"><div><p className="eyebrow">{headingContent.eyebrow}</p><h2>{headingContent.title}</h2></div></div>
|
||||
<div className="nds-section-heading nebula-section-heading">
|
||||
<div><p className="eyebrow">{headingContent.eyebrow}</p><h2>{headingContent.title}</h2></div>
|
||||
<div className="nebula-collection-views" role="group" aria-label={headingContent.views.label}>
|
||||
<Tabs tabs={VIEWS.map((id) => ({ id, label: headingContent.views[id] }))} activeTab={view} onChange={setView} />
|
||||
</div>
|
||||
</div>
|
||||
{recycling.count > 0 && <DashboardAside>
|
||||
<section className="nds-panel nebula-recycle-box" aria-label={content.barLabel}>
|
||||
<StardustBalance value={wallet.stardust} />
|
||||
|
|
@ -98,7 +128,7 @@ export function CollectionPanel({ catalog, state, runMutation, busy, headingCont
|
|||
{preview.count ? <p><strong>{countDuplicates(preview.count)}</strong> à recycler pour <strong>+{formatStardust(preview.stardust)}</strong></p> : <p>{content.none}</p>}
|
||||
<div className="nebula-recycle-box-actions">
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || Boolean(state.pendingOpening) || !preview.count} onClick={() => setConfirmingRecycle(true)}>{content.allButton}</button>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" onClick={() => setOwnership(showingDuplicates ? [] : ["duplicates"])}>{showingDuplicates ? content.viewAll : content.viewDuplicates}</button>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" onClick={() => { setView("album"); setOwnership(showingDuplicates ? [] : ["duplicates"]); }}>{showingDuplicates ? content.viewAll : content.viewDuplicates}</button>
|
||||
</div>
|
||||
{state.pendingOpening && <p className="nebula-form-help">{content.pending} <a href={cardsHref("packs")}>{content.pendingAction}</a></p>}
|
||||
</section>
|
||||
|
|
@ -108,11 +138,15 @@ export function CollectionPanel({ catalog, state, runMutation, busy, headingCont
|
|||
<label className="nds-filter-search"><span className="sr-only">Recherche</span><input className="nds-input" data-size="sm" type="search" value={search} placeholder="Rechercher..." onChange={(event) => setSearch(event.target.value)} /></label>
|
||||
<CardsFilterMenu label="Collection" options={collectionOptions} selected={collectionIds} onChange={setCollectionIds} />
|
||||
<CardsFilterMenu label="Rareté" options={rarityOptions} selected={rarities} onChange={setRarities} />
|
||||
<CardsFilterMenu label="Possession" options={OWNERSHIP_OPTIONS} selected={ownership} onChange={setOwnership} />
|
||||
{view === "album" ? <CardsFilterMenu label="Possession" options={OWNERSHIP_OPTIONS} selected={ownership} onChange={setOwnership} />
|
||||
: <CardsFilterMenu label={statsContent.shapeFilter} options={shapeOptions} selected={shapes} onChange={setShapes} />}
|
||||
<Tooltip as="button" className="filter-reset-button nds-icon-button nds-filter-reset" content={headingContent.resetFilters} data-size="xs" type="button" aria-label={headingContent.resetFilters} onClick={resetFilters}><Icon name="rubber" /></Tooltip>
|
||||
<ActiveFilterBadges items={activeFilters} />
|
||||
</section>
|
||||
<section aria-label="Cartes de la collection">
|
||||
{view === "stats" ? <CollectionStats catalog={catalog} rows={shownStatRows} total={allStatRows.length} mode={hasCurrent ? statMode : "profile"} onModeChange={setStatMode}
|
||||
targets={targets} onTargetsChange={setTargets} hasCurrent={hasCurrent} currentMax={currentMax} content={statsContent} statNames={cardSheetContent.stats}
|
||||
onSelect={(row) => setSelected({ entry: { edition: row.edition, card: row.card }, tab: "improve" })} />
|
||||
: <section aria-label="Cartes de la collection">
|
||||
{editions.length ? <div className="nebula-album-groups">{collections.map((collection) => {
|
||||
const shownEditions = editions.filter((edition) => cards.get(edition.cardId).collectionId === collection.id);
|
||||
if (!shownEditions.length) return null;
|
||||
|
|
@ -129,13 +163,13 @@ export function CollectionPanel({ catalog, state, runMutation, busy, headingCont
|
|||
const quantity = quantities.get(edition.id) || 0;
|
||||
const discovered = quantity > 0;
|
||||
return <div key={edition.id} className="nebula-album-entry" data-missing={!quantity || undefined} data-undiscovered={!discovered || undefined}>
|
||||
<NebulaCard catalog={catalog} entry={entry} quantity={quantity} size="md" concealed={!discovered} backCollection={collection} onSelect={discovered ? () => setSelected(entry) : undefined} />
|
||||
<NebulaCard catalog={catalog} entry={entry} quantity={quantity} size="md" concealed={!discovered} backCollection={collection} onSelect={discovered ? () => setSelected({ entry, tab: "card" }) : undefined} />
|
||||
{discovered && favorites.has(edition.id) && <span className="nebula-favorite-mark" aria-label="Favorite">★</span>}
|
||||
</div>;
|
||||
})}</div>
|
||||
</section>;
|
||||
})}</div> : <div className="nds-empty-state"><p>Aucune édition ne correspond à ces filtres.</p></div>}
|
||||
</section>
|
||||
</section>}
|
||||
{confirmingRecycle && <ConfirmModal
|
||||
title={fillTemplate(content.confirmTitle, { count: countDuplicates(preview.count) })}
|
||||
message={fillTemplate(content.confirmText, { rarities: frenchList(chosenRarities.map((rarity) => rarityAdjective(catalog, rarity.id, 2))), stardust: formatStardust(preview.stardust) })}
|
||||
|
|
@ -148,6 +182,6 @@ export function CollectionPanel({ catalog, state, runMutation, busy, headingCont
|
|||
{/* Seules les raretés recyclées cette fois, avec ce que rapporte chacun de leurs doublons. */}
|
||||
<ul className="nebula-shop-rates" aria-label={content.ratesLabel}>{chosenRarities.map((rarity) => <li key={rarity.id} data-rarity={rarity.id}><span>{rarity.label}</span><StardustBalance value={shop.stardustValues[rarity.id] ?? 0} /></li>)}</ul>
|
||||
</ConfirmModal>}
|
||||
{selected && <CardDetailModal catalog={catalog} state={state} entry={selected} content={cardSheetContent} runMutation={runMutation} busy={busy} onClose={() => setSelected(null)} onStartTransfer={onStartTransfer} />}
|
||||
{selected && <CardDetailModal catalog={catalog} state={state} entry={selected.entry} initialTab={selected.tab} content={cardSheetContent} runMutation={runMutation} busy={busy} onClose={() => setSelected(null)} onStartTransfer={onStartTransfer} />}
|
||||
</>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue