Let administrators save particles on mythic variations
Lightning, twinkles and fireflies move from a visual lab prototype to real settings. The catalog declares the animations, their motifs, sliders and zones; migration 24 stores each variation's particles; the service validates and normalizes them behind a dedicated admin route and records the change in the history. Published editions carry the particle fields, so every card of the variation shows them in collections, card sheets and openings. The Particles tab of the variation editor now saves with the same Enregistrer button as the finish and tunings, including when a variation is created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f77a0ca577
commit
6737a89a1c
21 changed files with 419 additions and 124 deletions
|
|
@ -1,10 +1,12 @@
|
|||
// Rôle : configure l'ouverture mythique d'une carte légendaire et ses variations. L'ouverture s'enregistre à chaque
|
||||
// changement ; une variation se règle dans le panneau à onglets partagé avec l'Atelier visuel et s'enregistre avec son bouton.
|
||||
// changement ; une variation (finition, paliers, particules) se règle dans le panneau à onglets partagé avec l'Atelier visuel
|
||||
// et s'enregistre avec son bouton.
|
||||
// Changer la finition d'une variation garde son identifiant : les joueurs gardent leurs exemplaires et voient la nouvelle finition.
|
||||
import { Tooltip } from "../../../components/Tooltip.jsx";
|
||||
import { useState } from "react";
|
||||
import { ConfirmModal } from "../../../components/ToolboxModals.jsx";
|
||||
import { updateCardMythic, updateMythicFinish, updateMythicTuning } from "../cardsApi.js";
|
||||
import { updateCardMythic, updateMythicFinish, updateMythicFlare, updateMythicTuning } from "../cardsApi.js";
|
||||
import { flareEditionFields, flareMotifOf, flareOfEdition, NO_FLARE, sameFlare } from "../holoFlares.js";
|
||||
import { NebulaCard } from "../NebulaCard.jsx";
|
||||
import { resolveMythicOpeningStyle, withCardOpeningSetting } from "../openingEffects.js";
|
||||
import { openingSettingFor, withoutOpeningSetting } from "./catalogSettings.js";
|
||||
|
|
@ -42,17 +44,22 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
const levelOf = (value) => (effectOf(value.effectPresetId)?.level ? value.level : DEFAULT_TUNING);
|
||||
const savedValue = (edition) => {
|
||||
const finish = finishOf(edition);
|
||||
return { formatId: finish.formatId, effectPresetId: finish.effectPresetId, paletteId: finish.paletteId, intensity: edition.holoIntensity ?? DEFAULT_TUNING, level: edition.holoLevel ?? DEFAULT_TUNING };
|
||||
return { formatId: finish.formatId, effectPresetId: finish.effectPresetId, paletteId: finish.paletteId, intensity: edition.holoIntensity ?? DEFAULT_TUNING, level: edition.holoLevel ?? DEFAULT_TUNING, flare: flareOfEdition(edition, catalog) };
|
||||
};
|
||||
const valueOf = (edition) => edits[edition.id] || savedValue(edition);
|
||||
const changesOf = (edition) => {
|
||||
const value = valueOf(edition);
|
||||
const finish = finishOfValue(value);
|
||||
const finishChanged = Boolean(finish && finish.id !== edition.finishIds[0]);
|
||||
const tuningChanged = value.intensity !== (edition.holoIntensity ?? DEFAULT_TUNING) || levelOf(value) !== (edition.holoLevel ?? DEFAULT_TUNING);
|
||||
const flareChanged = !sameFlare(value.flare, flareOfEdition(edition, catalog), catalog);
|
||||
return {
|
||||
value,
|
||||
finish,
|
||||
finishChanged: Boolean(finish && finish.id !== edition.finishIds[0]),
|
||||
tuningChanged: value.intensity !== (edition.holoIntensity ?? DEFAULT_TUNING) || levelOf(value) !== (edition.holoLevel ?? DEFAULT_TUNING),
|
||||
finishChanged,
|
||||
tuningChanged,
|
||||
flareChanged,
|
||||
dirty: finishChanged || tuningChanged || flareChanged,
|
||||
// Une finition déjà portée par une autre variation de la carte, même retirée, ne peut pas être reprise.
|
||||
duplicated: Boolean(finish && mythics.some((other) => other.id !== edition.id && other.finishIds[0] === finish.id))
|
||||
};
|
||||
|
|
@ -60,8 +67,8 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
// Aperçu d'une variation avec ses réglages en cours.
|
||||
const withValue = (edition, value) => {
|
||||
const finish = finishOfValue(value);
|
||||
const { holoIntensity: _intensity, holoLevel: _level, ...base } = edition;
|
||||
return { ...base, finishIds: finish ? [finish.id] : edition.finishIds, ...(finish ? tuningEditionFields(effectOf(value.effectPresetId), value) : {}) };
|
||||
const { holoIntensity: _intensity, holoLevel: _level, flareId: _flare, flareMotifId: _motif, flarePaletteId: _palette, flareScope: _scope, flareIntensity: _flareIntensity, flareLevel: _flareLevel, flareCount: _count, ...base } = edition;
|
||||
return { ...base, finishIds: finish ? [finish.id] : edition.finishIds, ...(finish ? tuningEditionFields(effectOf(value.effectPresetId), value) : {}), ...flareEditionFields(value.flare, catalog) };
|
||||
};
|
||||
const draftFinish = draft ? finishOfValue(draft) : null;
|
||||
const draftDuplicated = Boolean(draftFinish && savedFinishIds.includes(draftFinish.id));
|
||||
|
|
@ -74,6 +81,8 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
const select = (key) => { setPreviewKey(key); restart(); };
|
||||
const save = (finishIds, nextOpening = opening) => mutateCatalog(() => updateCardMythic(card.id, { finishIds, opening: nextOpening }));
|
||||
const forget = (editionId) => setEdits(({ [editionId]: _done, ...others }) => others);
|
||||
// Réglages envoyés au service ; une animation vide retire les particules.
|
||||
const flarePayload = (flare) => ({ id: flare.id || null, motifId: flareMotifOf(catalog.flareEffects?.find((item) => item.id === flare.id), flare.motifId), paletteId: flare.paletteId, scope: flare.scope, intensity: flare.intensity, level: flare.level, count: flare.count });
|
||||
|
||||
async function createDraft() {
|
||||
const tuning = { intensity: draft.intensity, level: levelOf(draft) };
|
||||
|
|
@ -84,15 +93,18 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
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));
|
||||
// Ses particules aussi.
|
||||
if (created && draft.flare?.id) await mutateCatalog(() => updateMythicFlare(created.id, flarePayload(draft.flare)));
|
||||
select(created?.id || null);
|
||||
}
|
||||
}
|
||||
|
||||
// Enregistre la finition puis les paliers ; les réglages en cours ne sont oubliés que si tout est passé.
|
||||
// Enregistre la finition, puis les paliers, puis les particules ; les réglages en cours ne sont oubliés que si tout est passé.
|
||||
async function applyChanges(edition) {
|
||||
const { value, finish, finishChanged, tuningChanged } = changesOf(edition);
|
||||
const { value, finish, finishChanged, tuningChanged, flareChanged } = changesOf(edition);
|
||||
if (finishChanged && !(await mutateCatalog(() => updateMythicFinish(edition.id, finish.id)))?.catalog) return;
|
||||
if (tuningChanged && !(await mutateCatalog(() => updateMythicTuning(edition.id, { intensity: value.intensity, level: levelOf(value) })))?.catalog) return;
|
||||
if (flareChanged && !(await mutateCatalog(() => updateMythicFlare(edition.id, flarePayload(value.flare))))?.catalog) return;
|
||||
forget(edition.id);
|
||||
select(edition.id);
|
||||
}
|
||||
|
|
@ -112,18 +124,18 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
}
|
||||
|
||||
function addDraft() {
|
||||
setDraft({ effectPresetId: unusedFinish.effectPresetId, paletteId: unusedFinish.paletteId, formatId: unusedFinish.formatId, intensity: DEFAULT_TUNING, level: DEFAULT_TUNING });
|
||||
setDraft({ effectPresetId: unusedFinish.effectPresetId, paletteId: unusedFinish.paletteId, formatId: unusedFinish.formatId, intensity: DEFAULT_TUNING, level: DEFAULT_TUNING, flare: NO_FLARE });
|
||||
select(DRAFT_KEY);
|
||||
}
|
||||
|
||||
const draftEdition = draft && { id: `admin-preview-${card.id}-${draftFinish?.id || "draft"}`, cardId: card.id, rarity: "mythic", finishIds: draftFinish ? [draftFinish.id] : [], promotional: false, ...(draftFinish ? tuningEditionFields(effectOf(draft.effectPresetId), draft) : {}) };
|
||||
const draftEdition = draft && { id: `admin-preview-${card.id}-${draftFinish?.id || "draft"}`, cardId: card.id, rarity: "mythic", finishIds: draftFinish ? [draftFinish.id] : [], promotional: false, ...(draftFinish ? tuningEditionFields(effectOf(draft.effectPresetId), draft) : {}), ...flareEditionFields(draft.flare, catalog) };
|
||||
const selectedMythic = previewKey === DRAFT_KEY ? null : activeMythics.find((edition) => edition.id === previewKey) || (draft ? null : activeMythics[0]);
|
||||
const previewEdition = (selectedMythic && withValue(selectedMythic, valueOf(selectedMythic))) || draftEdition
|
||||
|| { id: `admin-preview-${card.id}`, cardId: card.id, rarity: "mythic", finishIds: [lookup.holographicFinishes[0]?.id], promotional: false };
|
||||
const previewLabel = lookup.finishes.get(previewEdition.finishIds[0])?.label;
|
||||
const previewCatalog = withCardOpeningSetting(catalog, card.id, opening);
|
||||
const selected = selectedMythic && changesOf(selectedMythic);
|
||||
const selectedDirty = Boolean(selected && (selected.finishChanged || selected.tuningChanged));
|
||||
const selectedDirty = Boolean(selected?.dirty);
|
||||
|
||||
return <section className="nebula-admin-mythic-editor" aria-label={`Version mythique de ${card.name}`}>
|
||||
<section className="nebula-admin-card-opening-block" aria-labelledby={`nebula-admin-card-opening-${card.id}`}>
|
||||
|
|
@ -148,7 +160,7 @@ export function MythicEditor({ catalog, lookup, card, dashboard, mutateCatalog,
|
|||
{activeMythics.map((edition) => {
|
||||
const finish = finishOf(edition);
|
||||
const changes = changesOf(edition);
|
||||
const dirty = changes.finishChanged || changes.tuningChanged;
|
||||
const dirty = changes.dirty;
|
||||
const isSelected = selectedMythic?.id === edition.id;
|
||||
return <article key={edition.id} className="nebula-admin-mythic-variation" role="group" aria-label={finish.label} data-selected={isSelected || undefined} data-modified={dirty || undefined}>
|
||||
<NebulaCard catalog={catalog} entry={{ card, edition: withValue(edition, changes.value) }} size="sm" onSelect={() => select(edition.id)} selected={isSelected} selectLabel={`Régler ${finish.label}`} />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue