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

@ -325,6 +325,12 @@ export function createCardsApiHandler({
json(res, 200, service.guessDaily(session.player.id, { day: body.day, cardId: body.cardId }));
return true;
}
if (req.method === "POST" && url.pathname === "/api/cards/daily/hints") {
rateLimit(req, "daily-hint", 30);
const body = await readBody(req);
json(res, 200, { daily: service.useDailyHint(session.player.id, { day: body.day, hint: body.hint }) });
return true;
}
if (req.method === "GET" && url.pathname === "/api/cards/expeditions") {
json(res, 200, service.expeditions.getExpeditions(session.player.id));
return true;

View file

@ -0,0 +1,320 @@
{
"subjects": [
{"id": "animal", "label": "Animal"},
{"id": "animal/amphibien", "label": "Amphibien"},
{"id": "animal/invertebre", "label": "Invertébré"},
{"id": "animal/mammifere", "label": "Mammifère"},
{"id": "animal/mammifere/canide", "label": "Canidé"},
{"id": "animal/mammifere/chauve-souris", "label": "Chauve-souris"},
{"id": "animal/mammifere/felin", "label": "Félin"},
{"id": "animal/mammifere/herisson", "label": "Hérisson"},
{"id": "animal/mammifere/mustelide", "label": "Mustélidé"},
{"id": "animal/mammifere/ongule", "label": "Ongulé"},
{"id": "animal/mammifere/panda", "label": "Panda"},
{"id": "animal/mammifere/raton-laveur", "label": "Raton laveur"},
{"id": "animal/mammifere/rongeur", "label": "Rongeur"},
{"id": "animal/mammifere/suricate", "label": "Suricate"},
{"id": "animal/oiseau", "label": "Oiseau"},
{"id": "animal/oiseau/aquatique", "label": "Aquatique"},
{"id": "animal/oiseau/passereau", "label": "Passereau"},
{"id": "animal/oiseau/rapace", "label": "Rapace"},
{"id": "animal/poisson", "label": "Poisson"},
{"id": "animal/reptile", "label": "Reptile"},
{"id": "objet", "label": "Objet"},
{"id": "objet/accessoire", "label": "Accessoire"},
{"id": "objet/aliment", "label": "Aliment"},
{"id": "objet/contenant", "label": "Contenant"},
{"id": "objet/decoration", "label": "Décoration"},
{"id": "objet/document", "label": "Document"},
{"id": "objet/instrument", "label": "Instrument"},
{"id": "objet/jeu", "label": "Jeu"},
{"id": "objet/luminaire", "label": "Luminaire"},
{"id": "objet/musique", "label": "Musique"},
{"id": "objet/outil", "label": "Outil"},
{"id": "nature", "label": "Nature"},
{"id": "nature/astre", "label": "Astre"},
{"id": "nature/constellation", "label": "Constellation"},
{"id": "nature/mineral", "label": "Minéral"},
{"id": "nature/phenomene", "label": "Phénomène"},
{"id": "nature/plante", "label": "Plante"},
{"id": "nature/trace", "label": "Trace"},
{"id": "fantastique", "label": "Fantastique"},
{"id": "fantastique/dragon", "label": "Dragon"},
{"id": "fantastique/yokai", "label": "Yokai"},
{"id": "lieu", "label": "Lieu"},
{"id": "lieu/batiment", "label": "Bâtiment"},
{"id": "lieu/espace", "label": "Espace"},
{"id": "lieu/passage", "label": "Passage"},
{"id": "lieu/paysage", "label": "Paysage"}
],
"themes": [
{"id": "star", "label": "Étoile", "words": ["étoile", "étoiles", "étoilée", "étoilées", "constellation", "constellations", "astres", "poussière", "poussières"]},
{"id": "cosmos", "label": "Cosmos", "words": ["comète", "comètes", "météorite", "nébuleuse", "nébuleuses", "saturne", "orbitaux", "astéroïde", "voie lactée"], "weakWords": ["astral", "astrale", "astrales", "céleste", "célestes", "stellaire", "stellaires", "cosmique", "cosmiques", "panda"]},
{"id": "moon", "label": "Lune", "words": ["lune", "croissant", "éclipse"], "weakWords": ["écarlate", "écarlates", "lunaire", "lunaires", "renard"]},
{"id": "light", "label": "Lumière", "words": ["aube", "aurore", "aurores", "lueur", "lueurs", "solaire", "solaires", "lumière", "braises", "prisme", "lanternes", "éclair", "premières", "arc en ciel"], "weakWords": ["loup", "capybara"]},
{"id": "night", "label": "Nuit", "words": ["nuit", "nuits", "minuit", "ombres", "nocturne", "nocturnes", "songes", "rêves", "crépuscule"]},
{"id": "winter", "label": "Hiver", "words": ["hiver", "neige", "neiges", "givre", "congères", "glaces", "patineuse"]},
{"id": "water", "label": "Eau", "words": ["eaux", "rosée", "pluie", "ruisseaux", "bassin", "lacs", "courants", "coquillages"]},
{"id": "air", "label": "Air", "words": ["vent", "vents", "nuage", "nuages", "brume", "brumes", "ciel", "cieux", "horizon", "tourbillon", "tempête"]},
{"id": "plant", "label": "Plante", "words": ["graines", "herbes", "cèdre", "feuillage", "pousses", "gui", "arbre"]},
{"id": "earth", "label": "Terre", "words": ["sables", "dunes", "pierres", "clairière", "collines", "ferme", "campement"]},
{"id": "treasure", "label": "Trésor", "words": ["or", "doré", "dorée", "pépites", "perles", "cristal", "coffre", "trésor", "clochettes"]},
{"id": "feast", "label": "Fête", "words": ["présent", "présents", "cadeau", "guirlande", "réveillon", "fête", "retrouvailles", "cortège", "vœux", "sommet", "traîneau", "artifice", "guitare", "tambour", "îles réunies"], "weakWords": ["renne"]},
{"id": "clothing", "label": "Vêtement", "words": ["bonnet", "cravate", "rubans", "costume", "armure", "masque", "laine", "emmitouflé"]},
{"id": "fight", "label": "Combat", "words": ["chasseur", "épée", "lames", "chevalier", "héros", "duel", "dresseur"]},
{"id": "travel", "label": "Voyage", "words": ["passage", "passages", "portes", "ruines", "guide", "messager", "cartographe", "dérive", "pilote", "voyage", "portails", "fusée", "errant", "vagabonde", "pas", "nœuds", "ouvreur", "poche"], "weakWords": ["île", "îles"]},
{"id": "watcher", "label": "Veilleur", "words": ["veilleur", "veilleurs", "veilleuse", "astronome", "observatoire", "observatoires", "vigie"]},
{"id": "role", "label": "Rôle", "words": ["maire", "collectionneur", "aventurier", "mage", "bâtisseuse", "lanceur", "porteur", "gardien", "maître", "imposteur", "barbouilleuse", "chapardeur", "visiteur"]},
{"id": "game", "label": "Jeu", "words": ["blocs", "cubes", "paquet", "manette", "arcade", "sauvegarde", "niveaux", "boule", "cartes", "pioche", "prix", "tombants"]},
{"id": "mystery", "label": "Mystère", "words": ["néant", "vide", "perdu", "écaille", "silencieuses", "fantômes", "cryptes", "reflets", "miroir", "murmure", "œil", "regards", "folle", "voilée", "frémissantes", "solitaire", "mystère", "replié", "autrefois"], "weakWords": ["dragon"]}
],
"compoundSubjects": ["raton laveur", "panda roux", "chauve-souris", "martin-pêcheur", "carpe koï", "rouge-gorge", "petit dragon", "petit tsuchinoko", "petit astéroïde", "longue-vue", "feu d'artifice", "hautes herbes", "grand prix", "grand salon", "grand vide", "vieux observatoires", "borne d'arcade"],
"cards": {
"starvoid-dragon": {"subject": "fantastique/dragon"},
"crimson-moon-kitsune": {"subject": "fantastique/yokai", "search": ["renard"]},
"milky-way-panda": {"subject": "animal/mammifere/panda"},
"constellation-magpie": {"subject": "animal/oiseau/passereau", "search": ["oiseau"]},
"solar-dawn-capybara": {"subject": "animal/mammifere/rongeur"},
"aurora-wolf": {"subject": "animal/mammifere/canide"},
"astral-crescent-howl": {"subject": "animal/mammifere/canide", "search": ["loup"]},
"eclipse-lynx": {"subject": "animal/mammifere/felin", "search": ["chat"]},
"silent-star-owl": {"subject": "animal/oiseau/rapace", "search": ["chouette", "oiseau"]},
"night-veil-bat": {"subject": "animal/mammifere/chauve-souris"},
"celestial-shadow-panther": {"subject": "animal/mammifere/felin", "search": ["chat"]},
"dawn-antler-deer": {"subject": "animal/mammifere/ongule", "search": ["faon", "biche"]},
"solar-dust-butterfly": {"subject": "animal/invertebre"},
"starlit-sand-fennec": {"subject": "animal/mammifere/canide", "search": ["renard"]},
"rose-dawn-hummingbird": {"subject": "animal/oiseau", "search": ["oiseau"]},
"astral-ember-salamander": {"subject": "animal/amphibien", "search": ["lézard"]},
"orbital-ring-turtle": {"subject": "animal/reptile"},
"cosmic-water-axolotl": {"subject": "animal/amphibien", "search": ["salamandre"]},
"astral-prism-chameleon": {"subject": "animal/reptile", "search": ["lézard"]},
"stellar-current-otter": {"subject": "animal/mammifere/mustelide"},
"moonrain-frog": {"subject": "animal/amphibien", "search": ["rainette", "crapaud"]},
"nebula-mist-jellyfish": {"subject": "animal/invertebre"},
"comet-squirrel": {"subject": "animal/mammifere/rongeur"},
"deep-sky-ray": {"subject": "animal/poisson", "search": ["poisson"]},
"star-spined-hedgehog": {"subject": "animal/mammifere/herisson"},
"lunar-cloud-rabbit": {"subject": "animal/mammifere", "search": ["lièvre"]},
"twilight-red-panda": {"subject": "animal/mammifere/panda"},
"pale-moon-owl": {"subject": "animal/oiseau/rapace", "search": ["hibou", "oiseau"]},
"night-reflection-raccoon": {"subject": "animal/mammifere/raton-laveur"},
"astral-snow-fox-cub": {"subject": "animal/mammifere/canide", "search": ["renard"]},
"starry-dream-dormouse": {"subject": "animal/mammifere/rongeur", "search": ["souris"]},
"first-light-duckling": {"subject": "animal/oiseau/aquatique", "search": ["canard", "oiseau"]},
"solar-seed-hamster": {"subject": "animal/mammifere/rongeur", "search": ["souris"]},
"golden-dew-fawn": {"subject": "animal/mammifere/ongule", "search": ["cerf", "biche"]},
"amber-dune-meerkat": {"subject": "animal/mammifere/suricate", "search": ["mangouste"]},
"pink-horizon-robin": {"subject": "animal/oiseau/passereau", "search": ["oiseau"]},
"celestial-stream-platypus": {"subject": "animal/mammifere"},
"azure-stone-gecko": {"subject": "animal/reptile", "search": ["lézard"]},
"celestial-mirror-kingfisher": {"subject": "animal/oiseau/aquatique", "search": ["oiseau"]},
"mist-pearl-tree-frog": {"subject": "animal/amphibien", "search": ["grenouille", "crapaud"]},
"moon-shell-otter-pup": {"subject": "animal/mammifere/mustelide", "search": ["loutre"]},
"lunar-mist-chinchilla": {"subject": "animal/mammifere/rongeur", "search": ["souris"]},
"starlit-ice-penguin": {"subject": "animal/oiseau/aquatique", "search": ["pingouin", "oiseau"]},
"lavender-sky-koala": {"subject": "animal/mammifere"},
"stellar-wind-ferret": {"subject": "animal/mammifere/mustelide", "search": ["belette"]},
"opaline-cloud-alpaca": {"subject": "animal/mammifere/ongule", "search": ["lama"]},
"cosmic-cloud-heart": {"subject": "lieu/espace", "search": ["galaxie"]},
"dragon-constellation": {"subject": "nature/constellation"},
"wolf-constellation": {"subject": "nature/constellation"},
"fox-constellation": {"subject": "nature/constellation"},
"panda-constellation": {"subject": "nature/constellation"},
"capybara-constellation": {"subject": "nature/constellation"},
"magpie-constellation": {"subject": "nature/constellation"},
"void-scale": {"subject": "nature/trace", "search": ["dragon"]},
"astral-wolf-pendant": {"subject": "objet/accessoire"},
"celestial-fox-mask": {"subject": "objet/accessoire", "search": ["kitsune"]},
"azure-horizon-bamboo": {"subject": "nature/plante"},
"solar-dawn-pebble": {"subject": "nature/mineral", "search": ["caillou"]},
"constellation-feather": {"subject": "nature/trace"},
"star-compass": {"subject": "objet/instrument"},
"watchers-spyglass": {"subject": "objet/instrument", "search": ["longue-vue", "télescope"]},
"forgotten-sky-map": {"subject": "objet/document"},
"night-hourglass": {"subject": "objet/instrument", "search": ["temps"]},
"astronomers-notebook": {"subject": "objet/document", "search": ["livre"]},
"pocket-astrolabe": {"subject": "objet/instrument"},
"meteorite-fragment": {"subject": "nature/mineral", "search": ["pierre", "caillou"]},
"stardust-vial": {"subject": "nature/mineral"},
"moon-shard": {"subject": "nature/mineral", "search": ["pierre", "caillou"]},
"nebula-pearl": {"subject": "nature/mineral", "search": ["bille"]},
"wandering-asteroid": {"subject": "nature/astre", "search": ["météorite", "rocher"]},
"broken-saturn-ring": {"subject": "nature/mineral"},
"twilight-lantern": {"subject": "objet/luminaire", "search": ["lampe"]},
"midnight-cup": {"subject": "objet/contenant", "search": ["mug"]},
"observatory-key": {"subject": "objet/outil"},
"astral-inkwell": {"subject": "objet/contenant"},
"watchers-candle": {"subject": "objet/luminaire", "search": ["chandelle"]},
"stellar-memory-box": {"subject": "objet/contenant", "search": ["coffret"]},
"first-crescent": {"subject": "nature/astre", "search": ["lune"]},
"lonely-star": {"subject": "nature/astre"},
"cosmic-dust-cloud": {"subject": "nature/phenomene", "search": ["galaxie"]},
"horizon-glow": {"subject": "nature/phenomene", "search": ["coucher"]},
"veiled-moon": {"subject": "nature/astre"},
"shooting-star": {"subject": "nature/astre"},
"mythic-card-pull": {"subject": "fantastique/dragon", "search": ["dragon"]},
"crimson-card-trade": {"subject": "fantastique/yokai", "search": ["kitsune", "renard", "pie", "oiseau"]},
"dawn-card-trade": {"subject": "animal/mammifere/rongeur", "search": ["capybara", "panda"]},
"astral-pack-opening": {"subject": "fantastique/dragon", "search": ["dragon", "paquet"]},
"next-booster-wait": {"subject": "fantastique/dragon", "search": ["dragon", "sablier"]},
"collectors-treasure": {"subject": "fantastique/dragon", "search": ["dragon", "classeur"]},
"grand-astral-hall": {"subject": "lieu/batiment"},
"astral-booster": {"subject": "objet/jeu", "search": ["booster"]},
"collector-binder": {"subject": "objet/document", "search": ["livre", "album"]},
"astral-card-stack": {"subject": "objet/jeu"},
"celestial-storage-box": {"subject": "objet/contenant", "search": ["boîte", "trésor"]},
"stardust-dragon": {"subject": "fantastique/dragon"},
"golden-attic-squirrel": {"subject": "animal/mammifere/rongeur"},
"star-chest-tortoise": {"subject": "animal/reptile"},
"gold-nugget-panther": {"subject": "animal/mammifere/felin", "search": ["chat"]},
"golden-current-koi": {"subject": "animal/poisson", "search": ["poisson"]},
"night-of-return-dragon": {"subject": "fantastique/dragon"},
"midnight-snowy-owl": {"subject": "animal/oiseau/rapace", "search": ["hibou", "chouette", "oiseau"]},
"gift-sleigh-reindeer": {"subject": "animal/mammifere/ongule", "search": ["cerf"]},
"grand-feast-bear": {"subject": "animal/mammifere"},
"golden-ribbon-ermine": {"subject": "animal/mammifere/mustelide", "search": ["belette", "furet"]},
"gift-bearer-penguin": {"subject": "animal/oiseau/aquatique", "search": ["pingouin", "oiseau"]},
"fireworks-lynx": {"subject": "animal/mammifere/felin", "search": ["chat"]},
"bundled-little-dragon": {"subject": "fantastique/dragon"},
"lunar-ice-seal": {"subject": "animal/mammifere", "search": ["otarie"]},
"starry-snowdrift-hare": {"subject": "animal/mammifere", "search": ["lapin"]},
"cookie-thief-raccoon": {"subject": "animal/mammifere/raton-laveur"},
"frost-wool-sheep": {"subject": "animal/mammifere/ongule", "search": ["agneau"]},
"garland-hedgehog": {"subject": "animal/mammifere/herisson"},
"gift-wrap-kitten": {"subject": "animal/mammifere/felin", "search": ["chat"]},
"greeting-card-owl": {"subject": "animal/oiseau/rapace", "search": ["hibou", "oiseau"]},
"mistletoe-bullfinch": {"subject": "animal/oiseau/passereau", "search": ["oiseau"]},
"skating-otter": {"subject": "animal/mammifere/mustelide"},
"snow-dream-marmot": {"subject": "animal/mammifere/rongeur"},
"winter-stash-squirrel": {"subject": "animal/mammifere/rongeur"},
"wool-hat-fox-cub": {"subject": "animal/mammifere/canide", "search": ["renard"]},
"reunited-isles-feast": {"subject": "lieu/paysage"},
"celestial-gift": {"subject": "objet/decoration", "search": ["cadeau"]},
"midnight-firework": {"subject": "objet/decoration"},
"reindeer-constellation": {"subject": "nature/constellation"},
"reunion-lantern": {"subject": "objet/luminaire", "search": ["lampe"]},
"reunited-islands-tree": {"subject": "nature/plante"},
"snowman": {"subject": "objet/decoration"},
"starry-snowflake": {"subject": "nature/phenomene"},
"star-yule-log": {"subject": "objet/aliment", "search": ["gâteau"]},
"tree-top-star": {"subject": "objet/decoration"},
"watchers-hot-chocolate": {"subject": "objet/aliment"},
"golden-block-hero-dragon": {"subject": "fantastique/dragon"},
"ancient-blade-kitsune": {"subject": "fantastique/yokai", "search": ["renard"]},
"star-trainer-panda": {"subject": "animal/mammifere/panda"},
"aurora-bolt-wolf": {"subject": "animal/mammifere/canide"},
"cube-world-magpie": {"subject": "animal/oiseau/passereau", "search": ["oiseau"]},
"peaceful-isle-mayor-capybara": {"subject": "animal/mammifere/rongeur"},
"rainbow-grand-prix": {"subject": "animal/mammifere/mustelide", "search": ["loutre", "écureuil", "course"]},
"lynx-panther-duel": {"subject": "animal/mammifere/felin"},
"star-gobbler-axolotl": {"subject": "animal/amphibien", "search": ["salamandre"]},
"pearl-maze-hedgehog": {"subject": "animal/mammifere/herisson"},
"falling-blocks-chameleon": {"subject": "animal/reptile", "search": ["lézard"]},
"shadow-mage-owl": {"subject": "animal/oiseau/rapace", "search": ["chouette", "oiseau"]},
"golden-tree-knight-deer": {"subject": "animal/mammifere/ongule", "search": ["faon", "biche"]},
"crimson-crypt-bat": {"subject": "animal/mammifere/chauve-souris"},
"wyvern-hunter-fennec": {"subject": "animal/mammifere/canide", "search": ["renard"]},
"portal-frog": {"subject": "animal/amphibien", "search": ["rainette", "crapaud"]},
"egg-tossing-gecko": {"subject": "animal/reptile", "search": ["lézard"]},
"impostor-raccoon": {"subject": "animal/mammifere/raton-laveur"},
"lost-ruins-meerkat": {"subject": "animal/mammifere/suricate", "search": ["mangouste"]},
"whirlwind-ferret": {"subject": "animal/mammifere/mustelide", "search": ["belette"]},
"red-tie-platypus": {"subject": "animal/mammifere"},
"ink-splash-tree-frog": {"subject": "animal/amphibien", "search": ["grenouille", "crapaud"]},
"jellybean-alpaca": {"subject": "animal/mammifere/ongule", "search": ["lama"]},
"green-crystal-koala": {"subject": "animal/mammifere"},
"little-farm-duckling": {"subject": "animal/oiseau/aquatique", "search": ["canard", "oiseau"]},
"steel-ball-hamster": {"subject": "animal/mammifere/rongeur", "search": ["souris"]},
"sprout-follower-dormouse": {"subject": "animal/mammifere/rongeur", "search": ["souris"]},
"rocket-penguin": {"subject": "animal/oiseau/aquatique", "search": ["pingouin", "oiseau"]},
"ghost-hunter-red-panda": {"subject": "animal/mammifere/panda"},
"rhythm-guitar-robin": {"subject": "animal/oiseau/passereau", "search": ["oiseau"]},
"monster-slayer-fox-cub": {"subject": "animal/mammifere/canide", "search": ["renard"]},
"orange-armor-chinchilla": {"subject": "animal/mammifere/rongeur", "search": ["souris"]},
"level-isles": {"subject": "lieu/paysage"},
"golden-mystery-block": {"subject": "objet/jeu"},
"golden-spotted-mushroom": {"subject": "nature/plante"},
"crystal-hearts": {"subject": "objet/jeu"},
"ancient-pedestal-sword": {"subject": "objet/outil"},
"clearing-chest": {"subject": "objet/contenant", "search": ["trésor"]},
"hilltop-golden-ring": {"subject": "objet/jeu"},
"rustling-tall-grass": {"subject": "nature/plante"},
"starry-capture-sphere": {"subject": "objet/jeu"},
"cube-island": {"subject": "lieu/paysage"},
"bell-bag": {"subject": "objet/contenant", "search": ["bourse"]},
"pearl-maze": {"subject": "lieu/batiment"},
"falling-blocks": {"subject": "objet/jeu", "search": ["briques"]},
"vintage-controller": {"subject": "objet/jeu", "search": ["console"]},
"island-arcade-cabinet": {"subject": "objet/jeu"},
"adventurer-potion": {"subject": "objet/aliment", "search": ["fiole"]},
"save-crystal": {"subject": "objet/jeu"},
"rainbow-road": {"subject": "lieu/passage"},
"camp-roast": {"subject": "objet/aliment", "search": ["viande"]},
"watchers-guide-magpie": {"subject": "animal/oiseau/passereau", "search": ["oiseau"]},
"scale-keeper-dragon": {"subject": "fantastique/dragon"},
"hidden-passage-kitsune": {"subject": "fantastique/yokai", "search": ["renard"]},
"first-observatory-salamander": {"subject": "animal/amphibien", "search": ["lézard"]},
"drifting-isle-turtle": {"subject": "animal/reptile"},
"map-keeper-owl": {"subject": "animal/oiseau/rapace", "search": ["chouette", "oiseau"]},
"starless-night-bat": {"subject": "animal/mammifere/chauve-souris"},
"apprentice-watcher-owl": {"subject": "animal/oiseau/rapace", "search": ["hibou", "oiseau"]},
"cartographer-gecko": {"subject": "animal/reptile", "search": ["lézard"]},
"lookout-meerkat": {"subject": "animal/mammifere/suricate", "search": ["mangouste"]},
"skyboat-pilot-otter": {"subject": "animal/mammifere/mustelide"},
"isle-messenger-ferret": {"subject": "animal/mammifere/mustelide", "search": ["belette"]},
"light-currents": {"subject": "lieu/espace"},
"dawn-shore": {"subject": "lieu/paysage"},
"forgotten-ruins": {"subject": "lieu/batiment"},
"great-void": {"subject": "lieu/espace"},
"scale-crater": {"subject": "lieu/paysage"},
"comet-lakes": {"subject": "lieu/paysage"},
"old-observatories": {"subject": "lieu/batiment"},
"long-night-ice": {"subject": "lieu/paysage"},
"milky-way-band": {"subject": "lieu/espace", "search": ["galaxie"]},
"pale-moon-slope": {"subject": "lieu/paysage"},
"aurora-sky": {"subject": "lieu/espace"},
"lost-observatory": {"subject": "lieu/batiment"},
"crimson-passage": {"subject": "lieu/passage"},
"watchers-longsight": {"subject": "objet/instrument", "search": ["lunette", "télescope"]},
"travel-rations": {"subject": "objet/aliment", "search": ["nourriture", "galettes"]},
"watchers-treasure-map": {"subject": "objet/document"},
"pale-moon-talisman": {"subject": "objet/accessoire"},
"mad-compass": {"subject": "objet/instrument"},
"shooting-star-net": {"subject": "objet/outil"},
"storm-lantern": {"subject": "objet/luminaire", "search": ["lampe"]},
"fog-bell": {"subject": "objet/musique", "search": ["clochette"]},
"crimson-procession-kitsune": {"subject": "fantastique/yokai", "search": ["renard"]},
"last-passage-wolf": {"subject": "animal/mammifere/canide"},
"twin-lantern-nekomata": {"subject": "fantastique/yokai", "search": ["chat"]},
"mist-cauldron-tanuki": {"subject": "animal/mammifere/canide", "search": ["raton"]},
"high-gate-raven": {"subject": "animal/oiseau/passereau", "search": ["oiseau"]},
"spirit-drum-dragon": {"subject": "fantastique/dragon"},
"wind-blade-ferret": {"subject": "animal/mammifere/mustelide", "search": ["belette"]},
"deceptive-reflection-otter": {"subject": "animal/mammifere/mustelide"},
"living-mask-kitten": {"subject": "animal/mammifere/felin", "search": ["chat"]},
"moon-thread-spider": {"subject": "animal/invertebre"},
"snowdrift-fox-cub": {"subject": "animal/mammifere/canide", "search": ["renard"]},
"laughing-umbrella": {"subject": "fantastique/yokai"},
"whispering-lantern": {"subject": "fantastique/yokai", "search": ["lampe"]},
"wandering-white-cloth": {"subject": "fantastique/yokai", "search": ["tissu", "drap", "fantôme"]},
"red-grass-tsuchinoko": {"subject": "fantastique/yokai", "search": ["serpent"]},
"crimson-pool-frog": {"subject": "animal/amphibien", "search": ["rainette", "crapaud"]},
"watchful-foliage-bat": {"subject": "animal/mammifere/chauve-souris"},
"bad-dream-baku": {"subject": "fantastique/yokai", "search": ["tapir"]},
"hollow-cedar-spirit": {"subject": "fantastique/yokai", "search": ["arbre"]},
"tiny-step-teapot": {"subject": "fantastique/yokai"},
"hundred-gaze-screen": {"subject": "fantastique/yokai"},
"hundred-lantern-isle": {"subject": "lieu/paysage"},
"broken-dawn-mirror": {"subject": "objet/accessoire"},
"first-visitor-mask": {"subject": "objet/accessoire"},
"procession-drum": {"subject": "objet/musique"},
"last-passage-bell": {"subject": "objet/musique", "search": ["cloche", "clochette"]},
"mist-fan": {"subject": "objet/accessoire"},
"red-moon-comb": {"subject": "objet/accessoire"},
"folded-umbrella": {"subject": "objet/accessoire"},
"reflection-bowl": {"subject": "objet/contenant"},
"hundred-knot-rope": {"subject": "objet/outil"},
"passage-screen": {"subject": "objet/decoration"}
}
}

View file

@ -0,0 +1,181 @@
// Rôle : indices de la Carte du jour : sujet (arbre) et thème du nom de chaque carte, comparaison d'un essai, page abîmée et
// forme du nom. Les données viennent de content/daily-clues.json ; les règles sont pures.
import { readFileSync } from "node:fs";
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.
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: "shape", after: 4 })
]);
const SUBJECT_ID_PATTERN = /^[a-z0-9-]+(\/[a-z0-9-]+)*$/;
const THEME_ID_PATTERN = /^[a-z0-9-]+$/;
// Une branche plus fournie ne renseigne plus assez : elle est à découper.
export const MAX_SUBJECT_CARDS = 15;
const MAX_WORDS_IN_EXPRESSION = 3;
// Petits mots laissés lisibles dans la forme du nom et jamais masqués dans la page.
const SMALL_WORDS = new Set(["de", "du", "la", "le", "les", "des", "l", "d", "un", "une", "a", "au", "aux", "et", "en", "qui"]);
const ARTICLES = new Set(["le", "la", "les", "l"]);
function plain(text) {
return text.normalize("NFD").replace(/\p{Diacritic}/gu, "").replace(/œ/gi, "oe").toLowerCase();
}
const tokens = (text) => plain(text).match(/[a-z0-9]+/g) || [];
// Table « suite de mots → thème ». Un mot ne désigne jamais deux thèmes.
function wordTable(themes, field) {
const table = new Map();
for (const theme of themes) {
for (const entry of theme[field] || []) {
const key = tokens(entry).join(" ");
if (!key || key.split(" ").length > MAX_WORDS_IN_EXPRESSION) throw new TypeError(`Daily theme ${theme.id}: « ${entry} » must hold 1 to ${MAX_WORDS_IN_EXPRESSION} words.`);
if (table.has(key)) throw new TypeError(`Daily theme ${theme.id}: « ${entry} » already belongs to ${table.get(key)}.`);
table.set(key, theme.id);
}
}
return table;
}
// Premier thème rencontré en lisant les mots, l'expression la plus longue d'abord (« voie lactée » avant « lactée »).
function firstTheme(words, table) {
for (let start = 0; start < words.length; start += 1) {
for (let size = Math.min(MAX_WORDS_IN_EXPRESSION, words.length - start); size > 0; size -= 1) {
const theme = table.get(words.slice(start, start + size).join(" "));
if (theme) return theme;
}
}
return null;
}
// Le thème vient des mots du nom, toujours le même pour un même mot. Le sujet (« Renardeau ») ne compte qu'à défaut : d'abord les
// mots du thème, puis ses mots faibles, trop répandus pour l'emporter (« astral », ou le personnage d'une constellation).
function themeReader(content) {
const strong = wordTable(content.themes, "words");
const weak = wordTable(content.themes, "weakWords");
const compounds = content.compoundSubjects.map(tokens).sort((left, right) => right.length - left.length);
return (name) => {
let words = tokens(name);
if (ARTICLES.has(words[0])) words = words.slice(1);
const subjectLength = compounds.find((compound) => compound.every((word, index) => words[index] === word))?.length ?? 1;
const rest = words.slice(subjectLength);
return firstTheme(rest, strong) || firstTheme(rest, weak) || firstTheme(words.slice(0, subjectLength), strong);
};
}
function requireLabelled(items, pattern, name) {
const ids = new Set();
for (const item of items) {
if (!pattern.test(item?.id ?? "") || typeof item.label !== "string" || !item.label) throw new TypeError(`Daily ${name} ${item?.id ?? "?"} needs an id and a label.`);
if (ids.has(item.id)) throw new TypeError(`Daily ${name} ${item.id} is declared twice.`);
ids.add(item.id);
}
return ids;
}
// Contenu prêt à l'emploi : libellés, chemin du sujet de chaque carte, lecture du thème et mots de recherche.
export function prepareDailyClues(content) {
const subjectIds = requireLabelled(content.subjects, SUBJECT_ID_PATTERN, "subject");
for (const id of subjectIds) {
const parent = id.split("/").slice(0, -1).join("/");
if (parent && !subjectIds.has(parent)) throw new TypeError(`Daily subject ${id} has no parent ${parent}.`);
}
requireLabelled(content.themes, THEME_ID_PATTERN, "theme");
for (const [cardId, clues] of Object.entries(content.cards)) {
if (!subjectIds.has(clues.subject)) throw new TypeError(`Daily clues of ${cardId} use an unknown subject ${clues.subject}.`);
if (clues.search != null && (!Array.isArray(clues.search) || clues.search.some((word) => typeof word !== "string" || !word.trim()))) throw new TypeError(`Daily clues of ${cardId} need search words.`);
}
return {
subjectLabels: new Map(content.subjects.map((subject) => [subject.id, subject.label])),
themeLabels: new Map(content.themes.map((theme) => [theme.id, theme.label])),
cards: content.cards,
themeOf: themeReader(content)
};
}
export function loadDailyClues(path = DEFAULT_DAILY_CLUES_PATH) {
return prepareDailyClues(JSON.parse(readFileSync(path, "utf8")));
}
// Ce qui manque au catalogue pour que chaque carte ait ses indices. Vérifié par les tests, pas au démarrage : une carte sans
// sujet ni thème reste jouable, sans comparaison.
export function dailyCluesIssues(catalog, clues) {
const cardIds = new Set(catalog.cards.map((card) => card.id));
const counts = new Map();
const issues = [];
for (const card of catalog.cards) {
const subject = clues.cards[card.id]?.subject;
if (!subject) issues.push(`${card.id}: no subject`);
else counts.set(subject, (counts.get(subject) || 0) + 1);
if (!clues.themeOf(card.name)) issues.push(`${card.id}: no theme for « ${card.name} »`);
}
for (const cardId of Object.keys(clues.cards)) if (!cardIds.has(cardId)) issues.push(`${cardId}: unknown card`);
for (const [subject, count] of counts) if (count > MAX_SUBJECT_CARDS) issues.push(`${subject}: ${count} cards, to split`);
return issues;
}
// Comparaison d'un essai. Sujet : les étapes communes aux deux chemins, puis la première qui diffère, jamais le reste du chemin
// de la réponse (ni sa longueur). Thème : celui de l'essai, et s'il est celui de la réponse.
export function compareClues(clues, answer, guess) {
const steps = (card) => clues.cards[card.id]?.subject?.split("/") || [];
const mine = steps(answer);
const theirs = steps(guess);
let common = 0;
while (common < mine.length && common < theirs.length && mine[common] === theirs[common]) common += 1;
const label = (length) => clues.subjectLabels.get(theirs.slice(0, length).join("/"));
const theme = clues.themeOf(guess.name);
return {
subject: {
common: theirs.slice(0, common).map((_, index) => label(index + 1)),
different: common < theirs.length ? label(common + 1) : null
},
theme: theme ? { label: clues.themeLabels.get(theme), same: theme === clues.themeOf(answer.name) } : null
};
}
const textParts = (text) => text.split(/([\p{L}\p{N}]+)/u).filter(Boolean);
const isWord = (part) => /[\p{L}\p{N}]/u.test(part);
// Deux mots de la même famille : au singulier ou au pluriel, ou presque tout en commun (« patineuse » et « patine »).
function sameFamily(left, right) {
const first = left.replace(/[sx]$/, "");
const second = right.replace(/[sx]$/, "");
if (first === second) return true;
let length = 0;
while (length < first.length && length < second.length && first[length] === second[length]) length += 1;
return length >= 5 && length >= Math.min(first.length, second.length) - 1;
}
// Un mot caché n'est jamais envoyé : il devient un morceau sans texte.
const hide = (parts) => parts.map(({ text, hidden }) => (hidden ? { hidden: true } : { text }));
// Page abîmée : la première phrase de la description, sans les mots de la famille de ceux du nom.
export function damagedPage(card) {
const sentence = card.description.match(/^.*?[.!?…]+(?=\s|$)/s)?.[0] || card.description;
const names = tokens(card.name).filter((word) => word.length > 2 && !SMALL_WORDS.has(word));
return hide(textParts(sentence).map((text) => {
const word = plain(text);
return { text, hidden: word.length > 2 && !SMALL_WORDS.has(word) && names.some((name) => sameFamily(name, word)) };
}));
}
// Forme du nom : ses petits mots et sa ponctuation, sans la longueur des autres mots.
export function nameShape(name) {
return hide(textParts(name).map((text) => ({ text, hidden: isWord(text) && !SMALL_WORDS.has(plain(text)) })));
}
// Un indice par essai raté, au choix parmi ceux que le nombre d'essais ratés a ouverts.
export function dailyHintCredits(wrongCount, usedCount) {
return Math.max(0, Math.min(wrongCount, DAILY_HINTS.length) - usedCount);
}
export function canUseDailyHint(hintId, wrongCount, used) {
const hint = DAILY_HINTS.find((item) => item.id === hintId);
return Boolean(hint) && !used.includes(hintId) && wrongCount >= hint.after && dailyHintCredits(wrongCount, used.length) > 0;
}

View file

@ -1,4 +1,4 @@
// Rôle : règles pures de la Carte du jour (jour de Paris, tirage de la carte, indices, zoom et série de victoires).
// Rôle : règles pures de la Carte du jour (jour de Paris, tirage de la carte, zoom et série de victoires).
// Le service les applique avec la base ; aucune fonction ici ne lit la base ni l'horloge.
import { randomInt } from "node:crypto";
@ -76,20 +76,6 @@ export function dailyCrop(width, height, focus, zoom) {
return { left: offset(width, cropWidth, focus.x), top: offset(height, cropHeight, focus.y), width: cropWidth, height: cropHeight };
}
// Indice d'un essai : bonne collection ou non, et rareté de la réponse par rapport à celle de l'essai.
export function guessHint(catalog, answerId, guessId) {
const cards = new Map(catalog.cards.map((card) => [card.id, card]));
const rank = new Map(catalog.rarities.map((rarity, index) => [rarity.id, index]));
const answerRank = rank.get(cardRarity(catalog, answerId));
const guessRank = rank.get(cardRarity(catalog, guessId));
return {
cardId: guessId,
correct: guessId === answerId,
sameCollection: cards.get(guessId)?.collectionId === cards.get(answerId)?.collectionId,
rarity: answerRank === guessRank ? "equal" : answerRank > guessRank ? "higher" : "lower"
};
}
export function dailyZoom(wrongCount, finished) {
if (finished) return 1;
return DAILY_ZOOM_STEPS[Math.min(Math.max(0, wrongCount), DAILY_ZOOM_STEPS.length - 1)];

View file

@ -511,6 +511,12 @@ export const MIGRATIONS = [
`
DELETE FROM card_equipment WHERE equipment_edition_id IN (
'astronomers-notebook-standard', 'starry-snowflake-standard', 'clearing-chest-standard', 'red-moon-comb-standard', 'first-visitor-mask-standard');
`,
// Indices au choix de la Carte du jour : ceux que le joueur a retournés, et s'il possédait la carte au tirage (NULL pour une
// partie d'avant cette migration), pour qu'un paquet ouvert pendant la partie ne change pas l'indice.
`
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));
`
];

View file

@ -3,7 +3,8 @@ 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 { computeStreak, DAILY_REPEAT_WINDOW_DAYS, dailyCandidates, dailyDayKey, dailyZoom, drawDailyPuzzle, guessHint, isDayKey, MAX_DAILY_GUESSES, nextDailyAt, shiftDayKey } from "./daily.js";
import { cardRarity, 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";
import { ExpeditionService } from "./expedition-service.js";
@ -71,7 +72,7 @@ const FLARE_ERROR_MESSAGES = {
export class CardsService {
// `destinations` : destinations des Expéditions validées ; sans elles, celles du dépôt (services/cards/content).
// `alerts` : { available, publicOrigin } pour les alertes Discord des Expéditions (bot configuré, lien des messages).
constructor({ database, catalog, now = Date.now, random, devPerks = false, destinations = null, alerts = {} } = {}) {
constructor({ database, catalog, now = Date.now, random, devPerks = false, destinations = null, dailyClues = null, alerts = {} } = {}) {
// Serveur Vite local uniquement : ressources permanentes du compte de développement pour tester le jeu sans attendre.
this.devPerks = devPerks;
this.database = database;
@ -81,6 +82,7 @@ export class CardsService {
this.now = now;
// Tirage d'un entier de 0 à max − 1. Sans source fournie (le serveur), le hasard cryptographique, comme les paquets.
this.random = random ?? ((max) => randomInt(max));
this.dailyClues = dailyClues || loadDailyClues();
this.reloadCatalog();
this.expeditions = new ExpeditionService(this, destinations || loadExpeditionDestinations(DEFAULT_DESTINATIONS_PATH, catalog), alerts);
}
@ -900,7 +902,7 @@ export class CardsService {
}
dailyAttemptRow(playerId, day) {
return this.db.prepare("SELECT card_id, focus_x, focus_y, guesses_json, status, reward FROM daily_attempts WHERE player_id = ? AND day = ?").get(playerId, day);
return this.db.prepare("SELECT card_id, focus_x, focus_y, guesses_json, hints_json, owned, status, reward FROM daily_attempts WHERE player_id = ? AND day = ?").get(playerId, day);
}
// Partie du joueur pour ce jour, tirée s'il n'en a pas encore : pas de carte qu'il a déjà eue ces 60 derniers jours.
@ -910,13 +912,19 @@ export class CardsService {
const recent = this.db.prepare("SELECT card_id FROM daily_attempts WHERE player_id = ? AND day >= ?").all(playerId, shiftDayKey(day, -DAILY_REPEAT_WINDOW_DAYS)).map((row) => row.card_id);
const drawn = drawDailyPuzzle(this.catalog, recent, this.random);
if (!drawn) fail(409, "DAILY_UNAVAILABLE", "Aucune carte ne peut être tirée aujourd’hui.");
this.db.prepare("INSERT INTO daily_attempts(player_id, day, card_id, focus_x, focus_y, guesses_json, status, reward, created_at, updated_at) VALUES (?, ?, ?, ?, ?, '[]', 'playing', 0, ?, ?)")
.run(playerId, day, drawn.cardId, drawn.focusX, drawn.focusY, this.now(), this.now());
this.db.prepare("INSERT INTO daily_attempts(player_id, day, card_id, focus_x, focus_y, guesses_json, owned, status, reward, created_at, updated_at) VALUES (?, ?, ?, ?, ?, '[]', ?, 'playing', 0, ?, ?)")
.run(playerId, day, drawn.cardId, drawn.focusX, drawn.focusY, Number(this.ownsCard(playerId, drawn.cardId)), this.now(), this.now());
}
const row = this.dailyAttemptRow(playerId, day);
// Une carte retirée du catalogue après son tirage ne peut plus être affichée.
if (!this.index.cards.has(row.card_id)) fail(503, "DAILY_UNAVAILABLE", "La Carte du jour est indisponible.");
return { day, number, cardId: row.card_id, focus: { x: row.focus_x, y: row.focus_y }, guesses: JSON.parse(row.guesses_json), status: row.status, earned: row.reward };
return { day, number, cardId: row.card_id, focus: { x: row.focus_x, y: row.focus_y }, guesses: JSON.parse(row.guesses_json), hints: JSON.parse(row.hints_json), status: row.status, earned: row.reward,
// Une partie tirée avant que la possession soit figée la lit dans la collection.
owned: row.owned == null ? this.ownsCard(playerId, row.card_id) : Boolean(row.owned) };
}
ownsCard(playerId, cardId) {
return this.collectionOf(playerId).some((entry) => this.index.editions.get(entry.editionId)?.cardId === cardId);
}
todayPuzzle(playerId) {
@ -938,7 +946,38 @@ export class CardsService {
// Zoom de la partie : il se relâche à chaque essai raté et vaut 1 une fois la partie terminée.
dailyPuzzleZoom(puzzle) {
return dailyZoom(puzzle.guesses.length - (puzzle.status === "won" ? 1 : 0), puzzle.status !== "playing");
return dailyZoom(this.dailyWrongCount(puzzle), puzzle.status !== "playing");
}
dailyWrongCount(puzzle) {
return puzzle.guesses.length - (puzzle.status === "won" ? 1 : 0);
}
// Comparaison d'un essai. Une carte retirée du catalogue depuis l'essai n'a plus rien à comparer.
dailyGuessView(puzzle, cardId) {
const guess = this.index.cards.get(cardId);
const clues = guess ? compareClues(this.dailyClues, this.index.cards.get(puzzle.cardId), guess) : { subject: { common: [], different: null }, theme: null };
return { cardId, correct: cardId === puzzle.cardId, ...clues };
}
// Valeur d'un indice retourné : seuls ceux-là quittent le serveur.
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;
return id === "page" ? damagedPage(card) : nameShape(card.name);
}
dailyHintChoices(puzzle) {
const wrong = this.dailyWrongCount(puzzle);
return DAILY_HINTS.map(({ id, after }) => ({ id, after, available: puzzle.status === "playing" && canUseDailyHint(id, wrong, puzzle.hints) }));
}
// Mots qui font aussi trouver une carte dans la liste des propositions (« pingouin » pour un manchot).
dailySearchWords(collectionIds) {
const open = new Set(collectionIds);
return Object.fromEntries(this.catalog.cards.filter((card) => open.has(card.collectionId) && this.dailyClues.cards[card.id]?.search).map((card) => [card.id, this.dailyClues.cards[card.id].search]));
}
// La réponse n'est envoyée qu'une fois la partie terminée, et l'illustration n'arrive que recadrée (voir dailyImage).
@ -950,7 +989,10 @@ export class CardsService {
maxGuesses: MAX_DAILY_GUESSES,
zoom: this.dailyPuzzleZoom(puzzle),
status: puzzle.status,
guesses: puzzle.guesses.map((cardId) => guessHint(this.catalog, puzzle.cardId, cardId)),
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),
collectionIds: this.dailyCollectionIds(playerId, puzzle.cardId),
reward: this.shopSetting.dailyReward,
earned: puzzle.earned,
@ -961,7 +1003,8 @@ export class CardsService {
}
getDaily(playerId) {
return this.dailyView(playerId, this.todayPuzzle(playerId));
const view = this.dailyView(playerId, this.todayPuzzle(playerId));
return { ...view, searchWords: this.dailySearchWords(view.collectionIds) };
}
// Résumé pour le tableau de bord du joueur, sans tirer sa carte : il n'en a une qu'en ouvrant la Carte du jour.
@ -1001,6 +1044,23 @@ export class CardsService {
return { daily, state: this.getState(playerId) };
}
// Un indice par essai raté, au choix ; il ne coûte aucun essai et vaut pour le jour annoncé par le client.
useDailyHint(playerId, { day, hint } = {}) {
if (!isDayKey(day) || !DAILY_HINTS.some((item) => item.id === hint)) fail(400, "DAILY_HINT_INVALID", "Indice invalide.");
return this.database.transaction(() => {
const today = dailyDayKey(this.now());
if (day !== today) fail(409, "DAILY_EXPIRED", "Une nouvelle Carte du jour est arrivée : rechargez la partie.");
const puzzle = this.ensureDailyPuzzle(playerId, today);
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.");
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 });
});
}
// Ce que l'API doit envoyer de l'illustration du joueur : le fichier, le point de zoom et le zoom courant.
dailyImage(playerId) {
const puzzle = this.todayPuzzle(playerId);