Compare the subject and theme of each daily guess, let players choose their hints and find cards by related words
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 22m58s
Validate and deploy Sokko G / deploy (push) Successful in 17s

Collection and rarity hints only helped players who owned the daily card. Each guess now shows the common part of its subject and whether the theme of its name matches. A wrong guess earns one hint of the player's choice, the same list for everyone so that nothing reveals the ownership: album, rarity, collection, damaged page or name shape. Hidden words never leave the server, and the ownership is the one of the draw.

The guess list also finds a card by a related word, and the album no longer searches the description of unknown cards. Principles and data: docs/carte-du-jour.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-24 23:09:08 +01:00
parent 5a794e5220
commit 62042c4c36
24 changed files with 1081 additions and 128 deletions

View file

@ -2094,17 +2094,23 @@ test("a player finds the daily card with hints and copies the result", async ({
const database = new DatabaseSync(databasePath, { readOnly: true });
const { card_id: answerId } = database.prepare("SELECT attempt.card_id FROM daily_attempts AS attempt JOIN players ON players.id = attempt.player_id WHERE players.discord_id = 'dev-admin' ORDER BY attempt.day DESC LIMIT 1").get();
database.close();
const { answer, wrong, sameCollection } = await page.evaluate(async (answerCardId) => {
const { answer, wrong } = await page.evaluate(async (answerCardId) => {
const [config, daily] = await Promise.all(["/api/cards/config", "/api/cards/daily"].map(async (path) => (await globalThis.fetch(path)).json()));
const cards = config.catalog.cards;
const answerCard = cards.find((card) => card.id === answerCardId);
// Une carte de la même collection si elle en a d'autres (la collection de la boutique n'en compte qu'une).
const others = cards.filter((card) => card.id !== answerCard.id && daily.collectionIds.includes(card.collectionId));
const wrongCard = others.find((card) => card.collectionId === answerCard.collectionId) || others[0];
return { answer: answerCard.name, wrong: wrongCard.name, sameCollection: wrongCard.collectionId === answerCard.collectionId };
const wrongCard = cards.find((card) => card.id !== answerCard.id && card.id !== "starlit-ice-penguin" && daily.collectionIds.includes(card.collectionId));
return { answer: answerCard.name, wrong: wrongCard.name };
}, answerId);
// Aucun indice avant le premier essai raté.
const hints = page.getByRole("region", { name: "Indices", exact: true });
await expect(hints.getByRole("button")).toHaveCount(5);
await expect(hints.getByRole("button", { disabled: false })).toHaveCount(0);
const input = page.getByRole("combobox", { name: /^Votre proposition/ });
// Un mot proche trouve aussi une carte dont le nom ne le contient pas.
await input.fill("pingouin");
await expect(page.getByRole("option", { name: "Manchot des Glaces Étoilées", exact: true })).toBeVisible();
// La recherche ignore les accents et la casse.
await input.fill(wrong.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase());
// Les suggestions dépassent du panneau sans être coupées ni recouvertes.
@ -2114,11 +2120,27 @@ test("a player finds the daily card with hints and copies the result", async ({
const guesses = page.locator(".nebula-daily-guess");
await expect(guesses).toHaveCount(1);
await expect(guesses.first()).toContainText(wrong);
await expect(guesses.first()).toContainText(sameCollection ? "Même collection" : "Pas dans");
await expect(guesses.first().locator(".nebula-daily-step").first()).toBeVisible();
await expect(guesses.first().locator(".nebula-daily-theme")).toBeVisible();
// Un essai raté fait venir un morceau plus large de l'illustration.
await expect(image).not.toHaveAttribute("src", firstCrop);
await expect.poll(() => image.evaluate((element) => element.naturalWidth)).toBe(720);
await expect(page.locator(`.nebula-daily-steps li[data-result="${sameCollection ? "close" : "miss"}"]`)).toHaveCount(1);
const close = await guesses.first().evaluate((row) => Boolean(row.querySelector(".nebula-daily-theme[data-same]")) || row.querySelectorAll(".nebula-daily-step[data-same]").length > 1);
await expect(page.locator(`.nebula-daily-steps li[data-result="${close ? "close" : "miss"}"]`)).toHaveCount(1);
// Un essai raté donne un indice, au choix parmi les trois ouverts ; il se retourne sur place et referme les autres.
await expect(hints).toContainText("1 indice à retourner, au choix.");
await expect(hints.getByRole("button", { disabled: false })).toHaveCount(3);
await hints.getByRole("button", { name: /^Dans votre album/ }).click();
await expect(hints.locator('.nebula-daily-hint[data-state="open"]')).toContainText(/Oui, elle y est|Non, elle vous manque/);
await expect(hints.getByRole("button", { disabled: false })).toHaveCount(0);
await expect(guesses).toHaveCount(1);
// Une partie en cours, de l'image aux indices, tient dans un écran de 1280 × 720 sous le bandeau du site (68 px).
await expect.poll(() => page.locator(".nebula-daily-layout").evaluate((layout) => layout.getBoundingClientRect().height)).toBeLessThan(652);
await hints.evaluate((section) => section.scrollIntoView({ block: "end" }));
await expect(input).toBeInViewport();
expect(await page.evaluate(() => [...globalThis.document.querySelectorAll(".nebula-daily-row > *, .nebula-daily-hint")].filter((cell) => cell.scrollWidth > cell.clientWidth + 1).map((cell) => cell.textContent))).toEqual([]);
await page.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-playing.png") });
await input.fill(answer);
await page.getByRole("button", { name: "Proposer", exact: true }).click();
@ -2134,10 +2156,11 @@ test("a player finds the daily card with hints and copies the result", async ({
await result.getByRole("button", { name: "Copier le résultat", exact: true }).click();
await expect(result.getByRole("button", { name: "Résultat copié", exact: true })).toBeVisible();
const copied = await page.evaluate(() => globalThis.navigator.clipboard.readText());
expect(copied).toBe(`Sokko TCG · Carte du jour #1 · 2/6\n${sameCollection ? "🟨" : "⬛"}🟩\nhttp://127.0.0.1:4180/#/cards/daily`);
expect(copied).toBe(`Sokko TCG · Carte du jour #1 · 2/6 · 💡1\n${close ? "🟨" : "⬛"}🟩\nhttp://127.0.0.1:4180/#/cards/daily`);
// En demi-écran, la page passe sur une colonne sans défilement horizontal ; le menu replié nomme la Guilde, la quête étant terminée.
await page.setViewportSize({ width: 768, height: 900 });
await page.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-half.png"), fullPage: true });
await expect(selectTrigger(page, "Sections de Sokko TCG")).toHaveText("Sections de Sokko TCG : Guilde");
const overflow = await page.evaluate(() => [".nebula-dashboard-menu", ".nebula-daily"].map((selector) => {
const element = globalThis.document.querySelector(selector);