Add a daily tip to the Sokko TCG home that explains hidden mechanics

39 short tips cover packs, collection, trades, the daily card and Expeditions (getting cards, succeeding, groups, loot, improving cards, bag items). Each one has a topic that starts with its part of the game, such as "Expéditions · Réussir". Every figure comes from the current settings through tipValues(), so a tip follows an admin change. Expedition tips only show while Expeditions are open. The tip of the day is the same for everyone, "Astuce suivante" shows the next ones, and the card sits under the key figures so the home still fits a 1280 × 720 screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-19 10:56:01 +01:00
parent 17bec5d690
commit e8ec657193
11 changed files with 167 additions and 2 deletions

View file

@ -2,6 +2,7 @@
import { useState } from "react";
import { CardDetailModal } from "./CardDetailModal.jsx";
import { DashboardAside, DashboardStat } from "./CardsDashboard.jsx";
import { DailyTip } from "./DailyTip.jsx";
import { readCollection } from "./collectionState.js";
import { NebulaCard } from "./NebulaCard.jsx";
import { OpeningReserve } from "./OpeningReserve.jsx";
@ -27,7 +28,7 @@ function GuildBanner({ state, content, guildContent }) {
</section>;
}
export function CardsHomePanel({ catalog, state, runMutation, busy, content, guildContent, cardSheetContent, onOpenPacks }) {
export function CardsHomePanel({ catalog, state, runMutation, busy, content, guildContent, tipsContent, cardSheetContent, onOpenPacks }) {
const [detailOpen, setDetailOpen] = useState(false);
const collectibleCards = catalog.cards.filter((card) => catalog.editions.some((edition) => edition.cardId === card.id && !edition.promotional));
const collectibleEditions = catalog.editions.filter((edition) => !edition.promotional);
@ -68,6 +69,8 @@ export function CardsHomePanel({ catalog, state, runMutation, busy, content, gui
<DashboardStat label={content.stardust} value={<StardustBalance value={state.wallet.stardust} />} />
<DashboardStat label={content.recyclable} value={state.recycling.count} />
</section>
{/* Sous les chiffres clés : en 1280 × 720, l'Accueil tient encore sans défiler jusqu'à eux. */}
<DailyTip content={tipsContent} values={state.tipValues} day={state.daily?.day ?? new Date().toISOString().slice(0, 10)} />
{detailOpen && rarest && <CardDetailModal catalog={catalog} state={state} entry={rarest} content={cardSheetContent} runMutation={runMutation} busy={busy} onClose={() => setDetailOpen(false)} />}
</section>;
}

View file

@ -273,7 +273,7 @@ export function CardsPage({ siteContent, cardsConfig, playerSection = "", player
hrefFor={(id) => id === "home" ? "#/cards" : `#/cards/${id}`}
switchLink={state.player.isAdmin ? { href: "#/cards/admin", label: "Administration" } : null}
>
{section === "home" && <CardsHomePanel {...panelProps} content={content.home} guildContent={content.guild} onOpenPacks={openPacks} />}
{section === "home" && <CardsHomePanel {...panelProps} content={content.home} guildContent={content.guild} tipsContent={content.tips} onOpenPacks={openPacks} />}
{section === "guild" && <GuildPanel catalog={catalog} state={state} content={content.guild} />}
{section === "daily" && <DailyPanel {...panelProps} content={content.daily} />}
{section === "expeditions" && <ExpeditionsPanel {...panelProps} content={{ ...content.expeditions, cardSheet: content.cardSheet }} joinId={decodeURIComponent(playerSubsection)} />}

View file

@ -0,0 +1,23 @@
// Rôle : encart « Astuce du jour » de l'Accueil : une astuce simple sur une mécanique peu visible du jeu, la même pour tous ce jour-là,
// puis les suivantes à la demande. Les chiffres viennent des réglages en cours (`state.tipValues`) ; les astuces des Expéditions ne
// s'affichent que si elles sont ouvertes.
import { useState } from "react";
import { fillTemplate } from "./dailyShare.js";
import { availableTips, tipOfDay } from "./dailyTips.js";
// `content` : textes cards.tips ; `day` : jour de la Carte du jour (heure de Paris), sinon la date du navigateur.
export function DailyTip({ content, values, day }) {
const tips = availableTips(content.items, values);
const [offset, setOffset] = useState(0);
if (!tips.length) return null;
const tip = tips[(tipOfDay(day, tips.length) + offset) % tips.length];
// L'intitulé dit ce que l'astuce touche (« Expéditions · Réussir ») ; l'astuce et son intitulé changent ensemble.
return <section className="nds-panel nebula-home-tip" aria-label={content.label}>
<div className="nebula-home-tip-copy" aria-live="polite">
<p className="eyebrow">{content.eyebrow}</p>
<h3>{tip.topic}</h3>
<p className="nebula-home-tip-text">{fillTemplate(tip.text, values ?? {})}</p>
</div>
{tips.length > 1 && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" onClick={() => setOffset(offset + 1)}>{content.next}</button>}
</section>;
}

View file

@ -0,0 +1,14 @@
// Rôle : règles pures de l'« Astuce du jour » : astuces affichables et rang de l'astuce du jour.
// Astuces affichables, dans l'ordre de `site.json` : celles des Expéditions seulement si elles sont ouvertes.
export function availableTips(items, values) {
return items.filter((item) => item.scope !== "expeditions" || values?.expeditions);
}
// Astuce du jour : un rang tiré de la date (AAAA-MM-JJ), stable toute la journée et le même pour tous.
export function tipOfDay(day, count) {
if (!count) return 0;
let hash = 0;
for (const character of String(day)) hash = (hash * 31 + character.charCodeAt(0)) >>> 0;
return hash % count;
}