Add the recruitment screen of the daily team

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-25 21:45:37 +01:00
parent 71cf739a2e
commit 08c3c8f6a2
18 changed files with 654 additions and 3 deletions

View file

@ -17,12 +17,13 @@ import { PrivacyNotice } from "./PrivacyNotice.jsx";
import { GuildPanel } from "./GuildPanel.jsx";
import { pendingQuestCount } from "./guildQuests.js";
import { ShopPanel } from "./ShopPanel.jsx";
import { TeamPanel } from "./TeamPanel.jsx";
import { TransfersPanel } from "./TransfersPanel.jsx";
// Le jeu, puis l'économie et les échanges, puis le journal : mêmes groupes séparés par un filet que l'administration.
const PLAYER_NAVIGATION = [["home", "guild", "packs", "collection"], ["shop", "transfers"], ["history", "account"]];
// Sections sans entrée de menu, ouvertes depuis une autre : le menu y désigne cette section parente.
const SUBSECTION_PARENTS = { daily: "guild", expeditions: "guild" };
const SUBSECTION_PARENTS = { daily: "guild", team: "guild", expeditions: "guild" };
const PLAYER_SECTIONS = new Set([...PLAYER_NAVIGATION.flat(), ...Object.keys(SUBSECTION_PARENTS)]);
// Ancienne adresse conservée pour les favoris : le recyclage vit désormais dans la Collection.
const PLAYER_SECTION_ALIASES = { recycling: "collection" };
@ -307,6 +308,7 @@ export function CardsPage({ siteContent, cardsConfig, playerSection = "", player
{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 === "team" && <TeamPanel {...panelProps} content={content.team} statLabels={content.expeditions.stats} />}
{section === "expeditions" && <ExpeditionsPanel {...panelProps} content={{ ...content.expeditions, cardSheet: content.cardSheet }} joinId={decodeURIComponent(playerSubsection)} />}
{section === "packs" && <PackPanel {...panelProps} content={content.packs} reserveContent={content.home} />}
{section === "collection" && <CollectionPanel {...panelProps} headingContent={content.collection} recyclingContent={content.recycling} onStartTransfer={startTransfer} />}

View file

@ -53,7 +53,29 @@ function ExpeditionsQuest({ summary, pending, content, now }) {
}
// Tuile de chaque type de quête, choisie par l'identifiant donné dans guildQuests.
const QUEST_TILES = { daily: DailyQuest, expeditions: ExpeditionsQuest };
const TEAM_COVER = "/static/img/cards/watchers-logbooks/rare/light_currents.webp";
// Équipe du jour : recruter, reprendre un recrutement, ou revoir son équipe.
function TeamQuest({ summary: team, pending, content }) {
const status = { recruiting: content.teamRecruiting, ready: fillTemplate(content.teamReady, { day: team.teamDay, max: team.maxDays }) }[team.status] || content.teamToRecruit;
return <article className="nds-card nebula-quest" data-status={team.status} aria-labelledby="nebula-quest-team-title">
<div className="nebula-quest-media">
<div className="nds-card-cover nebula-quest-cover" aria-hidden="true"><img src={TEAM_COVER} alt="" /></div>
{team.goldStars > 0 && <span className="nds-badge" data-variant="gold">{fillTemplate(content.teamStars, { count: team.goldStars, max: team.maxGoldStars })}</span>}
</div>
<div className="nds-card-body nebula-quest-body">
<p className="eyebrow">{content.teamKind}</p>
<h3 id="nebula-quest-team-title">{content.teamTitle}</h3>
<p>{content.teamDescription}</p>
<p className="nebula-quest-status">{status}</p>
<div className="nds-card-actions">
<a className="nds-button" data-size="sm" data-variant={pending ? "primary" : "secondary"} href="#/cards/team">{team.status === "ready" ? content.teamOpen : team.status === "recruiting" ? content.teamResume : content.teamRecruit}</a>
</div>
</div>
</article>;
}
const QUEST_TILES = { daily: DailyQuest, team: TeamQuest, expeditions: ExpeditionsQuest };
export function GuildPanel({ catalog, state, content }) {
// Heure d'affichage de la page, remise à jour au prochain retour d'expédition : la tuile passe alors d'elle-même au butin.

View file

@ -0,0 +1,34 @@
// Rôle : présente un compagnon de l'Équipe du jour : illustration, spécialité en couleur, Puissance et stats fortes.
import { STAT_IDS } from "./expeditionFormat.js";
import { MaskIcon } from "./ExpeditionLabels.jsx";
import { fillTemplate } from "./dailyShare.js";
import { bandOf, BALANCED, mainStats, specialtyStyle } from "./teamFormat.js";
export function SpecialtyBand({ companion, content, statLabels }) {
return <span className="nebula-team-band">{bandOf(companion).map((id) => <span key={id} style={{ "--specialty": `var(--color-stat-${id})` }}>
<MaskIcon name={id} />{id === BALANCED ? content.balanced : statLabels[id]}
</span>)}</span>;
}
// `onSelect` : toute la carte devient un bouton, avec `actionLabel` en pied. `badge` : mention sur l'illustration.
export function TeamCompanion({ catalog, companion, content, statLabels, badge = "", footer = null, onSelect = null, actionLabel = "", disabled = false, showPower = true }) {
const card = catalog.cards.find((item) => item.id === companion.cardId);
const strong = mainStats(companion);
const name = card?.name || content.unknownCard;
const Tag = onSelect ? "button" : "div";
const action = onSelect ? { type: "button", disabled, onClick: onSelect, "aria-label": fillTemplate(content.recruitLabel, { card: name }) } : {};
return <Tag className="nebula-team-companion" style={specialtyStyle(companion)} {...action}>
<span className="nebula-team-art">
{card?.image && <img src={card.image} alt="" loading="lazy" draggable="false" />}
{badge && <span className="nebula-team-tag">{badge}</span>}
{companion.lent && <span className="nebula-team-tag" data-side="end">{content.lent}</span>}
</span>
<SpecialtyBand companion={companion} content={content} statLabels={statLabels} />
<span className="nebula-team-name">{name}</span>
{showPower && <span className="nebula-team-power">{fillTemplate(content.power, { power: companion.power })}</span>}
<span className="nebula-team-strong">{strong.map((stat) => <span key={stat}><MaskIcon name={stat} /><span className="sr-only">{statLabels[stat]} </span>{companion.stats[stat]}</span>)}</span>
<span className="nebula-team-stats">{STAT_IDS.filter((stat) => !strong.includes(stat)).map((stat) => <span key={stat}><MaskIcon name={stat} /><span className="sr-only">{statLabels[stat]} </span>{companion.stats[stat]}</span>)}</span>
{footer}
{onSelect && <span className="nebula-team-action" aria-hidden="true">{actionLabel}</span>}
</Tag>;
}

View file

@ -0,0 +1,119 @@
// Rôle : page de l'Équipe du jour : réserve d'étoiles dorées, recrutement, équipe prête et choix de la garder ou d'en recruter une autre.
import { useEffect, useRef, useState } from "react";
import { chooseTeamCharacter, keepTeamCompanion, loadTeam, recruitTeam, revealTeamStar } from "./cardsApi.js";
import { fillTemplate } from "./dailyShare.js";
import { TeamCompanion } from "./TeamCompanion.jsx";
import { TeamBest, TeamCourse, TeamRecruitment } from "./TeamRecruitment.jsx";
import { TeamSky } from "./TeamSky.jsx";
import { averagePower, countText, fateOf } from "./teamFormat.js";
function GoldReserve({ team, content }) {
return <span className="nebula-team-reserve" role="img" aria-label={fillTemplate(content.reserveLabel, { count: team.goldStars, max: team.maxGoldStars })}>
<span>{content.reserve}</span>
{Array.from({ length: team.maxGoldStars }, (_, index) => <i key={index} data-full={index < team.goldStars || undefined}>★</i>)}
</span>;
}
// Recruter remplace l'équipe : une équipe encore utilisable demande une confirmation.
function RecruitAction({ team, content, busy, onRecruit }) {
const [confirming, setConfirming] = useState(false);
const losing = team.status === "ready";
const reserve = team.goldStars ? countText(content.reserveWillBeUsed, team.goldStars) : content.reserveEmpty;
if (confirming) return <div className="nds-inline-notice nebula-team-confirm" data-variant="warning" role="group" aria-label={content.confirmTitle}>
<p>{content.confirmText} {reserve}</p>
<div className="nds-toolbar">
<button className="nds-button" data-size="sm" data-variant="danger" type="button" disabled={busy} onClick={onRecruit}>{content.confirmAction}</button>
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" autoFocus onClick={() => setConfirming(false)}>{content.keepTeam}</button>
</div>
</div>;
return <div className="nebula-team-recruit">
<button className="nds-button" data-variant={losing ? "secondary" : "primary"} type="button" disabled={busy} onClick={() => (losing ? setConfirming(true) : onRecruit())}>{losing ? content.recruitAnother : content.recruitStart}</button>
<p>{reserve}</p>
</div>;
}
function TeamMembers({ catalog, companions, powers, content, statLabels }) {
return <ul className="nebula-team-list">{companions.map((companion) => {
const fate = powers && fateOf(companion, powers, content);
return <li key={companion.cardId}><TeamCompanion catalog={catalog} companion={companion} content={content} statLabels={statLabels} footer={fate && <span className="nebula-team-fate" data-fate={fate.kind}>{fate.text}</span>} /></li>;
})}</ul>;
}
export function TeamPanel({ catalog, state, runMutation, busy, content, statLabels }) {
const [team, setTeam] = useState(null);
const [loadError, setLoadError] = useState("");
const [reloadKey, setReloadKey] = useState(0);
const [notice, setNotice] = useState("");
// Paliers du recrutement qui vient de se terminer : le bilan dévoile ses étoiles une fois, avant de jouer.
const [finishedPowers, setFinishedPowers] = useState(null);
const readyTitleRef = useRef(null);
useEffect(() => { if (finishedPowers) readyTitleRef.current?.focus(); }, [finishedPowers]);
useEffect(() => {
let active = true;
loadTeam()
.then((result) => { if (active) { setTeam(result.team); setLoadError(""); } })
.catch((error) => { if (active) setLoadError(error.message); });
return () => { active = false; };
}, [reloadKey]);
if (loadError) return <section className="nds-empty-state" role="alert"><h2>{content.title}</h2><p>{loadError}</p><button className="nds-button" data-variant="secondary" type="button" onClick={() => setReloadKey((key) => key + 1)}>{content.retry}</button></section>;
if (!team) return <section className="nds-empty-state" aria-busy="true"><h2>{content.title}</h2></section>;
// Les refus propres à l'équipe restent dans ce panneau ; runMutation garde le reste (erreurs réseau, solde).
async function play(action) {
setNotice("");
const result = await runMutation(async () => {
try {
return await action();
} catch (error) {
if (String(error.code || "").startsWith("TEAM_")) return { teamError: error };
throw error;
}
});
if (result?.team) {
if (team.status === "recruiting" && result.team.status === "ready") setFinishedPowers(team.recruitment.powers);
setTeam(result.team);
} else if (result?.teamError) {
setNotice(result.teamError.message);
setReloadKey((key) => key + 1);
}
}
const recruiting = team.status === "recruiting";
const dailyToPlay = state.daily && (state.daily.status === "playing" || state.daily.rewardPending);
const recruit = () => play(() => recruitTeam(team.day));
return <section className="nebula-team" aria-labelledby="nebula-team-title" aria-busy={busy || undefined}>
<div className="nds-section-heading nebula-section-heading">
<div><p className="eyebrow">{content.eyebrow}</p><h2 id="nebula-team-title">{content.title}</h2></div>
<div className="nebula-team-heading-actions"><GoldReserve team={team} content={content} /><a className="nds-button" data-size="sm" data-variant="secondary" href="#/cards/guild">{content.back}</a></div>
</div>
{notice && <p className="nds-inline-notice" data-variant="warning" role="status">{notice}</p>}
{!team.enabled && !recruiting && <p className="nds-inline-notice" role="status">{content.closed}</p>}
{recruiting && <TeamRecruitment catalog={catalog} team={team} content={content} statLabels={statLabels} busy={busy}
onChoose={(cardId) => play(() => chooseTeamCharacter(cardId))} onReveal={(index) => play(() => revealTeamStar(index))} onKeep={() => play(() => keepTeamCompanion(team.recruitment.current.cardId))} />}
{!recruiting && finishedPowers && team.status === "ready" && <section className="nebula-team-ready" aria-labelledby="nebula-team-ready-title">
<h3 id="nebula-team-ready-title" ref={readyTitleRef} tabIndex={-1}>{content.readyTitle}</h3>
<p>{fillTemplate(content.readyText, { power: averagePower(team.companions) })}{team.lastDust > 0 && ` ${fillTemplate(content.readyDust, { count: team.lastDust })}`}</p>
<TeamMembers catalog={catalog} companions={team.companions} powers={finishedPowers} content={content} statLabels={statLabels} />
<TeamBest companions={team.companions} content={content} statLabels={statLabels} />
<div className="nds-panel nebula-team-stars-panel"><p>{content.skyRevealed}</p><TeamSky sky={team.lastSky} content={content} /></div>
<div className="nds-toolbar nebula-team-actions"><button className="nds-button" data-variant="primary" type="button" onClick={() => setFinishedPowers(null)}>{content.readyAction}</button></div>
</section>}
{!recruiting && !(finishedPowers && team.status === "ready") && <>
{team.status === "ready" ? <section className="nebula-team-ready" aria-labelledby="nebula-team-current-title">
<h3 id="nebula-team-current-title">{fillTemplate(content.teamDay, { day: team.teamDay, max: team.maxDays })}</h3>
<p>{team.teamDay === team.maxDays ? content.lastDay : team.canRecruit ? content.keepOrRecruit : content.teamText}</p>
<TeamMembers catalog={catalog} companions={team.companions} content={content} statLabels={statLabels} />
<TeamBest companions={team.companions} content={content} statLabels={statLabels} />
</section> : <section className="nebula-team-ready" aria-labelledby="nebula-team-none-title">
<h3 id="nebula-team-none-title">{team.status === "expired" ? content.expiredTitle : content.noneTitle}</h3>
<p>{fillTemplate(team.status === "expired" ? content.expiredText : content.noneText, { max: team.maxDays })}</p>
</section>}
{team.canRecruit && dailyToPlay && team.goldStars < team.maxGoldStars && <p className="nds-inline-notice" role="status">{content.dailyFirst} <a href="#/cards/daily">{content.dailyLink}</a></p>}
{team.canRecruit && <RecruitAction key={team.status} team={team} content={content} busy={busy} onRecruit={recruit} />}
<TeamCourse zones={team.zones} content={content} statLabels={statLabels} />
</>}
</section>;
}

View file

@ -0,0 +1,117 @@
// Rôle : recrutement de l'Équipe du jour : choix d'un personnage, puis amélioration en révélant des étoiles.
import { Fragment, useEffect, useRef } from "react";
import { fillTemplate } from "./dailyShare.js";
import { STAT_IDS } from "./expeditionFormat.js";
import { MaskIcon } from "./ExpeditionLabels.jsx";
import { TeamCompanion } from "./TeamCompanion.jsx";
import { TeamSky } from "./TeamSky.jsx";
import { countText, fateOf, isMissing, mainStats, riskPct, teamBest } from "./teamFormat.js";
export function TeamBest({ companions, content, statLabels }) {
const best = teamBest(companions);
return <dl className="nebula-team-best" aria-label={content.bestTitle}>{STAT_IDS.map((stat) => <div key={stat} style={{ "--specialty": `var(--color-stat-${stat})` }}>
<dt><MaskIcon name={stat} />{statLabels[stat]}</dt><dd>{best[stat]}</dd>
</div>)}</dl>;
}
export function TeamCourse({ zones, content, statLabels }) {
return <section className="nebula-team-course" aria-labelledby="nebula-team-course-title">
<h3 id="nebula-team-course-title">{content.courseTitle}</h3>
<ol>{zones.map((stat, index) => <li key={index} style={{ "--specialty": `var(--color-stat-${stat})` }}><MaskIcon name={stat} />{statLabels[stat]}</li>)}</ol>
</section>;
}
function TeamSoFar({ catalog, team, recruitment, content, statLabels }) {
return <section className="nebula-team-so-far" aria-labelledby="nebula-team-so-far-title">
<h3 id="nebula-team-so-far-title">{content.yourTeam}</h3>
{team.length > 0 && <TeamBest companions={team} content={content} statLabels={statLabels} />}
<ul className="nebula-team-list">{Array.from({ length: recruitment.size }, (_, index) => {
const companion = team[index];
if (!companion) return <li key={index}><span className="nebula-team-empty">{fillTemplate(content.emptySlot, { number: index + 1 })}</span></li>;
const fate = fateOf(companion, recruitment.powers, content);
return <li key={index}><TeamCompanion catalog={catalog} companion={companion} content={content} statLabels={statLabels} footer={<span className="nebula-team-fate" data-fate={fate.kind}>{fate.text}</span>} /></li>;
})}</ul>
</section>;
}
function Steps({ count, size, step, content }) {
return <ol className="nebula-team-steps">
<li data-current="true">{fillTemplate(content.stepCount, { count, max: size })}</li>
<li data-current={step === 1 || undefined} aria-current={step === 1 ? "step" : undefined}>{content.stepRecruit}</li>
<li data-current={step === 2 || undefined} aria-current={step === 2 ? "step" : undefined}>{content.stepImprove}</li>
</ol>;
}
function StarsRule({ hidden, recruitment, content }) {
const total = hidden.gold + hidden.black + hidden.dust;
if (!total) return <p>{content.noStars}</p>;
const kinds = ["gold", "black", "dust"].filter((kind) => hidden[kind] > 0);
const texts = { gold: content.hiddenGold, black: content.hiddenBlack, dust: content.hiddenDust };
const separator = (index) => (index === 0 ? " " : index === kinds.length - 1 ? content.listLast : content.listSeparator);
return <p>{fillTemplate(content.hiddenStars, { count: total })}{kinds.map((kind, index) => <Fragment key={kind}>
{separator(index)}<strong data-kind={kind}>{countText(texts[kind].name, hidden[kind])}</strong>{countText(texts[kind].effect, hidden[kind], { value: recruitment.dustValue })}
</Fragment>)}. {hidden.black > 0 ? fillTemplate(content.blackRule, { power: recruitment.fallPower }) : content.safeRule}</p>;
}
function Improve({ catalog, recruitment, last, content, statLabels, busy, titleRef, onReveal, onKeep }) {
const { current, powers, hidden, sky } = recruitment;
const top = current.step === powers.length - 1;
const total = hidden.gold + hidden.black + hidden.dust;
const over = current.fallen || top || !total;
const risk = riskPct(hidden);
const strong = mainStats(current);
const keepRef = useRef(null);
// Fin des essais : le bouton qui continue reçoit le focus, l'étoile cliquée ne réagit plus.
useEffect(() => { if (over) keepRef.current?.focus({ preventScroll: true }); }, [over]);
return <div className="nebula-team-improve">
<div className="nebula-team-rule">
<h3 ref={titleRef} tabIndex={-1}>{content.improveTitle}</h3>
<StarsRule hidden={hidden} recruitment={recruitment} content={content} />
</div>
<TeamCompanion catalog={catalog} companion={current} content={content} statLabels={statLabels} />
<div className="nds-panel nebula-team-stars-panel">
<ol className="nebula-team-ladder" data-fallen={current.fallen || undefined}>{powers.map((power, index) => <li key={power} data-state={index <= current.step ? "reached" : index === current.step + 1 && !over ? "next" : undefined}>
<small>{index ? countText(content.ladderStep, index) : content.ladderStart}</small>
<strong>{power}</strong>
<small>{strong.map((stat) => `${statLabels[stat]} ${recruitment.ladder[index][stat]}`).join(" · ")}</small>
</li>)}</ol>
<TeamSky sky={sky} content={content} canReveal={!over && !busy} onReveal={onReveal} />
<p className="nebula-team-risk" role="status">
{current.fallen ? fillTemplate(content.fallen, { power: recruitment.fallPower }) : top ? content.top : !total ? content.noStars
: hidden.black > 0 ? fillTemplate(content.risk, { risk }) : content.noRisk}
</p>
<div className="nds-toolbar nebula-team-actions">
<button ref={keepRef} className="nds-button" data-variant={over ? "primary" : "secondary"} type="button" disabled={busy} onClick={onKeep}>{over ? (last ? content.seeTeam : content.nextCompanion) : fillTemplate(content.keepAt, { power: current.power })}</button>
{!over && <span>{content.orClickStar}</span>}
</div>
<p className="nebula-team-note">{content.starsShared}</p>
</div>
</div>;
}
export function TeamRecruitment({ catalog, team, content, statLabels, busy, onChoose, onReveal, onKeep }) {
const { recruitment, companions, zones } = team;
const count = companions.length + 1;
const titleRef = useRef(null);
const step = `${count}-${recruitment.current ? "improve" : "offer"}`;
const shownStep = useRef(step);
// Chaque étape remplace la précédente : son titre reçoit le focus, pour le clavier, le lecteur d'écran et le défilement.
useEffect(() => {
if (shownStep.current === step) return;
shownStep.current = step;
titleRef.current?.focus();
}, [step]);
return <>
<Steps count={count} size={recruitment.size} step={recruitment.current ? 2 : 1} content={content} />
{recruitment.current
? <Improve key={recruitment.current.cardId} catalog={catalog} recruitment={recruitment} last={count === recruitment.size} content={content} statLabels={statLabels} busy={busy} titleRef={titleRef} onReveal={onReveal} onKeep={onKeep} />
: <section aria-labelledby="nebula-team-offer-title" className="nebula-team-offer">
<h3 id="nebula-team-offer-title" ref={titleRef} tabIndex={-1}>{content.offerTitle}</h3>
<p>{fillTemplate(content.offerText, { power: recruitment.powers[0] })}{companions.length === 0 && recruitment.extraGold > 0 && <> <strong>{countText(content.reserveUsed, recruitment.extraGold)}</strong></>}</p>
<div className="nebula-team-offer-cards">{recruitment.offer.map((companion) => <TeamCompanion key={companion.cardId} catalog={catalog} companion={companion} content={content} statLabels={statLabels} showPower={false} disabled={busy}
badge={isMissing(companion, companions, zones) ? content.missing : ""} actionLabel={content.recruitAction} onSelect={() => onChoose(companion.cardId)} />)}</div>
</section>}
<TeamSoFar catalog={catalog} team={companions} recruitment={recruitment} content={content} statLabels={statLabels} />
<TeamCourse zones={zones} content={content} statLabels={statLabels} />
</>;
}

View file

@ -0,0 +1,20 @@
// Rôle : affiche les étoiles d'un recrutement, cachées ou révélées, et laisse choisir celle à révéler.
import { CurrencyIcon } from "./Currency.jsx";
import { fillTemplate } from "./dailyShare.js";
// Le ciel tient sur deux rangées.
function Star({ star, index, content, canReveal, onReveal }) {
const label = star.kind ? content.stars[star.kind] : fillTemplate(content.hiddenStar, { number: index + 1 });
const locked = Boolean(star.kind) || !canReveal;
return <button className="nebula-team-star" type="button" data-kind={star.kind || "hidden"} data-missed={(star.kind && !star.revealed) || undefined} aria-label={label} aria-disabled={locked || undefined} onClick={() => { if (!locked) onReveal(index); }}>
<span aria-hidden="true">{star.kind === "dust" ? <CurrencyIcon kind="stardust" /> : { gold: "★", black: "✖" }[star.kind] || "?"}</span>
</button>;
}
export function TeamSky({ sky, content, canReveal = false, onReveal = () => {} }) {
const half = Math.ceil(sky.length / 2);
const rows = [[sky.slice(0, half), 0], [sky.slice(half), half]];
return <div className="nebula-team-sky" role="group" aria-label={content.skyLabel} style={{ "--star-count": half }}>{rows.map(([stars, start]) => <div key={start}>
{stars.map((star, position) => <Star key={start + position} star={star} index={start + position} content={content} canReveal={canReveal} onReveal={onReveal} />)}
</div>)}</div>;
}

View file

@ -95,6 +95,27 @@ export function guessDaily(day, cardId) {
return request("/daily/guesses", { method: "POST", body: JSON.stringify({ day, cardId }) });
}
export function loadTeam() {
return request("/team");
}
// Un recrutement vaut pour le jour affiché, comme un essai de la Carte du jour.
export function recruitTeam(day) {
return request("/team/recruit", { method: "POST", body: JSON.stringify({ day }) });
}
export function chooseTeamCharacter(cardId) {
return request("/team/choose", { method: "POST", body: JSON.stringify({ cardId }) });
}
export function revealTeamStar(index) {
return request("/team/stars", { method: "POST", body: JSON.stringify({ index }) });
}
export function keepTeamCompanion(cardId) {
return request("/team/keep", { method: "POST", body: JSON.stringify({ cardId }) });
}
// Récompense d'une victoire : "stardust" ou "star" (moins de poussière et une étoile dorée).
export function chooseDailyReward(day, choice) {
return request("/daily/reward", { method: "POST", body: JSON.stringify({ day, choice }) });

View file

@ -15,6 +15,9 @@ export function expeditionsPending(summary, now = Date.now()) {
export function guildQuests(state, now = Date.now()) {
const quests = [];
if (state.daily) quests.push({ id: "daily", pending: state.daily.status === "playing" || Boolean(state.daily.rewardPending), summary: state.daily });
// L'Équipe du jour n'apparaît que si elle est ouverte, ou tant qu'un recrutement n'est pas terminé.
const team = state.team;
if (team && (team.enabled || team.status === "recruiting")) quests.push({ id: "team", pending: team.status !== "ready", summary: team });
const expeditions = state.expeditions;
if (expeditions && (expeditions.enabled || expeditions.running || expeditions.returned || expeditions.forming)) quests.push({ id: "expeditions", pending: expeditionsPending(expeditions, now), summary: expeditions });
return quests;

View file

@ -0,0 +1,44 @@
// Rôle : règles d'affichage de l'Équipe du jour (stats fortes d'un compagnon, meilleures stats d'une équipe, textes au pluriel).
import { fillTemplate } from "./dailyShare.js";
import { STAT_IDS } from "./expeditionFormat.js";
// Spécialités affichées sur le bandeau : celles données par le serveur, ou l'équilibre.
export const BALANCED = "balanced";
export const bandOf = (companion) => (companion.specialties.length ? companion.specialties : [BALANCED]);
// Stats montrées en grand : les spécialités, sinon la plus haute.
export function mainStats({ specialties, stats }) {
if (specialties.length) return specialties;
return [STAT_IDS.reduce((best, stat) => (stats[stat] > stats[best] ? stat : best), STAT_IDS[0])];
}
export const teamBest = (companions) => Object.fromEntries(STAT_IDS.map((stat) => [stat, Math.max(0, ...companions.map((companion) => companion.stats[stat]))]));
export const averagePower = (companions) => Math.round(companions.reduce((sum, companion) => sum + companion.power, 0) / companions.length);
// Un candidat « manque à l'équipe » s'il a une spécialité du parcours que personne n'a encore.
export function isMissing(companion, team, zones) {
const covered = new Set(team.flatMap((member) => member.specialties));
return team.length > 0 && companion.specialties.some((stat) => zones.includes(stat) && !covered.has(stat));
}
// Texte au singulier ou au pluriel : `{ one, many }`, avec `{count}`.
export const countText = (texts, count, values = {}) => fillTemplate(count > 1 ? texts.many : texts.one, { count, ...values });
export const riskPct = ({ gold, black, dust }) => {
const total = gold + black + dust;
return total ? Math.round((black / total) * 100) : 0;
};
// Couleurs d'une spécialité, ou des deux : lues par la bordure et le bandeau.
export function specialtyStyle(companion) {
const band = bandOf(companion);
return { "--specialty-start": `var(--color-stat-${band[0]})`, "--specialty-end": `var(--color-stat-${band.at(-1)})` };
}
// Ce que les étoiles ont fait d'un compagnon.
export function fateOf({ fallen, step }, powers, content) {
if (fallen) return { kind: "fallen", text: content.fateFallen };
if (step === powers.length - 1) return { kind: "top", text: content.fateTop };
return step ? { kind: "improved", text: countText(content.fateImproved, step) } : { kind: "none", text: content.fateNone };
}

View file

@ -38,6 +38,7 @@
.nebula-mask-icon[data-icon="endurance"] { --nebula-icon: url("/static/icons/shield.svg"); }
.nebula-mask-icon[data-icon="fortune"] { --nebula-icon: url("/static/icons/clover.svg"); }
.nebula-mask-icon[data-icon="orientation"] { --nebula-icon: url("/static/icons/map.svg"); }
.nebula-mask-icon[data-icon="balanced"] { --nebula-icon: url("/static/icons/wheel.svg"); }
.nebula-mask-icon[data-icon="cards"] { --nebula-icon: url("/static/icons/tcg.svg"); }
.nebula-mask-icon[data-icon="eclats"] { --nebula-icon: url("/static/icons/eclat-outline.svg"); }
.nebula-mask-icon[data-icon="stardust"] { --nebula-icon: url("/static/icons/stardust-outline.svg"); }

View file

@ -0,0 +1,115 @@
// Rôle : met en page l'Équipe du jour de Sokko TCG (compagnons et couleurs de spécialité, étoiles, recrutement, équipe).
.nebula-team { display: grid; gap: var(--space-5); min-width: 0; container: nebula-team / inline-size; }
.nebula-team .nds-section-heading.nebula-section-heading { margin-bottom: 0; }
.nebula-team :is(h3, p, ul, ol, dl, dd) { margin: 0; }
.nebula-team :is(ul, ol) { padding: 0; list-style: none; }
.nebula-team h3 { font-size: var(--font-size-lg); scroll-margin-top: 80px; }
.nebula-team h3:focus { outline: none; }
.nebula-team-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); }
.nebula-team-reserve { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--color-text-secondary); font-size: var(--font-size-sm); }
.nebula-team-reserve > span { margin-right: var(--space-1); }
.nebula-team-reserve i { display: grid; width: 24px; height: 24px; border: 2px dashed var(--color-border-hover); border-radius: 50%; color: transparent; font-size: var(--font-size-xs); font-style: normal; place-items: center; }
.nebula-team-reserve i[data-full] { border: 2px solid var(--color-accent-gold); background: rgba(246, 196, 83, 0.14); color: var(--color-accent-gold); }
// Compagnon : bordure et bandeau à la couleur de sa spécialité, ou des deux.
.nebula-team-companion {
--specialty-start: var(--color-stat-balanced);
--specialty-end: var(--color-stat-balanced);
display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0; width: 100%; min-width: 0; overflow: hidden; padding: 0; border: 2px solid transparent; border-radius: var(--radius-md);
background: linear-gradient(var(--color-bg-surface-alt), var(--color-bg-surface-alt)) padding-box, linear-gradient(90deg, var(--specialty-start) 50%, var(--specialty-end) 50%) border-box;
color: var(--color-text-primary); font: inherit; text-align: left;
}
button.nebula-team-companion { cursor: pointer; transition: transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
button.nebula-team-companion:is(:hover, :focus-visible):not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-md); }
button.nebula-team-companion:focus-visible { outline: 2px solid var(--color-text-primary); outline-offset: 2px; }
button.nebula-team-companion:disabled { cursor: default; opacity: 0.7; }
.nebula-team-art { position: relative; display: block; background: var(--color-bg-deep); aspect-ratio: 1; }
.nebula-team-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.nebula-team-tag { position: absolute; top: var(--space-2); left: var(--space-2); max-width: calc(100% - var(--space-4)); padding: 1px var(--space-2); border-radius: var(--radius-pill); background: rgba(7, 9, 19, 0.88); color: var(--color-text-primary); font-size: var(--font-size-xs); font-weight: 700; }
.nebula-team-tag[data-side="end"] { top: auto; right: var(--space-2); bottom: var(--space-2); left: auto; color: var(--color-text-secondary); }
.nebula-team-band { display: flex; }
.nebula-team-band > span { display: flex; flex: 1 1 0; align-items: center; justify-content: center; gap: var(--space-1); min-width: 0; padding: 3px var(--space-1); background: var(--specialty); color: var(--color-text-inverse); font-size: var(--font-size-sm); font-weight: 800; }
.nebula-team-band > span:not(:only-child) { font-size: var(--font-size-xs); }
.nebula-team-name { overflow: hidden; color: var(--color-text-primary); padding: var(--space-2) var(--space-2) 0; font-size: var(--font-size-sm); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.nebula-team-power { padding: 0 var(--space-2); color: var(--color-text-secondary); font-size: var(--font-size-sm); }
.nebula-team-strong { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); padding: 0 var(--space-2); font-size: var(--font-size-xl); font-variant-numeric: tabular-nums; font-weight: 800; }
.nebula-team-stats { display: flex; flex-wrap: wrap; gap: 0 var(--space-2); padding: 0 var(--space-2) var(--space-2); color: var(--color-text-muted); font-size: var(--font-size-xs); font-variant-numeric: tabular-nums; }
// Un texte sans couleur propre suit son bloc, pas la couleur des textes secondaires du tableau de bord.
.nebula-team :is(.nebula-team-star, .nebula-team-band > span, .nebula-team-strong, .nebula-team-stats) span { color: inherit; }
.nebula-team-strong { color: var(--color-text-primary); }
.nebula-team-strong > span, .nebula-team-stats > span { display: inline-flex; align-items: center; gap: 3px; }
.nebula-team-fate { padding: 0 var(--space-2) var(--space-2); color: var(--color-text-muted); font-size: var(--font-size-xs); font-weight: 700; }
.nebula-team-fate[data-fate="top"] { color: var(--color-accent-gold); }
.nebula-team-fate[data-fate="improved"] { color: var(--color-success); }
.nebula-team-fate[data-fate="fallen"] { color: var(--color-danger); }
.nebula-team-action { margin: auto var(--space-2) var(--space-2); padding: 6px; border-radius: var(--radius-sm); background: var(--color-primary-active); color: var(--color-text-primary); font-weight: 700; text-align: center; }
button.nebula-team-companion:hover:not(:disabled) .nebula-team-action { background: var(--color-primary); }
.nebula-team-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); }
.nebula-team-list > li { display: grid; min-width: 0; }
.nebula-team-empty { display: grid; min-height: 160px; border: 2px dashed var(--color-border-hover); border-radius: var(--radius-md); color: var(--color-text-muted); font-size: var(--font-size-sm); place-items: center; }
.nebula-team-so-far, .nebula-team-ready, .nebula-team-offer, .nebula-team-course { display: grid; gap: var(--space-3); min-width: 0; }
.nebula-team :is(.nebula-team-offer, .nebula-team-ready) > p { max-width: 70ch; color: var(--color-text-secondary); }
.nebula-team-offer-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 230px)); gap: var(--space-4); }
.nebula-team-best { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.nebula-team-best > div { display: flex; align-items: center; gap: var(--space-2); padding: 3px var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: var(--font-size-sm); }
.nebula-team-best dt { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--specialty); font-weight: 600; }
.nebula-team-best dd { font-variant-numeric: tabular-nums; font-weight: 800; }
.nebula-team-course ol { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.nebula-team-course li { display: inline-flex; align-items: center; gap: var(--space-1); padding: 3px var(--space-3); border: 1px solid color-mix(in srgb, var(--specialty) 45%, transparent); border-radius: var(--radius-sm); color: var(--specialty); font-size: var(--font-size-sm); font-weight: 600; }
.nebula-team-steps { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.nebula-team-steps li { padding: 2px var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-pill); color: var(--color-text-muted); font-size: var(--font-size-sm); font-weight: 600; }
.nebula-team-steps li[data-current] { border-color: var(--color-accent-gold); color: var(--color-accent-gold); }
// Amélioration : le compagnon à gauche, les étoiles à droite.
.nebula-team-improve { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.nebula-team-rule { display: grid; grid-column: 1 / -1; gap: var(--space-2); }
.nebula-team-rule p { max-width: 80ch; }
.nebula-team-rule strong[data-kind="gold"] { color: var(--color-accent-gold); }
.nebula-team-rule strong[data-kind="black"] { padding: 0 var(--space-2); border: 1px solid var(--color-text-secondary); border-radius: var(--radius-pill); background: #000; color: var(--color-text-primary); }
.nebula-team-rule strong[data-kind="dust"] { color: #c4b5fd; }
.nds-panel.nebula-team-stars-panel { display: grid; gap: var(--space-3); min-width: 0; padding: var(--space-4) var(--space-5); }
.nebula-team-ladder { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: var(--space-2); }
.nebula-team-ladder li { display: grid; padding: var(--space-2) var(--space-1); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text-muted); text-align: center; }
.nebula-team-ladder strong { font-size: var(--font-size-xl); font-variant-numeric: tabular-nums; line-height: 1.2; }
.nebula-team-ladder small { overflow-wrap: anywhere; font-size: var(--font-size-xs); }
.nebula-team-ladder li[data-state="reached"] { border-color: var(--color-accent-gold); background: rgba(246, 196, 83, 0.1); color: var(--color-accent-gold); }
.nebula-team-ladder li[data-state="next"] { border-color: var(--color-text-primary); border-style: dashed; color: var(--color-text-primary); }
.nebula-team-ladder[data-fallen] li { opacity: 0.4; }
.nebula-team-sky { display: grid; gap: var(--space-2); padding-block: var(--space-2) var(--space-3); }
.nebula-team-sky > div { display: flex; justify-content: center; gap: clamp(4px, 1.4cqi, 12px); }
.nebula-team-star { display: grid; flex: 0 0 min(64px, calc((100% - (var(--star-count) - 1) * 12px) / var(--star-count))); min-width: 0; padding: 0; border: 2px solid var(--color-border-hover); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5a48a8, #211b4d); color: var(--color-text-primary); cursor: pointer; font: inherit; font-size: var(--font-size-xl); aspect-ratio: 1; place-items: center; transition: transform var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
.nebula-team-star:nth-child(even) { translate: 0 10px; }
.nebula-team-star:hover:not([aria-disabled]) { border-color: var(--color-text-primary); box-shadow: var(--shadow-primary); }
.nebula-team-star:focus-visible { outline: 2px solid var(--color-text-primary); outline-offset: 2px; }
.nebula-team-star[aria-disabled] { cursor: default; }
.nebula-team-star > span { display: grid; place-items: center; }
.nebula-team-star[data-kind="gold"], .nebula-team-star[data-kind="gold"]:hover { border-color: var(--color-accent-gold); background: #241d08; color: var(--color-accent-gold); }
.nebula-team-star[data-kind="black"], .nebula-team-star[data-kind="black"]:hover { border-color: var(--color-text-secondary); background: #000; }
.nebula-team-star[data-kind="dust"], .nebula-team-star[data-kind="dust"]:hover { border-color: #c4b5fd; background: radial-gradient(circle at 35% 30%, #6d52c9, #2c1d63); }
.nebula-team-star[data-missed] { opacity: 0.45; }
.nebula-team-risk { font-weight: 700; }
.nebula-team-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.nebula-team-actions > span, .nebula-team-note, .nebula-team-recruit p { color: var(--color-text-muted); font-size: var(--font-size-sm); }
.nebula-team-recruit { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.nebula-team-confirm { display: grid; gap: var(--space-3); margin: 0; }
.nebula-team > .nds-inline-notice { margin: 0; }
@container nebula-team (max-width: 760px) {
.nebula-team-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nebula-team-improve { grid-template-columns: 170px minmax(0, 1fr); }
.nebula-team-offer-cards { gap: var(--space-3); }
}
@container nebula-team (max-width: 520px) {
.nebula-team-improve { grid-template-columns: minmax(0, 1fr); }
.nebula-team-improve > .nebula-team-companion { max-width: 200px; }
.nebula-team-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
:is(button.nebula-team-companion, .nebula-team-star) { transition: none; }
}

View file

@ -42,6 +42,13 @@
--color-info: #38bdf8;
--color-info-soft: rgba(56, 189, 248, 0.13);
// Spécialités de l'Équipe du jour : toujours avec leur nom et leur icône.
--color-stat-bravoure: #e0706a;
--color-stat-endurance: #6aa6ff;
--color-stat-fortune: #f7d154;
--color-stat-orientation: #63cc7c;
--color-stat-balanced: #e8edf5;
--color-rarity-common: #9ca3af;
--color-rarity-rare: #3b82f6;
--color-rarity-epic: #d946ef;

View file

@ -8,6 +8,7 @@
@use "nebula-expedition-destinations";
@use "nebula-expedition-loadout";
@use "nebula-expedition-journey";
@use "nebula-team";
// Feuilles qui suivent les cartes dans main.scss.
@use "games/checklist";
@use "design-system/attributes";