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
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue