sokko-g/website/src/features/cards/admin/AdminVisualLab.jsx
Shinuwa bd1da42c7f Add the Prismatic Backdrop holographic effect for cutout artwork
The new mythic effect works on two levels. An opaque iridescent film is
painted under the artwork and only shows through its transparent areas,
while a light overlay makes the whole card shine. Both follow the card
tilt without any running animation, like the Diffraction Sheen.

Cards can declare cutout versions of their artwork with the __cutout
suffix: cutoutImage for the standard format and fullCutoutImage for the
full-art format. The catalog only accepts the format's own image name
followed by __cutout. Prismatic Backdrop finishes use them when present
and fall back to the opaque artwork otherwise. The Mythic Card Pull gets
both cutout versions, and the admin visual lab previews the effect on them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:33:35 +01:00

99 lines
8.5 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 : bancs d'essai visuels de l'administration : effets holographiques mythiques, puis effets d'ouverture par rareté.
import { SelectDropdown } from "../../../components/SelectDropdown.jsx";
import { useState } from "react";
import { NebulaCard } from "../NebulaCard.jsx";
import { MATCH_HOLO_PALETTE_ID, MATCH_HOLO_PALETTE_LABEL, withCardOpeningSetting } from "../openingEffects.js";
import { SwatchDropdown } from "./SwatchDropdown.jsx";
const OPENING_EFFECT_DESCRIPTIONS = {
rare: "Une légère aura bleue précède le retournement de la carte.",
epic: "Une aura violet-magenta accompagne le retournement et une gerbe d’étincelles.",
legendary: "Une aura dorée intense libère une explosion dense de particules largement dispersées.",
mythic: "Une aura irisée aux couleurs de la palette de particules précède une gerbe de particules assorties, dont la forme et la palette se règlent ci-dessous."
};
function OpeningEffectPreview({ catalog, lookup, effect }) {
const [revealed, setRevealed] = useState(false);
const sourceParticles = catalog.particlePresets.find((item) => item.id === effect.particlePresetId);
const [shapeId, setShapeId] = useState(sourceParticles?.shapeId || catalog.particleShapes[0]?.id || "");
const [paletteId, setPaletteId] = useState(sourceParticles?.paletteId || catalog.particlePalettes[0]?.id || "");
// Sans variation mythique enregistrée, l'aperçu en compose une pour rester testable depuis une base neuve.
const legendary = catalog.editions.find((item) => item.rarity === "legendary" && !item.promotional);
const edition = catalog.editions.find((item) => item.rarity === effect.rarity && !item.promotional && !item.retired)
|| (effect.rarity === "mythic" && legendary ? { id: `admin-preview-${legendary.cardId}`, cardId: legendary.cardId, rarity: "mythic", finishIds: [lookup.holographicFinishes[0]?.id], promotional: false } : null);
const card = lookup.cards.get(edition?.cardId);
if (!edition || !card) return null;
const rarityLabel = lookup.rarityLabel(effect.rarity);
const customizable = effect.rarity === "mythic" && Boolean(sourceParticles);
// Un réglage de carte temporaire impose la forme et la palette choisies, quels que soient les réglages enregistrés.
const previewCatalog = customizable ? withCardOpeningSetting(catalog, card.id, { particleShapeId: shapeId, particlePaletteId: paletteId }) : catalog;
const paletteOptions = [...catalog.particlePalettes, { id: MATCH_HOLO_PALETTE_ID, label: MATCH_HOLO_PALETTE_LABEL }];
const resetPreview = (setter) => (value) => { setter(value); setRevealed(false); };
return <article className="nds-card nebula-admin-style-card nebula-admin-opening-effect-card" data-rarity={effect.rarity} aria-labelledby={`nebula-admin-opening-effect-${effect.id}`}>
<div className="nebula-admin-style-preview">
<NebulaCard catalog={previewCatalog} entry={{ edition, card }} size="lg" faceUp={false} revealed={revealed} replayable revealLabel={`la carte ${rarityLabel}`} onReveal={() => setRevealed(true)} onConceal={() => setRevealed(false)} backCollection={lookup.collections.get(card.collectionId)} />
<span>Aperçu · {card.name}{edition.rarity === "mythic" ? ` — ${lookup.finishes.get(edition.finishIds[0])?.label || ""}` : ""}</span>
</div>
<div className="nebula-admin-style-copy">
<p className="eyebrow">Effet de rareté</p>
<h4 id={`nebula-admin-opening-effect-${effect.id}`}>{rarityLabel}</h4>
<code>{effect.id}</code>
<p>{OPENING_EFFECT_DESCRIPTIONS[effect.rarity]}</p>
{customizable && <div className="nebula-admin-opening-controls" aria-label="Personnalisation des particules">
<SwatchDropdown label="Forme de particules" value={shapeId} options={catalog.particleShapes} onChange={resetPreview(setShapeId)} />
<SwatchDropdown label="Palette de particules" value={paletteId} options={paletteOptions} onChange={resetPreview(setPaletteId)} />
</div>}
<p className="nebula-admin-opening-hint">Cliquez sur la carte pour la révéler, puis cliquez à nouveau pour la retourner.</p>
</div>
</article>;
}
function HolographicEffectPreview({ catalog, effect, editions, previewCard }) {
const finishes = catalog.finishes.filter((finish) => finish.effectPresetId === effect.id);
const [paletteId, setPaletteId] = useState(finishes[0]?.paletteId || catalog.effectPalettes[0]?.id || "");
// Un effet à sous-couche s'ouvre en pleine illustration quand la carte en a une version à zones vides et pas la version standard.
const [formatId, setFormatId] = useState(effect.id === "prismatic-backdrop" && previewCard.fullCutoutImage && !previewCard.cutoutImage ? "full-art" : "standard");
// Chaque combinaison format × effet × palette existe déjà comme finition générée.
const finishId = finishes.find((finish) => finish.paletteId === paletteId && finish.formatId === formatId)?.id || finishes[0]?.id;
const edition = { id: `admin-effect-preview-${effect.id}`, cardId: previewCard.id, rarity: "mythic", finishIds: [finishId], promotional: false };
return <article className="nds-card nebula-admin-style-card" aria-labelledby={`nebula-admin-effect-${effect.id}`}>
<div className="nebula-admin-style-preview"><NebulaCard catalog={catalog} entry={{ edition, card: previewCard }} size="lg" /><span>Aperçu · {previewCard.name}</span></div>
<div className="nebula-admin-style-copy">
<p className="eyebrow">Effet holographique</p>
<h4 id={`nebula-admin-effect-${effect.id}`}>{effect.label}</h4>
<code>{effect.id}</code>
<p>{editions.length ? `${editions.length} édition${editions.length > 1 ? "s" : ""} utilise${editions.length > 1 ? "nt" : ""} cet effet.` : "Aucune édition n’utilise encore cet effet."}</p>
<div className="nebula-admin-effect-list">
{previewCard.fullImage && <div><SelectDropdown label="Format" value={formatId} options={catalog.cardFormats.map((item) => ({ value: item.id, label: item.label }))} onChange={setFormatId} /></div>}
<div><SwatchDropdown label="Palette de couleurs" value={paletteId} options={catalog.effectPalettes} onChange={setPaletteId} /></div>
<div><SelectDropdown className="nebula-admin-disabled-field" label="Particules au survol" disabled value="" options={[{ value: "", label: "À venir" }]} onChange={() => {}} /></div>
</div>
</div>
</article>;
}
export function AdminVisualLab({ catalog, lookup }) {
// Un aperçu par rareté, la mythique en tête.
const openingEffects = catalog.rarities.toSorted((left, right) => (right.id === "mythic") - (left.id === "mythic"))
.map((rarity) => catalog.openingEffects.find((effect) => effect.rarity === rarity.id))
.filter(Boolean);
const mythicEditions = catalog.editions.filter((edition) => edition.rarity === "mythic");
const holographicEffects = catalog.effectPresets.map((effect) => {
const finishIds = new Set(catalog.finishes.filter((finish) => finish.effectPresetId === effect.id).map((finish) => finish.id));
return { effect, editions: mythicEditions.filter((edition) => edition.finishIds.some((id) => finishIds.has(id))) };
});
const previewCard = lookup.cards.get("mythic-card-pull") || lookup.cards.get(mythicEditions[0]?.cardId) || catalog.cards[0];
return <>
<section aria-labelledby="nebula-admin-holo-effects-title">
<div className="nds-section-heading nebula-section-heading"><div><h3 id="nebula-admin-holo-effects-title">Effets holographiques mythiques <span className="nds-badge" data-variant="neutral">{holographicEffects.length}</span></h3><p>Une carte par effet holographique. Changez sa palette de sept couleurs avec le menu associé.</p></div></div>
<div className="nebula-admin-style-grid nebula-admin-effect-grid">{holographicEffects.map(({ effect, editions }) => <HolographicEffectPreview key={effect.id} catalog={catalog} effect={effect} editions={editions} previewCard={previewCard} />)}</div>
</section>
<section aria-labelledby="nebula-admin-opening-effects-title">
<div className="nds-section-heading nebula-section-heading"><div><h3 id="nebula-admin-opening-effects-title">Effets d’ouverture <span className="nds-badge" data-variant="neutral">{openingEffects.length}</span></h3><p>Testez les animations de dévoilement utilisées pendant les ouvertures de paquets, une par rareté.</p></div></div>
<div className="nebula-admin-style-grid nebula-admin-opening-effect-grid" data-opening-group="rarities">{openingEffects.map((effect) => <OpeningEffectPreview key={effect.id} catalog={catalog} lookup={lookup} effect={effect} />)}</div>
</section>
</>;
}