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:
parent
5210503922
commit
9cf48ea0d0
36 changed files with 3124 additions and 20 deletions
|
|
@ -4,6 +4,7 @@ import { join, resolve } from "node:path";
|
|||
import { CardsDatabase } from "./database.js";
|
||||
import { loadCardsCatalog, publicCatalog } from "./catalog.js";
|
||||
import { createDailyImageRenderer } from "./daily-image.js";
|
||||
import { createMirrorImageRenderer } from "./mirror-image.js";
|
||||
import { DEFAULT_DESTINATIONS_PATH, loadExpeditionDestinations } from "./expedition-content.js";
|
||||
import { createDiscordAlertSender, dispatchAlerts } from "./discord-alerts.js";
|
||||
import { CardsService, DEV_DISCORD_ID } from "./service.js";
|
||||
|
|
@ -143,6 +144,7 @@ export function createCardsApiHandler({
|
|||
service = new CardsService({ database, catalog, now, random, devPerks, destinations, alerts: { available: Boolean(alertSender), publicOrigin: env.CARDS_PUBLIC_ORIGIN || null } });
|
||||
}
|
||||
const renderDailyImage = createDailyImageRenderer(join(projectRoot, "website", "public"));
|
||||
const renderMirrorImage = createMirrorImageRenderer(join(projectRoot, "website", "public"));
|
||||
const secureCookies = env.NODE_ENV === "production" || String(env.CARDS_PUBLIC_ORIGIN || "").startsWith("https://");
|
||||
const adminIds = new Set(String(env.CARDS_ADMIN_DISCORD_IDS || "").split(",").map((item) => item.trim()).filter(Boolean));
|
||||
service?.syncAdmins(adminIds, { keepDevAdmin: devAuth });
|
||||
|
|
@ -395,6 +397,50 @@ export function createCardsApiHandler({
|
|||
json(res, 200, service.team.updateSettings(session.player.id, (await readBody(req)).settings));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "GET" && url.pathname === "/api/cards/mirror") {
|
||||
json(res, 200, { mirror: service.mirror.view(session.player.id) });
|
||||
return true;
|
||||
}
|
||||
// Image mélangée de la partie, dans l'état où elle est (ou en ordre avec `model=1`) ; `v` (nombre de coups) évite seulement de relire une ancienne image.
|
||||
if (req.method === "GET" && url.pathname === "/api/cards/mirror/image") {
|
||||
rateLimit(req, "mirror-image", 60);
|
||||
const image = await renderMirrorImage(service.mirror.image(session.player.id, url.searchParams.get("mode"), { model: url.searchParams.get("model") === "1" }));
|
||||
res.writeHead(200, { "Content-Type": "image/webp", "Content-Length": image.length, "Cache-Control": "private, no-store", "X-Content-Type-Options": "nosniff" });
|
||||
res.end(image);
|
||||
return true;
|
||||
}
|
||||
if (req.method === "POST" && url.pathname === "/api/cards/mirror/start") {
|
||||
rateLimit(req, "mirror-start", 30);
|
||||
const body = await readBody(req);
|
||||
json(res, 200, service.mirror.start(session.player.id, { day: body.day, mode: body.mode }));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "POST" && url.pathname === "/api/cards/mirror/swap") {
|
||||
rateLimit(req, "mirror-swap", 240);
|
||||
const body = await readBody(req);
|
||||
json(res, 200, service.mirror.swap(session.player.id, { day: body.day, mode: body.mode, from: body.from, to: body.to, moves: body.moves }));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "POST" && url.pathname === "/api/cards/mirror/helpers") {
|
||||
rateLimit(req, "mirror-helpers", 60);
|
||||
const body = await readBody(req);
|
||||
json(res, 200, service.mirror.chooseHelpers(session.player.id, { day: body.day, mode: body.mode, cardIds: body.cardIds }));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "POST" && url.pathname === "/api/cards/mirror/help") {
|
||||
rateLimit(req, "mirror-help", 60);
|
||||
const body = await readBody(req);
|
||||
json(res, 200, service.mirror.useHelp(session.player.id, { day: body.day, mode: body.mode, cardId: body.cardId, help: body.help, moves: body.moves }));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "POST" && url.pathname === "/api/cards/mirror/reset") {
|
||||
json(res, 200, service.mirror.resetForTests(session.player.id));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "PUT" && url.pathname === "/api/cards/admin/mirror/settings") {
|
||||
json(res, 200, service.mirror.updateSettings(session.player.id, (await readBody(req)).settings));
|
||||
return true;
|
||||
}
|
||||
if (req.method === "GET" && url.pathname === "/api/cards/expeditions") {
|
||||
json(res, 200, service.expeditions.getExpeditions(session.player.id));
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue