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 };
}