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

@ -20,6 +20,9 @@ export function guildQuests(state, now = Date.now()) {
if (team && (team.enabled || team.status === "recruiting")) quests.push({ id: "team", pending: team.status !== "ready", summary: team });
// La Course attend une équipe et sa propre ouverture ; une course commencée se termine même si elle ferme.
if (team && ((team.raceEnabled && team.status === "ready") || team.race === "running")) quests.push({ id: "race", pending: team.race !== "finished", summary: team });
// Le Miroir brisé n'apparaît que s'il est ouvert, ou tant qu'une partie du jour n'est pas terminée.
const mirror = state.mirror;
if (mirror && (mirror.enabled || mirror.normal === "playing" || mirror.hard === "playing")) quests.push({ id: "mirror", pending: !mirrorDone(mirror), summary: mirror });
const expeditions = state.expeditions;
if (expeditions && (expeditions.enabled || expeditions.running || expeditions.returned || expeditions.forming)) quests.push({ id: "expeditions", pending: expeditionsPending(expeditions, now), summary: expeditions });
return quests;
@ -27,22 +30,28 @@ export function guildQuests(state, now = Date.now()) {
export const pendingQuestCount = (state) => guildQuests(state).filter((quest) => quest.pending).length;
// Miroir brisé terminé : le Normal puis le Difficile joués jusqu'au bout, gagnés ou non.
const finishedGame = (status) => status === "won" || status === "lost";
export const mirrorDone = (mirror) => finishedGame(mirror.normal) && finishedGame(mirror.hard);
// Quête quotidienne terminée aujourd'hui.
export function questDone({ id, summary }) {
if (id === "daily") return summary.status !== "playing" && !summary.rewardPending;
if (id === "race") return summary.race === "finished";
if (id === "mirror") return mirrorDone(summary);
return false;
}
// Ce que dit la Guilde au comptoir : la prochaine chose à faire, dans l'ordre du jour, puis le butin d'une expédition revenue.
export function guildGreeting(state, now = Date.now()) {
const { daily, team, expeditions } = state;
const { daily, team, mirror, expeditions } = state;
const teamOpen = Boolean(team?.enabled);
if (daily?.rewardPending) return "reward";
if (daily?.status === "playing") return teamOpen && team.status !== "ready" ? "dailyFirst" : "daily";
if (teamOpen && team.status === "recruiting") return "recruiting";
if (teamOpen && team.status !== "ready") return "recruit";
if (teamOpen && team.raceEnabled && team.race !== "finished") return "race";
if (mirror?.enabled && !mirrorDone(mirror)) return "mirror";
if (expeditions && (expeditions.returned > 0 || (expeditions.nextReturnAt != null && expeditions.nextReturnAt <= now))) return "loot";
return "done";
}