#/mobile/cards shows the game without the site shell: a title, a footer with the account and a discreet "Version complète" link, and a tab bar fixed at the bottom. Phones opening #/cards are sent to the same section in mobile mode unless the player chose the full version. Account, History and Administration point to the computer. The panels are the computer ones, adapted under .nebula-mobile (and body.nebula-mobile-body for dialogs) for a 393×852 reference phone: small cards with names under them when opening packs, a revealed card shown large on tap, tap-to-pick team recruitment with a single Recruit button and large stars, row lists for explorers and commons in the expedition pickers, a race track and circuit that read at phone size, and full-width actions throughout. Firefox no longer shows a mirrored back on a flipped card. Phone Playwright journeys check that every section fits the screen with no button wrapping, then open a pack, run an expedition and recruit a team by touch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
157 lines
10 KiB
JavaScript
157 lines
10 KiB
JavaScript
/**
|
|
* @file Hall de la Guilde des Veilleurs : le comptoir (accueil et avancée des quêtes du jour), les grandes missions
|
|
* (les Expéditions, mises en avant), l'équipe du joueur, puis le tableau des quêtes du jour, une tuile par
|
|
* quête avec son état.
|
|
*
|
|
* Utilisé par : CardsPage.jsx (section `guild`).
|
|
* Dépend de : guildQuests.js (quelles quêtes afficher et lesquelles attendent le joueur), TeamTable.jsx.
|
|
* Attention : une nouvelle quête demande sa tuile ici et son entrée dans guildQuests.js.
|
|
*/
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { fillTemplate, formatStreak } from "./textFormat.js";
|
|
import { expeditionQuestStatus } from "./expeditions/expeditionFormat.js";
|
|
import { guildGreeting, guildQuests, mirrorDone, questDone } from "./guildQuests.js";
|
|
import { TeamTable } from "./team/TeamTable.jsx";
|
|
import { useCardsHref } from "./useCardsHref.js";
|
|
|
|
const ART = {
|
|
hall: "/static/img/cards/guild/hall.webp",
|
|
clerk: "/static/img/cards/guild-veilleurs.webp",
|
|
daily: "/static/img/cards/guild/quest-daily.webp",
|
|
race: "/static/img/cards/guild/quest-race.webp",
|
|
mirror: "/static/img/cards/guild/quest-mirror.webp",
|
|
expeditions: "/static/img/cards/guild/quest-expeditions.webp"
|
|
};
|
|
|
|
/**
|
|
* Tuile d'une quête : son illustration, son type, son état et le bouton qui y mène. `badge` se pose sur l'illustration ; `sign`, une
|
|
* pancarte de bois penchée, signale une quête qui demande une équipe tant que le joueur n'en a pas ; `doneSign`, la pancarte « Fait »
|
|
* d'une quête du jour terminée. Les tuiles du tableau n'ont pas de phrase d'état (`status` vide) : pancartes et bouton la remplacent.
|
|
*/
|
|
function QuestTile({ id, art, kind, title, description, status = null, action, href, primary, badge = null, sign = "", doneSign = "", locked = false, done = false }) {
|
|
return <article className="nds-card nebula-quest" data-quest={id} data-done={done || undefined} data-locked={locked || undefined} aria-labelledby={`nebula-quest-${id}-title`}>
|
|
<div className="nebula-quest-media">
|
|
{/* L'illustration mène aussi à la quête, comme les couvertures des Toolboxes ; le bouton reste le lien annoncé. Celle qui porte
|
|
la pancarte (quête en équipe, sans équipe prête) ne l'est pas. */}
|
|
{sign ? <div className="nds-card-cover nebula-quest-cover" aria-hidden="true"><img src={art} alt="" loading="lazy" /></div>
|
|
: <a className="nds-card-cover nebula-quest-cover" href={href} tabIndex={-1} aria-hidden="true"><img src={art} alt="" loading="lazy" /></a>}
|
|
{sign && <span className="nebula-quest-sign">{sign}</span>}
|
|
{done && doneSign && <span className="nebula-quest-sign" data-kind="done"><i aria-hidden="true">✓</i>{doneSign}</span>}
|
|
{badge}
|
|
</div>
|
|
<div className="nds-card-body nebula-quest-body">
|
|
<p className="eyebrow">{kind}</p>
|
|
<h3 id={`nebula-quest-${id}-title`}>{title}</h3>
|
|
<p>{description}</p>
|
|
{status && <p className="nebula-quest-status">{status}</p>}
|
|
<div className="nds-card-actions"><a className="nds-button" data-size="sm" data-variant={primary ? "primary" : "secondary"} href={href}>{action}</a></div>
|
|
</div>
|
|
</article>;
|
|
}
|
|
|
|
function DailyQuest({ summary: daily, pending, content }) {
|
|
const cardsHref = useCardsHref();
|
|
const finished = daily.status !== "playing" && !daily.rewardPending;
|
|
return <QuestTile id="daily" art={ART.daily} kind={content.dailyKind} title={content.dailyTitle} description={content.dailyDescription} doneSign={content.doneSign}
|
|
action={finished ? content.dailyResult : daily.rewardPending ? content.dailyChoose : content.dailyAction} href={cardsHref("daily")} primary={pending} done={finished}
|
|
badge={daily.streak > 0 && <span className="nds-badge" data-variant="gold">{fillTemplate(content.dailyStreak, { streak: formatStreak(daily.streak) })}</span>} />;
|
|
}
|
|
|
|
/** La Course attend une équipe : sans elle, sa tuile renvoie au recrutement. */
|
|
function RaceQuest({ summary: team, pending, content }) {
|
|
const cardsHref = useCardsHref();
|
|
const locked = team.status !== "ready" && team.race === "none";
|
|
return <QuestTile id="race" art={ART.race} kind={content.raceKind} title={content.raceTitle} description={content.raceDescription} doneSign={content.doneSign}
|
|
action={locked ? content.raceToTeam : team.race === "finished" ? content.raceResult : content.raceAction} href={cardsHref(locked ? "team" : "race")}
|
|
primary={pending && !locked} locked={locked} done={team.race === "finished"} sign={locked ? content.groupSign : ""} />;
|
|
}
|
|
|
|
/** Miroir brisé : le Normal, puis le Difficile du jour, le même pour tous. */
|
|
function MirrorQuest({ summary: mirror, pending, content }) {
|
|
const cardsHref = useCardsHref();
|
|
const done = mirrorDone(mirror);
|
|
const playing = ["easy", "normal", "hard"].some((mode) => mirror[mode] === "playing");
|
|
return <QuestTile id="mirror" art={ART.mirror} kind={content.mirrorKind} title={content.mirrorTitle} description={content.mirrorDescription} doneSign={content.doneSign}
|
|
action={done ? content.mirrorResult : playing ? content.mirrorResume : content.mirrorAction} href={cardsHref("mirror")} primary={pending} done={done} />;
|
|
}
|
|
|
|
function ExpeditionsQuest({ summary, pending, content, now }) {
|
|
const cardsHref = useCardsHref();
|
|
const returned = summary.returned > 0 || (summary.nextReturnAt != null && summary.nextReturnAt <= now);
|
|
return <QuestTile id="expeditions" art={ART.expeditions} kind={content.expeditionsKind} title={content.expeditionsTitle} description={content.expeditionsDescription}
|
|
status={expeditionQuestStatus(summary, content, now)} href={cardsHref("expeditions")} primary={pending}
|
|
action={returned ? content.expeditionsClaim : summary.running ? content.expeditionsInProgress : summary.enabled ? content.expeditionsAction : content.expeditionsOpen} />;
|
|
}
|
|
|
|
const QUEST_TILES = { daily: DailyQuest, race: RaceQuest, mirror: MirrorQuest, expeditions: ExpeditionsQuest };
|
|
// Tableau des quêtes : celles qui se jouent seul d'abord, puis celles en équipe.
|
|
const BOARD = ["daily", "mirror", "race"];
|
|
|
|
/** Le comptoir : le dragon des Veilleurs, ce qu'il conseille de faire, et à droite l'avancée des quêtes du jour. */
|
|
function GuildCounter({ state, quests, content, now }) {
|
|
const daily = quests.filter((quest) => BOARD.includes(quest.id));
|
|
const done = daily.filter(questDone).length;
|
|
const greeting = content.greetings[guildGreeting(state, now)];
|
|
return <header className="nds-panel nebula-guild-hall">
|
|
<img className="nebula-guild-hall-bg" src={ART.hall} alt="" />
|
|
<img className="nebula-guild-clerk" src={ART.clerk} alt="" />
|
|
<div className="nebula-guild-welcome">
|
|
<p className="eyebrow">{content.eyebrow}</p>
|
|
<h2 id="nebula-guild-title">{content.title}</h2>
|
|
<div className="nebula-guild-speech" role="status"><strong>{greeting.title}</strong><span>{greeting.text}</span></div>
|
|
</div>
|
|
{daily.length > 0 && <p className="nebula-guild-progress" data-done={done === daily.length || undefined}>
|
|
<span>{content.dailyDone}</span>
|
|
<strong>{fillTemplate(content.dailyCount, { done, total: daily.length })}</strong>
|
|
<span className="nebula-guild-pips" aria-hidden="true">{daily.map((quest) => <i key={quest.id} data-done={questDone(quest) || undefined} />)}</span>
|
|
</p>}
|
|
</header>;
|
|
}
|
|
|
|
/** Votre équipe : le même bloc que sur la page Équipe du jour, avec le bouton qui y mène. */
|
|
function GuildTeam({ catalog, team, content, teamContent, statLabels }) {
|
|
const cardsHref = useCardsHref();
|
|
const ready = team.status === "ready";
|
|
const recruiting = team.status === "recruiting";
|
|
const text = ready ? fillTemplate(content.teamReady, { day: team.teamDay, max: team.maxDays }) : recruiting ? content.teamRecruiting : content.teamEmpty;
|
|
return <TeamTable catalog={catalog} companions={team.companions} content={teamContent} statLabels={statLabels} showBest={ready} seatLabel={teamContent.seat}
|
|
title={content.teamTitle} titleId="nebula-guild-team-title"
|
|
status={<>{text}{ready && <span className="nebula-team-days" aria-hidden="true">{Array.from({ length: team.maxDays }, (_, index) => <i key={index} data-on={index < team.teamDay || undefined} />)}</span>}</>}
|
|
action={<a className="nds-button" data-size="sm" data-variant={ready ? "secondary" : "primary"} href={cardsHref("team")}>{ready ? content.teamOpen : recruiting ? content.teamResume : content.teamRecruit}</a>} />;
|
|
}
|
|
|
|
export function GuildPanel({ catalog, state, content, teamContent, statLabels }) {
|
|
// Heure d'affichage de la page, remise à jour au prochain retour d'expédition : la tuile passe alors d'elle-même au butin.
|
|
const [now, setNow] = useState(() => Date.now());
|
|
const nextReturnAt = state.expeditions?.nextReturnAt ?? null;
|
|
useEffect(() => {
|
|
if (nextReturnAt == null || nextReturnAt <= now) return undefined;
|
|
// Un délai au-delà de 2^31 ms déborderait setTimeout ; l'expédition la plus longue reste bien en deçà.
|
|
const timer = setTimeout(() => setNow(Date.now()), Math.min(nextReturnAt - now + 500, 2 ** 31 - 1));
|
|
return () => clearTimeout(timer);
|
|
}, [nextReturnAt, now]);
|
|
const listed = guildQuests(state, now);
|
|
const team = state.team;
|
|
// La Course figure au tableau dès que l'Équipe du jour est ouverte, verrouillée tant qu'il n'y a pas d'équipe.
|
|
const quests = team?.raceEnabled && !listed.some((quest) => quest.id === "race") ? [...listed, { id: "race", pending: false, summary: team }] : listed;
|
|
const tile = ({ id, summary, pending }) => {
|
|
const Tile = QUEST_TILES[id];
|
|
return Tile ? <Tile key={id} catalog={catalog} summary={summary} pending={pending} content={content} now={now} /> : null;
|
|
};
|
|
const board = BOARD.flatMap((id) => quests.filter((quest) => quest.id === id));
|
|
const missions = quests.filter((quest) => quest.id === "expeditions");
|
|
return <section className="nebula-quests" aria-labelledby="nebula-guild-title">
|
|
<GuildCounter state={state} quests={quests} content={content} now={now} />
|
|
{missions.length > 0 && <section className="nebula-guild-missions" aria-labelledby="nebula-guild-missions-title">
|
|
<h3 id="nebula-guild-missions-title">{content.missionsTitle}</h3>
|
|
{missions.map(tile)}
|
|
</section>}
|
|
{team && (team.enabled || team.status === "recruiting") && <GuildTeam catalog={catalog} team={team} content={content} teamContent={teamContent} statLabels={statLabels} />}
|
|
{board.length > 0 && <section className="nebula-guild-board" aria-labelledby="nebula-guild-board-title">
|
|
<h3 id="nebula-guild-board-title">{content.boardTitle}</h3>
|
|
<div className="nebula-guild-notices">{board.map(tile)}</div>
|
|
</section>}
|
|
{!quests.length && <div className="nds-empty-state"><p>{content.empty}</p></div>}
|
|
</section>;
|
|
}
|