Add the shattered ice effect and five-step tunings for mythic variations
« Glace brisée » joins the holographic effects: a seamless shard mosaic in four facet groups that each light up near their own tilt, with glinting cracks; in the standard layout it covers the frame and text and stays under the artwork. Its masks come from scripts/generate-shattered-ice-textures.mjs. Each mythic variation now tunes its palette intensity and, when the effect declares one, its own level (prism speed, parallax amplitude, shard size), from 1 to 5 with 3 as the reference render. Tunings are stored on mythic_variations, set with range sliders when a variation is created or later in the mythic editor, logged in the history and previewed in the Visual Lab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
efdb5c558c
commit
808adadc0c
23 changed files with 463 additions and 31 deletions
|
|
@ -6,6 +6,9 @@ import { MATCH_HOLO_PALETTE_ID, MATCH_HOLO_PALETTE_LABEL, resolveMythicOpeningSt
|
|||
const STANDARD_CARD_LAYOUT = "standard";
|
||||
// Effets holographiques qui découpent l'illustration en calques de parallaxe (décor, puis héros détouré).
|
||||
const PARALLAX_EFFECTS = new Set(["prismatic-backdrop"]);
|
||||
// Effets holographiques à facettes : chaque groupe d'éclats de la mosaïque capte la lumière sous un angle qui lui est propre.
|
||||
const SHARD_EFFECTS = new Set(["shattered-ice"]);
|
||||
const SHARD_FACETS = [0, 1, 2, 3];
|
||||
|
||||
function useCardTilt() {
|
||||
const cardRef = useRef(null);
|
||||
|
|
@ -249,6 +252,9 @@ function CardFace({ entry, quantity, visual, size }) {
|
|||
{visual.effectPreset && <>
|
||||
<span className="nebula-card-holo-layer nebula-card-holo-primary" aria-hidden="true" />
|
||||
<span className="nebula-card-holo-layer nebula-card-holo-secondary" aria-hidden="true" />
|
||||
{SHARD_EFFECTS.has(visual.effectPreset.id) && <span className="nebula-card-holo-layer nebula-card-holo-shards" aria-hidden="true">
|
||||
{SHARD_FACETS.map((facet) => <i key={facet} data-facet={facet} />)}
|
||||
</span>}
|
||||
</>}
|
||||
<span className="nebula-card-glare" aria-hidden="true" />
|
||||
</div>;
|
||||
|
|
@ -275,6 +281,9 @@ export function NebulaCard({ catalog, entry, quantity = 0, size = "lg", faceUp =
|
|||
const visualAttributes = {
|
||||
"data-holo-effect": visual.effectPreset?.id,
|
||||
"data-holo-palette": visual.palette?.id,
|
||||
// Paliers de la variation (intensité de la palette, palier propre à l'effet) : le palier central n'a pas d'attribut.
|
||||
"data-holo-intensity": visual.effectPreset ? entry.edition?.holoIntensity : undefined,
|
||||
"data-holo-level": visual.effectPreset?.level ? entry.edition?.holoLevel : undefined,
|
||||
"data-particle-preset": displayedParticlePreset?.id,
|
||||
"data-particle-shape": displayedParticleShape?.id,
|
||||
"data-particle-palette": displayedParticlePalette?.id,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ const EVENT_LABELS = {
|
|||
shop_updated: "Boutique modifiée",
|
||||
catalog_card_mythic_updated: "Variations mythiques modifiées",
|
||||
catalog_mythic_finish_changed: "Finition mythique changée",
|
||||
catalog_mythic_tuning_changed: "Réglages mythiques changés",
|
||||
catalog_collection_opening_updated: "Effets d’ouverture modifiés",
|
||||
collection_opened: "Collection ouverte aux joueurs",
|
||||
collection_closed: "Collection fermée aux joueurs",
|
||||
|
|
@ -48,6 +49,16 @@ function mythicFinishDetail(entry, catalog) {
|
|||
return `${card} · ${label(entry.details.previousFinishId)} → ${label(entry.details.finishId)}`;
|
||||
}
|
||||
|
||||
// Paliers d'une variation : intensité de la palette, puis palier de son effet s'il en déclare un.
|
||||
function mythicTuningDetail(entry, catalog) {
|
||||
const card = catalog.cards.find((item) => item.id === entry.entityId)?.name || entry.entityId;
|
||||
const edition = catalog.editions.find((item) => item.id === entry.details.editionId);
|
||||
const finish = catalog.finishes.find((item) => item.id === edition?.finishIds[0]);
|
||||
const level = catalog.effectPresets.find((item) => item.id === finish?.effectPresetId)?.level;
|
||||
const step = (scale, value) => `${scale.label.toLowerCase()} ${(scale.levels[value - 1] || value).toLowerCase()} (${value}/${scale.levels.length})`;
|
||||
return [`${card} · ${finish?.label || entry.details.editionId}`, catalog.effectIntensity && step(catalog.effectIntensity, entry.details.intensity), level && step(level, entry.details.level)].filter(Boolean).join(" · ");
|
||||
}
|
||||
|
||||
function eventDetail(entry, catalog) {
|
||||
const { details, campaignName } = entry;
|
||||
switch (entry.type) {
|
||||
|
|
@ -59,6 +70,7 @@ function eventDetail(entry, catalog) {
|
|||
case "shop_updated": return shopChanges(details, catalog).filter(Boolean).join(" · ");
|
||||
case "catalog_card_mythic_updated": return mythicDetail(entry, catalog);
|
||||
case "catalog_mythic_finish_changed": return mythicFinishDetail(entry, catalog);
|
||||
case "catalog_mythic_tuning_changed": return mythicTuningDetail(entry, catalog);
|
||||
case "catalog_collection_opening_updated":
|
||||
case "collection_opened":
|
||||
case "collection_closed": return collectionName(entry, catalog);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ 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 { EffectTuningFields } from "./EffectTuningFields.jsx";
|
||||
import { tuningEditionFields } from "./effectTuning.js";
|
||||
import { SwatchDropdown } from "./SwatchDropdown.jsx";
|
||||
|
||||
const OPENING_EFFECT_DESCRIPTIONS = {
|
||||
|
|
@ -52,11 +54,13 @@ function OpeningEffectPreview({ catalog, lookup, effect }) {
|
|||
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 || "");
|
||||
// Paliers essayés sur l'aperçu, comme ceux qu'une variation mythique enregistre ; le palier central n'est pas transmis.
|
||||
const [tuning, setTuning] = useState({});
|
||||
// La parallaxe s'ouvre en pleine illustration quand la carte n'a de héros détouré que dans ce format.
|
||||
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 };
|
||||
const edition = { id: `admin-effect-preview-${effect.id}`, cardId: previewCard.id, rarity: "mythic", finishIds: [finishId], promotional: false, ...tuningEditionFields(effect, tuning) };
|
||||
|
||||
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>
|
||||
|
|
@ -68,6 +72,7 @@ function HolographicEffectPreview({ catalog, effect, editions, previewCard }) {
|
|||
<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><EffectTuningFields catalog={catalog} effect={effect} value={tuning} onChange={setTuning} /></div>
|
||||
<div><SelectDropdown className="nebula-admin-disabled-field" label="Particules au survol" disabled value="" options={[{ value: "", label: "À venir" }]} onChange={() => {}} /></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
40
website/src/features/cards/admin/EffectTuningFields.jsx
Normal file
40
website/src/features/cards/admin/EffectTuningFields.jsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Rôle : curseurs des paliers d'une variation mythique, de 1 à 5 : l'intensité de la palette, puis le palier propre à l'effet
|
||||
// (vitesse, amplitude, taille des éclats) quand le catalogue lui en déclare un. Le niveau 3 est le rendu de référence.
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { DEFAULT_TUNING } from "./effectTuning.js";
|
||||
|
||||
function TuningRange({ scale, value, disabled, onChange }) {
|
||||
const valueLabel = scale.levels[value - 1];
|
||||
return <label className="nebula-admin-tuning-range">
|
||||
<span>{scale.label}<span className="nebula-admin-tuning-value">{valueLabel}</span></span>
|
||||
<input className="nds-range" data-size="sm" type="range" min="1" max={scale.levels.length} step="1" value={value} disabled={disabled} aria-label={scale.label} aria-valuetext={valueLabel} onChange={(event) => onChange(Number(event.target.value))} />
|
||||
</label>;
|
||||
}
|
||||
|
||||
export function EffectTuningFields({ catalog, effect, value, disabled = false, onChange }) {
|
||||
const intensity = value.intensity ?? DEFAULT_TUNING;
|
||||
const level = value.level ?? DEFAULT_TUNING;
|
||||
return <div className="nebula-admin-tuning">
|
||||
<TuningRange scale={catalog.effectIntensity} value={intensity} disabled={disabled} onChange={(next) => onChange({ intensity: next, level })} />
|
||||
{effect?.level && <TuningRange scale={effect.level} value={level} disabled={disabled} onChange={(next) => onChange({ intensity, level: next })} />}
|
||||
</div>;
|
||||
}
|
||||
|
||||
// Curseurs d'une variation enregistrée : l'aperçu suit le curseur aussitôt, l'enregistrement attend que le réglage se pose,
|
||||
// pour ne pas envoyer une requête par cran pendant un glissement. Le parent le remonte (`key`) quand les paliers enregistrés
|
||||
// changent : il repart alors de ces valeurs.
|
||||
export function SavedEffectTuningFields({ catalog, effect, edition, disabled, onPreview, onSave }) {
|
||||
const saved = { intensity: edition.holoIntensity ?? DEFAULT_TUNING, level: edition.holoLevel ?? DEFAULT_TUNING };
|
||||
const [draft, setDraft] = useState(saved);
|
||||
const timer = useRef(null);
|
||||
useEffect(() => () => clearTimeout(timer.current), []);
|
||||
const change = (next) => {
|
||||
setDraft(next);
|
||||
onPreview?.(next);
|
||||
clearTimeout(timer.current);
|
||||
timer.current = setTimeout(() => {
|
||||
if (next.intensity !== saved.intensity || (effect?.level && next.level !== saved.level)) onSave(next);
|
||||
}, 450);
|
||||
};
|
||||
return <EffectTuningFields catalog={catalog} effect={effect} value={draft} disabled={disabled} onChange={change} />;
|
||||
}
|
||||
|
|
@ -4,10 +4,12 @@ import { Tooltip } from "../../../components/Tooltip.jsx";
|
|||
import { SelectDropdown } from "../../../components/SelectDropdown.jsx";
|
||||
import { useState } from "react";
|
||||
import { ConfirmModal } from "../../../components/ToolboxModals.jsx";
|
||||
import { updateCardMythic, updateMythicFinish } from "../cardsApi.js";
|
||||
import { updateCardMythic, updateMythicFinish, updateMythicTuning } from "../cardsApi.js";
|
||||
import { NebulaCard } from "../NebulaCard.jsx";
|
||||
import { resolveMythicOpeningStyle, withCardOpeningSetting } from "../openingEffects.js";
|
||||
import { openingSettingFor, withoutOpeningSetting } from "./catalogSettings.js";
|
||||
import { EffectTuningFields, SavedEffectTuningFields } from "./EffectTuningFields.jsx";
|
||||
import { DEFAULT_TUNING, tuningEditionFields } from "./effectTuning.js";
|
||||
import { MythicOpeningFields } from "./MythicOpeningFields.jsx";
|
||||
import { PaletteSwatches, SwatchDropdown } from "./SwatchDropdown.jsx";
|
||||
|
||||
|
|
@ -41,6 +43,8 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
// Variation dont la finition est en cours de changement : { editionId, effectPresetId, paletteId, formatId }.
|
||||
const [editing, setEditing] = useState(null);
|
||||
const [pendingFinishChange, setPendingFinishChange] = useState(null);
|
||||
// Paliers en cours de glissement sur une variation enregistrée, appliqués à l'aperçu avant leur enregistrement.
|
||||
const [tuningPreview, setTuningPreview] = useState({});
|
||||
const [revealed, setRevealed] = useState(false);
|
||||
const [replayKey, setReplayKey] = useState(0);
|
||||
|
||||
|
|
@ -52,7 +56,15 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
// Une finition déjà portée par une autre variation de la carte, même retirée, ne peut pas être reprise.
|
||||
const editingDuplicated = Boolean(editingFinish && mythics.some((edition) => edition.id !== editing.editionId && edition.finishIds[0] === editingFinish.id));
|
||||
const editingUnchanged = Boolean(editingFinish && editingEdition?.finishIds[0] === editingFinish.id);
|
||||
const withEditedFinish = (edition) => (editingFinish && editing?.editionId === edition.id ? { ...edition, finishIds: [editingFinish.id] } : edition);
|
||||
const effectOfFinish = (finishId) => catalog.effectPresets.find((item) => item.id === lookup.finishes.get(finishId)?.effectPresetId);
|
||||
// Aperçu d'une variation : sa finition en cours de changement et ses paliers en cours de glissement.
|
||||
const withEditedFinish = (edition) => {
|
||||
const finished = editingFinish && editing?.editionId === edition.id ? { ...edition, finishIds: [editingFinish.id] } : edition;
|
||||
const preview = tuningPreview[edition.id];
|
||||
if (!preview) return finished;
|
||||
const { holoIntensity: _intensity, holoLevel: _level, ...base } = finished;
|
||||
return { ...base, ...tuningEditionFields(effectOfFinish(finished.finishIds[0]), preview) };
|
||||
};
|
||||
// Sans image au bon format, le choix du format n'existe pas pour cette carte.
|
||||
const unusedFinish = lookup.holographicFinishes.find((finish) => !savedFinishIds.includes(finish.id) && (card.fullImage || finish.formatId === "standard"));
|
||||
const collection = lookup.collections.get(card.collectionId);
|
||||
|
|
@ -63,11 +75,14 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
const save = (finishIds, nextOpening = opening) => mutateCatalog(() => updateCardMythic(card.id, { finishIds, opening: nextOpening }));
|
||||
|
||||
async function validateDraft() {
|
||||
const tuning = { intensity: draft.intensity, level: effectOfFinish(draftFinish.id)?.level ? draft.level : DEFAULT_TUNING };
|
||||
const result = await save([...savedFinishIds, draftFinish.id]);
|
||||
if (result?.catalog) {
|
||||
setDraft(null);
|
||||
// L'identifiant d'une nouvelle variation peut être suffixé : il se lit dans le catalogue renvoyé.
|
||||
const created = result.catalog.editions.find((edition) => edition.cardId === card.id && edition.rarity === "mythic" && !edition.retired && edition.finishIds[0] === draftFinish.id);
|
||||
// Les paliers choisis à la création s'enregistrent sur la variation qui vient d'être créée.
|
||||
if (created && (tuning.intensity !== DEFAULT_TUNING || tuning.level !== DEFAULT_TUNING)) await mutateCatalog(() => updateMythicTuning(created.id, tuning));
|
||||
select(created?.id || null);
|
||||
}
|
||||
}
|
||||
|
|
@ -79,6 +94,13 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
select(edition.id);
|
||||
}
|
||||
|
||||
async function changeTuning(edition, { intensity, level }) {
|
||||
const tuning = { intensity, level: effectOfFinish(edition.finishIds[0])?.level ? level : DEFAULT_TUNING };
|
||||
const result = await mutateCatalog(() => updateMythicTuning(edition.id, tuning));
|
||||
setTuningPreview(({ [edition.id]: _done, ...others }) => others);
|
||||
if (result?.catalog) setPreviewKey(edition.id);
|
||||
}
|
||||
|
||||
async function changeFinish(editionId, finishId) {
|
||||
const result = await mutateCatalog(() => updateMythicFinish(editionId, finishId));
|
||||
if (result?.catalog) {
|
||||
|
|
@ -97,7 +119,7 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
if (result?.catalog && previewKey === edition.id) setPreviewKey(null);
|
||||
}
|
||||
|
||||
const draftEdition = draft && { id: `admin-preview-${card.id}-${draftFinish?.id || "draft"}`, cardId: card.id, rarity: "mythic", finishIds: draftFinish ? [draftFinish.id] : [], promotional: false };
|
||||
const draftEdition = draft && { id: `admin-preview-${card.id}-${draftFinish?.id || "draft"}`, cardId: card.id, rarity: "mythic", finishIds: draftFinish ? [draftFinish.id] : [], promotional: false, ...(draftFinish ? tuningEditionFields(effectOfFinish(draftFinish.id), draft) : {}) };
|
||||
const previewMythic = activeMythics.find((edition) => edition.id === previewKey) || activeMythics[0];
|
||||
const previewEdition = (previewKey === DRAFT_KEY && draftEdition) || (previewMythic && withEditedFinish(previewMythic)) || draftEdition
|
||||
|| { id: `admin-preview-${card.id}`, cardId: card.id, rarity: "mythic", finishIds: [lookup.holographicFinishes[0]?.id], promotional: false };
|
||||
|
|
@ -154,6 +176,7 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
<div><dt>Effet</dt><dd>{effect?.label}</dd></div>
|
||||
<div><dt>Particules</dt><dd>À venir</dd></div>
|
||||
</dl>
|
||||
<SavedEffectTuningFields key={`${edition.id}-${edition.holoIntensity ?? DEFAULT_TUNING}-${edition.holoLevel ?? DEFAULT_TUNING}-${finish.id}`} catalog={catalog} effect={effect} edition={edition} disabled={busy || Boolean(editing)} onPreview={(next) => { setTuningPreview((previews) => ({ ...previews, [edition.id]: next })); setPreviewKey(edition.id); }} onSave={(next) => changeTuning(edition, next)} />
|
||||
</>}
|
||||
<span className="nebula-admin-mythic-status">
|
||||
<span className="nds-badge" data-variant="success">Tirable</span>
|
||||
|
|
@ -176,10 +199,11 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
</span>
|
||||
</div>
|
||||
<FinishFields catalog={catalog} card={card} value={draft} busy={busy} duplicated={draftDuplicated} onChange={(next) => { setDraft(next); select(DRAFT_KEY); }} />
|
||||
<EffectTuningFields catalog={catalog} effect={draftFinish && effectOfFinish(draftFinish.id)} value={draft} disabled={busy} onChange={(tuning) => { setDraft({ ...draft, ...tuning }); setPreviewKey(DRAFT_KEY); }} />
|
||||
</div>
|
||||
</div>
|
||||
</article>}
|
||||
{!draft && <button className="nds-button nebula-admin-mythic-add" data-variant="dashed" type="button" disabled={busy || Boolean(editing) || !unusedFinish} onClick={() => { setDraft({ effectPresetId: unusedFinish.effectPresetId, paletteId: unusedFinish.paletteId, formatId: unusedFinish.formatId }); select(DRAFT_KEY); }}><span aria-hidden="true">+</span>Ajouter une variation{!unusedFinish && <small>Toutes les combinaisons effet × palette existent déjà.</small>}</button>}
|
||||
{!draft && <button className="nds-button nebula-admin-mythic-add" data-variant="dashed" type="button" disabled={busy || Boolean(editing) || !unusedFinish} onClick={() => { setDraft({ effectPresetId: unusedFinish.effectPresetId, paletteId: unusedFinish.paletteId, formatId: unusedFinish.formatId, intensity: DEFAULT_TUNING, level: DEFAULT_TUNING }); select(DRAFT_KEY); }}><span aria-hidden="true">+</span>Ajouter une variation{!unusedFinish && <small>Toutes les combinaisons effet × palette existent déjà.</small>}</button>}
|
||||
</div>
|
||||
{retiredMythics.length > 0 && <div className="nds-toolbar nebula-admin-actions">
|
||||
{retiredMythics.map((edition) => <button key={edition.id} className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy || Boolean(editing)} onClick={() => save([...savedFinishIds, edition.finishIds[0]])}>Réactiver {finishOf(edition).label}</button>)}
|
||||
|
|
|
|||
10
website/src/features/cards/admin/effectTuning.js
Normal file
10
website/src/features/cards/admin/effectTuning.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Rôle : valeurs communes des paliers d'une variation mythique (intensité de la palette, palier propre à l'effet), de 1 à 5.
|
||||
export const DEFAULT_TUNING = 3;
|
||||
|
||||
// Un palier central n'est pas transmis : la carte garde son rendu de référence, sans attribut.
|
||||
export function tuningEditionFields(effect, { intensity = DEFAULT_TUNING, level = DEFAULT_TUNING } = {}) {
|
||||
return {
|
||||
...(intensity !== DEFAULT_TUNING ? { holoIntensity: intensity } : {}),
|
||||
...(effect?.level && level !== DEFAULT_TUNING ? { holoLevel: level } : {})
|
||||
};
|
||||
}
|
||||
|
|
@ -147,6 +147,10 @@ export function updateMythicFinish(editionId, finishId) {
|
|||
return request(`/admin/catalog/mythics/${encodeURIComponent(editionId)}/finish`, { method: "PUT", body: JSON.stringify({ finishId }) });
|
||||
}
|
||||
|
||||
export function updateMythicTuning(editionId, { intensity, level }) {
|
||||
return request(`/admin/catalog/mythics/${encodeURIComponent(editionId)}/tuning`, { method: "PUT", body: JSON.stringify({ intensity, level }) });
|
||||
}
|
||||
|
||||
export function updateCollectionMythicOpening(collectionId, { particleShapeId, particlePaletteId }) {
|
||||
return request(`/admin/catalog/collections/${encodeURIComponent(collectionId)}/mythic-opening`, { method: "PUT", body: JSON.stringify({ particleShapeId, particlePaletteId }) });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue