The 48 files of the Daily Card, Expeditions, Daily Team and race, Broken Mirror and card rendering move to daily/, expeditions/, team/, mirror/ and rendering/ under website/src/features/cards, with every relative import rewritten. The root keeps the page, server calls, cache and the player sections outside the Guild. The cards README, the quest recipe and the current docs follow the new paths; dated audits and plans keep theirs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
3.5 KiB
JavaScript
58 lines
3.5 KiB
JavaScript
/**
|
||
* @file 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>;
|
||
}
|