Rework the daily card page around what the player knows and hints opened in any order
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6993080d81
commit
880f007cce
24 changed files with 812 additions and 415 deletions
|
|
@ -470,3 +470,4 @@
|
|||
{"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"}}
|
||||
{"id":"int-713bb81bbe6b5a692cc892313d4a7a78","kind":"field_change","created_at":"2026-11-25T08:36:07.250219052Z","actor":"Shinuwa","issue_id":"sokko-g-gaen","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Réglages verrouillés (Boutique, Guilde, Collections) jusqu'au rechargement des données ; E2E avec requêtes ralenties, qui échoue sans le correctif."}}
|
||||
{"id":"int-a3d3c093a559038cc8b7b6db96f6de98","kind":"field_change","created_at":"2026-11-25T11:03:41.887954851Z","actor":"Shinuwa","issue_id":"sokko-g-bj77","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Illustration, description, mot de recherche et document mis à jour ; tests, garde des images et E2E Sokko TCG passent."}}
|
||||
{"id":"int-4088c2c07b8a4f26cfa3131309c1e737","kind":"field_change","created_at":"2026-11-25T13:00:43.332505594Z","actor":"Shinuwa","issue_id":"sokko-g-wb4a","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Page de la Carte du jour refondue dans le jeu, tests et documentation à jour"}}
|
||||
|
|
|
|||
|
|
@ -1637,19 +1637,22 @@ a en couverture (96 px) un dos de carte vierge, propre à aucune collection (`em
|
|||
les pages Guilde et Carte du jour (`daily`, sans entrée propre), le menu désigne la Guilde. La page Guilde n'a pas de
|
||||
bouton de retour, l'Accueil étant dans le menu ; la Carte du jour garde dans son en-tête un retour (`nds-button` `sm`
|
||||
secondaire) vers la Guilde.
|
||||
La Carte du jour place côte à côte l'illustration carrée (360 px au plus),
|
||||
recadrée par le serveur sur la zone visible au zoom courant (chaque nouveau morceau apparaît en fondu), avec une rangée de six
|
||||
pastilles d'essais (gris : raté, `warning` : même thème ou deux étapes du sujet en commun, `success` : trouvée), et
|
||||
une colonne de jeu. Celle-ci contient le formulaire `nds-panel` avec `CategoryAutocompleteInput`
|
||||
(le panneau laisse dépasser les suggestions, que la prop `keywords` complète de mots proches), puis la grille des six
|
||||
essais (`.nebula-daily-row` : carte, chemin du sujet, thème), dont les lignes à venir gardent la hauteur stable. Une étape ou
|
||||
un thème trouvé porte ✓ sur fond `success`, une étape fausse ✗ et un texte barré. Dessous, sur toute la largeur, cinq tuiles
|
||||
d'indice (`.nebula-daily-hint`, `data-state` `locked`, `ready` bordée d'or, `open`) se retournent sur place. La partie, hors en-tête
|
||||
de page, tient dans un écran de 1280 × 720 : l'illustration se resserre à 268 px sous 1200 px de conteneur. Sous 720 px,
|
||||
les deux colonnes s'empilent et les tuiles passent en 3 + 2. La fin de partie remplace
|
||||
le formulaire par un `nds-panel` : titre, réponse et description, badges (poussière gagnée,
|
||||
possession, série), bouton primaire « Copier le résultat » et compte à rebours, avec la carte
|
||||
en `md` à droite.
|
||||
La Carte du jour (`_nebula-daily.scss`, container `nebula-daily`) place côte à côte l'illustration carrée (panneau de 340 px au plus,
|
||||
380 px dès 1000 px de container), recadrée par le serveur sur la zone visible au zoom courant (chaque nouveau morceau apparaît en
|
||||
fondu), et le panneau de saisie : question, piste de six essais (`.nebula-daily-track`, ✗ raté, ≈ proche en `warning`, ✓ trouvée en
|
||||
`success`, numéro en cours en violet), `CategoryAutocompleteInput` en mode recherche (`searchTexts` : liste après saisie, texte trouvé
|
||||
surligné, « mot proche », cartes déjà proposées grisées, absence de résultat dite, Entrée prend la première option ; `keywords` donne
|
||||
les mots proches ; la liste couvre toute la ligne), puis les règles du départ ou le bilan du dernier essai et « Ce que vous savez »
|
||||
(`.nebula-daily-know`, pastilles `.nebula-daily-chip`, contour `success` ou texte `warning` sur ce que le dernier essai apprend).
|
||||
Dessous, sur toute la largeur, cinq cadres d'indice (`.nebula-daily-hint`, `data-state` `locked`, `ready` bordé d'or avec sa loupe pleine,
|
||||
`open`) dans une grille de trois colonnes à hauteur fixe de 88 px : aucun ne change de taille quand un autre s'ouvre. Une pastille
|
||||
(`.nebula-daily-purse`) compte les indices à dévoiler, une loupe chacun. Icônes au trait dans `DailyIcon`. Enfin la grille des essais
|
||||
joués (`.nebula-daily-guess`) : vert, comme la réponse ; barré, différent ; le mot du nom qui donne le thème est souligné ; avant le premier
|
||||
essai, les cinq familles de sujets. En 1280 × 720, l'illustration, la saisie et les indices tiennent sous le bandeau du site ; sous
|
||||
620 px de container, tout passe sur une colonne. La fin de partie met la carte (`md`, 270 px au plus) et sa possession à la place de
|
||||
l'illustration, et à la place de la saisie un panneau : résultat, indices utilisés, piste, description, « La réponse » (même
|
||||
cadre que « Ce que vous savez » ; après une défaite, en gris ce que le joueur n'avait pas trouvé), gains d'une victoire,
|
||||
bouton primaire « Copier le résultat » et compte à rebours. Les indices n'y sont plus affichés.
|
||||
|
||||
Les Expéditions (`expeditions`, sans entrée propre : le menu désigne la Guilde) ont leur tuile dans la
|
||||
Guilde tant qu'elles sont ouvertes ou qu'une expédition du joueur n'est pas terminée. Leur page
|
||||
|
|
|
|||
|
|
@ -106,15 +106,16 @@ Carte du jour (migrations 7, 18 et 26, règles pures dans `services/cards/daily.
|
|||
`focus_y` situent le point zoomé (20 à 80 % de l'image) ; `guesses_json` liste les cartes
|
||||
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 ;
|
||||
passées avec la carte commune de leur jour. `hints_json` liste les indices dévoilés, dans l'ordre ;
|
||||
`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
|
||||
contient celui de la précédente ; `phrase`, son nom avec l'article ; `sentences`, ses phrases propres), 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
|
||||
communes ; `subject.different`, la première qui diffère, chacune avec `label`, `phrase` et parfois `sentences` ; `theme`, dont `span`
|
||||
situe dans le nom le mot qui le donne), indices dévoilés (`hints`), indices
|
||||
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
|
||||
cartes peuvent être proposées et mots de recherche de ces cartes (`searchWords`). `answerCardId` et `answerClues` (sujet et thème) ne sont renvoyés 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
|
||||
(`Cache-Control: private, no-store`) pour ne pas révéler la carte par son nom de fichier.
|
||||
|
|
@ -126,9 +127,9 @@ 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`, `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.
|
||||
- `POST /api/cards/daily/hints` (`{ day, hint }`) : dévoile un indice (`album`, `collection`, `theme`,
|
||||
`shape`, `page`), un par essai raté et dans n'importe quel ordre, sans coûter d'essai. `DAILY_HINT_INVALID`, `DAILY_HINT_LOCKED`, `DAILY_EXPIRED` ou
|
||||
`DAILY_FINISHED` sinon ; un indice déjà dévoilé est renvoyé tel quel. Les mots cachés de la description et du nom ne sont jamais envoyés.
|
||||
|
||||
Expéditions (migration 8, règles pures dans `services/cards/expedition-rules.js`, service dans
|
||||
`services/cards/expedition-service.js`, réglages dans `services/cards/expedition-settings.js`) :
|
||||
|
|
|
|||
|
|
@ -9,19 +9,26 @@ Décidé avec le propriétaire du jeu le 24 novembre 2026. Le format des donnée
|
|||
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.
|
||||
|
||||
Tous reçoivent les mêmes comparaisons et peuvent retourner les mêmes indices, au choix : rien à l'écran ne trahit si la carte est possédée, sauf l'indice qui le dit. Retourner un indice ne coûte ni essai ni récompense ; le résultat partagé affiche leur nombre (💡).
|
||||
Tous reçoivent les mêmes comparaisons et peuvent dévoiler les mêmes indices, au choix : rien à l'écran ne trahit si la carte est possédée, sauf l'indice qui le dit. Dévoiler un indice ne coûte ni essai ni récompense ; le résultat partagé affiche leur nombre (💡).
|
||||
|
||||
## Ce que montre chaque essai
|
||||
|
||||
- **Sujet** : les étapes communes à la carte proposée et à la réponse, puis la première qui diffère. La suite du chemin de la réponse et sa longueur restent cachées.
|
||||
- **Thème du nom** : le même ou non.
|
||||
- **Thème** : le même ou non, et le mot du nom de la carte proposée qui le donne, souligné.
|
||||
- Une phrase sur le sujet, qui dit aussi quand l'essai n'apprend rien (« vous le saviez déjà »), puis **« Ce que vous savez »** : le meilleur chemin trouvé, les étapes écartées juste après lui et le thème. Rien de ce qui est acquis ne disparaît à l'essai suivant ; ce que le dernier essai apprend est en couleur.
|
||||
- La grille garde tous les essais : vert, comme la réponse ; barré, différent.
|
||||
|
||||
| Indice au choix | Dès |
|
||||
Un essai raté = un indice à dévoiler, n'importe lequel et dans n'importe quel ordre (décidé le 25 novembre 2026, sans seuil) :
|
||||
|
||||
| Indice | Ce qu'il dit |
|
||||
|---|---|
|
||||
| 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 |
|
||||
| Dans votre album | possédée au tirage ou non |
|
||||
| Collection | sa collection |
|
||||
| Thème | celui de son nom ; affiché sans rien coûter si un essai l'a déjà trouvé |
|
||||
| Nom à trous | ses petits mots, sans la longueur des autres |
|
||||
| Description partielle | première phrase de la description, sans les mots du nom |
|
||||
|
||||
Pris seul, sans les comparaisons, le nom à trous laisse 8,9 cartes en moyenne, le thème 14,8 et la collection 52 : aucun ne donne la réponse dès le premier essai. La partie finie, la réponse complète remplace les indices.
|
||||
|
||||
## Les données
|
||||
|
||||
|
|
@ -29,10 +36,11 @@ Tout est dans [daily-clues.json](../services/cards/content/daily-clues.json) ; l
|
|||
|
||||
### L'arbre des sujets
|
||||
|
||||
Cinq familles : **Animal** (existe dans la réalité), **Objet** (fabriqué), **Nature** (naturel sans être un animal), **Créature fantastique** (vivante sans exister dans la réalité), **Lieu** (on s'y rend). On classe le sujet principal de l'illustration, pas son décor ni ses pouvoirs.
|
||||
Cinq familles : **Animal** (inspiré d'un animal réel), **Objet** (fabriqué), **Nature** (naturel sans être un animal), **Créature fantastique** (vivante sans exister dans la réalité), **Lieu** (on s'y rend). On classe le sujet principal de l'illustration, pas son décor ni ses pouvoirs.
|
||||
|
||||
- Un mot = un seul concept : ni « et », ni « ou », ni « autre ».
|
||||
- Une branche s'ouvre quand plusieurs espèces ou plusieurs cartes la remplissent : une espèce isolée s'arrête à l'étape du dessus (le phoque à « Mammifère »), sinon la branche donnerait la réponse.
|
||||
- Chaque étape a son étiquette (`label`) et son nom dans une phrase (`phrase`, « un canidé »). `sentences` remplace au besoin les phrases du site : l'étiquette « Animal » reste courte, sa phrase dit « inspirée d'un animal réel ».
|
||||
- 15 cartes au plus par branche, un test le vérifie : au-delà, on la découpe.
|
||||
- La profondeur varie d'une famille à l'autre.
|
||||
- Branches peu fournies, à alimenter par de nouvelles cartes : Poisson et Invertébré, Phénomène et Trace, Passage, Musique.
|
||||
|
|
@ -63,6 +71,9 @@ Au 24 novembre 2026, le sujet seul laisse 7,6 cartes en moyenne sur 246, le suje
|
|||
- Indices différents ou dans un autre ordre selon la possession : les montrer la trahit.
|
||||
- É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.
|
||||
- Longueur ou première lettre des mots dans le nom à trous : 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.
|
||||
- Baisse de la récompense quand on dévoile un indice.
|
||||
- Seuils d'essais ratés par indice : ils compliquaient les règles sans protéger la réponse.
|
||||
- Dans les propositions : vignettes des cartes et retrait des cartes devenues impossibles, qui joueraient à la place du joueur.
|
||||
- Bilan du seul dernier essai : il faisait oublier ce qui était acquis.
|
||||
|
|
|
|||
|
|
@ -2115,52 +2115,83 @@ test("a player finds the daily card with hints and copies the result", async ({
|
|||
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);
|
||||
await expect(hints).toContainText("Aucun indice à dévoiler");
|
||||
// Avant le premier essai, les règles et les cinq familles de sujets.
|
||||
await expect(page.locator(".nebula-daily-rules li")).toHaveCount(3);
|
||||
await expect(page.locator(".nebula-daily-families li")).toHaveCount(5);
|
||||
|
||||
const input = page.getByRole("combobox", { name: /^Votre proposition/ });
|
||||
const input = page.getByRole("combobox", { name: "Quelle est cette carte ?" });
|
||||
const propose = page.getByRole("button", { name: "Proposer", exact: true });
|
||||
await expect(propose).toBeDisabled();
|
||||
await input.fill("zzz");
|
||||
await expect(page.getByRole("option")).toHaveText(["Aucune carte pour « zzz »."]);
|
||||
await expect(propose).toBeDisabled();
|
||||
// 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();
|
||||
await expect(page.getByRole("option", { name: "Manchot des Glaces Étoilées" })).toContainText("mot proche : pingouin");
|
||||
// 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.
|
||||
await expectOpenMenuVisible(page, ".nebula-daily-form .nds-autocomplete-menu");
|
||||
await page.getByRole("option", { name: wrong, exact: true }).click();
|
||||
await page.getByRole("button", { name: "Proposer", exact: true }).click();
|
||||
// Entrée prend la première suggestion, puis propose la carte choisie.
|
||||
await input.fill(wrong.slice(0, -1));
|
||||
await input.press("Enter");
|
||||
await expect(input).toHaveValue(wrong);
|
||||
await input.press("Enter");
|
||||
const guesses = page.locator(".nebula-daily-guess");
|
||||
await expect(guesses).toHaveCount(1);
|
||||
await expect(guesses.first()).toContainText(wrong);
|
||||
await expect(guesses.first().locator(".nebula-daily-step").first()).toBeVisible();
|
||||
await expect(guesses.first().locator(".nebula-daily-theme")).toBeVisible();
|
||||
await expect(guesses.first().locator("u")).toHaveCount(1);
|
||||
const feedback = page.locator(".nebula-daily-feedback");
|
||||
await expect(feedback).toContainText(`${wrong} : raté`);
|
||||
await expect(feedback.getByRole("heading", { name: "Ce que vous savez" })).toBeVisible();
|
||||
// La saisie reprend la main ; une carte proposée est citée sans pouvoir être choisie.
|
||||
await expect(input).toBeFocused();
|
||||
await input.fill(wrong);
|
||||
await expect(page.locator(".nebula-daily-form [role=option][aria-disabled=true]")).toContainText("déjà proposée");
|
||||
await expect(propose).toBeDisabled();
|
||||
await input.fill("");
|
||||
// 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);
|
||||
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);
|
||||
await expect(page.locator(`.nebula-daily-track li[data-result="${close ? "close" : "miss"}"]`)).toHaveCount(1);
|
||||
|
||||
// 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(2);
|
||||
// Un essai raté donne un indice à dévoiler, n'importe lequel ; il s'ouvre sur place, sans changer la taille des cadres, et referme les autres.
|
||||
await expect(hints).toContainText("1 indice à dévoiler");
|
||||
const sameTheme = await guesses.first().locator(".nebula-daily-theme[data-same]").count();
|
||||
await expect(hints.getByRole("button", { disabled: false })).toHaveCount(5 - sameTheme);
|
||||
const frames = () => hints.locator("li").evaluateAll((items) => items.map((item) => [item.offsetWidth, item.offsetHeight].join("×")));
|
||||
const closedFrames = await frames();
|
||||
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.locator(".nebula-daily-hint[data-hint=album][data-state=open]")).toContainText(/Oui, vous l’avez|Non, pas encore/);
|
||||
expect(await frames()).toEqual(closedFrames);
|
||||
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);
|
||||
// L'image, la saisie et les indices tiennent dans un écran de 1280 × 720 sous le bandeau du site (68 px).
|
||||
await expect.poll(() => page.locator(".nebula-daily-layout").evaluate((layout) => layout.querySelector(".nebula-daily-hints").getBoundingClientRect().bottom - layout.getBoundingClientRect().top)).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-start.png"), fullPage: true });
|
||||
expect(await page.evaluate(() => [...globalThis.document.querySelectorAll(".nebula-daily-guess > *, .nebula-daily-hint > *, .nebula-daily-form")].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();
|
||||
await propose.click();
|
||||
const result = page.locator(".nebula-daily-result");
|
||||
await expect(result.getByRole("heading", { name: "Trouvée en 2/6 !" })).toBeVisible();
|
||||
await expect(result).toContainText("+10 poussières gagnées");
|
||||
await expect(result.locator(".nebula-daily-answer strong")).toHaveText(answer);
|
||||
await expect(result.locator(".nebula-card")).toBeVisible();
|
||||
// La partie finie, l'illustration entière arrive à sa taille d'origine, à la place des morceaux de 720 px.
|
||||
await expect.poll(() => image.evaluate((element) => element.naturalWidth)).not.toBe(720);
|
||||
await expect(page.getByRole("combobox", { name: /^Votre proposition/ })).toHaveCount(0);
|
||||
await expect(result.getByRole("heading", { name: "Trouvée en 2 essais !" })).toBeVisible();
|
||||
await expect(result).toContainText("1 indice utilisé");
|
||||
await expect(result).toContainText("+10 poussières");
|
||||
await expect(result.getByRole("heading", { name: "La réponse" })).toBeVisible();
|
||||
await expect(result.locator(".nebula-daily-chip[data-found]").first()).toBeVisible();
|
||||
// La partie finie, la carte prend la place de l'illustration zoomée, et les indices s'effacent.
|
||||
await expect(page.locator(".nebula-daily-stage .nebula-card")).toContainText(answer);
|
||||
await expect(image).toHaveCount(0);
|
||||
await expect(hints).toHaveCount(0);
|
||||
await expect(input).toHaveCount(0);
|
||||
await page.screenshot({ path: join(tmpdir(), "sokkog-cards-daily-won.png"), fullPage: true });
|
||||
|
||||
await result.getByRole("button", { name: "Copier le résultat", exact: true }).click();
|
||||
await expect(result.getByRole("button", { name: "Résultat copié", exact: true })).toBeVisible();
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
{
|
||||
"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": "Créature 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"}
|
||||
{"id": "animal", "label": "Animal", "phrase": "un animal", "sentences": {"same": "Sa famille est bien inspirée d’{subject} réel", "different": "Sa famille n’est pas inspirée d’{subject} réel", "but": ", mais pas d’{subject}"}},
|
||||
{"id": "animal/amphibien", "label": "Amphibien", "phrase": "un amphibien"},
|
||||
{"id": "animal/invertebre", "label": "Invertébré", "phrase": "un invertébré"},
|
||||
{"id": "animal/mammifere", "label": "Mammifère", "phrase": "un mammifère"},
|
||||
{"id": "animal/mammifere/canide", "label": "Canidé", "phrase": "un canidé"},
|
||||
{"id": "animal/mammifere/chauve-souris", "label": "Chauve-souris", "phrase": "une chauve-souris"},
|
||||
{"id": "animal/mammifere/felin", "label": "Félin", "phrase": "un félin"},
|
||||
{"id": "animal/mammifere/herisson", "label": "Hérisson", "phrase": "un hérisson"},
|
||||
{"id": "animal/mammifere/mustelide", "label": "Mustélidé", "phrase": "un mustélidé"},
|
||||
{"id": "animal/mammifere/ongule", "label": "Ongulé", "phrase": "un ongulé"},
|
||||
{"id": "animal/mammifere/panda", "label": "Panda", "phrase": "un panda"},
|
||||
{"id": "animal/mammifere/raton-laveur", "label": "Raton laveur", "phrase": "un raton laveur"},
|
||||
{"id": "animal/mammifere/rongeur", "label": "Rongeur", "phrase": "un rongeur"},
|
||||
{"id": "animal/mammifere/suricate", "label": "Suricate", "phrase": "un suricate"},
|
||||
{"id": "animal/oiseau", "label": "Oiseau", "phrase": "un oiseau"},
|
||||
{"id": "animal/oiseau/aquatique", "label": "Aquatique", "phrase": "un oiseau aquatique"},
|
||||
{"id": "animal/oiseau/passereau", "label": "Passereau", "phrase": "un passereau"},
|
||||
{"id": "animal/oiseau/rapace", "label": "Rapace", "phrase": "un rapace"},
|
||||
{"id": "animal/poisson", "label": "Poisson", "phrase": "un poisson"},
|
||||
{"id": "animal/reptile", "label": "Reptile", "phrase": "un reptile"},
|
||||
{"id": "objet", "label": "Objet", "phrase": "un objet"},
|
||||
{"id": "objet/accessoire", "label": "Accessoire", "phrase": "un accessoire"},
|
||||
{"id": "objet/aliment", "label": "Aliment", "phrase": "un aliment"},
|
||||
{"id": "objet/contenant", "label": "Contenant", "phrase": "un contenant"},
|
||||
{"id": "objet/decoration", "label": "Décoration", "phrase": "une décoration"},
|
||||
{"id": "objet/document", "label": "Document", "phrase": "un document"},
|
||||
{"id": "objet/instrument", "label": "Instrument", "phrase": "un instrument"},
|
||||
{"id": "objet/jeu", "label": "Jeu", "phrase": "un jeu"},
|
||||
{"id": "objet/luminaire", "label": "Luminaire", "phrase": "un luminaire"},
|
||||
{"id": "objet/musique", "label": "Musique", "phrase": "un objet de musique"},
|
||||
{"id": "objet/outil", "label": "Outil", "phrase": "un outil"},
|
||||
{"id": "nature", "label": "Nature", "phrase": "un élément de la nature"},
|
||||
{"id": "nature/astre", "label": "Astre", "phrase": "un astre"},
|
||||
{"id": "nature/constellation", "label": "Constellation", "phrase": "une constellation"},
|
||||
{"id": "nature/mineral", "label": "Minéral", "phrase": "un minéral"},
|
||||
{"id": "nature/phenomene", "label": "Phénomène", "phrase": "un phénomène"},
|
||||
{"id": "nature/plante", "label": "Plante", "phrase": "une plante"},
|
||||
{"id": "nature/trace", "label": "Trace", "phrase": "une trace"},
|
||||
{"id": "fantastique", "label": "Créature fantastique", "phrase": "une créature fantastique"},
|
||||
{"id": "fantastique/dragon", "label": "Dragon", "phrase": "un dragon"},
|
||||
{"id": "fantastique/yokai", "label": "Yokai", "phrase": "un yokai"},
|
||||
{"id": "lieu", "label": "Lieu", "phrase": "un lieu"},
|
||||
{"id": "lieu/batiment", "label": "Bâtiment", "phrase": "un bâtiment"},
|
||||
{"id": "lieu/espace", "label": "Espace", "phrase": "un espace"},
|
||||
{"id": "lieu/passage", "label": "Passage", "phrase": "un passage"},
|
||||
{"id": "lieu/paysage", "label": "Paysage", "phrase": "un paysage"}
|
||||
],
|
||||
"themes": [
|
||||
{"id": "star", "label": "Étoile", "words": ["étoile", "étoiles", "étoilée", "étoilées", "constellation", "constellations", "astres", "poussière", "poussières"]},
|
||||
|
|
|
|||
|
|
@ -1,26 +1,19 @@
|
|||
// 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.
|
||||
// Rôle : indices de la Carte du jour : sujet (arbre) et thème du nom de chaque carte, comparaison d'un essai, description partielle
|
||||
// et nom à trous. 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. 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: "collection", after: 1 }),
|
||||
Object.freeze({ id: "page", after: 2 }),
|
||||
Object.freeze({ id: "theme", after: 3 }),
|
||||
Object.freeze({ id: "shape", after: 4 })
|
||||
]);
|
||||
// Indices facultatifs, dans leur ordre d'affichage : un par essai raté, dans l'ordre que choisit le joueur.
|
||||
export const DAILY_HINTS = Object.freeze(["album", "collection", "theme", "shape", "page"]);
|
||||
|
||||
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.
|
||||
// Petits mots laissés lisibles dans le nom à trous et jamais masqués dans la description.
|
||||
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"]);
|
||||
|
||||
|
|
@ -28,6 +21,8 @@ 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) || [];
|
||||
// Mots d'un nom avec leur place dans le texte d'origine.
|
||||
const placedTokens = (text) => [...text.matchAll(/[\p{L}\p{N}]+/gu)].map((match) => ({ key: plain(match[0]), start: match.index, end: match.index + match[0].length }));
|
||||
|
||||
// Table « suite de mots → thème ». Un mot ne désigne jamais deux thèmes.
|
||||
function wordTable(themes, field) {
|
||||
|
|
@ -43,12 +38,13 @@ function wordTable(themes, field) {
|
|||
return table;
|
||||
}
|
||||
|
||||
// Premier thème rencontré en lisant les mots, l'expression la plus longue d'abord (« voie lactée » avant « lactée »).
|
||||
// Premier thème rencontré en lisant les mots, l'expression la plus longue d'abord (« voie lactée » avant « lactée »), et sa place.
|
||||
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;
|
||||
const found = words.slice(start, start + size);
|
||||
const theme = table.get(found.map((word) => word.key).join(" "));
|
||||
if (theme) return { id: theme, span: [found[0].start, found.at(-1).end] };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
@ -61,9 +57,9 @@ function themeReader(content) {
|
|||
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;
|
||||
let words = placedTokens(name);
|
||||
if (ARTICLES.has(words[0]?.key)) words = words.slice(1);
|
||||
const subjectLength = compounds.find((compound) => compound.every((word, index) => words[index]?.key === word))?.length ?? 1;
|
||||
const rest = words.slice(subjectLength);
|
||||
return firstTheme(rest, strong) || firstTheme(rest, weak) || firstTheme(words.slice(0, subjectLength), strong);
|
||||
};
|
||||
|
|
@ -79,6 +75,13 @@ function requireLabelled(items, pattern, name) {
|
|||
return ids;
|
||||
}
|
||||
|
||||
// Phrases propres à un sujet, à la place de celles du site : tout ou rien, et chacune nomme le sujet.
|
||||
const SENTENCE_KEYS = ["same", "different", "but"];
|
||||
function requireSubjectTexts(subject) {
|
||||
if (typeof subject.phrase !== "string" || !/^une? /.test(subject.phrase)) throw new TypeError(`Daily subject ${subject.id} needs a phrase starting with « un » or « une ».`);
|
||||
if (subject.sentences && !SENTENCE_KEYS.every((key) => subject.sentences[key]?.includes("{subject}"))) throw new TypeError(`Daily subject ${subject.id} needs sentences that name it: ${SENTENCE_KEYS.join(", ")}.`);
|
||||
}
|
||||
|
||||
// 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");
|
||||
|
|
@ -86,16 +89,19 @@ export function prepareDailyClues(content) {
|
|||
const parent = id.split("/").slice(0, -1).join("/");
|
||||
if (parent && !subjectIds.has(parent)) throw new TypeError(`Daily subject ${id} has no parent ${parent}.`);
|
||||
}
|
||||
content.subjects.forEach(requireSubjectTexts);
|
||||
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.`);
|
||||
}
|
||||
const themeMatch = themeReader(content);
|
||||
return {
|
||||
subjectLabels: new Map(content.subjects.map((subject) => [subject.id, subject.label])),
|
||||
subjects: new Map(content.subjects.map(({ id, ...step }) => [id, step])),
|
||||
themeLabels: new Map(content.themes.map((theme) => [theme.id, theme.label])),
|
||||
cards: content.cards,
|
||||
themeOf: themeReader(content)
|
||||
themeMatch,
|
||||
themeOf: (name) => themeMatch(name)?.id ?? null
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -120,25 +126,35 @@ export function dailyCluesIssues(catalog, clues) {
|
|||
return issues;
|
||||
}
|
||||
|
||||
// Étapes du sujet d'une carte, de la famille à l'espèce, et thème de son nom.
|
||||
function subjectSteps(clues, card) {
|
||||
const path = clues.cards[card.id]?.subject?.split("/") || [];
|
||||
return path.map((_, index) => clues.subjects.get(path.slice(0, index + 1).join("/")));
|
||||
}
|
||||
function themeView(clues, card) {
|
||||
const match = clues.themeMatch(card.name);
|
||||
return match && { label: clues.themeLabels.get(match.id), span: match.span };
|
||||
}
|
||||
|
||||
// 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.
|
||||
// de la réponse (ni sa longueur). Thème : celui de l'essai, le mot de son nom qui le donne, 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);
|
||||
const mine = subjectSteps(clues, answer);
|
||||
const theirs = subjectSteps(clues, 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);
|
||||
const theme = themeView(clues, guess);
|
||||
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
|
||||
subject: { common: theirs.slice(0, common), different: theirs[common] ?? null },
|
||||
theme: theme && { ...theme, same: clues.themeOf(guess.name) === clues.themeOf(answer.name) }
|
||||
};
|
||||
}
|
||||
|
||||
// Indices complets de la réponse, pour la fin de partie.
|
||||
export function answerClues(clues, answer) {
|
||||
return { subject: subjectSteps(clues, answer), theme: themeView(clues, answer) };
|
||||
}
|
||||
|
||||
const textParts = (text) => text.split(/([\p{L}\p{N}]+)/u).filter(Boolean);
|
||||
const isWord = (part) => /[\p{L}\p{N}]/u.test(part);
|
||||
|
||||
|
|
@ -155,8 +171,8 @@ function sameFamily(left, right) {
|
|||
// 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) {
|
||||
// Description partielle : sa première phrase, sans les mots de la famille de ceux du nom.
|
||||
export function partialDescription(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) => {
|
||||
|
|
@ -165,18 +181,17 @@ export function damagedPage(card) {
|
|||
}));
|
||||
}
|
||||
|
||||
// Forme du nom : ses petits mots et sa ponctuation, sans la longueur des autres mots.
|
||||
// Nom à trous : 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.
|
||||
// Un indice par essai raté, au choix.
|
||||
export function dailyHintCredits(wrongCount, usedCount) {
|
||||
return Math.max(0, Math.min(wrongCount, DAILY_HINTS.length) - usedCount);
|
||||
}
|
||||
|
||||
// `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) && !known.includes(hintId) && !used.includes(hintId) && wrongCount >= hint.after && dailyHintCredits(wrongCount, used.length) > 0;
|
||||
return DAILY_HINTS.includes(hintId) && !known.includes(hintId) && !used.includes(hintId) && dailyHintCredits(wrongCount, used.length) > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ 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, isDayKey, MAX_DAILY_GUESSES, nextDailyAt, shiftDayKey } from "./daily.js";
|
||||
import { canUseDailyHint, compareClues, DAILY_HINTS, dailyHintCredits, damagedPage, loadDailyClues, nameShape } from "./daily-clues.js";
|
||||
import { answerClues, canUseDailyHint, compareClues, DAILY_HINTS, dailyHintCredits, loadDailyClues, nameShape, partialDescription } 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";
|
||||
|
|
@ -960,13 +960,13 @@ export class CardsService {
|
|||
return { cardId, correct: cardId === puzzle.cardId, ...clues };
|
||||
}
|
||||
|
||||
// Valeur d'un indice retourné : seuls ceux-là quittent le serveur.
|
||||
// Valeur d'un indice dévoilé : 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 === "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);
|
||||
return id === "page" ? partialDescription(card) : nameShape(card.name);
|
||||
}
|
||||
|
||||
// Le thème n'est plus un indice dès qu'un essai l'a trouvé.
|
||||
|
|
@ -979,7 +979,7 @@ export class CardsService {
|
|||
dailyHintChoices(puzzle) {
|
||||
const wrong = this.dailyWrongCount(puzzle);
|
||||
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) }));
|
||||
return DAILY_HINTS.map((id) => ({ id, 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).
|
||||
|
|
@ -1001,14 +1001,15 @@ export class CardsService {
|
|||
guesses: puzzle.guesses.map((cardId) => this.dailyGuessView(puzzle, cardId)),
|
||||
hints: puzzle.hints.map((id) => ({ id, value: this.dailyHintValue(puzzle, id) })),
|
||||
hintChoices,
|
||||
// Jamais plus que d'indices à retourner : un thème déjà trouvé laisse un crédit sans emploi.
|
||||
// Jamais plus que d'indices à dévoiler : 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,
|
||||
streak: this.dailyStreak(playerId, puzzle.day),
|
||||
nextAt: nextDailyAt(this.now()),
|
||||
answerCardId: finished ? puzzle.cardId : null
|
||||
answerCardId: finished ? puzzle.cardId : null,
|
||||
answerClues: finished ? answerClues(this.dailyClues, this.index.cards.get(puzzle.cardId)) : null
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1056,13 +1057,13 @@ export class CardsService {
|
|||
|
||||
// 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.");
|
||||
if (!isDayKey(day) || !DAILY_HINTS.includes(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.
|
||||
// Dévoiler 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, this.dailyKnownHints(puzzle))) fail(409, "DAILY_HINT_LOCKED", "Cet indice n’est pas encore disponible.");
|
||||
const hints = [...puzzle.hints, hint];
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ import sharp from "sharp";
|
|||
import { createCardsApiHandler } from "../services/cards/api.js";
|
||||
import { buildPublishedCatalog, prepareVersionedCatalog } from "../services/cards/catalog.js";
|
||||
import { computeStreak, dailyCandidates, dailyCrop, dailyDayKey, dailyZoom, drawDailyPuzzle, MAX_DAILY_GUESSES, nextDailyAt, shiftDayKey } from "../services/cards/daily.js";
|
||||
import { canUseDailyHint, compareClues, DAILY_HINTS, dailyCluesIssues, dailyHintCredits, damagedPage, loadDailyClues, nameShape, prepareDailyClues } from "../services/cards/daily-clues.js";
|
||||
import { answerClues, canUseDailyHint, compareClues, DAILY_HINTS, dailyCluesIssues, dailyHintCredits, loadDailyClues, nameShape, partialDescription, prepareDailyClues } from "../services/cards/daily-clues.js";
|
||||
import { CardsDatabase } from "../services/cards/database.js";
|
||||
import { CardsService } from "../services/cards/service.js";
|
||||
import { dailyKnowledge, dailyVerdict } from "../website/src/features/cards/dailyKnowledge.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 }];
|
||||
|
|
@ -83,31 +84,58 @@ test("a daily theme comes from the words of the name, the subject only by defaul
|
|||
assert.equal(theme("Encrier Astral"), "Cosmos");
|
||||
assert.equal(theme("Constellation du Loup"), "Lumière");
|
||||
assert.equal(theme("Premier Croissant"), "Lune");
|
||||
const content = { subjects: [{ id: "animal", label: "Animal" }], themes: [{ id: "one", label: "Un", words: ["lune"] }, { id: "two", label: "Deux", words: ["Lune"] }], compoundSubjects: [], cards: {} };
|
||||
const content = { subjects: [{ id: "animal", label: "Animal", phrase: "un animal" }], themes: [{ id: "one", label: "Un", words: ["lune"] }, { id: "two", label: "Deux", words: ["Lune"] }], compoundSubjects: [], cards: {} };
|
||||
assert.throws(() => prepareDailyClues(content), /already belongs to one/);
|
||||
assert.throws(() => prepareDailyClues({ ...content, themes: [], subjects: [{ id: "animal/oiseau", label: "Oiseau" }] }), /has no parent animal/);
|
||||
assert.throws(() => prepareDailyClues({ ...content, themes: [], cards: { card: { subject: "objet" } } }), /unknown subject objet/);
|
||||
const subject = (extra) => prepareDailyClues({ ...content, themes: [], subjects: [{ id: "animal", label: "Animal", ...extra }] });
|
||||
assert.throws(() => subject({ phrase: "animal" }), /needs a phrase/);
|
||||
assert.throws(() => subject({ phrase: "un animal", sentences: { same: "C’est {subject}" } }), /needs sentences/);
|
||||
});
|
||||
|
||||
test("a daily guess shows the common part of the subject and the theme, never the rest of the answer", () => {
|
||||
const answer = cardNamed("Renardeau des Congères");
|
||||
const compare = (name) => compareClues(clues, answer, cardNamed(name));
|
||||
assert.deepEqual(compare("Épée du Socle Ancien"), { subject: { common: [], different: "Objet" }, theme: { label: "Combat", same: false } });
|
||||
const compare = (name) => {
|
||||
const { subject, theme } = compareClues(clues, answer, cardNamed(name));
|
||||
return { subject: { common: subject.common.map((step) => step.label), different: subject.different?.label ?? null }, theme };
|
||||
};
|
||||
assert.deepEqual(compare("Épée du Socle Ancien"), { subject: { common: [], different: "Objet" }, theme: { label: "Combat", span: [0, 4], same: false } });
|
||||
assert.deepEqual(compare("Loutre Pilote du Bateau du Ciel").subject, { common: ["Animal", "Mammifère"], different: "Mustélidé" });
|
||||
assert.deepEqual(compare("Loup des Aurores").subject, { common: ["Animal", "Mammifère", "Canidé"], different: null });
|
||||
// Une espèce sans branche s'arrête à « Mammifère » : rien ne dit que la réponse va plus loin.
|
||||
assert.deepEqual(compare("Phoque des Glaces Lunaires"), { subject: { common: ["Animal", "Mammifère"], different: null }, theme: { label: "Hiver", same: true } });
|
||||
assert.deepEqual(compare("Phoque des Glaces Lunaires"), { subject: { common: ["Animal", "Mammifère"], different: null }, theme: { label: "Hiver", span: [11, 17], same: true } });
|
||||
// Une carte sans indices reste jouable, sans comparaison.
|
||||
assert.deepEqual(compareClues(clues, answer, { id: "new-card", name: "Chose Inconnue" }), { subject: { common: [], different: null }, theme: null });
|
||||
});
|
||||
|
||||
test("the damaged page and the name shape hide words without sending them", () => {
|
||||
test("the partial description and the name shape hide words without sending them", () => {
|
||||
const hedgehog = cardNamed("Hérisson à la Guirlande");
|
||||
assert.equal(shown(damagedPage(hedgehog)), "En voulant aider à décorer le sapin, il s'est emmêlé dans la ▒.");
|
||||
assert.equal(shown(partialDescription(hedgehog)), "En voulant aider à décorer le sapin, il s'est emmêlé dans la ▒.");
|
||||
assert.equal(shown(nameShape("Renardeau des Neiges Astrales")), "▒ des ▒ ▒");
|
||||
assert.equal(shown(nameShape("L'Échange de l'Aube")), "L'▒ de l'▒");
|
||||
assert.ok(nameShape(hedgehog.name).filter((part) => part.hidden).every((part) => Object.keys(part).join() === "hidden"));
|
||||
for (const card of baseCatalog.cards) assert.ok(damagedPage(card).some((part) => part.text) && nameShape(card.name).some((part) => part.hidden), card.id);
|
||||
for (const card of baseCatalog.cards) assert.ok(partialDescription(card).some((part) => part.text) && nameShape(card.name).some((part) => part.hidden), card.id);
|
||||
});
|
||||
|
||||
test("what a player learned adds up, whatever the order of the guesses", async () => {
|
||||
const content = JSON.parse(await readFile("website/public/data/site.json", "utf8")).cards.daily;
|
||||
const answer = cardNamed("Petit Tsuchinoko des Herbes Rouges");
|
||||
const guesses = (...names) => names.map((name) => compareClues(clues, answer, cardNamed(name)));
|
||||
const verdict = (...names) => dailyVerdict(guesses(...names), content).map((part) => part.text).join("");
|
||||
const umbrella = "Parapluie à l'Œil Rieur";
|
||||
// Un essai moins bon n'efface rien : la famille écartée n'apprend plus rien une fois la bonne connue.
|
||||
assert.deepEqual(dailyKnowledge(guesses(umbrella, "Loup des Aurores")), { path: ["Créature fantastique", "Yokai"], ruledOut: [], theme: null, ruledOutThemes: ["Mystère", "Lumière"] });
|
||||
assert.deepEqual(dailyKnowledge(guesses("Loup des Aurores", "Dragon du Néant Étoilé")).ruledOut, ["Dragon"]);
|
||||
assert.equal(dailyKnowledge(guesses("Loup des Aurores"), "Plante").theme, "Plante");
|
||||
assert.equal(dailyKnowledge(guesses("Esprit du Cèdre Creux")).theme, "Plante");
|
||||
assert.equal(verdict(umbrella), "C’est bien un yokai.");
|
||||
assert.equal(verdict("Dragon du Néant Étoilé"), "C’est bien une créature fantastique, mais pas un dragon.");
|
||||
assert.equal(verdict("Loup des Aurores"), "Sa famille n’est pas inspirée d’un animal réel.");
|
||||
assert.equal(verdict(umbrella, "Loup des Aurores"), "Sa famille n’est pas inspirée d’un animal réel : vous le saviez déjà.");
|
||||
assert.equal(verdict("Épée du Socle Ancien", "Dragon du Néant Étoilé", umbrella), "C’est bien un yokai.");
|
||||
const fox = compareClues(clues, cardNamed("Renardeau des Congères"), cardNamed("Manchot des Glaces Étoilées"));
|
||||
assert.equal(dailyVerdict([fox], content).map((part) => part.text).join(""), "Sa famille est bien inspirée d’un animal réel, mais pas d’un oiseau.");
|
||||
assert.deepEqual(dailyVerdict([{ subject: { common: [], different: null }, theme: null }], content), []);
|
||||
});
|
||||
|
||||
test("a wrong daily guess earns one hint of the player's choice", () => {
|
||||
|
|
@ -118,14 +146,11 @@ test("a wrong daily guess earns one hint of the player's choice", () => {
|
|||
assert.equal(canUseDailyHint("album", 1, []), true);
|
||||
assert.equal(canUseDailyHint("album", 2, ["album"]), false);
|
||||
assert.equal(canUseDailyHint("collection", 1, ["album"]), false);
|
||||
assert.equal(canUseDailyHint("theme", 2, []), false);
|
||||
assert.equal(canUseDailyHint("theme", 3, []), true);
|
||||
// Chaque indice est ouvert dès le premier essai raté : le joueur choisit l'ordre.
|
||||
for (const hint of DAILY_HINTS) assert.equal(canUseDailyHint(hint, 1, []), true, hint);
|
||||
// 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);
|
||||
assert.equal(canUseDailyHint("unknown", 6, []), false);
|
||||
});
|
||||
|
||||
|
|
@ -215,6 +240,9 @@ test("wrong daily guesses unzoom the card until the player runs out of guesses",
|
|||
assert.equal(last.zoom, 1);
|
||||
assert.equal(last.earned, 0);
|
||||
assert.equal(last.answerCardId, service.todayPuzzle(player.id).cardId);
|
||||
// La réponse détaillée n'arrive qu'avec la fin de partie.
|
||||
assert.equal(daily.answerClues, null);
|
||||
assert.deepEqual(last.answerClues, answerClues(clues, service.index.cards.get(last.answerCardId)));
|
||||
assert.throws(() => service.guessDaily(player.id, { day: "2026-11-13", cardId: others.at(-1) }), (error) => error.code === "DAILY_FINISHED");
|
||||
assert.equal(service.getState(player.id).wallet.stardust, 0);
|
||||
});
|
||||
|
|
@ -229,8 +257,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", "collection"]);
|
||||
assert.throws(() => flip("page"), (error) => error.code === "DAILY_HINT_LOCKED");
|
||||
assert.deepEqual(service.guessDaily(player.id, { day, cardId: others[0] }).daily.hintChoices.filter((choice) => choice.available).map((choice) => choice.id).filter((id) => id !== "theme"), ["album", "collection", "shape", "page"]);
|
||||
// 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);
|
||||
service.db.prepare("INSERT INTO collection_cards(player_id, edition_id, quantity, acquired_at) VALUES (?, ?, 1, 0)").run(player.id, edition.id);
|
||||
|
|
@ -271,10 +298,10 @@ test("the theme hint names the theme of the answer, unless a guess already found
|
|||
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.choice, { id: "theme", 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.deepEqual(found.choice, { id: "theme", 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 });
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ test("large sass files stay split by stable responsibility", async () => {
|
|||
"website/src/styles/toolboxes/calendar/_date-picker.scss",
|
||||
"website/src/styles/toolboxes/calendar/_event-controls.scss",
|
||||
"website/src/styles/toolboxes/calendar/_form-actions.scss",
|
||||
"website/src/styles/_nebula-daily.scss",
|
||||
"website/src/styles/_nebula-expeditions.scss",
|
||||
"website/src/styles/_nebula-expedition-destinations.scss",
|
||||
"website/src/styles/_nebula-expedition-loadout.scss",
|
||||
|
|
@ -135,7 +136,7 @@ test("Sokko TCG styles load with their route and keep the single-sheet cascade",
|
|||
const main = uses(await readFile(`${root}/main.scss`, "utf8"));
|
||||
const route = uses(await readFile(`${root}/cards-route.scss`, "utf8"));
|
||||
const cardSheets = route.filter((name) => name.startsWith("nebula-"));
|
||||
assert.deepEqual(cardSheets, ["nebula-cards", "nebula-expeditions", "nebula-expedition-destinations", "nebula-expedition-loadout", "nebula-expedition-journey"]);
|
||||
assert.deepEqual(cardSheets, ["nebula-cards", "nebula-daily", "nebula-expeditions", "nebula-expedition-destinations", "nebula-expedition-loadout", "nebula-expedition-journey"]);
|
||||
assert.ok(cardSheets.every((name) => !main.includes(name)), "main.scss must not load the Sokko TCG sheets");
|
||||
// La feuille de route ré-émet, dans le même ordre, toutes les feuilles qui suivaient les cartes dans main.scss.
|
||||
const after = main.slice(main.indexOf("nebula-cards-nav") + 1);
|
||||
|
|
|
|||
|
|
@ -723,51 +723,85 @@
|
|||
"eyebrow": "Quête quotidienne",
|
||||
"title": "Carte du jour",
|
||||
"number": "Défi n° {number}",
|
||||
"intro": "Une illustration du TCG se cache derrière ce zoom. Chaque essai raté l’éloigne un peu et compare votre carte à la réponse.",
|
||||
"maybeNotOwned": "La carte n’est pas forcément dans votre album.",
|
||||
"intro": "Proposez une carte, même au hasard. Elle n’est pas forcément dans votre album. À chaque essai raté :",
|
||||
"ruleZoom": "l’image recule un peu ;",
|
||||
"ruleCompare": "votre carte est comparée à la réponse ;",
|
||||
"ruleHint": "vous gagnez un indice à dévoiler.",
|
||||
"imageAlt": "Illustration de la Carte du jour, agrandie",
|
||||
"imageLoading": "Chargement de l’illustration…",
|
||||
"imageError": "L’illustration n’a pas pu être chargée.",
|
||||
"guessLabel": "Votre proposition",
|
||||
"guessPlaceholder": "Nom d’une carte",
|
||||
"guessLabel": "Quelle est cette carte ?",
|
||||
"guessPlaceholder": "Nom ou mot : loup, lune…",
|
||||
"guessAction": "Proposer",
|
||||
"guessUnknown": "Choisissez une carte de la liste.",
|
||||
"guessRepeated": "Vous avez déjà proposé cette carte.",
|
||||
"search": { "keyword": "mot proche : {word}", "used": "déjà proposée", "none": "Aucune carte pour « {query} »." },
|
||||
"attempts": "Essai {count} sur {max}",
|
||||
"attempt": "Essai {count} sur {max}",
|
||||
"columnGuess": "Essai",
|
||||
"lastAttempt": "Dernier essai",
|
||||
"attemptResult": "Essai {count} : {result}",
|
||||
"attemptsLeft": "Essais restants : {count}",
|
||||
"results": { "miss": "raté", "close": "proche", "correct": "trouvé" },
|
||||
"missed": " : raté",
|
||||
"hintGained": "+1 indice",
|
||||
"lastAttemptNotice": "Dernier essai !",
|
||||
"subjectSame": "C’est bien {subject}",
|
||||
"subjectDifferent": "Ce n’est pas {subject}",
|
||||
"subjectBut": ", mais pas {subject}",
|
||||
"subjectKnown": " : vous le saviez déjà.",
|
||||
"knowTitle": "Ce que vous savez",
|
||||
"notFoundYet": "pas encore trouvé",
|
||||
"ruledOutOne": "écarté :",
|
||||
"ruledOutMany": "écartés :",
|
||||
"guessesTitle": "Vos essais",
|
||||
"guessesEmpty": "Vos essais s’afficheront ici, comparés à la réponse : le thème de son nom et son sujet, qui appartient à l’une de ces cinq familles.",
|
||||
"families": [
|
||||
{ "name": "Animal", "text": "inspiré d’un animal réel" },
|
||||
{ "name": "Créature fantastique", "text": "dragon, kitsune, yokai…" },
|
||||
{ "name": "Objet", "text": "épée, lanterne…" },
|
||||
{ "name": "Nature", "text": "astre, plante, pierre…" },
|
||||
{ "name": "Lieu", "text": "île, bâtiment…" }
|
||||
],
|
||||
"keySame": "Vert",
|
||||
"keySameText": " : comme la réponse",
|
||||
"keyDifferent": "barré",
|
||||
"keyDifferentText": " : différent",
|
||||
"columnGuess": "Carte",
|
||||
"columnSubject": "Sujet",
|
||||
"columnTheme": "Thème du nom",
|
||||
"columnTheme": "Thème",
|
||||
"sameStep": "trouvé : {label}",
|
||||
"differentStep": "différent : {label}",
|
||||
"sameTheme": "même thème : {label}",
|
||||
"differentTheme": "autre thème : {label}",
|
||||
"noTheme": "Aucun",
|
||||
"legendTheme": "Le mot souligné donne le thème.",
|
||||
"legendClose": "Proche : au moins deux étapes du sujet, ou le même thème.",
|
||||
"hintsTitle": "Indices",
|
||||
"hintsNone": "Chaque essai raté donne droit à un indice, au choix. Rien n’oblige à l’utiliser.",
|
||||
"hintsOne": "1 indice à retourner, au choix.",
|
||||
"hintsMany": "{count} indices à retourner, au choix.",
|
||||
"hintAfterOne": "Après 1 essai raté",
|
||||
"hintAfterMany": "Après {count} essais ratés",
|
||||
"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",
|
||||
"hintTheme": "Thème du nom",
|
||||
"hintCollection": "Collection",
|
||||
"hintPage": "Page abîmée du carnet",
|
||||
"hintShape": "Forme du nom",
|
||||
"hintsRule": "Un essai raté = un indice de votre choix à dévoiler.",
|
||||
"hintsOne": "Dévoilez celui que vous voulez, dans n’importe quel ordre.",
|
||||
"hintsMany": "Dévoilez ceux que vous voulez, dans n’importe quel ordre.",
|
||||
"hintsNext": "Le prochain essai raté vous donne un indice à dévoiler.",
|
||||
"hintsSpent": "Vous avez utilisé tous vos indices.",
|
||||
"hintCreditsNone": "Aucun indice à dévoiler",
|
||||
"hintCreditsOne": "{count} indice à dévoiler",
|
||||
"hintCreditsMany": "{count} indices à dévoiler",
|
||||
"hintOpen": "Dévoiler cet indice",
|
||||
"hintKnown": "{title} · déjà trouvé",
|
||||
"hints": {
|
||||
"album": { "title": "Dans votre album", "text": "Oui ou non ?" },
|
||||
"collection": { "title": "Collection", "text": "D’où vient-elle ?" },
|
||||
"theme": { "title": "Thème", "text": "Que dit son nom ?" },
|
||||
"shape": { "title": "Nom à trous", "text": "Ses petits mots" },
|
||||
"page": { "title": "Description partielle", "text": "Une phrase, sans les mots de son nom" }
|
||||
},
|
||||
"hintAlbumYes": "Oui, vous l’avez",
|
||||
"hintAlbumNo": "Non, pas encore",
|
||||
"hintHiddenWord": "mot effacé",
|
||||
"hintsUsed": "Indices retournés : {count}",
|
||||
"found": "Bonne réponse",
|
||||
"wonTitle": "Trouvée en {count}/{max} !",
|
||||
"hintsUsedOne": "{count} indice utilisé",
|
||||
"hintsUsedMany": "{count} indices utilisés",
|
||||
"wonFirstTitle": "Trouvée du premier coup !",
|
||||
"wonTitle": "Trouvée en {count} essais !",
|
||||
"lostTitle": "Ce sera pour demain",
|
||||
"lostText": "La carte du jour était :",
|
||||
"answerTitle": "La réponse",
|
||||
"reward": "Récompense : {reward}",
|
||||
"earned": "+{reward} gagnées",
|
||||
"earned": "+{reward}",
|
||||
"owned": "Dans votre album",
|
||||
"notOwned": "Pas encore dans votre album",
|
||||
"streak": "Série : {streak}",
|
||||
|
|
@ -778,8 +812,7 @@
|
|||
"expired": "Une nouvelle Carte du jour est arrivée.",
|
||||
"reload": "Charger la nouvelle carte",
|
||||
"unavailable": "Aucune Carte du jour n’est disponible pour le moment.",
|
||||
"back": "Retour à la Guilde",
|
||||
"guessesTitle": "Vos essais"
|
||||
"back": "Retour à la Guilde"
|
||||
},
|
||||
"packs": {
|
||||
"eyebrow": "Sélection de paquets",
|
||||
|
|
|
|||
|
|
@ -1,15 +1,23 @@
|
|||
// Rôle : fournit un champ NDS d'autocomplete libre pour les catégories.
|
||||
// Rôle : fournit un champ NDS d'autocomplete, libre pour les catégories ou en mode recherche (`searchTexts`) : la liste attend une saisie,
|
||||
// surligne le texte trouvé, dit pourquoi une option apparaît et l'absence de résultat, et Entrée prend la première option.
|
||||
import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
||||
|
||||
// Recherche sans casse ni accents : « neant » trouve « Néant ».
|
||||
function searchKey(value) {
|
||||
return value.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase();
|
||||
return value.normalize("NFD").replace(/\p{Diacritic}/gu, "").replace(/[’`]/g, "'").replace(/œ/gi, "oe").toLowerCase();
|
||||
}
|
||||
|
||||
// Texte trouvé dans l'option, surligné ; tel quel quand la recherche n'a pas la même longueur que le texte (« œ »).
|
||||
function HighlightedText({ text, query }) {
|
||||
const start = searchKey(text).indexOf(query);
|
||||
if (!query || start < 0 || searchKey(text).length !== text.length) return text;
|
||||
return <>{text.slice(0, start)}<mark>{text.slice(start, start + query.length)}</mark>{text.slice(start + query.length)}</>;
|
||||
}
|
||||
|
||||
// Mots proches d'une option (`keywords`, une Map option → mots) : ils ne comptent qu'à partir de trois lettres, par leur début.
|
||||
const MIN_KEYWORD_QUERY = 3;
|
||||
function matchesKeyword(words, query) {
|
||||
return words.some((word) => searchKey(word).startsWith(query));
|
||||
function matchingKeyword(words, query) {
|
||||
return words.find((word) => searchKey(word).startsWith(query));
|
||||
}
|
||||
|
||||
function normalizeOptions(options) {
|
||||
|
|
@ -29,6 +37,8 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
name,
|
||||
options,
|
||||
keywords,
|
||||
usedOptions,
|
||||
searchTexts,
|
||||
placeholder,
|
||||
value,
|
||||
onChange,
|
||||
|
|
@ -46,17 +56,19 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
const [activeIndex, setActiveIndex] = useState(-1);
|
||||
const cleanOptions = useMemo(() => normalizeOptions(options), [options]);
|
||||
const cleanValue = String(value || "");
|
||||
const query = searchKey(cleanValue.trim());
|
||||
const filteredOptions = useMemo(() => {
|
||||
const query = searchKey(cleanValue.trim());
|
||||
if (!query) return cleanOptions.slice(0, maxOptions);
|
||||
const matches = cleanOptions.filter((option) => searchKey(option).includes(query));
|
||||
const close = keywords && query.length >= MIN_KEYWORD_QUERY
|
||||
? cleanOptions.filter((option) => !searchKey(option).includes(query) && matchesKeyword(keywords.get(option) || [], query))
|
||||
? cleanOptions.filter((option) => !searchKey(option).includes(query) && matchingKeyword(keywords.get(option) || [], query))
|
||||
: [];
|
||||
return [...matches, ...close].slice(0, maxOptions);
|
||||
}, [cleanOptions, cleanValue, keywords, maxOptions]);
|
||||
}, [cleanOptions, keywords, maxOptions, query]);
|
||||
// Options déjà prises : citées en fin de liste, sans pouvoir être choisies.
|
||||
const usedMatches = searchTexts && query ? (usedOptions || []).filter((option) => searchKey(option).includes(query)) : [];
|
||||
const menuId = `${inputId}-menu`;
|
||||
const showMenu = open && filteredOptions.length > 0;
|
||||
const showMenu = open && (searchTexts ? Boolean(query) : filteredOptions.length > 0);
|
||||
|
||||
// Au clavier, l'option active reste visible quand la liste défile.
|
||||
useEffect(() => {
|
||||
|
|
@ -98,6 +110,7 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
|
||||
function handleKeyDown(event) {
|
||||
if (!filteredOptions.length) {
|
||||
if (event.key === "Escape") setOpen(false);
|
||||
onKeyDown?.(event);
|
||||
return;
|
||||
}
|
||||
|
|
@ -112,6 +125,9 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
} else if (event.key === "Enter" && open && activeIndex >= 0) {
|
||||
event.preventDefault();
|
||||
selectOption(filteredOptions[activeIndex]);
|
||||
} else if (event.key === "Enter" && open && searchTexts && query && !cleanOptions.some((option) => searchKey(option) === query)) {
|
||||
event.preventDefault();
|
||||
selectOption(filteredOptions[0]);
|
||||
} else if (event.key === "Escape" && open) {
|
||||
setOpen(false);
|
||||
setActiveIndex(-1);
|
||||
|
|
@ -155,9 +171,12 @@ export const CategoryAutocompleteInput = forwardRef(function CategoryAutocomplet
|
|||
onMouseDown={(event) => event.preventDefault()}
|
||||
onClick={() => selectOption(option)}
|
||||
>
|
||||
{option}
|
||||
{searchTexts ? <HighlightedText text={option} query={query} /> : option}
|
||||
{searchTexts && !searchKey(option).includes(query) && <small>{searchTexts.keyword.replace("{word}", matchingKeyword(keywords.get(option) || [], query))}</small>}
|
||||
</button>
|
||||
))}
|
||||
{usedMatches.map((option) => <div className="nds-autocomplete-option" key={option} role="option" aria-disabled="true" aria-selected="false" onMouseDown={(event) => event.preventDefault()}>{option}<small>{searchTexts.used}</small></div>)}
|
||||
{searchTexts && !filteredOptions.length && !usedMatches.length && <div className="nds-autocomplete-option" role="option" aria-disabled="true" aria-selected="false" onMouseDown={(event) => event.preventDefault()}>{searchTexts.none.replace("{query}", cleanValue.trim())}</div>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
54
website/src/features/cards/DailyFeedback.jsx
Normal file
54
website/src/features/cards/DailyFeedback.jsx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
// Rôle : sous la saisie de la Carte du jour, les règles avant le premier essai, puis le bilan du dernier essai et « Ce que vous savez ».
|
||||
import { Fragment } from "react";
|
||||
import { DailyIcon } from "./DailyIcon.jsx";
|
||||
import { dailyKnowledge, dailyVerdict } from "./dailyKnowledge.js";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
|
||||
// Étapes d'un sujet en pastilles ; `isFound` dit lesquelles le joueur a trouvées, `isNew` celles que le dernier essai vient d'apprendre.
|
||||
export function SubjectChips({ labels, isFound = () => true, isNew = () => false }) {
|
||||
return <span className="nebula-daily-path">{labels.map((label, index) => <span key={label} className="nebula-daily-path-step">
|
||||
{index > 0 && <span aria-hidden="true">›</span>}
|
||||
<span className="nebula-daily-chip" data-found={isFound(index) || undefined} data-new={isNew(index) || undefined}>{label}</span>
|
||||
</span>)}</span>;
|
||||
}
|
||||
|
||||
function RuledOut({ labels, known, content }) {
|
||||
if (!labels.length) return null;
|
||||
return <span className="nebula-daily-ruled-out">{labels.length > 1 ? content.ruledOutMany : content.ruledOutOne} {labels.map((label, index) => <Fragment key={label}>{index > 0 && ", "}<s data-new={!known.includes(label) || undefined}>{label}</s></Fragment>)}</span>;
|
||||
}
|
||||
|
||||
export function DailyRules({ content }) {
|
||||
return <div className="nebula-daily-rules">
|
||||
<p>{content.intro}</p>
|
||||
<ul>{[["zoomOut", content.ruleZoom], ["compare", content.ruleCompare], ["lens", content.ruleHint]].map(([icon, text]) => <li key={icon}><span className="nebula-daily-disc"><DailyIcon name={icon} /></span>{text}</li>)}</ul>
|
||||
</div>;
|
||||
}
|
||||
|
||||
export function DailyFeedback({ catalog, daily, content }) {
|
||||
const guess = daily.guesses.at(-1);
|
||||
const name = catalog.cards.find((card) => card.id === guess.cardId)?.name || guess.cardId;
|
||||
const themeHint = daily.hints.find((hint) => hint.id === "theme")?.value ?? null;
|
||||
const now = dailyKnowledge(daily.guesses, themeHint);
|
||||
const before = dailyKnowledge(daily.guesses.slice(0, -1), themeHint);
|
||||
const verdict = dailyVerdict(daily.guesses, content);
|
||||
return <div className="nebula-daily-feedback" key={guess.cardId}>
|
||||
<div className="nebula-daily-verdict">
|
||||
<p><strong>{name}</strong>{content.missed}</p>
|
||||
<span className="nebula-daily-gains">
|
||||
{daily.hintCredits > 0 && <span data-kind="hint"><DailyIcon name="lens" />{content.hintGained}</span>}
|
||||
{daily.guesses.length === daily.maxGuesses - 1 && <span data-kind="last">{content.lastAttemptNotice}</span>}
|
||||
</span>
|
||||
{verdict.length > 0 && <p className="nebula-daily-verdict-subject">{verdict.map((part, index) => (part.tone ? <b key={index} data-tone={part.tone}>{part.text}</b> : <span key={index}>{part.text}</span>))}</p>}
|
||||
</div>
|
||||
<section className="nebula-daily-know" aria-labelledby="nebula-daily-know-title">
|
||||
<h3 id="nebula-daily-know-title">{content.knowTitle}</h3>
|
||||
<dl>
|
||||
<dt>{content.columnSubject}</dt>
|
||||
<dd>{now.path.length ? <SubjectChips labels={now.path} isNew={(index) => index >= before.path.length} /> : <span>{content.notFoundYet}</span>}<RuledOut labels={now.ruledOut} known={before.ruledOut} content={content} /></dd>
|
||||
<dt>{content.columnTheme}</dt>
|
||||
<dd>{now.theme ? <SubjectChips labels={[now.theme]} isNew={() => !before.theme} /> : <><span>{content.notFoundYet}</span><RuledOut labels={now.ruledOutThemes} known={before.ruledOutThemes} content={content} /></>}</dd>
|
||||
</dl>
|
||||
</section>
|
||||
<span className="sr-only">{fillTemplate(content.attemptsLeft, { count: daily.maxGuesses - daily.guesses.length })}</span>
|
||||
</div>;
|
||||
}
|
||||
|
|
@ -1,40 +1,54 @@
|
|||
// Rôle : grille des six essais de la Carte du jour : la carte proposée, son sujet et son thème comparés à ceux de la réponse.
|
||||
import { Fragment } from "react";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
// Rôle : grille des essais de la Carte du jour : la carte proposée, son sujet et son thème comparés à ceux de la réponse.
|
||||
import { dailyGuessResult, DAILY_MARKS, fillTemplate } from "./dailyShare.js";
|
||||
|
||||
// Chemin du sujet : les étapes trouvées, puis la première qui diffère. Le chemin de la réponse n'est jamais montré.
|
||||
function SubjectPath({ subject, content }) {
|
||||
return <span className="nebula-daily-path">
|
||||
{subject.common.map((label, index) => <Fragment key={label}>
|
||||
{index > 0 && <span aria-hidden="true">›</span>}
|
||||
<span className="nebula-daily-step" data-same="true" aria-label={fillTemplate(content.sameStep, { label })}><span aria-hidden="true">✓</span>{label}</span>
|
||||
</Fragment>)}
|
||||
{subject.different && <>
|
||||
{subject.common.length > 0 && <span aria-hidden="true">›</span>}
|
||||
<span className="nebula-daily-step" aria-label={fillTemplate(content.differentStep, { label: subject.different })}><span aria-hidden="true">✗</span><s>{subject.different}</s></span>
|
||||
</>}
|
||||
</span>;
|
||||
const steps = [...subject.common.map((step) => ({ label: step.label, same: true })), ...(subject.different ? [{ label: subject.different.label, same: false }] : [])];
|
||||
return <span className="nebula-daily-path">{steps.map(({ label, same }, index) => <span key={label} className="nebula-daily-path-step">
|
||||
{index > 0 && <span aria-hidden="true">›</span>}
|
||||
<Compared label={label} same={same} text={same ? content.sameStep : content.differentStep} className="nebula-daily-step" />
|
||||
</span>)}</span>;
|
||||
}
|
||||
|
||||
// Vert : comme la réponse. Barré : différent. Le sens est aussi dit aux lecteurs d'écran.
|
||||
function Compared({ label, same, text, className }) {
|
||||
const Tag = same ? "b" : "s";
|
||||
return <span className={className} data-same={same || undefined}><span className="sr-only">{fillTemplate(text, { label })}</span><Tag aria-hidden="true">{label}</Tag></span>;
|
||||
}
|
||||
|
||||
// Nom de la carte, le mot qui donne son thème souligné.
|
||||
function CardName({ name, theme }) {
|
||||
if (!theme) return <strong>{name}</strong>;
|
||||
const [start, end] = theme.span;
|
||||
return <strong>{name.slice(0, start)}<u data-same={theme.same || undefined}>{name.slice(start, end)}</u>{name.slice(end)}</strong>;
|
||||
}
|
||||
|
||||
function DailyFamilies({ content }) {
|
||||
return <section className="nebula-daily-families" aria-label={content.guessesTitle}>
|
||||
<p>{content.guessesEmpty}</p>
|
||||
<ul>{content.families.map(({ name, text }) => <li key={name}><b>{name}</b><span>{text}</span></li>)}</ul>
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function DailyGuesses({ catalog, daily, content }) {
|
||||
const finished = daily.status !== "playing";
|
||||
const rows = Array.from({ length: finished ? daily.guesses.length : daily.maxGuesses }, (_, index) => daily.guesses[index] || null);
|
||||
if (!daily.guesses.length) return <DailyFamilies content={content} />;
|
||||
const playing = daily.status === "playing";
|
||||
const results = daily.guesses.map(dailyGuessResult);
|
||||
return <section className="nebula-daily-guesses" aria-labelledby="nebula-daily-guesses-title">
|
||||
<h3 id="nebula-daily-guesses-title" className="sr-only">{content.guessesTitle}</h3>
|
||||
<div className="nebula-daily-columns" aria-hidden="true"><span>{content.columnGuess}</span><span>{content.columnSubject}</span><span>{content.columnTheme}</span></div>
|
||||
<ol>{rows.map((guess, index) => {
|
||||
if (!guess) {
|
||||
const next = index === daily.guesses.length;
|
||||
return <li key={index} className="nebula-daily-row" data-empty="true" aria-hidden="true"><strong data-next={next || undefined}>{next ? fillTemplate(content.attempt, { count: index + 1, max: daily.maxGuesses }) : ""}</strong><span /><span /></li>;
|
||||
}
|
||||
const card = catalog.cards.find((item) => item.id === guess.cardId);
|
||||
return <li key={guess.cardId} className="nebula-daily-row nebula-daily-guess" data-correct={guess.correct || undefined}>
|
||||
<strong>{card?.name || guess.cardId}</strong>
|
||||
<div className="nebula-daily-heading">
|
||||
<h3 id="nebula-daily-guesses-title">{content.guessesTitle}</h3>
|
||||
<p aria-hidden="true"><span><b>{content.keySame}</b>{content.keySameText}</span> <span><s>{content.keyDifferent}</s>{content.keyDifferentText}</span></p>
|
||||
</div>
|
||||
<div className="nebula-daily-columns" aria-hidden="true"><span /><span>{content.columnGuess}</span><span>{content.columnSubject}</span><span>{content.columnTheme}</span></div>
|
||||
<ol>{daily.guesses.map((guess, index) => {
|
||||
const result = results[index];
|
||||
return <li key={guess.cardId} className="nebula-daily-guess" data-result={result} data-last={(playing && index === daily.guesses.length - 1) || undefined}>
|
||||
<span className="nebula-daily-mark" data-result={result}><span aria-hidden="true">{DAILY_MARKS[result]}</span><span className="sr-only">{fillTemplate(content.attemptResult, { count: index + 1, result: content.results[result] })}</span></span>
|
||||
<CardName name={catalog.cards.find((item) => item.id === guess.cardId)?.name || guess.cardId} theme={guess.theme} />
|
||||
<SubjectPath subject={guess.subject} content={content} />
|
||||
{guess.theme
|
||||
? <span className="nebula-daily-theme" data-same={guess.theme.same || undefined} aria-label={fillTemplate(guess.theme.same ? content.sameTheme : content.differentTheme, { label: guess.theme.label })}><span aria-hidden="true">{guess.theme.same ? "✓" : "✗"}</span>{guess.theme.label}</span>
|
||||
: <span className="nebula-daily-theme">{content.noTheme}</span>}
|
||||
<span className="nebula-daily-theme-cell" data-label={content.columnTheme}>{guess.theme ? <Compared label={guess.theme.label} same={guess.theme.same} text={guess.theme.same ? content.sameTheme : content.differentTheme} className="nebula-daily-theme" /> : content.noTheme}</span>
|
||||
</li>;
|
||||
})}</ol>
|
||||
<p className="nebula-daily-legend"><span>{content.legendTheme}</span>{results.includes("close") && <span><b aria-hidden="true">{DAILY_MARKS.close}</b> {content.legendClose}</span>}</p>
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,55 @@
|
|||
// Rôle : indices facultatifs de la Carte du jour : cinq tuiles face cachée, une à retourner par essai raté, au choix du joueur.
|
||||
// Rôle : indices facultatifs de la Carte du jour : cinq cadres de taille fixe, un à dévoiler par essai raté, dans l'ordre choisi par le joueur.
|
||||
import { DailyIcon } from "./DailyIcon.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
|
||||
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 }) {
|
||||
return <span className={className}>{parts.map((part, index) => (part.hidden
|
||||
function MaskedText({ parts, content }) {
|
||||
return parts.map((part, index) => (part.hidden
|
||||
? <span key={index} className="nebula-daily-gap"><span className="sr-only">{content.hintHiddenWord}</span></span>
|
||||
: <span key={index}>{part.text}</span>))}</span>;
|
||||
: <span key={index}>{part.text}</span>));
|
||||
}
|
||||
|
||||
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 === "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"} />;
|
||||
if (hint.id === "album") return <strong>{hint.value ? content.hintAlbumYes : content.hintAlbumNo}</strong>;
|
||||
if (hint.id === "theme") return <strong>{hint.value}</strong>;
|
||||
if (hint.id === "collection") return <strong>{catalog.collections.find((item) => item.id === hint.value)?.name}</strong>;
|
||||
if (hint.id === "page") return <em><MaskedText parts={hint.value} content={content} /></em>;
|
||||
return <strong><MaskedText parts={hint.value} content={content} /></strong>;
|
||||
}
|
||||
|
||||
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 });
|
||||
function helpText(daily, content) {
|
||||
if (daily.hintCredits > 1) return content.hintsMany;
|
||||
if (daily.hintCredits === 1) return content.hintsOne;
|
||||
if (!daily.guesses.length) return content.hintsRule;
|
||||
return daily.guesses.length === daily.maxGuesses - 1 || daily.hintChoices.every((choice) => choice.known || daily.hints.some((hint) => hint.id === choice.id)) ? content.hintsSpent : content.hintsNext;
|
||||
}
|
||||
|
||||
// Réserve d'indices : une loupe par indice à dévoiler.
|
||||
function HintPurse({ credits, content }) {
|
||||
return <span className="nebula-daily-purse" data-on={credits > 0 || undefined} role="status">
|
||||
{Array.from({ length: Math.max(1, credits) }, (_, index) => <DailyIcon key={index} name="lens" />)}
|
||||
{credits ? fillTemplate(credits > 1 ? content.hintCreditsMany : content.hintCreditsOne, { count: credits }) : content.hintCreditsNone}
|
||||
</span>;
|
||||
}
|
||||
|
||||
export function DailyHints({ catalog, daily, busy, content, onUse }) {
|
||||
const flipped = new Map(daily.hints.map((hint) => [hint.id, hint]));
|
||||
const wrongCount = daily.guesses.filter((guess) => !guess.correct).length;
|
||||
const credits = daily.hintCredits;
|
||||
const help = daily.status !== "playing" ? "" : credits > 1 ? fillTemplate(content.hintsMany, { count: credits }) : credits === 1 ? content.hintsOne : content.hintsNone;
|
||||
const opened = new Map(daily.hints.map((hint) => [hint.id, hint]));
|
||||
const guessedTheme = daily.guesses.find((guess) => guess.theme?.same)?.theme.label;
|
||||
return <section className="nebula-daily-hints" aria-labelledby="nebula-daily-hints-title">
|
||||
<div className="nebula-daily-hints-heading"><h3 id="nebula-daily-hints-title">{content.hintsTitle}</h3><p role="status">{help}</p></div>
|
||||
<ul>{daily.hintChoices.map((choice) => {
|
||||
const hint = flipped.get(choice.id);
|
||||
const label = content[HINT_LABELS[choice.id]];
|
||||
if (hint) return <li key={choice.id} className="nebula-daily-hint" data-state="open"><small>{label}</small><HintValue catalog={catalog} hint={hint} content={content} /></li>;
|
||||
const status = hintStatus(choice, daily, wrongCount, content);
|
||||
return <li key={choice.id} className="nebula-daily-hint" data-state={choice.available ? "ready" : "locked"}>
|
||||
<button type="button" disabled={busy || !choice.available} onClick={() => onUse(choice.id)}><strong>{label}</strong><small>{status}</small></button>
|
||||
<div className="nebula-daily-heading">
|
||||
<h3 id="nebula-daily-hints-title">{content.hintsTitle}</h3>
|
||||
<p>{helpText(daily, content)}</p>
|
||||
<HintPurse credits={daily.hintCredits} content={content} />
|
||||
</div>
|
||||
<ul>{daily.hintChoices.map(({ id, known, available }) => {
|
||||
const { title, text } = content.hints[id];
|
||||
// Un thème trouvé par un essai s'affiche ouvert, sans coûter d'indice.
|
||||
const found = known && id === "theme" && guessedTheme ? { id, value: guessedTheme } : null;
|
||||
const hint = opened.get(id) || found;
|
||||
const icon = <span className="nebula-daily-disc"><DailyIcon name={id} /></span>;
|
||||
if (hint) return <li key={id} className="nebula-daily-hint" data-hint={id} data-state="open"><div>{icon}<span><small>{opened.has(id) ? title : fillTemplate(content.hintKnown, { title })}</small><HintValue catalog={catalog} hint={hint} content={content} /></span></div></li>;
|
||||
return <li key={id} className="nebula-daily-hint" data-hint={id} data-state={available ? "ready" : "locked"}>
|
||||
<button type="button" disabled={busy || !available} title={available ? content.hintOpen : undefined} onClick={() => onUse(id)}>{icon}<span><strong>{title}</strong><small>{text}</small></span><span className="nebula-daily-lens"><DailyIcon name="lens" /></span></button>
|
||||
</li>;
|
||||
})}</ul>
|
||||
</section>;
|
||||
|
|
|
|||
15
website/src/features/cards/DailyIcon.jsx
Normal file
15
website/src/features/cards/DailyIcon.jsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Rôle : icônes au trait de la Carte du jour (indices, loupe et règles du départ), teintées par la couleur du texte.
|
||||
const PATHS = {
|
||||
zoomOut: <><rect x="3.5" y="3.5" width="17" height="17" rx="3" /><path d="M8.5 12h-3m13 0h-3M12 8.5v-3m0 13v-3M5.5 12l1.8-1.5M5.5 12l1.8 1.5M18.5 12l-1.8-1.5m1.8 1.5-1.8 1.5" /></>,
|
||||
compare: <><rect x="3.5" y="5" width="7" height="14" rx="1.5" /><rect x="13.5" y="5" width="7" height="14" rx="1.5" /><path d="M6 10h2m8 0h2M6 14h2m8 0h2" /></>,
|
||||
lens: <><circle cx="10.5" cy="10.5" r="6.5" /><path d="m15.5 15.5 5.5 5.5" /></>,
|
||||
album: <><path d="M12 6.5C10 5 7 4.5 3.5 4.8v13.7c3.5-.3 6.5.2 8.5 1.7 2-1.5 5-2 8.5-1.7V4.8C17 4.5 14 5 12 6.5Z" /><path d="M12 6.5v13.7" /></>,
|
||||
collection: <><rect x="9" y="3.5" width="11.5" height="15" rx="2" /><path d="M6.5 6.5v12.2a2 2 0 0 0 2 2h8M3.5 9.5v9" /></>,
|
||||
page: <><path d="M6 3.5h8L18.5 8v12L16 18.5l-2 2-2.5-2-2 2-3-2-.5 1Z" /><path d="M14 3.5V8h4.5M9 11.5h6M9 14.5h4" /></>,
|
||||
theme: <><path d="m12 3.5 2 6.5 6.5 2-6.5 2-2 6.5-2-6.5-6.5-2 6.5-2Z" /><path d="M19 3.5v3M17.5 5h3" /></>,
|
||||
shape: <><path d="M3 18 7.2 6.5h.6L12 18M4.6 14h5.8" /><path d="M14.5 18H21M14.5 13H21" strokeDasharray="2.5 1.6" /></>
|
||||
};
|
||||
|
||||
export function DailyIcon({ name }) {
|
||||
return <svg className="nebula-daily-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">{PATHS[name]}</svg>;
|
||||
}
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
// Rôle : présente la Carte du jour : illustration zoomée, propositions comparées, indices au choix, révélation et résultat à partager.
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { CategoryAutocompleteInput } from "../../components/CategoryAutocompleteInput.jsx";
|
||||
import { flipDailyHint, guessDaily, loadDaily, loadDailyImage } from "./cardsApi.js";
|
||||
import { readCollection } from "./collectionState.js";
|
||||
import { DailyFeedback, DailyRules } from "./DailyFeedback.jsx";
|
||||
import { DailyGuesses } from "./DailyGuesses.jsx";
|
||||
import { DailyHints } from "./DailyHints.jsx";
|
||||
import { dailyGuessResult, dailyShareText, fillTemplate, findCardByName, formatCountdown, formatStreak } from "./dailyShare.js";
|
||||
import { DailyResult } from "./DailyResult.jsx";
|
||||
import { fillTemplate, findCardByName } from "./dailyShare.js";
|
||||
import { DailyTrack } from "./DailyTrack.jsx";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
|
|
@ -21,40 +24,6 @@ function referenceEntry(catalog, cardId) {
|
|||
return card && edition ? { editionId: edition.id, edition, card } : null;
|
||||
}
|
||||
|
||||
function DailyResult({ catalog, state, daily, content, now }) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const answer = referenceEntry(catalog, daily.answerCardId);
|
||||
const owned = readCollection(state).ownedCardIds.has(daily.answerCardId);
|
||||
const won = daily.status === "won";
|
||||
async function share() {
|
||||
const text = dailyShareText(daily, { title: content.shareTitle, url: `${window.location.origin}/#/cards/daily` });
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
} catch {
|
||||
setCopied(false);
|
||||
}
|
||||
}
|
||||
return <section className="nds-panel nebula-daily-result" aria-labelledby="nebula-daily-result-title" data-status={daily.status}>
|
||||
<div className="nebula-daily-result-copy">
|
||||
<h3 id="nebula-daily-result-title">{won ? fillTemplate(content.wonTitle, { count: daily.guesses.length, max: daily.maxGuesses }) : content.lostTitle}</h3>
|
||||
{!won && <p>{content.lostText}</p>}
|
||||
{answer && <p className="nebula-daily-answer"><strong>{answer.card.name}</strong>{answer.card.description && <span>{answer.card.description}</span>}</p>}
|
||||
<div className="nebula-daily-result-badges">
|
||||
{won && daily.earned > 0 && <span className="nds-badge" data-variant="gold">{fillTemplate(content.earned, { reward: formatStardust(daily.earned) })}</span>}
|
||||
<span className="nds-badge" data-variant={owned ? "success" : "neutral"}>{owned ? content.owned : content.notOwned}</span>
|
||||
{daily.hints.length > 0 && <span className="nds-badge" data-variant="neutral">{fillTemplate(content.hintsUsed, { count: daily.hints.length })}</span>}
|
||||
{daily.streak > 0 && <span className="nds-badge" data-variant="neutral">{fillTemplate(content.streak, { streak: formatStreak(daily.streak) })}</span>}
|
||||
</div>
|
||||
<div className="nds-toolbar nebula-daily-result-actions">
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={share}>{copied ? content.shared : content.share}</button>
|
||||
<span className="nebula-daily-next">{fillTemplate(content.next, { time: formatCountdown(daily.nextAt - now) })}</span>
|
||||
</div>
|
||||
</div>
|
||||
{answer && <div className="nebula-daily-result-card"><NebulaCard catalog={catalog} entry={answer} size="md" /></div>}
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
||||
const [daily, setDaily] = useState(null);
|
||||
const [loadError, setLoadError] = useState("");
|
||||
|
|
@ -63,7 +32,10 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
const [guess, setGuess] = useState("");
|
||||
const [notice, setNotice] = useState("");
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
const inputRef = useRef(null);
|
||||
const [refocus, setRefocus] = useState(0);
|
||||
const day = daily?.day || "";
|
||||
const answer = useMemo(() => (daily?.answerCardId ? referenceEntry(catalog, daily.answerCardId) : null), [catalog, daily]);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
|
|
@ -75,9 +47,11 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
|
||||
// Le serveur n'envoie que la zone visible au zoom courant : chaque essai raté recharge un morceau plus large, et
|
||||
// l'illustration entière n'arrive qu'en fin de partie. Le morceau précédent reste affiché pendant le chargement.
|
||||
// La partie finie, la carte elle-même prend la place de l'illustration.
|
||||
const cardShown = Boolean(answer);
|
||||
const zoom = daily?.zoom ?? 0;
|
||||
useEffect(() => {
|
||||
if (!day) return undefined;
|
||||
if (!day || cardShown) return undefined;
|
||||
let active = true;
|
||||
let url = "";
|
||||
loadDailyImage()
|
||||
|
|
@ -91,13 +65,18 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
active = false;
|
||||
if (url) URL.revokeObjectURL(url);
|
||||
};
|
||||
}, [day, zoom]);
|
||||
}, [day, zoom, cardShown]);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => setNow(Date.now()), COUNTDOWN_TICK_MS);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
// Un essai envoyé rend la main à la saisie, désactivée le temps de la réponse.
|
||||
useEffect(() => {
|
||||
if (refocus) inputRef.current?.focus({ preventScroll: true });
|
||||
}, [refocus]);
|
||||
|
||||
const guessable = useMemo(() => {
|
||||
if (!daily) return [];
|
||||
const collections = new Set(daily.collectionIds);
|
||||
|
|
@ -105,6 +84,7 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
return catalog.cards.filter((card) => collections.has(card.collectionId) && !guessed.has(card.id)).sort((left, right) => left.name.localeCompare(right.name, "fr"));
|
||||
}, [catalog.cards, daily]);
|
||||
const options = useMemo(() => guessable.map((card) => card.name), [guessable]);
|
||||
const guessedNames = useMemo(() => (daily?.guesses || []).map((item) => catalog.cards.find((card) => card.id === item.cardId)?.name).filter(Boolean), [catalog.cards, daily]);
|
||||
const searchWords = daily?.searchWords;
|
||||
const keywords = useMemo(() => new Map(guessable.filter((card) => searchWords?.[card.id]).map((card) => [card.name, searchWords[card.id]])), [guessable, searchWords]);
|
||||
|
||||
|
|
@ -113,6 +93,7 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
|
||||
const expired = now >= daily.nextAt;
|
||||
const finished = daily.status !== "playing";
|
||||
const owned = answer && readCollection(state).ownedCardIds.has(answer.card.id);
|
||||
const imageUrl = image.day === daily.day ? image.url : "";
|
||||
const imageFailed = image.day === daily.day && image.failed;
|
||||
|
||||
|
|
@ -133,16 +114,20 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
return Boolean(result?.daily);
|
||||
}
|
||||
|
||||
const chosen = findCardByName(guessable, guess);
|
||||
const tried = daily.guesses.length;
|
||||
|
||||
async function submit(event) {
|
||||
event.preventDefault();
|
||||
setNotice("");
|
||||
const card = findCardByName(catalog.cards.filter((item) => daily.collectionIds.includes(item.collectionId)), guess);
|
||||
if (!card) return setNotice(content.guessUnknown);
|
||||
if (daily.guesses.some((item) => item.cardId === card.id)) return setNotice(content.guessRepeated);
|
||||
if (await play(() => guessDaily(daily.day, card.id))) setGuess("");
|
||||
if (!chosen) return;
|
||||
if (await play(() => guessDaily(daily.day, chosen.id))) {
|
||||
setGuess("");
|
||||
setRefocus((count) => count + 1);
|
||||
}
|
||||
}
|
||||
|
||||
function flipHint(hint) {
|
||||
function openHint(hint) {
|
||||
setNotice("");
|
||||
return play(() => flipDailyHint(daily.day, hint));
|
||||
}
|
||||
|
|
@ -156,32 +141,30 @@ export function DailyPanel({ catalog, state, runMutation, busy, content }) {
|
|||
</div>
|
||||
</div>
|
||||
{expired && <div className="nds-inline-notice nebula-daily-expired" data-variant="warning" role="status"><span>{content.expired}</span><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={() => { setNow(Date.now()); setReloadKey((key) => key + 1); }}>{content.reload}</button></div>}
|
||||
<div className="nebula-daily-layout">
|
||||
<div className="nebula-daily-layout" data-finished={finished || undefined}>
|
||||
<div className="nds-panel nebula-daily-stage">
|
||||
<div className="nebula-daily-frame" data-finished={finished || undefined}>
|
||||
{answer ? <>
|
||||
<NebulaCard catalog={catalog} entry={answer} size="md" />
|
||||
<span className="nds-badge" data-variant={owned ? "success" : "neutral"}>{owned ? content.owned : content.notOwned}</span>
|
||||
</> : <div className="nebula-daily-frame" data-finished={finished || undefined}>
|
||||
{imageUrl ? <img key={imageUrl} src={imageUrl} alt={content.imageAlt} draggable="false" /> : <span className="nebula-daily-frame-status" role={imageFailed ? "alert" : "status"}>{imageFailed ? content.imageError : content.imageLoading}</span>}
|
||||
</div>}
|
||||
</div>
|
||||
{finished ? <DailyResult catalog={catalog} card={answer?.card} daily={daily} content={content} now={now} /> : <form className="nds-panel nebula-daily-form" onSubmit={submit}>
|
||||
<div className="nebula-daily-ask-heading">
|
||||
<label htmlFor="nebula-daily-guess">{content.guessLabel}</label>
|
||||
<span>{tried === daily.maxGuesses - 1 ? content.lastAttempt : fillTemplate(content.attempts, { count: tried + 1, max: daily.maxGuesses })}</span>
|
||||
</div>
|
||||
<ol className="nebula-daily-steps" aria-label={fillTemplate(content.attempts, { count: Math.min(daily.guesses.length + (finished ? 0 : 1), daily.maxGuesses), max: daily.maxGuesses })}>
|
||||
{Array.from({ length: daily.maxGuesses }, (_, index) => {
|
||||
const item = daily.guesses[index];
|
||||
const result = item ? dailyGuessResult(item) : "empty";
|
||||
return <li key={index} data-result={result} />;
|
||||
})}
|
||||
</ol>
|
||||
</div>
|
||||
<div className="nebula-daily-play">
|
||||
{finished ? <DailyResult catalog={catalog} state={state} daily={daily} content={content} now={now} /> : <form className="nds-panel nebula-daily-form" onSubmit={submit}>
|
||||
{daily.guesses.length === 0 && <p>{content.intro} {content.maybeNotOwned}</p>}
|
||||
<label htmlFor="nebula-daily-guess">{content.guessLabel} · {fillTemplate(content.attempts, { count: daily.guesses.length + 1, max: daily.maxGuesses })}</label>
|
||||
<div className="nebula-daily-form-row">
|
||||
<CategoryAutocompleteInput id="nebula-daily-guess" name="guess" options={options} keywords={keywords} value={guess} placeholder={content.guessPlaceholder} maxOptions={MAX_SUGGESTIONS} disabled={busy || expired} onChange={(event) => { setGuess(event.target.value); setNotice(""); }} />
|
||||
<button className="nds-button" data-variant="primary" type="submit" disabled={busy || expired || !guess.trim()}>{content.guessAction}</button>
|
||||
</div>
|
||||
{notice && <p className="nds-inline-notice" data-variant="warning" role="status">{notice}</p>}
|
||||
</form>}
|
||||
<DailyGuesses catalog={catalog} daily={daily} content={content} />
|
||||
</div>
|
||||
<DailyHints catalog={catalog} daily={daily} busy={busy || expired} content={content} onUse={flipHint} />
|
||||
<DailyTrack daily={daily} content={content} />
|
||||
<div className="nebula-daily-form-row">
|
||||
<CategoryAutocompleteInput ref={inputRef} id="nebula-daily-guess" name="guess" options={options} keywords={keywords} usedOptions={guessedNames} searchTexts={content.search} value={guess} placeholder={content.guessPlaceholder} maxOptions={MAX_SUGGESTIONS} disabled={busy || expired} onChange={(event) => { setGuess(event.target.value); setNotice(""); }} />
|
||||
<button className="nds-button" data-variant="primary" type="submit" disabled={busy || expired || !chosen}>{content.guessAction}</button>
|
||||
</div>
|
||||
{notice && <p className="nds-inline-notice" data-variant="warning" role="status">{notice}</p>}
|
||||
<div className="nebula-daily-aside" aria-live="polite">{tried ? <DailyFeedback catalog={catalog} daily={daily} content={content} /> : <DailyRules content={content} />}</div>
|
||||
</form>}
|
||||
{!finished && <DailyHints catalog={catalog} daily={daily} busy={busy || expired} content={content} onUse={openHint} />}
|
||||
<DailyGuesses catalog={catalog} daily={daily} content={content} />
|
||||
</div>
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
53
website/src/features/cards/DailyResult.jsx
Normal file
53
website/src/features/cards/DailyResult.jsx
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Rôle : fin d'une partie de la Carte du jour : résultat, description, réponse détaillée, gains et résultat à partager.
|
||||
import { useState } from "react";
|
||||
import { SubjectChips } from "./DailyFeedback.jsx";
|
||||
import { dailyKnowledge } from "./dailyKnowledge.js";
|
||||
import { dailyShareText, fillTemplate, formatCountdown, formatStreak } from "./dailyShare.js";
|
||||
import { DailyTrack } from "./DailyTrack.jsx";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
function wonTitle(count, content) {
|
||||
return count === 1 ? content.wonFirstTitle : fillTemplate(content.wonTitle, { count });
|
||||
}
|
||||
|
||||
export function DailyResult({ catalog, card, daily, content, now }) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const won = daily.status === "won";
|
||||
const collection = catalog.collections.find((item) => item.id === card?.collectionId)?.name;
|
||||
const { subject, theme } = daily.answerClues;
|
||||
// Après une défaite, ce que les essais et l'indice ont trouvé reste en vert, le reste est en gris.
|
||||
const known = dailyKnowledge(daily.guesses, daily.hints.find((hint) => hint.id === "theme")?.value ?? null);
|
||||
async function share() {
|
||||
const text = dailyShareText(daily, { title: content.shareTitle, url: `${window.location.origin}/#/cards/daily` });
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
} catch {
|
||||
setCopied(false);
|
||||
}
|
||||
}
|
||||
return <section className="nds-panel nebula-daily-result" aria-labelledby="nebula-daily-result-title" data-status={daily.status}>
|
||||
<div className="nebula-daily-ask-heading">
|
||||
<h3 id="nebula-daily-result-title">{won ? wonTitle(daily.guesses.length, content) : content.lostTitle}</h3>
|
||||
{daily.hints.length > 0 && <span>{fillTemplate(daily.hints.length > 1 ? content.hintsUsedMany : content.hintsUsedOne, { count: daily.hints.length })}</span>}
|
||||
</div>
|
||||
<DailyTrack daily={daily} content={content} />
|
||||
{card?.description && <p className="nebula-daily-description">{card.description}</p>}
|
||||
<section className="nebula-daily-know" aria-labelledby="nebula-daily-answer-title">
|
||||
<h4 id="nebula-daily-answer-title">{content.answerTitle}</h4>
|
||||
<dl>
|
||||
{subject.length > 0 && <><dt>{content.columnSubject}</dt><dd><SubjectChips labels={subject.map((step) => step.label)} isFound={(index) => won || index < known.path.length} /></dd></>}
|
||||
{theme && <><dt>{content.columnTheme}</dt><dd><span className="nebula-daily-answer-theme"><SubjectChips labels={[theme.label]} isFound={() => won || Boolean(known.theme)} />{card && <span>« {card.name.slice(...theme.span)} »</span>}</span></dd></>}
|
||||
{collection && <><dt>{content.hints.collection.title}</dt><dd>{collection}</dd></>}
|
||||
</dl>
|
||||
</section>
|
||||
{won && <ul className="nebula-daily-rewards">
|
||||
{daily.earned > 0 && <li>{fillTemplate(content.earned, { reward: formatStardust(daily.earned) })}</li>}
|
||||
{daily.streak > 0 && <li>{fillTemplate(content.streak, { streak: formatStreak(daily.streak) })}</li>}
|
||||
</ul>}
|
||||
<div className="nebula-daily-result-actions">
|
||||
<button className="nds-button" data-variant="primary" type="button" onClick={share}>{copied ? content.shared : content.share}</button>
|
||||
<span>{fillTemplate(content.next, { time: formatCountdown(daily.nextAt - now) })}</span>
|
||||
</div>
|
||||
</section>;
|
||||
}
|
||||
12
website/src/features/cards/DailyTrack.jsx
Normal file
12
website/src/features/cards/DailyTrack.jsx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Rôle : piste des six essais de la Carte du jour : le signe de chaque essai joué, le numéro de ceux à venir.
|
||||
import { dailyGuessResult, DAILY_MARKS, fillTemplate } from "./dailyShare.js";
|
||||
|
||||
export function DailyTrack({ daily, content }) {
|
||||
const playing = daily.status === "playing";
|
||||
return <ol className="nebula-daily-track" aria-label={content.guessesTitle}>{Array.from({ length: daily.maxGuesses }, (_, index) => {
|
||||
const guess = daily.guesses[index];
|
||||
if (!guess) return <li key={index} data-now={(playing && index === daily.guesses.length) || undefined} aria-hidden="true">{playing ? index + 1 : ""}</li>;
|
||||
const result = dailyGuessResult(guess);
|
||||
return <li key={index} data-result={result}><span aria-hidden="true">{DAILY_MARKS[result]}</span><span className="sr-only">{fillTemplate(content.attemptResult, { count: index + 1, result: content.results[result] })}</span></li>;
|
||||
})}</ol>;
|
||||
}
|
||||
32
website/src/features/cards/dailyKnowledge.js
Normal file
32
website/src/features/cards/dailyKnowledge.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Rôle : règles d'affichage de ce qu'un joueur de la Carte du jour a appris : bilan cumulé de ses essais et phrase sur le dernier.
|
||||
|
||||
// Le sujet : le plus long chemin trouvé, puis seulement les étapes écartées juste après lui (une famille écartée n'apprend plus rien
|
||||
// une fois la bonne connue). Le thème : celui d'un essai ou de l'indice, sinon les thèmes écartés.
|
||||
export function dailyKnowledge(guesses, themeHint = null) {
|
||||
const path = guesses.reduce((best, guess) => (guess.subject.common.length > best.length ? guess.subject.common : best), []).map((step) => step.label);
|
||||
const ruledOut = guesses.filter((guess) => guess.subject.different && guess.subject.common.length === path.length).map((guess) => guess.subject.different.label);
|
||||
return {
|
||||
path,
|
||||
ruledOut: [...new Set(ruledOut)],
|
||||
theme: guesses.find((guess) => guess.theme?.same)?.theme.label ?? themeHint,
|
||||
ruledOutThemes: [...new Set(guesses.filter((guess) => guess.theme && !guess.theme.same).map((guess) => guess.theme.label))]
|
||||
};
|
||||
}
|
||||
|
||||
// Phrase sur le sujet du dernier essai, en morceaux ; `tone` marque le sujet nommé (`same` ou `different`). Vide pour une carte sans sujet.
|
||||
export function dailyVerdict(guesses, content) {
|
||||
const { common, different } = guesses.at(-1).subject;
|
||||
const found = common.at(-1);
|
||||
if (!found && !different) return [];
|
||||
const write = (template, step, tone) => {
|
||||
const [before, after] = template.split("{subject}");
|
||||
return [{ text: before }, { text: step.phrase, tone }, { text: after }];
|
||||
};
|
||||
const parts = found ? write(found.sentences?.same ?? content.subjectSame, found, "same") : write(different.sentences?.different ?? content.subjectDifferent, different, "different");
|
||||
if (found && different) parts.push(...write(found.sentences?.but ?? content.subjectBut, different, "different"));
|
||||
const before = dailyKnowledge(guesses.slice(0, -1));
|
||||
const now = dailyKnowledge(guesses);
|
||||
const learned = now.path.length > before.path.length || now.ruledOut.some((label) => !before.ruledOut.includes(label));
|
||||
parts.push({ text: learned ? "." : content.subjectKnown });
|
||||
return parts.filter((part) => part.text);
|
||||
}
|
||||
|
|
@ -27,9 +27,12 @@ export function dailyGuessResult(guess) {
|
|||
return guess.theme?.same || guess.subject.common.length > 1 ? "close" : "miss";
|
||||
}
|
||||
|
||||
// Signe de chaque résultat, sur la piste et dans la grille des essais.
|
||||
export const DAILY_MARKS = { miss: "✗", close: "≈", correct: "✓" };
|
||||
|
||||
const SHARE_SQUARES = { correct: "🟩", close: "🟨", miss: "⬛" };
|
||||
|
||||
// Une défaite se note X, comme dans les jeux du genre. Les indices retournés s'ajoutent au score : sans eux, rien.
|
||||
// Une défaite se note X, comme dans les jeux du genre. Les indices dévoilés s'ajoutent au score : sans eux, rien.
|
||||
export function dailyShareText(daily, { title, url }) {
|
||||
const score = daily.status === "won" ? `${daily.guesses.length}/${daily.maxGuesses}` : `X/${daily.maxGuesses}`;
|
||||
const hints = daily.hints.length ? ` · 💡${daily.hints.length}` : "";
|
||||
|
|
|
|||
|
|
@ -149,98 +149,6 @@
|
|||
.nebula-quest-body .nebula-quest-status { color: var(--color-text-primary); font-weight: 700; }
|
||||
.nebula-quest-body .nds-card-actions { display: flex; justify-self: stretch; justify-content: center; margin-top: var(--space-2); padding: 0; }
|
||||
|
||||
/* Carte du jour : illustration, propositions et grille des essais, puis les indices sur toute la largeur. */
|
||||
.nebula-daily { display: grid; gap: var(--space-4); min-width: 0; }
|
||||
.nebula-daily .nds-section-heading.nebula-section-heading { margin-bottom: 0; }
|
||||
.nebula-daily-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); }
|
||||
.nebula-daily-expired { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin: 0; }
|
||||
.nebula-daily-layout { display: grid; grid-template-columns: minmax(240px, 360px) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
|
||||
/* À côté du menu de sections (1280 px de large), l'illustration se resserre pour laisser lire la grille des essais. */
|
||||
@container nebula-dashboard (max-width: 1200px) {
|
||||
.nebula-daily-layout { grid-template-columns: minmax(200px, 268px) minmax(0, 1fr); }
|
||||
}
|
||||
@container nebula-dashboard (max-width: 720px) {
|
||||
.nebula-daily-layout { grid-template-columns: minmax(0, 1fr); }
|
||||
.nebula-daily-stage { justify-self: center; width: min(100%, 360px); }
|
||||
}
|
||||
.nds-panel.nebula-daily-stage { display: grid; gap: var(--space-3); padding: var(--space-3); }
|
||||
.nebula-daily-frame { display: grid; place-items: center; overflow: hidden; aspect-ratio: 1; border-radius: var(--radius-lg); background: var(--color-bg-deep); }
|
||||
/* Chaque morceau envoyé par le serveur (zone visible au zoom courant) apparaît en fondu à la place du précédent. */
|
||||
.nebula-daily-frame img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; animation: nebula-daily-image-in 450ms ease; }
|
||||
@keyframes nebula-daily-image-in { from { opacity: 0; transform: scale(1.04); } }
|
||||
@media (prefers-reduced-motion: reduce) { .nebula-daily-frame img { animation: none; } }
|
||||
.nebula-daily-frame-status { padding: var(--space-4); color: var(--color-text-muted); font-size: var(--font-size-sm); text-align: center; }
|
||||
.nebula-daily-steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
|
||||
.nebula-daily-steps li { height: 8px; border-radius: var(--radius-pill); background: var(--color-bg-hover); }
|
||||
.nebula-daily-steps li[data-result="miss"] { background: var(--color-text-disabled); }
|
||||
.nebula-daily-steps li[data-result="close"] { background: var(--color-warning); }
|
||||
.nebula-daily-steps li[data-result="correct"] { background: var(--color-success); }
|
||||
.nebula-daily-play { display: grid; gap: var(--space-3); min-width: 0; }
|
||||
/* La liste de suggestions dépasse du panneau : il ne la coupe pas et passe au-dessus de la liste des essais. */
|
||||
.nds-panel.nebula-daily-form { z-index: 2; display: grid; gap: var(--space-2); padding: var(--space-4); overflow: visible; }
|
||||
.nebula-daily-form p:not(.nds-inline-notice) { margin: 0; color: var(--color-text-secondary); }
|
||||
.nebula-daily-form label { color: var(--color-text-primary); font-weight: 700; }
|
||||
.nebula-daily-form .nds-inline-notice { margin: 0; }
|
||||
.nebula-daily-form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: start; }
|
||||
/* Grille des six essais : la carte proposée, le chemin de son sujet et son thème. Les lignes à venir gardent la hauteur stable. */
|
||||
.nebula-daily-guesses { display: grid; gap: var(--space-1); min-width: 0; }
|
||||
.nebula-daily-guesses ol { display: grid; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
|
||||
.nebula-daily-columns, .nebula-daily-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.9fr) minmax(0, 0.85fr); gap: var(--space-1); }
|
||||
.nebula-daily-columns { padding-inline: 2px; color: var(--color-text-muted); font-size: var(--font-size-xs); }
|
||||
.nebula-daily-row { min-height: 36px; }
|
||||
.nebula-daily-row > * { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 3px 8px; border-radius: var(--radius-sm); background: var(--color-bg-surface); color: var(--color-text-muted); font-size: 0.8125rem; line-height: 1.2; }
|
||||
.nebula-daily-row > strong { color: var(--color-text-primary); }
|
||||
.nebula-daily-row[data-empty] > * { opacity: 0.55; }
|
||||
.nebula-daily-row > strong[data-next] { opacity: 1; outline: 1px dashed var(--color-border-hover); outline-offset: -1px; color: var(--color-text-muted); font-weight: 400; }
|
||||
.nebula-daily-path { flex-wrap: wrap; row-gap: 3px; }
|
||||
.nebula-daily-step { display: inline-flex; align-items: center; gap: 4px; }
|
||||
.nebula-daily-step[data-same] { padding: 1px 8px; border-radius: var(--radius-pill); background: var(--color-success-soft); color: var(--color-success); font-weight: 600; }
|
||||
.nebula-daily-theme[data-same], .nebula-daily-row[data-correct] > * { background: var(--color-success-soft); color: var(--color-success); font-weight: 600; }
|
||||
|
||||
/* Indices au choix : cinq tuiles sur toute la largeur, qui se retournent sur place. */
|
||||
.nebula-daily-hints { display: grid; grid-column: 1 / -1; gap: var(--space-2); min-width: 0; }
|
||||
.nebula-daily-hints-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-3); }
|
||||
.nebula-daily-hints-heading :is(h3, p) { margin: 0; }
|
||||
.nebula-daily-hints-heading h3 { font-size: var(--font-size-base); }
|
||||
.nebula-daily-hints-heading p { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-hints ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
|
||||
.nebula-daily-hint { display: grid; min-width: 0; min-height: 104px; }
|
||||
.nebula-daily-hint > button { display: grid; align-content: center; justify-items: center; gap: 4px; padding: var(--space-2); border: 1px solid var(--color-border-hover); border-radius: var(--radius-md); background: radial-gradient(circle at 50% 45%, rgba(139, 92, 246, 0.3), transparent 68%), var(--color-bg-sidebar); color: var(--color-text-primary); font: inherit; text-align: center; }
|
||||
.nebula-daily-hint small { color: var(--color-text-muted); font-size: var(--font-size-xs); }
|
||||
.nebula-daily-hint[data-state="locked"] > button { opacity: 0.6; cursor: default; }
|
||||
.nebula-daily-hint[data-state="ready"] > button { border-color: var(--color-accent-gold); box-shadow: 0 0 18px rgba(246, 196, 83, 0.18); cursor: pointer; }
|
||||
.nebula-daily-hint[data-state="ready"] > button:hover { background-color: var(--color-bg-hover); }
|
||||
.nebula-daily-hint[data-state="ready"] > button:focus-visible { outline: 2px solid var(--color-accent-gold); outline-offset: 2px; }
|
||||
.nebula-daily-hint[data-state="ready"] small { color: var(--color-accent-gold); font-weight: 700; }
|
||||
.nebula-daily-hint[data-state="open"] { align-content: start; gap: 4px; padding: 10px 12px; border: 1px solid var(--color-border-hover); border-radius: var(--radius-md); background: var(--color-bg-elevated); animation: nebula-daily-hint-in 320ms var(--ease-standard); }
|
||||
@keyframes nebula-daily-hint-in { from { opacity: 0; transform: perspective(700px) rotateY(-80deg); } }
|
||||
@media (prefers-reduced-motion: reduce) { .nebula-daily-hint[data-state="open"] { animation: none; } }
|
||||
.nebula-daily-hint-value { color: var(--color-text-primary); font-size: var(--font-size-base); font-weight: 600; line-height: 1.3; }
|
||||
.nebula-daily-hint-page { color: var(--color-text-secondary); font-size: var(--font-size-sm); font-style: italic; line-height: 1.4; }
|
||||
.nebula-daily-gap { display: inline-block; width: 3em; height: 0.9em; border-radius: 3px; background: var(--color-text-disabled); vertical-align: -0.1em; }
|
||||
.nebula-daily-hint-value .nebula-daily-gap { width: 2.4em; background: var(--color-primary-border); }
|
||||
@container nebula-dashboard (max-width: 720px) {
|
||||
.nebula-daily-hints ul { grid-template-columns: repeat(6, minmax(0, 1fr)); }
|
||||
.nebula-daily-hint { grid-column: span 2; }
|
||||
.nebula-daily-hint:nth-child(n + 4) { grid-column: span 3; }
|
||||
}
|
||||
.nds-panel.nebula-daily-result { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: var(--space-4); align-items: center; padding: var(--space-5); }
|
||||
@container nebula-dashboard (max-width: 560px) {
|
||||
.nds-panel.nebula-daily-result { grid-template-columns: minmax(0, 1fr); }
|
||||
.nebula-daily-result-card { justify-self: center; }
|
||||
}
|
||||
.nebula-daily-result-copy { display: grid; gap: var(--space-3); min-width: 0; }
|
||||
.nebula-daily-result-copy :is(h3, p) { margin: 0; }
|
||||
.nebula-daily-result-copy h3 { font-size: var(--font-size-xl); }
|
||||
.nebula-daily-answer { display: grid; gap: var(--space-1); }
|
||||
.nebula-daily-answer strong { color: var(--color-text-primary); font-size: var(--font-size-lg); }
|
||||
.nebula-daily-answer span { color: var(--color-text-secondary); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-result-badges { display: flex; flex-wrap: wrap; gap: var(--space-2); }
|
||||
.nds-toolbar.nebula-daily-result-actions { flex-wrap: wrap; align-items: center; gap: var(--space-3); }
|
||||
.nebula-daily-next { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-result-card { width: 180px; }
|
||||
.nebula-daily-result-card .nebula-card { max-width: 180px; }
|
||||
|
||||
.nebula-pack-page { display: grid; gap: var(--space-6); }
|
||||
.nds-section-heading.nebula-pack-page-heading { align-items: stretch; }
|
||||
.nebula-pack-categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
|
||||
|
|
|
|||
168
website/src/styles/_nebula-daily.scss
Normal file
168
website/src/styles/_nebula-daily.scss
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
// Rôle : page de la Carte du jour : illustration et saisie côte à côte, indices à dévoiler, grille des essais et fin de partie.
|
||||
|
||||
.nebula-daily { display: grid; gap: var(--space-4); min-width: 0; container: nebula-daily / inline-size; }
|
||||
.nebula-daily .nds-section-heading.nebula-section-heading { margin-bottom: 0; }
|
||||
.nebula-daily-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); }
|
||||
.nebula-daily-expired { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin: 0; }
|
||||
.nebula-daily-layout :is(h3, h4, p, ul, ol, dl, dd) { margin: 0; }
|
||||
.nebula-daily-layout :is(ul, ol) { padding: 0; list-style: none; }
|
||||
.nebula-daily-layout :is(h3, h4) { font-size: var(--font-size-base); }
|
||||
|
||||
.nebula-daily-layout { display: grid; grid-template: "stage play" auto "hints hints" auto "guesses guesses" auto / min(340px, 44%) minmax(0, 1fr); gap: var(--space-5); }
|
||||
.nebula-daily-layout[data-finished] { grid-template: "stage play" auto "guesses guesses" auto / min(340px, 44%) minmax(0, 1fr); }
|
||||
@container nebula-daily (min-width: 1000px) {
|
||||
.nebula-daily-layout, .nebula-daily-layout[data-finished] { grid-template-columns: 380px minmax(0, 1fr); }
|
||||
}
|
||||
@container nebula-daily (max-width: 620px) {
|
||||
.nebula-daily-layout { grid-template: "stage" auto "play" auto "hints" auto "guesses" auto / minmax(0, 1fr); }
|
||||
.nebula-daily-layout[data-finished] { grid-template: "stage" auto "play" auto "guesses" auto / minmax(0, 1fr); }
|
||||
.nds-panel.nebula-daily-stage { justify-self: center; width: min(100%, 300px); }
|
||||
}
|
||||
|
||||
.nds-panel.nebula-daily-stage { grid-area: stage; display: grid; align-content: center; justify-items: center; gap: var(--space-3); padding: var(--space-3); }
|
||||
.nebula-daily-frame { display: grid; place-items: center; overflow: hidden; width: 100%; aspect-ratio: 1; border-radius: var(--radius-lg); background: var(--color-bg-deep); }
|
||||
/* Chaque morceau envoyé par le serveur (zone visible au zoom courant) apparaît en fondu à la place du précédent. */
|
||||
.nebula-daily-frame img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; animation: nebula-daily-image-in 450ms ease; }
|
||||
@keyframes nebula-daily-image-in { from { opacity: 0; transform: scale(1.04); } }
|
||||
.nebula-daily-frame-status { padding: var(--space-4); color: var(--color-text-muted); font-size: var(--font-size-sm); text-align: center; }
|
||||
.nebula-daily-stage .nebula-card[data-card-size="md"] { width: 100%; max-width: 270px; }
|
||||
|
||||
.nebula-daily-icon { display: block; width: 22px; height: 22px; }
|
||||
.nebula-daily-disc { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary-hover); }
|
||||
|
||||
/* Saisie. La liste de suggestions dépasse du panneau : il ne la coupe pas et passe au-dessus des indices et de la grille. */
|
||||
.nds-panel.nebula-daily-form, .nds-panel.nebula-daily-result { grid-area: play; display: grid; gap: var(--space-3); min-width: 0; padding: var(--space-4) var(--space-5); }
|
||||
.nds-panel.nebula-daily-form { z-index: 2; grid-template-rows: auto auto auto 1fr; overflow: visible; }
|
||||
.nebula-daily-form .nds-inline-notice { margin: 0; }
|
||||
.nebula-daily-ask-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px var(--space-3); }
|
||||
.nebula-daily-ask-heading :is(label, h3) { color: var(--color-text-primary); font-size: var(--font-size-lg); font-weight: 700; }
|
||||
.nebula-daily-ask-heading > span { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
|
||||
.nebula-daily-track li { display: grid; place-items: center; height: 30px; border: 1px solid var(--color-border); border-radius: 8px; color: var(--color-text-disabled); font-size: var(--font-size-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
|
||||
.nebula-daily-track li[data-now] { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-text-primary); }
|
||||
:is(.nebula-daily-track li, .nebula-daily-mark)[data-result="miss"] { border-color: transparent; background: var(--color-bg-hover); color: var(--color-text-secondary); }
|
||||
:is(.nebula-daily-track li, .nebula-daily-mark)[data-result="close"] { border-color: color-mix(in srgb, var(--color-warning) 50%, transparent); background: var(--color-warning-soft); color: var(--color-warning); }
|
||||
:is(.nebula-daily-track li, .nebula-daily-mark)[data-result="correct"] { border-color: color-mix(in srgb, var(--color-success) 60%, transparent); background: var(--color-success-soft); color: var(--color-success); }
|
||||
/* Au-dessus du bilan, que la liste de suggestions recouvre. */
|
||||
.nds-panel > .nebula-daily-form-row { position: relative; z-index: 3; }
|
||||
.nebula-daily-form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: start; }
|
||||
/* La liste prend la largeur de toute la ligne, bouton compris. */
|
||||
.nebula-daily-form .nds-autocomplete-field { position: static; }
|
||||
.nebula-daily-form .nds-autocomplete-option { display: block; font-weight: 400; text-align: left; text-overflow: clip; white-space: normal; }
|
||||
.nebula-daily-form .nds-autocomplete-option mark { background: none; color: var(--color-accent-gold); font-weight: 700; }
|
||||
.nebula-daily-form .nds-autocomplete-option small { margin-left: var(--space-2); color: var(--color-text-muted); }
|
||||
.nebula-daily-form .nds-autocomplete-option[aria-disabled] { color: var(--color-text-muted); }
|
||||
|
||||
/* Sous la saisie : les règles du départ, puis le bilan du dernier essai et ce que le joueur sait. */
|
||||
.nebula-daily-aside { display: grid; min-width: 0; padding-top: var(--space-3); border-top: 1px solid var(--color-border); }
|
||||
.nebula-daily-rules, .nebula-daily-feedback { display: grid; align-content: center; gap: var(--space-2); min-width: 0; color: var(--color-text-secondary); font-size: 0.9375rem; }
|
||||
.nebula-daily-rules ul { display: grid; gap: 5px; }
|
||||
.nebula-daily-rules li { display: flex; align-items: center; gap: 10px; font-size: var(--font-size-sm); }
|
||||
.nebula-daily-rules .nebula-daily-disc { width: 26px; height: 26px; }
|
||||
.nebula-daily-rules .nebula-daily-icon { width: 15px; height: 15px; }
|
||||
.nebula-daily-feedback { animation: nebula-daily-feedback-in 350ms ease; }
|
||||
@keyframes nebula-daily-feedback-in { from { opacity: 0.2; transform: translateY(-4px); } }
|
||||
.nebula-daily-verdict { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px var(--space-3); line-height: 1.4; }
|
||||
.nebula-daily-verdict > p:first-child { flex: 1 1 180px; min-width: 0; }
|
||||
.nebula-daily-verdict strong { color: var(--color-text-primary); }
|
||||
.nebula-daily-verdict-subject { flex: 1 0 100%; font-size: var(--font-size-sm); }
|
||||
.nebula-daily-verdict-subject b { font-weight: 600; }
|
||||
.nebula-daily-verdict-subject b[data-tone="same"] { color: var(--color-success); }
|
||||
.nebula-daily-verdict-subject b[data-tone="different"] { color: var(--color-warning); }
|
||||
.nebula-daily-gains { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.nebula-daily-gains > span { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 0.8125rem; font-weight: 700; }
|
||||
.nebula-daily-gains [data-kind="hint"] { background: rgba(246, 196, 83, 0.13); color: var(--color-accent-gold); }
|
||||
.nebula-daily-gains [data-kind="last"] { background: var(--color-warning-soft); color: var(--color-warning); }
|
||||
.nebula-daily-gains .nebula-daily-icon { width: 14px; height: 14px; }
|
||||
.nebula-daily-know { display: grid; gap: 7px; padding: 10px 14px 11px; border: 1px solid var(--color-border-hover); border-radius: 11px; background: rgba(5, 7, 17, 0.45); }
|
||||
.nebula-daily-know :is(h3, h4) { color: var(--color-text-primary); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-know dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; font-size: var(--font-size-sm); line-height: 1.4; }
|
||||
.nebula-daily-know :is(dt, dd > span, .nebula-daily-answer-theme > span) { color: var(--color-text-muted); }
|
||||
.nebula-daily-know dd { display: grid; gap: 2px; min-width: 0; color: var(--color-text-primary); }
|
||||
.nebula-daily-ruled-out { font-size: 0.8125rem; }
|
||||
.nebula-daily-ruled-out s { color: var(--color-text-secondary); }
|
||||
.nebula-daily-ruled-out s[data-new] { color: var(--color-warning); }
|
||||
.nebula-daily-path, .nebula-daily-path-step, .nebula-daily-answer-theme { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
|
||||
.nebula-daily-path-step { flex-wrap: nowrap; color: var(--color-text-muted); white-space: nowrap; }
|
||||
.nebula-daily-chip { padding: 0 8px; border: 1px solid var(--color-border-hover); border-radius: var(--radius-pill); color: var(--color-text-secondary); font-size: 0.8125rem; }
|
||||
.nebula-daily-chip[data-found] { border-color: transparent; background: var(--color-success-soft); color: var(--color-success); font-weight: 600; }
|
||||
.nebula-daily-chip[data-new] { border-color: var(--color-success); }
|
||||
@container nebula-daily (max-width: 380px) {
|
||||
.nebula-daily-form-row, .nebula-daily-know dl { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
|
||||
/* Indices : des cadres de taille fixe, que l'ouverture d'un autre ne change jamais. */
|
||||
.nebula-daily-hints { grid-area: hints; min-width: 0; }
|
||||
.nebula-daily-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-3); margin-bottom: var(--space-3); }
|
||||
.nebula-daily-heading > p { display: flex; flex: 1; flex-wrap: wrap; gap: 0 14px; min-width: 160px; color: var(--color-text-secondary); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-purse { display: inline-flex; align-items: center; gap: 6px; padding: 4px 13px; border: 1px solid var(--color-border-hover); border-radius: var(--radius-pill); color: var(--color-text-muted); font-size: var(--font-size-sm); font-weight: 700; }
|
||||
.nebula-daily-purse[data-on] { border-color: rgba(246, 196, 83, 0.55); background: rgba(246, 196, 83, 0.13); color: var(--color-accent-gold); }
|
||||
.nebula-daily-purse .nebula-daily-icon, .nebula-daily-lens .nebula-daily-icon { width: 18px; height: 18px; }
|
||||
.nebula-daily-hints ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 88px; gap: 10px; }
|
||||
.nebula-daily-hint { display: grid; min-width: 0; border: 1px solid var(--color-border-hover); border-radius: var(--radius-lg); background: var(--color-bg-surface); transition: border-color var(--duration-fast); }
|
||||
.nebula-daily-hint[data-hint="page"] { grid-column: span 2; }
|
||||
.nebula-daily-hint > :is(button, div) { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-width: 0; padding: 4px 12px; border: 0; border-radius: inherit; background: none; color: var(--color-text-primary); font: inherit; line-height: 1.3; text-align: left; }
|
||||
.nebula-daily-hint > * > span:nth-child(2) { display: grid; gap: 1px; min-width: 0; }
|
||||
.nebula-daily-hint strong { color: var(--color-text-primary); font-size: 0.9375rem; line-height: 1.25; overflow-wrap: break-word; }
|
||||
.nebula-daily-hint small { color: var(--color-text-muted); font-size: 0.8125rem; }
|
||||
.nebula-daily-hint em { font-size: var(--font-size-sm); line-height: 1.35; }
|
||||
.nebula-daily-lens { display: grid; place-items: center; width: 34px; height: 34px; border: 1px dashed var(--color-border-hover); border-radius: 50%; color: var(--color-text-disabled); }
|
||||
.nebula-daily-hint[data-state="locked"] > button { cursor: default; opacity: 1; }
|
||||
.nebula-daily-hint[data-state="locked"] strong { color: var(--color-text-secondary); }
|
||||
.nebula-daily-hint[data-state="ready"] { border-color: rgba(246, 196, 83, 0.6); }
|
||||
.nebula-daily-hint[data-state="ready"] > button { cursor: pointer; }
|
||||
.nebula-daily-hint[data-state="ready"]:hover { border-color: var(--color-accent-gold); background: var(--color-bg-elevated); }
|
||||
.nebula-daily-hint[data-state="ready"] > button:focus-visible { outline: 2px solid var(--color-accent-gold); outline-offset: 2px; }
|
||||
.nebula-daily-hint[data-state="ready"] .nebula-daily-disc { background: rgba(246, 196, 83, 0.13); color: var(--color-accent-gold); }
|
||||
.nebula-daily-hint[data-state="ready"] .nebula-daily-lens { border: 0; background: var(--color-accent-gold); color: var(--color-text-inverse); }
|
||||
.nebula-daily-hint[data-state="open"] { border-color: color-mix(in srgb, var(--color-success) 45%, transparent); background: var(--color-bg-elevated); }
|
||||
.nebula-daily-hint[data-state="open"] > div { grid-template-columns: 40px minmax(0, 1fr); animation: nebula-daily-hint-in 450ms ease; }
|
||||
.nebula-daily-hint[data-state="open"] .nebula-daily-disc { background: var(--color-success-soft); color: var(--color-success); }
|
||||
@keyframes nebula-daily-hint-in { from { opacity: 0.2; transform: perspective(600px) rotateX(-80deg); } }
|
||||
.nebula-daily-gap { display: inline-block; width: 2.6em; height: 0.85em; border-radius: 3px; background: var(--color-text-disabled); vertical-align: -0.08em; }
|
||||
|
||||
/* Grille des essais : vert comme la réponse, barré différent. */
|
||||
.nebula-daily-guesses, .nebula-daily-families { grid-area: guesses; min-width: 0; }
|
||||
.nebula-daily-guesses .nebula-daily-heading { margin-bottom: 4px; }
|
||||
.nebula-daily-guesses :is(b, u[data-same], .nebula-daily-heading b) { color: var(--color-success); font-weight: 600; }
|
||||
.nebula-daily-guesses s { color: var(--color-text-muted); }
|
||||
.nebula-daily-guesses ol { display: grid; gap: 5px; }
|
||||
.nebula-daily-columns, .nebula-daily-guess { display: grid; grid-template-columns: 22px minmax(0, 1.4fr) minmax(0, 1.5fr) minmax(0, 0.6fr); gap: 4px 14px; }
|
||||
.nebula-daily-columns { padding: 0 13px 4px; color: var(--color-text-muted); font-size: 0.8125rem; }
|
||||
.nebula-daily-guess { align-items: center; min-height: 46px; padding: 10px 12px; border: 1px solid transparent; border-radius: 9px; background: var(--color-bg-surface); font-size: var(--font-size-sm); line-height: 1.3; }
|
||||
.nebula-daily-guess[data-last] { border-color: var(--color-border-hover); background: var(--color-bg-elevated); }
|
||||
.nebula-daily-guess[data-result="correct"] { background: var(--color-success-soft); }
|
||||
.nebula-daily-guess > * { min-width: 0; overflow-wrap: break-word; }
|
||||
.nebula-daily-guess strong { color: var(--color-text-primary); font-size: 0.9375rem; }
|
||||
.nebula-daily-guess u { text-decoration: underline dotted 2px var(--color-text-muted); text-underline-offset: 3px; }
|
||||
.nebula-daily-guess u[data-same] { font-weight: inherit; text-decoration-color: currentcolor; }
|
||||
.nebula-daily-mark { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid transparent; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
|
||||
.nebula-daily-legend { display: flex; flex-wrap: wrap; gap: 2px 16px; padding: 6px 12px 0; color: var(--color-text-muted); font-size: 0.8125rem; }
|
||||
.nebula-daily-guesses .nebula-daily-legend b { color: var(--color-warning); }
|
||||
.nebula-daily-families { padding: 14px; border: 1px dashed var(--color-border-hover); border-radius: var(--radius-md); color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-daily-families ul { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
|
||||
.nebula-daily-families li { display: grid; line-height: 1.35; }
|
||||
.nebula-daily-families b { color: var(--color-text-secondary); }
|
||||
.nebula-daily-families span { font-size: 0.8125rem; }
|
||||
@container nebula-daily (max-width: 620px) {
|
||||
.nebula-daily-hints ul { grid-template-columns: minmax(0, 1fr); grid-auto-rows: 72px; }
|
||||
.nebula-daily-hint[data-hint="page"] { grid-column: auto; grid-row: span 2; }
|
||||
.nebula-daily-columns { display: none; }
|
||||
.nebula-daily-guess { grid-template-columns: 22px minmax(0, 1fr); }
|
||||
.nebula-daily-guess > :nth-child(n + 3) { grid-column: 2; }
|
||||
.nebula-daily-theme-cell::before { content: attr(data-label) " : "; color: var(--color-text-muted); }
|
||||
}
|
||||
|
||||
/* Fin de partie : la carte à gauche, le résultat à droite. */
|
||||
.nds-panel.nebula-daily-result { align-content: space-between; }
|
||||
.nebula-daily-result[data-status="won"] .nebula-daily-ask-heading h3 { color: var(--color-success); }
|
||||
.nebula-daily-result .nebula-daily-ask-heading h3 { font-size: var(--font-size-xl); }
|
||||
.nebula-daily-description { color: var(--color-text-secondary); font-size: 0.9375rem; font-style: italic; }
|
||||
.nebula-daily-rewards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-2); }
|
||||
.nebula-daily-rewards li { padding: 8px; border-radius: var(--radius-md); background: var(--color-bg-elevated); color: var(--color-accent-gold); font-size: var(--font-size-sm); font-weight: 700; text-align: center; }
|
||||
.nebula-daily-result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
|
||||
.nebula-daily-result-actions > span { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.nebula-daily :is(.nebula-daily-frame img, .nebula-daily-feedback, .nebula-daily-hint > div) { animation: none; }
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
// égale, ces dernières l'emportaient. Chargée après main.scss, cette feuille les ré-émet après les cartes pour garder
|
||||
// exactement cette priorité ; tests/styles-split.test.mjs vérifie que la liste suit main.scss.
|
||||
@use "nebula-cards";
|
||||
@use "nebula-daily";
|
||||
@use "nebula-expeditions";
|
||||
@use "nebula-expedition-destinations";
|
||||
@use "nebula-expedition-loadout";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue