sokko-g/website/src/features/cards/dailyShare.js
Shinuwa 8c0771f06f
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 23m32s
Validate and deploy Sokko G / deploy (push) Successful in 16s
Rework the Broken Mirror screens and the Guild quest board
The mirror page opens on two illustrated cards, Normal and Hard, painted
with Codex, with three small rule reminders; a card opens or starts its
game. The five companions of the daily team show as tiles: one click uses
a help, two per game, with no selection step. Helps are renamed after
what they do (swap anywhere, show a piece's place, double the rewards,
undo the last move, see the model again), use the shared tooltip and
keep the same height. Selecting a piece no longer waits for the server,
and showing a place aims at the selected piece. Under 960 px of
dashboard, like the section menu, the board goes on top and the moves
panel keeps only the count. Stardust is always written in full.

The Guild board shows four tiles per row on full screen, aligned with
subgrids, solo quests first. Status lines give way to a wooden "Fait"
sign on finished quests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 16:25:35 +01:00

40 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Rôle : règles d'affichage de la Carte du jour, quête de la Guilde des Veilleurs (textes, résultat à partager, compte à rebours, recherche de carte par nom).
export const fillTemplate = (template, values) => Object.entries(values).reduce((text, [key, value]) => text.replaceAll(`{${key}}`, String(value)), template);
export const formatStreak = (days) => `${days} jour${days > 1 ? "s" : ""}`;
// Recherche tolérante : sans accents, sans casse et quel que soit l'apostrophe tapée.
export function normalizeCardName(value) {
return String(value || "").normalize("NFD").replace(/\p{Diacritic}/gu, "").replace(/[’`]/g, "'").replace(/\s+/g, " ").trim().toLowerCase();
}
export function findCardByName(cards, name) {
const wanted = normalizeCardName(name);
return wanted ? cards.find((card) => normalizeCardName(card.name) === wanted) || null : null;
}
// Proche : même thème, ou au moins deux étapes du sujet en commun (« Animal » seul vaut pour presque la moitié des cartes).
export function dailyGuessResult(guess) {
if (guess.correct) return "correct";
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 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}` : "";
const squares = daily.guesses.map((guess) => SHARE_SQUARES[dailyGuessResult(guess)]).join("");
return [`${title} #${daily.number} · ${score}${hints}`, squares, url].filter(Boolean).join("\n");
}
export function formatCountdown(milliseconds) {
const minutes = Math.max(1, Math.ceil(milliseconds / 60_000));
const hours = Math.floor(minutes / 60);
return hours ? `${hours} h ${String(minutes % 60).padStart(2, "0")} min` : `${minutes} min`;
}