Make the broken mirror easier: wider margins, extra moves from balanced companions, hover outline on hard
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bbfb08676f
commit
734a3b6a8b
13 changed files with 82 additions and 52 deletions
|
|
@ -7,9 +7,9 @@ import { Readable } from "node:stream";
|
|||
import { test } from "node:test";
|
||||
import { createCardsApiHandler } from "../services/cards/api.js";
|
||||
import { buildPublishedCatalog, prepareVersionedCatalog } from "../services/cards/catalog.js";
|
||||
import { CardsDatabase } from "../services/cards/database.js";
|
||||
import { CardsDatabase, MIGRATIONS } from "../services/cards/database.js";
|
||||
import {
|
||||
aligned, BALANCED_HELP, cellCount, drawIllustration, HELPERS_PER_GAME, helpsOf, isSolved, minSwaps, previousMode, MAX_AMBIGUOUS_SHARE, MAX_FIXED_AT_START, mirrorCandidates, mirrorReward, MIRROR_MODES, pieceAt, placedCount, scramble, solve, swapCells, swapLimit
|
||||
aligned, BALANCED_HELP, cellCount, drawIllustration, HELPERS_PER_GAME, helpsOf, isSolved, EXTRA_MOVES, minSwaps, previousMode, MAX_AMBIGUOUS_SHARE, MAX_FIXED_AT_START, mirrorCandidates, mirrorReward, MIRROR_MODES, pieceAt, placedCells, placedCount, scramble, solve, swapCells, swapLimit
|
||||
} from "../services/cards/mirror-rules.js";
|
||||
import { loadMirrorMeasures } from "../services/cards/mirror-service.js";
|
||||
import { DEFAULT_MIRROR_SETTINGS, mirrorSettingsError, readMirrorSettings } from "../services/cards/mirror-settings.js";
|
||||
|
|
@ -204,6 +204,21 @@ test("the mirror is closed by default and only an administrator opens it", (t) =
|
|||
assert.equal(JSON.parse(db.prepare("SELECT settings_json FROM mirror_settings").get().settings_json).unknown, undefined);
|
||||
});
|
||||
|
||||
// Marges élargies le 29 novembre 2026 : des réglages restés sur les anciennes valeurs par défaut prennent les nouvelles.
|
||||
test("saved settings on the old default margins move to the wider ones, other margins stay", (t) => {
|
||||
const { database, db, mirror } = game(t);
|
||||
const version = MIGRATIONS.findIndex((migration) => typeof migration === "string" && migration.includes("'$.margins.hard', 14")) + 1;
|
||||
assert.ok(version > 0);
|
||||
const rerun = (margins) => {
|
||||
db.prepare("UPDATE mirror_settings SET settings_json = ?").run(JSON.stringify({ ...DEFAULT_MIRROR_SETTINGS, enabled: true, margins }));
|
||||
db.prepare("DELETE FROM schema_migrations WHERE version = ?").run(version);
|
||||
database.migrate();
|
||||
return mirror.settings.margins;
|
||||
};
|
||||
assert.deepEqual(rerun({ easy: 4, normal: 3, hard: 6 }), { easy: 4, normal: 6, hard: 14 });
|
||||
assert.deepEqual(rerun({ easy: 4, normal: 5, hard: 9 }), { easy: 4, normal: 5, hard: 9 });
|
||||
});
|
||||
|
||||
test("the easy picture swaps any two pieces, against the free minimum, and opens the normal one", (t) => {
|
||||
const context = game(t);
|
||||
const { mirror, player, db, service } = context;
|
||||
|
|
@ -271,7 +286,8 @@ test("the hard picture opens after the normal one and is the same for everyone",
|
|||
refuses("MIRROR_LOCKED", () => mirror.start(player.id, { day: DAY, mode: "normal" }));
|
||||
unlock(context, "hard");
|
||||
const hard = mirror.start(player.id, { day: DAY, mode: "hard" }).mirror;
|
||||
assert.deepEqual([hard.games.hard.cols, hard.games.hard.rows, hard.games.hard.placed], [5, 7, []]);
|
||||
assert.deepEqual([hard.games.hard.cols, hard.games.hard.rows, hard.games.hard.placedOnHover], [5, 7, true]);
|
||||
assert.deepEqual(hard.games.hard.placed, placedCells(stored(db, player.id, "hard").pos));
|
||||
assert.equal(hard.number, 1);
|
||||
|
||||
const other = service.upsertPlayer({ discordId: "3", displayName: "Noé", avatarUrl: "" });
|
||||
|
|
@ -322,7 +338,7 @@ test("a game without swaps left is lost and pays nothing", (t) => {
|
|||
|
||||
test("any companion of a ready daily team can help, once each, up to five per game", (t) => {
|
||||
const context = game(t, { team: true });
|
||||
const { mirror, player, db, clock, service } = context;
|
||||
const { mirror, player, db, service } = context;
|
||||
unlock(context);
|
||||
mirror.start(player.id, { day: DAY, mode: "normal" });
|
||||
assert.deepEqual(mirror.view(player.id).team, []);
|
||||
|
|
@ -373,15 +389,15 @@ test("any companion of a ready daily team can help, once each, up to five per ga
|
|||
db.prepare("UPDATE mirror_games SET state_json = ? WHERE player_id = ? AND mode = 'normal'").run(JSON.stringify(full), player.id);
|
||||
refuses("MIRROR_HELPS_EXHAUSTED", () => use(ids[2], "fortune"));
|
||||
|
||||
// Orientation : la vraie case du morceau choisi ; Équilibré : le modèle pendant 5 secondes.
|
||||
// Orientation : la vraie case du morceau choisi ; Équilibré : EXTRA_MOVES mouvements de plus.
|
||||
reset();
|
||||
withHelps([["orientation"], ["balanced"]]);
|
||||
refuses("MIRROR_INVALID", () => use(ids[0], "orientation"));
|
||||
const { pos } = stored(db, player.id, "normal");
|
||||
assert.deepEqual(use(ids[0], "orientation", 6).hint, [6, pieceAt(pos)[6]]);
|
||||
assert.ok(use(ids[1], "balanced").peekUntil > clock.now);
|
||||
assert.ok(mirror.image(player.id, "normal", { model: true }));
|
||||
clock.now += 10_000;
|
||||
const ahead = mirror.view(player.id).games.normal;
|
||||
const extra = use(ids[1], "balanced");
|
||||
assert.deepEqual([extra.limit, extra.left], [ahead.limit + EXTRA_MOVES, ahead.left + EXTRA_MOVES]);
|
||||
refuses("MIRROR_MODEL_HIDDEN", () => mirror.image(player.id, "normal", { model: true }));
|
||||
|
||||
// Fortune : le Trésor double le gain d'une image reconstituée.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue