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
|
|
@ -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>)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue