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