Refuse layered finishes without their files and lighten idle particle cards
The catalog now marks the prismatic parallax as a layered effect, and the service refuses to create a variation or change its finish to it when the card lacks the cutout and backdrop for that format; existing variations stay as they are. A test keeps the interface and the server in agreement for every card and finish. Particle cards no longer hold canvas pixels at rest, build their motif sprites on first use from a cache shared by all cards, and fade remaining twinkles and fireflies within half a second once the pointer leaves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6737a89a1c
commit
3b2dae0168
11 changed files with 202 additions and 27 deletions
|
|
@ -44,3 +44,15 @@ test("an unavailable effect or format explains which files are missing", () => {
|
|||
assert.equal(formatMissingHint(fullLayers, "prismatic-backdrop", "standard"), "Fichiers manquants : __cutout et __backdrop");
|
||||
assert.equal(formatMissingHint(fullLayers, "prismatic-backdrop", "full-art"), null);
|
||||
});
|
||||
|
||||
test("the interface and the server agree on which finishes a card can carry", async () => {
|
||||
const { missingFinishFiles, withGeneratedFinishes } = await import("../services/cards/catalog.js");
|
||||
const full = withGeneratedFinishes(catalog);
|
||||
assert.deepEqual(full.effectPresets.filter((preset) => preset.layers).map((preset) => preset.id), ["prismatic-backdrop"]);
|
||||
const holographic = full.finishes.filter((finish) => finish.effectPresetId);
|
||||
for (const card of full.cards) {
|
||||
for (const finish of holographic) {
|
||||
assert.equal(finishAvailable(card, finish.effectPresetId, finish.formatId), missingFinishFiles(full, card, finish.id).length === 0, `${card.id} × ${finish.id}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { readFile } from "node:fs/promises";
|
|||
import test from "node:test";
|
||||
import { flareEditionFields, flareOfEdition, MATCH_HOLO_FLARE_PALETTE, NO_FLARE, resolveFlare, sameFlare } from "../website/src/features/cards/holoFlares.js";
|
||||
import { boltGeometry, boltPath, TARGET_ZONE } from "../website/src/features/cards/holoLightning.js";
|
||||
import { motifAngle } from "../website/src/features/cards/flareSprites.js";
|
||||
import { canvasBacking, motifAngle } from "../website/src/features/cards/flareSprites.js";
|
||||
import { FIREFLY_COUNTS, fireflyFade, fireflyHeading } from "../website/src/features/cards/holoFireflies.js";
|
||||
import { TWINKLE_COUNTS, twinkleState } from "../website/src/features/cards/holoTwinkle.js";
|
||||
|
||||
|
|
@ -137,3 +137,18 @@ test("a published edition reads back as editable settings, compared by what they
|
|||
assert.ok(sameFlare({ ...NO_FLARE, id: "lightning", count: 5 }, { ...NO_FLARE, id: "lightning" }, catalog));
|
||||
assert.ok(!sameFlare({ ...NO_FLARE, id: "lightning" }, NO_FLARE, catalog));
|
||||
});
|
||||
|
||||
test("a particle canvas holds pixels only while it animates", () => {
|
||||
const canvas = { width: 300, height: 150 };
|
||||
const backing = canvasBacking(canvas);
|
||||
// Un canvas neuf rend aussitôt sa surface par défaut (300 x 150) ; un redimensionnement au repos n'en réserve pas.
|
||||
assert.deepEqual([canvas.width, canvas.height], [0, 0]);
|
||||
backing.resize(280, 240, 2);
|
||||
assert.deepEqual([canvas.width, canvas.height], [0, 0]);
|
||||
backing.attach();
|
||||
assert.deepEqual([canvas.width, canvas.height], [560, 480]);
|
||||
backing.resize(100, 50, 1.5);
|
||||
assert.deepEqual([canvas.width, canvas.height], [150, 75]);
|
||||
backing.release();
|
||||
assert.deepEqual([canvas.width, canvas.height], [0, 0]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { tmpdir } from "node:os";
|
|||
import { join } from "node:path";
|
||||
import { test } from "node:test";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { assertVersionedCatalogScope, buildPublishedCatalog, drawableRarities, publicCatalog, prepareVersionedCatalog, validateCardsCatalog, withGeneratedFinishes } from "../services/cards/catalog.js";
|
||||
import { assertVersionedCatalogScope, buildPublishedCatalog, drawableRarities, publicCatalog, prepareVersionedCatalog, validateCardsCatalog, withGeneratedFinishes, missingFinishFiles } from "../services/cards/catalog.js";
|
||||
import { INITIAL_COLLECTION_STATES, INITIAL_DROP_RATES, INITIAL_RECHARGE_SETTING, INITIAL_SHOP_SETTING } from "../services/cards/admin-seed.js";
|
||||
import { planRecycling } from "../services/cards/stardust.js";
|
||||
import { resolveMythicOpeningStyle, resolveOpeningEffect } from "../website/src/features/cards/openingEffects.js";
|
||||
|
|
@ -1295,6 +1295,29 @@ test("a mythic variation saves its particles, normalized, audited and kept acros
|
|||
database.close();
|
||||
});
|
||||
|
||||
test("a layered finish needs the card's cutout and backdrop, checked when a variation is created or changed", () => {
|
||||
const now = 1_800_000_000_000;
|
||||
const database = new CardsDatabase(":memory:");
|
||||
const service = new CardsService({ database, catalog: baseCatalog, now: () => now, random: () => 0 });
|
||||
const admin = service.upsertPlayer({ discordId: "layers-admin", displayName: "Admin", isAdmin: true });
|
||||
const cardOf = (id) => baseCatalog.cards.find((card) => card.id === id);
|
||||
assert.deepEqual(missingFinishFiles(baseCatalog, cardOf("night-of-return-dragon"), "prismatic-backdrop-solar"), ["__cutout", "__backdrop"]);
|
||||
assert.deepEqual(missingFinishFiles(baseCatalog, cardOf("night-of-return-dragon"), "full-art-prismatic-backdrop-solar"), []);
|
||||
assert.deepEqual(missingFinishFiles(baseCatalog, cardOf("night-of-return-dragon"), "spectral-prism-solar"), []);
|
||||
// La Pioche a ses calques dans les deux formats ; le Dragon de la Nuit du Retour seulement en pleine illustration.
|
||||
assert.doesNotThrow(() => service.setCardMythicConfig(admin.id, "mythic-card-pull", { finishIds: ["prismatic-backdrop-solar"] }));
|
||||
assert.throws(() => service.setCardMythicConfig(admin.id, "night-of-return-dragon", { finishIds: ["prismatic-backdrop-solar"] }), /Il manque les fichiers __cutout et __backdrop/);
|
||||
service.setCardMythicConfig(admin.id, "night-of-return-dragon", { finishIds: ["spectral-prism-solar"] });
|
||||
const dragon = service.catalog.editions.find((edition) => edition.cardId === "night-of-return-dragon" && edition.rarity === "mythic").id;
|
||||
assert.throws(() => service.setMythicFinish(admin.id, dragon, "prismatic-backdrop-cosmic"), (error) => error.code === "LAYERS_REQUIRED");
|
||||
assert.doesNotThrow(() => service.setMythicFinish(admin.id, dragon, "full-art-prismatic-backdrop-cosmic"));
|
||||
// Une variation déjà enregistrée sans ses fichiers (catalogue modifié depuis) reste enregistrable telle quelle.
|
||||
database.db.prepare("UPDATE mythic_variations SET finish_id = 'prismatic-backdrop-cosmic' WHERE edition_id = ?").run(dragon);
|
||||
const reloaded = new CardsService({ database, catalog: baseCatalog, now: () => now });
|
||||
assert.doesNotThrow(() => reloaded.setCardMythicConfig(admin.id, "night-of-return-dragon", { finishIds: ["prismatic-backdrop-cosmic", "spectral-prism-aurora"] }));
|
||||
database.close();
|
||||
});
|
||||
|
||||
test("particle animations are declared by the catalog and checked on editions", () => {
|
||||
const broken = (change) => { const catalog = structuredClone(rawCatalog); change(catalog); return () => prepareVersionedCatalog(catalog); };
|
||||
assert.throws(broken((catalog) => { catalog.flareScopes.reverse(); }), /flareScopes must start with art/);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue