Let administrators save particles on mythic variations
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 22m41s
Validate and deploy Sokko G / deploy (push) Successful in 14s

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:
Shinuwa 2026-11-22 16:44:32 +01:00
parent f77a0ca577
commit 6737a89a1c
21 changed files with 419 additions and 124 deletions

View file

@ -11,6 +11,7 @@ const EVENT_LABELS = {
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_mythic_flare_updated: "Particules mythiques changées",
catalog_collection_opening_updated: "Effets d’ouverture modifiés",
collection_opened: "Collection ouverte aux joueurs",
collection_closed: "Collection fermée aux joueurs",
@ -59,6 +60,22 @@ function mythicTuningDetail(entry, catalog) {
return [`${card} · ${finish?.label || entry.details.editionId}`, catalog.effectIntensity && step(catalog.effectIntensity, entry.details.intensity), level && step(level, entry.details.level)].filter(Boolean).join(" · ");
}
// Particules d'une variation : animation, motif et paliers déclarés, ou leur retrait.
function mythicFlareDetail(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 flare = entry.details.flare;
const effect = catalog.flareEffects?.find((item) => item.id === flare?.id);
const settings = !flare ? ["particules retirées"] : [
effect?.label || flare.id,
effect?.motifs?.find((item) => item.id === flare.motifId)?.label,
flare.scope === "card" ? "toute la carte" : null,
...(effect?.tunings || []).map((scale) => `${scale.label.toLowerCase()} ${(scale.levels[flare[scale.key] - 1] || flare[scale.key]).toLowerCase()}`)
];
return [`${card} · ${finish?.label || entry.details.editionId}`, ...settings].filter(Boolean).join(" · ");
}
function eventDetail(entry, catalog) {
const { details, campaignName } = entry;
switch (entry.type) {
@ -71,6 +88,7 @@ function eventDetail(entry, catalog) {
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_mythic_flare_updated": return mythicFlareDetail(entry, catalog);
case "catalog_collection_opening_updated":
case "collection_opened":
case "collection_closed": return collectionName(entry, catalog);

View file

@ -71,7 +71,7 @@ function HolographicBench({ catalog, effects: allEffects, previewCard }) {
const formatId = fittingFormat(catalog, previewCard, preset.id, value.formatId);
const finish = catalog.finishes.find((item) => item.effectPresetId === preset.id && item.paletteId === value.paletteId && item.formatId === formatId)
|| catalog.finishes.find((item) => item.effectPresetId === preset.id);
return { id: `admin-effect-preview-${preset.id}`, cardId: previewCard.id, rarity: "mythic", finishIds: [finish?.id], promotional: false, ...tuningEditionFields(preset, value), ...flareEditionFields(value.flare) };
return { id: `admin-effect-preview-${preset.id}`, cardId: previewCard.id, rarity: "mythic", finishIds: [finish?.id], promotional: false, ...tuningEditionFields(preset, value), ...flareEditionFields(value.flare, catalog) };
};
return <div className="nds-card nebula-admin-lab-bench">

View file

@ -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}`} />

View file

@ -3,7 +3,7 @@
import { useState } from "react";
import { SelectDropdown } from "../../../components/SelectDropdown.jsx";
import { Tabs } from "../../../components/Tabs.jsx";
import { DEFAULT_FLARE_SCOPE, DEFAULT_FLARE_TUNING, FLARE_EFFECTS, FLARE_SCOPES, MATCH_HOLO_FLARE_LABEL, MATCH_HOLO_FLARE_PALETTE } from "../holoFlares.js";
import { DEFAULT_FLARE_SCOPE, DEFAULT_FLARE_TUNING, flareMotifOf, MATCH_HOLO_FLARE_LABEL, MATCH_HOLO_FLARE_PALETTE } from "../holoFlares.js";
import { EffectTuningFields, TuningRange } from "./EffectTuningFields.jsx";
import { variationSummary } from "./effectTuning.js";
import { effectMissingHint, fittingFormat, formatMissingHint } from "./finishAvailability.js";
@ -33,7 +33,8 @@ export function VariationCustomizer({ catalog, card, value, showEffect = true, d
return { value: item.id, label: item.label, disabled: Boolean(hint), hint };
}).toSorted(enabledFirst);
const flare = value.flare;
const flareEffect = FLARE_EFFECTS.find((item) => item.id === flare?.id);
const flareEffects = catalog.flareEffects || [];
const flareEffect = flareEffects.find((item) => item.id === flare?.id);
const changeFlare = (next) => onChange({ ...value, flare: { ...flare, ...next } });
const changeEffect = (effectPresetId) => onChange({ ...value, effectPresetId, formatId: fittingFormat(catalog, card, effectPresetId, value.formatId) });
return <div className="nebula-admin-customizer">
@ -48,10 +49,10 @@ export function VariationCustomizer({ catalog, card, value, showEffect = true, d
<EffectTuningFields catalog={catalog} effect={effect} value={value} disabled={disabled} onChange={(tuning) => onChange({ ...value, ...tuning })} />
</> : flare ? <>
<div className="nebula-admin-customizer-choices">
<SelectDropdown className="nebula-admin-inline-field" label="Animation" size="sm" value={flare.id} disabled={disabled} options={[{ value: "", label: "Aucune" }, ...FLARE_EFFECTS.map((item) => ({ value: item.id, label: item.label }))]} onChange={(id) => changeFlare({ id })} />
{flareEffect?.motifs && <SelectDropdown className="nebula-admin-inline-field" label="Motif" size="sm" value={flareEffect.motifs.some((item) => item.id === flare.motifId) ? flare.motifId : flareEffect.motifs[0].id} disabled={disabled} options={flareEffect.motifs.map((item) => ({ value: item.id, label: item.label }))} onChange={(motifId) => changeFlare({ motifId })} />}
<SelectDropdown className="nebula-admin-inline-field" label="Animation" size="sm" value={flare.id} disabled={disabled} options={[{ value: "", label: "Aucune" }, ...flareEffects.map((item) => ({ value: item.id, label: item.label }))]} onChange={(id) => changeFlare({ id })} />
{flareEffect?.motifs && <SelectDropdown className="nebula-admin-inline-field" label="Motif" size="sm" value={flareMotifOf(flareEffect, flare.motifId)} disabled={disabled} options={flareEffect.motifs.map((item) => ({ value: item.id, label: item.label }))} onChange={(motifId) => changeFlare({ motifId })} />}
{flareEffect && <SwatchDropdown className="nebula-admin-inline-field" label="Palette" accessibleLabel="Palette des particules" value={flare.paletteId} options={[{ id: MATCH_HOLO_FLARE_PALETTE, label: MATCH_HOLO_FLARE_LABEL }, ...catalog.effectPalettes]} disabled={disabled} onChange={(paletteId) => changeFlare({ paletteId })} />}
{flareEffect && <SelectDropdown className="nebula-admin-inline-field" label="Zone" size="sm" value={flare.scope || DEFAULT_FLARE_SCOPE} disabled={disabled} options={FLARE_SCOPES.map((item) => ({ value: item.id, label: item.label }))} onChange={(scope) => changeFlare({ scope })} />}
{flareEffect && <SelectDropdown className="nebula-admin-inline-field" label="Zone" size="sm" value={flare.scope || DEFAULT_FLARE_SCOPE} disabled={disabled} options={(catalog.flareScopes || []).map((item) => ({ value: item.id, label: item.label }))} onChange={(scope) => changeFlare({ scope })} />}
</div>
{flareEffect && <div className="nebula-admin-tuning">
{flareEffect.tunings.map((scale) => <TuningRange key={scale.key} scale={scale} value={flare[scale.key] || DEFAULT_FLARE_TUNING} disabled={disabled} onChange={(next) => changeFlare({ [scale.key]: next })} />)}

View file

@ -1,7 +1,5 @@
// Rôle : valeurs communes des paliers d'une variation mythique (intensité de la palette, palier propre à l'effet), de 1 à 5,
// et résumé d'une ligne de ses réglages.
import { FLARE_EFFECTS } from "../holoFlares.js";
export const DEFAULT_TUNING = 3;
// Un palier central n'est pas transmis : la carte garde son rendu de référence, sans attribut.
@ -26,6 +24,6 @@ export function variationSummary(catalog, card, value) {
card.fullImage && format?.label,
`${catalog.effectIntensity.label} ${lower(intensity)}`,
effect?.level && `${effect.level.label} ${lower(effect.level.levels[(value.level ?? DEFAULT_TUNING) - 1])}`,
`Particules : ${lower(FLARE_EFFECTS.find((item) => item.id === value.flare?.id)?.label) || "aucune"}`
`Particules : ${lower(catalog.flareEffects?.find((item) => item.id === value.flare?.id)?.label) || "aucune"}`
].filter(Boolean).join(" · ");
}