Replace the rarity hint of the daily card with the theme of its name
The rarity alone left 71 cards out of 246 and only helped to filter the album; the theme leaves 15 and helps every player. It opens after three wrong guesses and is no longer offered once a guess has found it. Games that had flipped the rarity get their hint back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ac6ae7df62
commit
d5c2900eed
10 changed files with 89 additions and 31 deletions
|
|
@ -467,3 +467,4 @@
|
|||
{"id":"int-cd5e6c35cc6ec29ddb910b5e12e1cfe2","kind":"field_change","created_at":"2026-11-24T12:17:42.366711079Z","actor":"Shinuwa","issue_id":"sokko-g-dtrz","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"13 communes corrigées, 4 pouvoirs de collection et Adaptation du Cortège, pouvoirs expliqués dans l'interface ; check et e2e cartes verts"}}
|
||||
{"id":"int-5aaf018ecb831aae1f611786a3de9c70","kind":"field_change","created_at":"2026-11-24T14:37:43.987814761Z","actor":"Shinuwa","issue_id":"sokko-g-94pl","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Mythique prismatique, tokens de rareté centralisés, symboles dans l'historique ; check et e2e cartes verts"}}
|
||||
{"id":"int-03398e7ce6431c7affd16e514918aa37","kind":"field_change","created_at":"2026-11-24T21:54:50.806535658Z","actor":"Shinuwa","issue_id":"sokko-g-uv2n","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Sujet, thème, indices au choix et recherche par mots proches en place ; check, E2E, production, assets et E2E cartes verts"}}
|
||||
{"id":"int-a8de03cbd694d8b55d196658cfd983e8","kind":"field_change","created_at":"2026-11-24T22:48:44.872754074Z","actor":"Shinuwa","issue_id":"sokko-g-z30j","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Thème du nom à la place de la rareté, dès 3 essais ratés ; check et E2E cartes verts"}}
|
||||
|
|
|
|||
|
|
@ -107,13 +107,13 @@ Carte du jour (migrations 7, 18 et 26, règles pures dans `services/cards/daily.
|
|||
proposées dans l'ordre ; `status` vaut `playing`, `won` ou `lost` (6 essais au plus) ;
|
||||
`reward` est la poussière créditée par la victoire. La migration 18 a gardé les parties
|
||||
passées avec la carte commune de leur jour. `hints_json` liste les indices retournés, dans l'ordre ;
|
||||
`owned` dit si le joueur possédait la carte au tirage (NULL avant la migration 26 : lu dans la collection).
|
||||
`owned` dit si le joueur possédait la carte au tirage (NULL avant la migration 26 : lu dans la collection). La migration 27 a retiré l'ancien indice `rarity` des parties.
|
||||
- `services/cards/content/daily-clues.json` : arbre des sujets (`subjects`, l'identifiant d'une étape
|
||||
contient celui de la précédente), thèmes et leurs mots, sujets en plusieurs mots, puis le sujet et les mots de
|
||||
recherche de chaque carte. Une carte absente reste jouable, sans comparaison ; un test exige qu'il n'y en ait pas.
|
||||
- `GET /api/cards/daily` : partie du jour, comparaison de chaque essai (`subject.common`, les étapes
|
||||
communes ; `subject.different`, la première qui diffère ; `theme`), indices retournés (`hints`), indices
|
||||
disponibles (`hintChoices`, `hintCredits`), zoom, série de victoires, collections dont les
|
||||
disponibles (`hintChoices`, dont `known` pour un thème déjà trouvé ; `hintCredits`), zoom, série de victoires, collections dont les
|
||||
cartes peuvent être proposées et mots de recherche de ces cartes (`searchWords`). `answerCardId` n'est renvoyé qu'une fois la partie terminée, et
|
||||
le point zoomé jamais.
|
||||
- `GET /api/cards/daily/image` : l'illustration du joueur, sous cette adresse fixe
|
||||
|
|
@ -126,8 +126,8 @@ Carte du jour (migrations 7, 18 et 26, règles pures dans `services/cards/daily.
|
|||
sinon. Une victoire crédite `daily_reward` et inscrit `daily_won` (numéro, carte, essais,
|
||||
poussière) dans l'historique du joueur. Chaque essai renvoie aussi l'état complet, dont le
|
||||
résumé `daily` (statut, essais, série) qui alimente le bandeau et la page de la Guilde des Veilleurs.
|
||||
- `POST /api/cards/daily/hints` (`{ day, hint }`) : retourne un indice (`album`, `rarity`, `collection`,
|
||||
`page`, `shape`), un par essai raté, sans coûter d'essai. `DAILY_HINT_INVALID`, `DAILY_HINT_LOCKED`, `DAILY_EXPIRED` ou
|
||||
- `POST /api/cards/daily/hints` (`{ day, hint }`) : retourne un indice (`album`, `collection`, `page`,
|
||||
`theme`, `shape`), un par essai raté, sans coûter d'essai. `DAILY_HINT_INVALID`, `DAILY_HINT_LOCKED`, `DAILY_EXPIRED` ou
|
||||
`DAILY_FINISHED` sinon ; un indice déjà retourné est renvoyé tel quel. Les mots cachés de la page et du nom ne sont jamais envoyés.
|
||||
|
||||
Expéditions (migration 8, règles pures dans `services/cards/expedition-rules.js`, service dans
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Décidé avec le propriétaire du jeu le 24 novembre 2026. Le format des donnée
|
|||
|
||||
## Trois joueurs à servir
|
||||
|
||||
1. Celui qui possède la carte et fouille son album : la rareté et la collection l'aident, grâce aux filtres.
|
||||
1. Celui qui possède la carte et fouille son album : la collection l'aide, grâce aux filtres.
|
||||
2. Celui qui ne l'a pas : il doit trouver le **nom**, avec l'image et la liste des propositions.
|
||||
3. Celui qui joue sans regarder son album.
|
||||
|
||||
|
|
@ -18,8 +18,9 @@ Tous reçoivent les mêmes comparaisons et peuvent retourner les mêmes indices,
|
|||
|
||||
| Indice au choix | Dès |
|
||||
|---|---|
|
||||
| Dans votre album ?, Rareté, Collection | 1 essai raté |
|
||||
| Dans votre album ?, Collection | 1 essai raté |
|
||||
| Page abîmée (première phrase de la description, sans les mots du nom) | 2 essais ratés |
|
||||
| Thème du nom, sauf si un essai l'a déjà trouvé | 3 essais ratés |
|
||||
| Forme du nom (petits mots seuls, sans la longueur des autres) | 4 essais ratés |
|
||||
|
||||
## Les données
|
||||
|
|
@ -63,4 +64,5 @@ Au 24 novembre 2026, le sujet seul laisse 7,6 cartes en moyenne sur 246, le suje
|
|||
- Étiquettes d'Expédition comme indices : elles ne sont pas faites pour deviner un nom.
|
||||
- Pour les mammifères : régime alimentaire (invisible et discutable), déplacement (il faut connaître notre choix), habitat (les décors du jeu trompent), taille (tout est petit).
|
||||
- Longueur ou première lettre des mots dans la forme du nom : avec la liste des propositions, presque la réponse.
|
||||
- Rareté comme indice : seule, elle laisse 71 cartes en moyenne (15 pour le thème, 52 pour la collection), ne dit rien du nom et n'aide qu'à filtrer l'album.
|
||||
- Baisse de la récompense quand on retourne un indice.
|
||||
|
|
|
|||
|
|
@ -2128,9 +2128,9 @@ test("a player finds the daily card with hints and copies the result", async ({
|
|||
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.
|
||||
// Un essai raté donne un indice, au choix parmi les deux 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 expect(hints.getByRole("button", { disabled: false })).toHaveCount(2);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ import { fileURLToPath } from "node:url";
|
|||
|
||||
export const DEFAULT_DAILY_CLUES_PATH = fileURLToPath(new URL("./content/daily-clues.json", import.meta.url));
|
||||
|
||||
// Indices facultatifs et nombre d'essais ratés à partir duquel chacun s'ouvre. La forme du nom, avec le sujet, ne laisse presque
|
||||
// qu'une carte : elle attend le quatrième.
|
||||
// Indices facultatifs et nombre d'essais ratés à partir duquel chacun s'ouvre. Le thème, puis la forme du nom, ne laissent presque
|
||||
// qu'une carte à qui connaît le sujet : ils attendent le troisième et le quatrième.
|
||||
export const DAILY_HINTS = Object.freeze([
|
||||
Object.freeze({ id: "album", after: 1 }),
|
||||
Object.freeze({ id: "rarity", after: 1 }),
|
||||
Object.freeze({ id: "collection", after: 1 }),
|
||||
Object.freeze({ id: "page", after: 2 }),
|
||||
Object.freeze({ id: "theme", after: 3 }),
|
||||
Object.freeze({ id: "shape", after: 4 })
|
||||
]);
|
||||
|
||||
|
|
@ -175,7 +175,8 @@ export function dailyHintCredits(wrongCount, usedCount) {
|
|||
return Math.max(0, Math.min(wrongCount, DAILY_HINTS.length) - usedCount);
|
||||
}
|
||||
|
||||
export function canUseDailyHint(hintId, wrongCount, used) {
|
||||
// `known` : indices qui n'apprendraient rien au joueur (un thème qu'un essai a déjà trouvé).
|
||||
export function canUseDailyHint(hintId, wrongCount, used, known = []) {
|
||||
const hint = DAILY_HINTS.find((item) => item.id === hintId);
|
||||
return Boolean(hint) && !used.includes(hintId) && wrongCount >= hint.after && dailyHintCredits(wrongCount, used.length) > 0;
|
||||
return Boolean(hint) && !known.includes(hintId) && !used.includes(hintId) && wrongCount >= hint.after && dailyHintCredits(wrongCount, used.length) > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -517,6 +517,11 @@ export const MIGRATIONS = [
|
|||
`
|
||||
ALTER TABLE daily_attempts ADD COLUMN hints_json TEXT NOT NULL DEFAULT '[]' CHECK (json_valid(hints_json));
|
||||
ALTER TABLE daily_attempts ADD COLUMN owned INTEGER CHECK (owned IS NULL OR owned IN (0, 1));
|
||||
`,
|
||||
// L'indice « Rareté » laisse la place au thème du nom : il est retiré des parties qui l'avaient retourné, ce qui rend leur indice.
|
||||
`
|
||||
UPDATE daily_attempts SET hints_json = (SELECT json_group_array(hint.value) FROM json_each(daily_attempts.hints_json) AS hint WHERE hint.value <> 'rarity')
|
||||
WHERE EXISTS (SELECT 1 FROM json_each(daily_attempts.hints_json) AS hint WHERE hint.value = 'rarity');
|
||||
`
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|||
import { normalizeReward } from "./rewards.js";
|
||||
import { MASS_RECYCLE_RARITIES, planRecycling, spareQuantity, validateShopSetting } from "./stardust.js";
|
||||
import { DEFAULT_EFFECT_TUNING, DEFAULT_FLARE_SCOPE, FULL_ART_FORMAT, isEffectTuning, missingFinishFiles, normalizeFlare, buildPublishedCatalog, collectionDrawableEditions, createCatalogIndex, holographicFinishIds, isMythicEditionIdOf, legendaryParentEdition, MATCH_HOLO_PALETTE_ID, mythicEditionId, publicCatalog, validateRarityWeights } from "./catalog.js";
|
||||
import { cardRarity, computeStreak, DAILY_REPEAT_WINDOW_DAYS, dailyCandidates, dailyDayKey, dailyZoom, drawDailyPuzzle, isDayKey, MAX_DAILY_GUESSES, nextDailyAt, shiftDayKey } from "./daily.js";
|
||||
import { computeStreak, DAILY_REPEAT_WINDOW_DAYS, dailyCandidates, dailyDayKey, dailyZoom, drawDailyPuzzle, isDayKey, MAX_DAILY_GUESSES, nextDailyAt, shiftDayKey } from "./daily.js";
|
||||
import { canUseDailyHint, compareClues, DAILY_HINTS, dailyHintCredits, damagedPage, loadDailyClues, nameShape } from "./daily-clues.js";
|
||||
import { calculateRecharge, pinnedRecharge, drawPack, drawShopPack, MAX_RECHARGE_INTERVAL_MS, MAX_RESERVE_OPENINGS, MIN_RECHARGE_INTERVAL_MS, spendOpening } from "./game-rules.js";
|
||||
import { DEFAULT_DESTINATIONS_PATH, loadExpeditionDestinations } from "./expedition-content.js";
|
||||
|
|
@ -964,14 +964,22 @@ export class CardsService {
|
|||
dailyHintValue(puzzle, id) {
|
||||
const card = this.index.cards.get(puzzle.cardId);
|
||||
if (id === "album") return puzzle.owned;
|
||||
if (id === "rarity") return cardRarity(this.catalog, card.id);
|
||||
if (id === "collection") return card.collectionId;
|
||||
if (id === "theme") return this.dailyClues.themeLabels.get(this.dailyClues.themeOf(card.name)) ?? null;
|
||||
return id === "page" ? damagedPage(card) : nameShape(card.name);
|
||||
}
|
||||
|
||||
// Le thème n'est plus un indice dès qu'un essai l'a trouvé.
|
||||
dailyKnownHints(puzzle) {
|
||||
const themeOf = (cardId) => this.dailyClues.themeOf(this.index.cards.get(cardId)?.name ?? "");
|
||||
const theme = themeOf(puzzle.cardId);
|
||||
return !theme || puzzle.guesses.some((cardId) => themeOf(cardId) === theme) ? ["theme"] : [];
|
||||
}
|
||||
|
||||
dailyHintChoices(puzzle) {
|
||||
const wrong = this.dailyWrongCount(puzzle);
|
||||
return DAILY_HINTS.map(({ id, after }) => ({ id, after, available: puzzle.status === "playing" && canUseDailyHint(id, wrong, puzzle.hints) }));
|
||||
const known = this.dailyKnownHints(puzzle);
|
||||
return DAILY_HINTS.map(({ id, after }) => ({ id, after, known: known.includes(id), available: puzzle.status === "playing" && canUseDailyHint(id, wrong, puzzle.hints, known) }));
|
||||
}
|
||||
|
||||
// Mots qui font aussi trouver une carte dans la liste des propositions (« pingouin » pour un manchot).
|
||||
|
|
@ -983,6 +991,7 @@ export class CardsService {
|
|||
// La réponse n'est envoyée qu'une fois la partie terminée, et l'illustration n'arrive que recadrée (voir dailyImage).
|
||||
dailyView(playerId, puzzle) {
|
||||
const finished = puzzle.status !== "playing";
|
||||
const hintChoices = this.dailyHintChoices(puzzle);
|
||||
return {
|
||||
day: puzzle.day,
|
||||
number: puzzle.number,
|
||||
|
|
@ -991,8 +1000,9 @@ export class CardsService {
|
|||
status: puzzle.status,
|
||||
guesses: puzzle.guesses.map((cardId) => this.dailyGuessView(puzzle, cardId)),
|
||||
hints: puzzle.hints.map((id) => ({ id, value: this.dailyHintValue(puzzle, id) })),
|
||||
hintChoices: this.dailyHintChoices(puzzle),
|
||||
hintCredits: finished ? 0 : dailyHintCredits(this.dailyWrongCount(puzzle), puzzle.hints.length),
|
||||
hintChoices,
|
||||
// Jamais plus que d'indices à retourner : un thème déjà trouvé laisse un crédit sans emploi.
|
||||
hintCredits: Math.min(dailyHintCredits(this.dailyWrongCount(puzzle), puzzle.hints.length), hintChoices.filter((choice) => choice.available).length),
|
||||
collectionIds: this.dailyCollectionIds(playerId, puzzle.cardId),
|
||||
reward: this.shopSetting.dailyReward,
|
||||
earned: puzzle.earned,
|
||||
|
|
@ -1054,7 +1064,7 @@ export class CardsService {
|
|||
if (puzzle.status !== "playing") fail(409, "DAILY_FINISHED", "Vous avez déjà terminé la Carte du jour.");
|
||||
// Retourner deux fois le même indice (double clic, deux onglets) ne coûte rien.
|
||||
if (puzzle.hints.includes(hint)) return this.dailyView(playerId, puzzle);
|
||||
if (!canUseDailyHint(hint, this.dailyWrongCount(puzzle), puzzle.hints)) fail(409, "DAILY_HINT_LOCKED", "Cet indice n’est pas encore disponible.");
|
||||
if (!canUseDailyHint(hint, this.dailyWrongCount(puzzle), puzzle.hints, this.dailyKnownHints(puzzle))) fail(409, "DAILY_HINT_LOCKED", "Cet indice n’est pas encore disponible.");
|
||||
const hints = [...puzzle.hints, hint];
|
||||
this.db.prepare("UPDATE daily_attempts SET hints_json = ?, updated_at = ? WHERE player_id = ? AND day = ?").run(JSON.stringify(hints), this.now(), playerId, today);
|
||||
return this.dailyView(playerId, { ...puzzle, hints });
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import { CardsService } from "../services/cards/service.js";
|
|||
const baseCatalog = prepareVersionedCatalog(JSON.parse(await readFile("website/public/data/cards/catalog.json", "utf8")));
|
||||
const ACTIVE_STATES = [{ collectionId: "primordial-nebula", active: true }, { collectionId: "dream-arcade", active: false }];
|
||||
const catalog = buildPublishedCatalog(baseCatalog, { variations: [], collectionStates: ACTIVE_STATES, dropRates: [{ collectionId: "primordial-nebula", rarityWeights: { common: 64, rare: 24, epic: 8, legendary: 3, mythic: 1 } }] });
|
||||
const standardRarity = (cardId) => catalog.editions.find((edition) => edition.cardId === cardId && edition.rarity !== "mythic" && !edition.promotional).rarity;
|
||||
|
||||
test("the daily day changes at midnight in Paris, in winter and in summer", () => {
|
||||
assert.equal(dailyDayKey(Date.parse("2026-11-13T22:59:59Z")), "2026-11-13");
|
||||
|
|
@ -118,7 +117,12 @@ test("a wrong daily guess earns one hint of the player's choice", () => {
|
|||
assert.equal(canUseDailyHint("album", 0, []), false);
|
||||
assert.equal(canUseDailyHint("album", 1, []), true);
|
||||
assert.equal(canUseDailyHint("album", 2, ["album"]), false);
|
||||
assert.equal(canUseDailyHint("rarity", 1, ["album"]), false);
|
||||
assert.equal(canUseDailyHint("collection", 1, ["album"]), false);
|
||||
assert.equal(canUseDailyHint("theme", 2, []), false);
|
||||
assert.equal(canUseDailyHint("theme", 3, []), true);
|
||||
// Un thème déjà trouvé par un essai n'est plus un indice.
|
||||
assert.equal(canUseDailyHint("theme", 3, [], ["theme"]), false);
|
||||
assert.equal(canUseDailyHint("rarity", 6, []), false);
|
||||
assert.equal(canUseDailyHint("page", 1, []), false);
|
||||
assert.equal(canUseDailyHint("shape", 3, []), false);
|
||||
assert.equal(canUseDailyHint("shape", 4, ["album"]), true);
|
||||
|
|
@ -225,7 +229,7 @@ test("a player flips the daily hints in the order of their choice, for free", ()
|
|||
assert.throws(() => flip("album"), (error) => error.code === "DAILY_HINT_LOCKED");
|
||||
assert.throws(() => flip("answer"), (error) => error.code === "DAILY_HINT_INVALID");
|
||||
assert.throws(() => service.useDailyHint(player.id, { day: "demain", hint: "album" }), (error) => error.code === "DAILY_HINT_INVALID");
|
||||
assert.deepEqual(service.guessDaily(player.id, { day, cardId: others[0] }).daily.hintChoices.filter((choice) => choice.available).map((choice) => choice.id), ["album", "rarity", "collection"]);
|
||||
assert.deepEqual(service.guessDaily(player.id, { day, cardId: others[0] }).daily.hintChoices.filter((choice) => choice.available).map((choice) => choice.id), ["album", "collection"]);
|
||||
assert.throws(() => flip("page"), (error) => error.code === "DAILY_HINT_LOCKED");
|
||||
// La possession est celle du tirage : une carte reçue pendant la partie ne change pas l'indice.
|
||||
const edition = service.catalog.editions.find((item) => item.cardId === answer.id);
|
||||
|
|
@ -235,7 +239,7 @@ test("a player flips the daily hints in the order of their choice, for free", ()
|
|||
assert.equal(album.hintCredits, 0);
|
||||
assert.equal(album.guesses.length, 1);
|
||||
assert.deepEqual(flip("album").hints, album.hints);
|
||||
assert.throws(() => flip("rarity"), (error) => error.code === "DAILY_HINT_LOCKED");
|
||||
assert.throws(() => flip("collection"), (error) => error.code === "DAILY_HINT_LOCKED");
|
||||
for (const cardId of others.slice(1, 4)) service.guessDaily(player.id, { day, cardId });
|
||||
assert.equal(service.getDaily(player.id).hintCredits, 3);
|
||||
flip("shape");
|
||||
|
|
@ -249,9 +253,42 @@ test("a player flips the daily hints in the order of their choice, for free", ()
|
|||
assert.equal(won.hints.length, 4);
|
||||
assert.equal(won.earned, 10);
|
||||
assert.equal(won.hintCredits, 0);
|
||||
assert.throws(() => flip("rarity"), (error) => error.code === "DAILY_FINISHED");
|
||||
assert.throws(() => flip("theme"), (error) => error.code === "DAILY_FINISHED");
|
||||
clock.now = Date.parse("2026-11-13T23:00:00Z");
|
||||
assert.throws(() => flip("rarity"), (error) => error.code === "DAILY_EXPIRED");
|
||||
assert.throws(() => flip("theme"), (error) => error.code === "DAILY_EXPIRED");
|
||||
});
|
||||
|
||||
test("the theme hint names the theme of the answer, unless a guess already found it", () => {
|
||||
const day = "2026-11-13";
|
||||
const play = (sameTheme) => {
|
||||
const { service, player, wrongCards } = dailyService();
|
||||
const themeOf = (cardId) => clues.themeOf(service.index.cards.get(cardId).name);
|
||||
const theme = themeOf(service.todayPuzzle(player.id).cardId);
|
||||
const others = wrongCards().filter((cardId) => themeOf(cardId) !== theme);
|
||||
const guesses = sameTheme ? [wrongCards().find((cardId) => themeOf(cardId) === theme), ...others] : others;
|
||||
let daily;
|
||||
for (const cardId of guesses.slice(0, 3)) daily = service.guessDaily(player.id, { day, cardId }).daily;
|
||||
return { service, player, others, choice: daily.hintChoices.find((item) => item.id === "theme"), flip: () => service.useDailyHint(player.id, { day, hint: "theme" }), label: clues.themeLabels.get(theme) };
|
||||
};
|
||||
const unknown = play(false);
|
||||
assert.deepEqual(unknown.choice, { id: "theme", after: 3, known: false, available: true });
|
||||
assert.deepEqual(unknown.flip().hints, [{ id: "theme", value: unknown.label }]);
|
||||
const found = play(true);
|
||||
assert.deepEqual(found.choice, { id: "theme", after: 3, known: true, available: false });
|
||||
assert.throws(found.flip, (error) => error.code === "DAILY_HINT_LOCKED");
|
||||
// Le crédit que le thème aurait pris n'est pas annoncé quand il ne reste rien à retourner.
|
||||
for (const cardId of found.others.slice(2, 4)) found.service.guessDaily(found.player.id, { day, cardId });
|
||||
for (const hint of ["album", "collection", "page", "shape"]) found.service.useDailyHint(found.player.id, { day, hint });
|
||||
assert.equal(found.service.getDaily(found.player.id).hintCredits, 0);
|
||||
});
|
||||
|
||||
test("games that had flipped the former rarity hint get their hint back", () => {
|
||||
const { service, player, database } = dailyService();
|
||||
service.todayPuzzle(player.id);
|
||||
database.db.prepare("UPDATE daily_attempts SET hints_json = '[\"album\",\"rarity\",\"page\"]'").run();
|
||||
database.db.prepare("DELETE FROM schema_migrations WHERE version = 27").run();
|
||||
database.migrate();
|
||||
assert.equal(database.db.prepare("SELECT hints_json FROM daily_attempts").get().hints_json, '["album","page"]');
|
||||
});
|
||||
|
||||
test("a daily game drawn before the hints reads the ownership in the collection", () => {
|
||||
|
|
@ -364,10 +401,10 @@ test("the daily API requires a session, protects guesses and serves only the vis
|
|||
assert.equal(unprotected.status, 403);
|
||||
const wrong = handler.service.catalog.cards.find((item) => item.id !== answer && daily.json.collectionIds.includes(item.collectionId)).id;
|
||||
await call(handler, { method: "POST", path: "/api/cards/daily/guesses", headers: { cookie, "x-csrf-token": csrf }, body: { day: daily.json.day, cardId: wrong } });
|
||||
assert.equal((await call(handler, { method: "POST", path: "/api/cards/daily/hints", headers: { cookie }, body: { day: daily.json.day, hint: "rarity" } })).status, 403);
|
||||
const hint = await call(handler, { method: "POST", path: "/api/cards/daily/hints", headers: { cookie, "x-csrf-token": csrf }, body: { day: daily.json.day, hint: "rarity" } });
|
||||
assert.equal((await call(handler, { method: "POST", path: "/api/cards/daily/hints", headers: { cookie }, body: { day: daily.json.day, hint: "collection" } })).status, 403);
|
||||
const hint = await call(handler, { method: "POST", path: "/api/cards/daily/hints", headers: { cookie, "x-csrf-token": csrf }, body: { day: daily.json.day, hint: "collection" } });
|
||||
assert.equal(hint.status, 200);
|
||||
assert.deepEqual(hint.json.daily.hints, [{ id: "rarity", value: standardRarity(answer) }]);
|
||||
assert.deepEqual(hint.json.daily.hints, [{ id: "collection", value: handler.service.index.cards.get(answer).collectionId }]);
|
||||
const won = await call(handler, { method: "POST", path: "/api/cards/daily/guesses", headers: { cookie, "x-csrf-token": csrf }, body: { day: daily.json.day, cardId: answer } });
|
||||
assert.equal(won.status, 200);
|
||||
assert.equal(won.json.daily.status, "won");
|
||||
|
|
|
|||
|
|
@ -752,10 +752,11 @@
|
|||
"hintNext": "Au prochain essai raté",
|
||||
"hintFlip": "Retourner",
|
||||
"hintUnused": "Non retourné",
|
||||
"hintKnown": "Déjà trouvé",
|
||||
"hintAlbum": "Dans votre album ?",
|
||||
"hintAlbumYes": "Oui, elle y est",
|
||||
"hintAlbumNo": "Non, elle vous manque",
|
||||
"hintRarity": "Rareté",
|
||||
"hintTheme": "Thème du nom",
|
||||
"hintCollection": "Collection",
|
||||
"hintPage": "Page abîmée du carnet",
|
||||
"hintShape": "Forme du nom",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Rôle : indices facultatifs de la Carte du jour : cinq tuiles face cachée, une à retourner par essai raté, au choix du joueur.
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
|
||||
const HINT_LABELS = { album: "hintAlbum", rarity: "hintRarity", collection: "hintCollection", page: "hintPage", shape: "hintShape" };
|
||||
const HINT_LABELS = { album: "hintAlbum", collection: "hintCollection", page: "hintPage", theme: "hintTheme", shape: "hintShape" };
|
||||
|
||||
// Texte dont certains mots manquent : le serveur ne les envoie pas.
|
||||
function MaskedText({ parts, content, className }) {
|
||||
|
|
@ -12,13 +12,14 @@ function MaskedText({ parts, content, className }) {
|
|||
|
||||
function HintValue({ catalog, hint, content }) {
|
||||
if (hint.id === "album") return <span className="nebula-daily-hint-value">{hint.value ? content.hintAlbumYes : content.hintAlbumNo}</span>;
|
||||
if (hint.id === "rarity") return <span className="nebula-daily-hint-value">{catalog.rarities.find((item) => item.id === hint.value)?.label}</span>;
|
||||
if (hint.id === "theme") return <span className="nebula-daily-hint-value">{hint.value}</span>;
|
||||
if (hint.id === "collection") return <span className="nebula-daily-hint-value">{catalog.collections.find((item) => item.id === hint.value)?.name}</span>;
|
||||
return <MaskedText parts={hint.value} content={content} className={hint.id === "page" ? "nebula-daily-hint-page" : "nebula-daily-hint-value"} />;
|
||||
}
|
||||
|
||||
function hintStatus(choice, daily, wrongCount, content) {
|
||||
if (daily.status !== "playing") return content.hintUnused;
|
||||
if (choice.known) return content.hintKnown;
|
||||
if (choice.available) return content.hintFlip;
|
||||
if (wrongCount >= choice.after) return content.hintNext;
|
||||
return choice.after === 1 ? content.hintAfterOne : fillTemplate(content.hintAfterMany, { count: choice.after });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue