Add the Broken Mirror puzzle to the Guild

A daily puzzle: a card illustration cut into pieces, rebuilt by swapping
two pieces of the same row or column within a limited number of swaps.
The normal picture is a square card in 4 x 4, drawn for each player, with
placed pieces outlined in green; the hard one is a 5 x 7 portrait shared
by everyone each day, with a result to copy. The limit is the computer's
best result (beam search) plus a margin, and every swap left adds
stardust. Two companions of the daily team can each give one help, by
specialty; a double specialty picks one when used.

The server keeps the piece positions, sends the picture already shuffled
and checks every swap. Uniform illustrations are left out, from measures
written by scripts/mirror-illustrations.mjs. The Guild gets its quest and
a Codex tile, the administration a tab (opening, rewards, margins, the
day's summary), and migration 30 its tables. New collections must plan at
least one double-specialty character, counted by
scripts/team-specialties.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-28 13:38:46 +01:00
parent 5210503922
commit 9cf48ea0d0
36 changed files with 3124 additions and 20 deletions

View file

@ -564,6 +564,37 @@ export const MIGRATIONS = [
) STRICT;
ALTER TABLE daily_attempts ADD COLUMN reward_offer_json TEXT CHECK (reward_offer_json IS NULL OR json_valid(reward_offer_json));
ALTER TABLE daily_attempts ADD COLUMN reward_choice TEXT CHECK (reward_choice IS NULL OR reward_choice IN ('pending', 'stardust', 'star'));
`,
// Miroir brisé : ses réglages, l'illustration et le mélange du Difficile (les mêmes pour tous un jour donné), et les parties des
// joueurs (une par mode et par jour), avec leur état complet : le client ne reçoit jamais la solution.
`
CREATE TABLE mirror_settings (
id INTEGER PRIMARY KEY CHECK (id = 1),
settings_json TEXT NOT NULL CHECK (json_valid(settings_json)),
updated_at INTEGER NOT NULL,
updated_by TEXT REFERENCES players(id)
) STRICT;
INSERT INTO mirror_settings(id, settings_json, updated_at, updated_by) VALUES (1, '{}', 0, NULL);
CREATE TABLE mirror_days (
day TEXT PRIMARY KEY,
card_id TEXT NOT NULL,
start_json TEXT NOT NULL CHECK (json_valid(start_json)),
par INTEGER NOT NULL CHECK (par >= 0),
created_at INTEGER NOT NULL
) STRICT;
CREATE TABLE mirror_games (
player_id TEXT NOT NULL REFERENCES players(id) ON DELETE CASCADE,
day TEXT NOT NULL,
mode TEXT NOT NULL CHECK (mode IN ('normal', 'hard')),
card_id TEXT NOT NULL,
status TEXT NOT NULL CHECK (status IN ('playing', 'won', 'lost')),
state_json TEXT NOT NULL CHECK (json_valid(state_json)),
reward INTEGER NOT NULL DEFAULT 0 CHECK (reward >= 0),
started_at INTEGER NOT NULL,
finished_at INTEGER,
PRIMARY KEY (player_id, day, mode)
) STRICT;
CREATE INDEX mirror_games_day ON mirror_games(day, mode);
`
];