Rework the daily team screens, share its team block and give the race its admin tab
The daily team page now opens on a welcome screen with the three steps, and the recruitment keeps the same look: golden steps, the choice in a golden panel with the hidden stars, a team summary of colored mini cards and its strengths, and a reroll badge. One "Your team" block is shared by the Guild, the recruitment and the ready team. The header shows the extra golden stars and the balms; the tips button is gone. On the Guild, team quests carry a "En groupe" sign until the team is ready and the streak badge stays readable. The race gets its own admin tab: its own opening, the day's circuit and results, rewards by place and the watchers' skill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
327337075b
commit
52b35880f2
23 changed files with 570 additions and 253 deletions
|
|
@ -2,25 +2,28 @@
|
|||
// missions (les Expéditions, mises en avant), l'équipe du joueur, puis le tableau des quêtes du jour. Chaque quête a sa tuile, avec son état.
|
||||
import { useEffect, useState } from "react";
|
||||
import { dailyQuestStatus, fillTemplate, formatStreak } from "./dailyShare.js";
|
||||
import { expeditionQuestStatus, ITEM_ART } from "./expeditionFormat.js";
|
||||
import { expeditionQuestStatus } from "./expeditionFormat.js";
|
||||
import { guildGreeting, guildQuests, questDone } from "./guildQuests.js";
|
||||
import { TeamCompanion } from "./TeamCompanion.jsx";
|
||||
import { TeamTable } from "./TeamTable.jsx";
|
||||
|
||||
const ART = {
|
||||
hall: "/static/img/cards/guild/hall.webp",
|
||||
table: "/static/img/cards/guild/tavern.webp",
|
||||
clerk: "/static/img/cards/guild-veilleurs.webp",
|
||||
daily: "/static/img/cards/guild/quest-daily.webp",
|
||||
race: "/static/img/cards/guild/quest-race.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.
|
||||
function QuestTile({ id, art, kind, title, description, status, action, href, primary, badge = null, locked = false, done = false }) {
|
||||
// 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.
|
||||
function QuestTile({ id, art, kind, title, description, status, action, href, primary, badge = null, sign = "", 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é. */}
|
||||
<a className="nds-card-cover nebula-quest-cover" href={href} tabIndex={-1} aria-hidden="true"><img src={art} alt="" loading="lazy" /></a>
|
||||
{/* 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>}
|
||||
{badge}
|
||||
</div>
|
||||
<div className="nds-card-body nebula-quest-body">
|
||||
|
|
@ -46,7 +49,7 @@ function RaceQuest({ summary: team, pending, content }) {
|
|||
const status = locked ? content.raceLocked : { running: content.raceRunning, finished: content.raceFinished }[team.race] || content.raceToRun;
|
||||
return <QuestTile id="race" art={ART.race} kind={content.raceKind} title={content.raceTitle} description={content.raceDescription} status={status}
|
||||
action={locked ? content.raceToTeam : team.race === "finished" ? content.raceResult : content.raceAction} href={locked ? "#/cards/team" : "#/cards/race"}
|
||||
primary={pending && !locked} locked={locked} done={team.race === "finished"} />;
|
||||
primary={pending && !locked} locked={locked} done={team.race === "finished"} sign={locked ? content.groupSign : ""} />;
|
||||
}
|
||||
|
||||
function ExpeditionsQuest({ summary, pending, content, now }) {
|
||||
|
|
@ -80,30 +83,15 @@ function GuildCounter({ state, quests, content, now }) {
|
|||
</header>;
|
||||
}
|
||||
|
||||
// Votre équipe : les cinq compagnons (ou leurs places à pourvoir), et à côté ce qui sert à la former ou la soigner.
|
||||
function GuildTeam({ catalog, state, team, content, teamContent, statLabels }) {
|
||||
// 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 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;
|
||||
const slots = Array.from({ length: 5 }, (_, index) => team.companions[index] || null);
|
||||
return <section className="nds-panel nebula-guild-team" aria-labelledby="nebula-guild-team-title">
|
||||
<img className="nebula-guild-team-bg" src={ART.table} alt="" />
|
||||
<div className="nebula-guild-team-head">
|
||||
<h3 id="nebula-guild-team-title">{content.teamTitle}</h3>
|
||||
<p>{text}{ready && <span className="nebula-guild-days" aria-hidden="true">{Array.from({ length: team.maxDays }, (_, index) => <i key={index} data-on={index < team.teamDay || undefined} />)}</span>}</p>
|
||||
</div>
|
||||
<ol className="nebula-guild-team-list">{slots.map((companion, index) => <li key={companion?.cardId ?? `slot-${index}`}>
|
||||
{companion ? <TeamCompanion catalog={catalog} companion={companion} content={teamContent} statLabels={statLabels} size="sm" /> : <span className="nebula-guild-team-slot">{content.teamSeat}</span>}
|
||||
</li>)}</ol>
|
||||
<aside className="nebula-guild-team-side">
|
||||
<dl>
|
||||
<div><dt>{content.goldStars}</dt><dd className="nebula-guild-stars" aria-label={fillTemplate(content.goldStarsLabel, { count: team.goldStars, max: team.maxGoldStars })}>{"★".repeat(team.goldStars)}<i>{"★".repeat(team.maxGoldStars - team.goldStars)}</i></dd></div>
|
||||
<div><dt><img src={ITEM_ART.balm} alt="" />{content.balms}</dt><dd>{state.items?.balm ?? 0}</dd></div>
|
||||
</dl>
|
||||
{!ready && team.goldStars > 0 && <p>{fillTemplate(team.goldStars > 1 ? content.teamStars : content.teamStar, { count: team.goldStars })}</p>}
|
||||
<a className="nds-button" data-size="sm" data-variant={ready ? "secondary" : "primary"} href="#/cards/team">{ready ? content.teamOpen : recruiting ? content.teamResume : content.teamRecruit}</a>
|
||||
</aside>
|
||||
</section>;
|
||||
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="#/cards/team">{ready ? content.teamOpen : recruiting ? content.teamResume : content.teamRecruit}</a>} />;
|
||||
}
|
||||
|
||||
export function GuildPanel({ catalog, state, content, teamContent, statLabels }) {
|
||||
|
|
@ -119,7 +107,7 @@ export function GuildPanel({ catalog, state, content, teamContent, statLabels })
|
|||
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?.enabled && !listed.some((quest) => quest.id === "race") ? [...listed, { id: "race", pending: false, summary: team }] : listed;
|
||||
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;
|
||||
|
|
@ -132,7 +120,7 @@ export function GuildPanel({ catalog, state, content, teamContent, statLabels })
|
|||
<h3 id="nebula-guild-missions-title">{content.missionsTitle}</h3>
|
||||
{missions.map(tile)}
|
||||
</section>}
|
||||
{team && (team.enabled || team.status === "recruiting") && <GuildTeam catalog={catalog} state={state} team={team} content={content} teamContent={teamContent} statLabels={statLabels} />}
|
||||
{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>
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ export function RacePanel({ catalog, runMutation, busy, content, teamContent, st
|
|||
|
||||
const { race } = team;
|
||||
const interrupted = !live && race?.status === "running";
|
||||
const choosing = !live && !race && team.status === "ready" && team.enabled;
|
||||
const choosing = !live && !race && team.status === "ready" && team.raceEnabled;
|
||||
return <section className="nebula-race" aria-labelledby="nebula-race-title">
|
||||
<div className="nds-section-heading nebula-section-heading">
|
||||
<div><p className="eyebrow">{content.eyebrow}</p><h2 id="nebula-race-title">{content.title}</h2></div>
|
||||
|
|
@ -112,7 +112,7 @@ export function RacePanel({ catalog, runMutation, busy, content, teamContent, st
|
|||
onBoost={(boosts) => { recordRaceBoosts(boosts).catch(() => {}); }} onFinish={finish} onOver={over} />}
|
||||
{interrupted && <div className="nds-panel nebula-race-interrupted"><h3>{content.interruptedTitle}</h3><p>{content.interruptedText}</p><button className="nds-button" data-variant="primary" type="button" disabled={busy} onClick={finishInterrupted}>{content.interruptedAction}</button></div>}
|
||||
{showResult && <RaceResult catalog={catalog} race={race} nextAt={team.nextAt} content={content} teamContent={teamContent} titleRef={titleRef} />}
|
||||
{!live && !race && !choosing && <div className="nds-empty-state"><p>{team.enabled ? content.needTeam : teamContent.closed}</p>{team.enabled && <a className="nds-button" data-variant="primary" href="#/cards/team">{content.recruitFirst}</a>}</div>}
|
||||
{!live && !race && !choosing && <div className="nds-empty-state"><p>{!team.enabled ? teamContent.closed : !team.raceEnabled ? content.closed : content.needTeam}</p>{team.raceEnabled && <a className="nds-button" data-variant="primary" href="#/cards/team">{content.recruitFirst}</a>}</div>}
|
||||
{choosing && <>
|
||||
<RaceCircuit zones={team.zones} content={content} statLabels={statLabels} />
|
||||
<section className="nebula-race-choice" aria-labelledby="nebula-race-choice-title">
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
// Rôle : fenêtre d'aide de l'Équipe du jour : comment recruter, et ce qui est conseillé.
|
||||
import { useState } from "react";
|
||||
import { Modal } from "../../components/Modal.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
|
||||
export function TeamGuide({ content, maxDays }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
return <>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" onClick={() => setOpen(true)}>{content.guideAction}</button>
|
||||
{open && <Modal dialogClassName="confirm-modal nds-modal nebula-team-guide" labelledBy="nebula-team-guide-title" onRequestClose={() => setOpen(false)}>
|
||||
<h2 id="nebula-team-guide-title">{content.guideTitle}</h2>
|
||||
<h3>{content.guideHowTitle}</h3>
|
||||
<ol>{content.guideHow.map((text) => <li key={text}>{fillTemplate(text, { max: maxDays })}</li>)}</ol>
|
||||
<h3>{content.guideTipsTitle}</h3>
|
||||
<ul>{content.guideTips.map((text) => <li key={text}>{text}</li>)}</ul>
|
||||
<div className="nds-toolbar"><button className="nds-button" data-variant="primary" type="button" onClick={() => setOpen(false)}>{content.guideClose}</button></div>
|
||||
</Modal>}
|
||||
</>;
|
||||
}
|
||||
|
|
@ -2,11 +2,12 @@
|
|||
import { useEffect, useRef, useState } from "react";
|
||||
import { chooseTeamCharacter, healTeamCompanion, keepTeamCompanion, loadTeam, recruitTeam, rerollTeamOffer, resetTeam, revealTeamStar } from "./cardsApi.js";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { TeamCompanion } from "./TeamCompanion.jsx";
|
||||
import { TeamGuide } from "./TeamGuide.jsx";
|
||||
import { TeamBest, TeamRecruitment } from "./TeamRecruitment.jsx";
|
||||
import { ITEM_ART } from "./expeditionFormat.js";
|
||||
import { TeamRecruitment } from "./TeamRecruitment.jsx";
|
||||
import { TeamSky } from "./TeamSky.jsx";
|
||||
import { averagePower, countText, fateOf } from "./teamFormat.js";
|
||||
import { TeamTable } from "./TeamTable.jsx";
|
||||
import { TeamWelcome } from "./TeamWelcome.jsx";
|
||||
import { averagePower, countText } 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 })}>
|
||||
|
|
@ -15,6 +16,13 @@ function GoldReserve({ team, content }) {
|
|||
</span>;
|
||||
}
|
||||
|
||||
// Baumes disponibles, à côté des étoiles dorées : ils soignent un compagnon affaibli pendant le recrutement.
|
||||
function BalmCount({ team, content }) {
|
||||
return <span className="nebula-team-balms" role="img" aria-label={fillTemplate(content.balmsLabel, { count: team.balms ?? 0 })} title={content.balmsHelp}>
|
||||
<img src={ITEM_ART.balm} alt="" /><span>{content.balms}</span><strong>{team.balms ?? 0}</strong>
|
||||
</span>;
|
||||
}
|
||||
|
||||
// Recruter remplace l'équipe : une équipe encore utilisable demande une confirmation.
|
||||
function RecruitAction({ team, content, busy, onRecruit }) {
|
||||
const [confirming, setConfirming] = useState(false);
|
||||
|
|
@ -33,13 +41,6 @@ function RecruitAction({ team, content, busy, onRecruit }) {
|
|||
</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("");
|
||||
|
|
@ -85,35 +86,33 @@ export function TeamPanel({ catalog, state, runMutation, busy, content, statLabe
|
|||
const recruiting = team.status === "recruiting";
|
||||
const dailyToPlay = state.daily && (state.daily.status === "playing" || state.daily.rewardPending);
|
||||
const recruit = () => play(() => recruitTeam(team.day));
|
||||
const recruitBlock = team.canRecruit && <>
|
||||
{dailyToPlay && team.goldStars < team.maxGoldStars && <p className="nds-inline-notice" role="status">{content.dailyFirst} <a href="#/cards/daily">{content.dailyLink}</a></p>}
|
||||
<RecruitAction key={team.status} team={team} content={content} busy={busy} onRecruit={recruit} />
|
||||
</>;
|
||||
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} /><TeamGuide content={content} maxDays={team.maxDays} />{team.devReset && <button className="nds-button" data-size="sm" data-variant="danger" type="button" disabled={busy} onClick={() => { setFinishedPowers(null); play(() => resetTeam()); }}>{content.devReset}</button>}<a className="nds-button" data-size="sm" data-variant="secondary" href="#/cards/guild">{content.back}</a></div>
|
||||
<div className="nebula-team-heading-actions"><GoldReserve team={team} content={content} /><BalmCount team={team} content={content} />{team.devReset && <button className="nds-button" data-size="sm" data-variant="danger" type="button" disabled={busy} onClick={() => { setFinishedPowers(null); play(() => resetTeam()); }}>{content.devReset}</button>}<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))} onReroll={(offer) => play(() => rerollTeamOffer(offer))} onReveal={(index) => play(() => revealTeamStar(index))} onHeal={() => play(() => healTeamCompanion(team.recruitment.current.cardId))} 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} />
|
||||
{!recruiting && finishedPowers && team.status === "ready" && <section className="nebula-team-ready" aria-label={content.readyTitle}>
|
||||
<TeamTable catalog={catalog} companions={team.companions} content={content} statLabels={statLabels} powers={finishedPowers} size="md"
|
||||
title={content.readyTitle} titleId="nebula-team-ready-title" titleRef={readyTitleRef}
|
||||
status={<>{fillTemplate(content.readyText, { power: averagePower(team.companions) })}{team.lastDust > 0 && ` ${fillTemplate(content.readyDust, { count: team.lastDust })}`}</>}
|
||||
action={<button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={() => setFinishedPowers(null)}>{content.readyAction}</button>} />
|
||||
<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} />}
|
||||
{team.status === "ready" ? <section className="nebula-team-ready" aria-label={content.yourTeam}>
|
||||
<TeamTable catalog={catalog} companions={team.companions} content={content} statLabels={statLabels} size="md"
|
||||
title={fillTemplate(content.teamDay, { day: team.teamDay, max: team.maxDays })} titleId="nebula-team-current-title"
|
||||
status={<>{team.teamDay === team.maxDays ? content.lastDay : team.canRecruit ? content.keepOrRecruit : content.teamText}<span className="nebula-team-days" aria-hidden="true">{Array.from({ length: team.maxDays }, (_, index) => <i key={index} data-on={index < team.teamDay || undefined} />)}</span></>} />
|
||||
</section> : <TeamWelcome catalog={catalog} team={team} content={content} action={recruitBlock} />}
|
||||
{team.status === "ready" && recruitBlock}
|
||||
</>}
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,18 +2,12 @@
|
|||
import { useEffect, useRef } from "react";
|
||||
import { CurrencyIcon } from "./Currency.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { ITEM_ART, STAT_IDS } from "./expeditionFormat.js";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { ITEM_ART } from "./expeditionFormat.js";
|
||||
import { TeamCompanion } from "./TeamCompanion.jsx";
|
||||
import { TeamSky } from "./TeamSky.jsx";
|
||||
import { countText, fateOf, isMissing, mainStats, riskLevel, 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>;
|
||||
}
|
||||
import { TeamBest, TeamTable } from "./TeamTable.jsx";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { BALANCED, bandOf, countText, isMissing, mainStats, riskLevel, riskPct, specialtyStyle } from "./teamFormat.js";
|
||||
|
||||
// Étoiles encore cachées : un nombre par sorte, avec son effet en quelques mots.
|
||||
function StarsLeft({ recruitment, content }) {
|
||||
|
|
@ -31,30 +25,27 @@ function StarsLeft({ recruitment, content }) {
|
|||
</section>;
|
||||
}
|
||||
|
||||
// Équipe en construction : sa meilleure valeur par stat, à côté du choix.
|
||||
function TeamSummary({ team, content, statLabels }) {
|
||||
return <section className="nebula-team-summary" aria-labelledby="nebula-team-summary-title">
|
||||
<h3 id="nebula-team-summary-title">{content.yourTeam}</h3>
|
||||
<TeamBest companions={team} content={content} statLabels={statLabels} />
|
||||
</section>;
|
||||
}
|
||||
|
||||
// Ses compagnons, en petit, sous le choix.
|
||||
function TeamMembers({ catalog, team, recruitment, content, statLabels }) {
|
||||
return <ol className="nebula-team-members" aria-label={content.recruitedTitle}>{Array.from({ length: recruitment.size }, (_, index) => {
|
||||
const companion = team[index];
|
||||
if (!companion) return <li key={index}><span className="nebula-team-slot">{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} size="sm" footer={<span className="nebula-team-fate" data-fate={fate.kind}>{fate.text}</span>} /></li>;
|
||||
// Les deux étapes d'un compagnon, avec les numéros dorés de l'accueil.
|
||||
// L'équipe en bref : une mini-carte par place, sans illustration, à la couleur de la spécialité (bicolore s'il y en a deux), avec
|
||||
// l'icône et la Puissance ; la place en cours en doré, les places libres en pointillés.
|
||||
function MiniTeam({ companions, size, content, statLabels }) {
|
||||
return <ol className="nebula-team-mini" aria-label={content.yourTeam}>{Array.from({ length: size }, (_, index) => {
|
||||
const companion = companions[index];
|
||||
if (!companion) return <li key={index} data-current={index === companions.length || undefined}><span aria-hidden="true">{index === companions.length ? "?" : index + 1}</span><span className="sr-only">{index === companions.length ? content.seatCurrent : content.seat}</span></li>;
|
||||
const band = bandOf(companion);
|
||||
const names = band.map((id) => (id === BALANCED ? content.balanced : statLabels[id]));
|
||||
return <li key={index} data-filled="true" style={specialtyStyle(companion)} title={names.join(" · ")}>
|
||||
<span className="nebula-team-mini-icons" aria-hidden="true">{band.map((id) => <MaskIcon key={id} name={id} />)}</span>
|
||||
<strong>{companion.power}</strong>
|
||||
<span className="sr-only">{names.join(", ")}</span>
|
||||
</li>;
|
||||
})}</ol>;
|
||||
}
|
||||
|
||||
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 Steps({ step, content }) {
|
||||
return <ol className="nebula-team-steps">{[content.stepRecruit, content.stepImprove].map((label, index) => <li key={label} data-current={step === index + 1 || undefined} aria-current={step === index + 1 ? "step" : undefined}>
|
||||
<span aria-hidden="true">{index + 1}</span>{label}
|
||||
</li>)}</ol>;
|
||||
}
|
||||
|
||||
function Improve({ catalog, recruitment, last, content, statLabels, busy, titleRef, onReveal, onHeal, onKeep }) {
|
||||
|
|
@ -70,7 +61,7 @@ function Improve({ catalog, recruitment, last, content, statLabels, busy, titleR
|
|||
return <div className="nebula-team-improve">
|
||||
<h3 ref={titleRef} tabIndex={-1}>{content.improveTitle}</h3>
|
||||
<TeamCompanion catalog={catalog} companion={current} content={content} statLabels={statLabels} />
|
||||
<div className="nds-panel nebula-team-stars-panel">
|
||||
<div className="nebula-team-stars-panel">
|
||||
<ol className="nebula-team-ladder" data-fallen={(current.fallen && !current.healed) || undefined}>{powers.map((power, index) => <li key={power} data-state={index <= (current.healed ? 0 : current.step) ? "reached" : index === current.step + 1 && !over ? "next" : undefined}>
|
||||
<small>{index ? countText(content.ladderStep, index) : content.ladderStart}</small>
|
||||
<strong>{power}</strong>
|
||||
|
|
@ -103,23 +94,34 @@ export function TeamRecruitment({ catalog, team, content, statLabels, busy, onCh
|
|||
shownStep.current = step;
|
||||
titleRef.current?.focus();
|
||||
}, [step]);
|
||||
return <>
|
||||
<Steps count={count} size={recruitment.size} step={recruitment.current ? 2 : 1} content={content} />
|
||||
<div className="nebula-team-recruiting">
|
||||
<div className="nebula-team-main">
|
||||
{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} onHeal={onHeal} 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>
|
||||
return <div className="nebula-team-recruiting">
|
||||
<section className="nds-panel nebula-team-stage" aria-label={fillTemplate(content.stepCount, { count, max: recruitment.size })}>
|
||||
<Steps step={recruitment.current ? 2 : 1} content={content} />
|
||||
<div className="nebula-team-stage-main">{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} onHeal={onHeal} 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>
|
||||
{/* Le bouton qui renouvelle la proposition, au-dessus des cartes, aligné sur leur bord droit. */}
|
||||
<div className="nebula-team-offer-pick">
|
||||
<div className="nebula-team-reroll"><button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy || !recruitment.rerolls} title={recruitment.rerolls ? countText(content.rerollsLeft, recruitment.rerolls) : content.rerollsNone} onClick={() => onReroll(recruitment.offer.map((companion) => companion.cardId))}>
|
||||
{content.reroll}<span className="nebula-team-reroll-count" aria-hidden="true">×{recruitment.rerolls}</span><span className="sr-only">{recruitment.rerolls ? countText(content.rerollsLeft, recruitment.rerolls) : content.rerollsNone}</span>
|
||||
</button></div>
|
||||
<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) ? content.missing : ""} actionLabel={content.recruitAction} onSelect={() => onChoose(companion.cardId)} />)}</div>
|
||||
<div className="nds-toolbar nebula-team-actions"><button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy || !recruitment.rerolls} onClick={() => onReroll(recruitment.offer.map((companion) => companion.cardId))}>{content.reroll}</button><span>{recruitment.rerolls ? countText(content.rerollsLeft, recruitment.rerolls) : content.rerollsNone}</span></div>
|
||||
</section>}
|
||||
badge={isMissing(companion, companions) ? content.missing : ""} actionLabel={content.recruitAction} onSelect={() => onChoose(companion.cardId)} />)}</div>
|
||||
</div>
|
||||
</section>}</div>
|
||||
<div className="nebula-team-stage-side">
|
||||
<StarsLeft recruitment={recruitment} content={content} />
|
||||
{/* Rappel des points forts de l'équipe, pour comparer les cartes proposées sans descendre jusqu'à elle. */}
|
||||
<section className="nebula-team-stage-best" aria-labelledby="nebula-team-stage-best-title">
|
||||
<h3 id="nebula-team-stage-best-title">{content.stageBestTitle}</h3>
|
||||
<MiniTeam companions={companions} size={recruitment.size} content={content} statLabels={statLabels} />
|
||||
{companions.length ? <TeamBest companions={companions} content={content} statLabels={statLabels} /> : <p>{content.stageBestEmpty}</p>}
|
||||
</section>
|
||||
</div>
|
||||
<StarsLeft recruitment={recruitment} content={content} />
|
||||
<TeamSummary team={companions} content={content} statLabels={statLabels} />
|
||||
<TeamMembers catalog={catalog} team={companions} recruitment={recruitment} content={content} statLabels={statLabels} />
|
||||
</div>
|
||||
</>;
|
||||
</section>
|
||||
<TeamTable catalog={catalog} companions={companions} slots={recruitment.size} content={content} statLabels={statLabels} powers={recruitment.powers}
|
||||
title={content.yourTeam} titleId="nebula-team-summary-title" status={fillTemplate(content.stepCount, { count, max: recruitment.size })} seatLabel={content.seat} currentLabel={content.seatCurrent} />
|
||||
</div>;
|
||||
}
|
||||
|
|
|
|||
39
website/src/features/cards/TeamTable.jsx
Normal file
39
website/src/features/cards/TeamTable.jsx
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Rôle : bloc « Votre équipe », le même sur la Guilde et sur la page Équipe du jour : la table de l'équipe en fond, ses compagnons
|
||||
// (ou leurs places à pourvoir, numérotées en pointillés), puis ses points forts. L'équipe n'y est liée à aucun jeu.
|
||||
import { STAT_IDS } from "./expeditionFormat.js";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { TeamCompanion } from "./TeamCompanion.jsx";
|
||||
import { fateOf, teamBest } from "./teamFormat.js";
|
||||
|
||||
const TABLE_ART = "/static/img/cards/guild/tavern.webp";
|
||||
|
||||
// Meilleure valeur de l'équipe dans chaque stat.
|
||||
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>;
|
||||
}
|
||||
|
||||
// `status` : phrase à côté du titre ; `action` : bouton de l'en-tête ; `powers` : paliers d'un recrutement, pour dire ce que chaque
|
||||
// compagnon y est devenu ; `size` : « sm » (Guilde, recrutement) ou « md » (équipe prête) ; `currentLabel` : la première place libre
|
||||
// est celle du compagnon en cours de recrutement.
|
||||
export function TeamTable({ catalog, companions, slots = 5, content, statLabels, title, titleId, titleRef = null, status = null, action = null, powers = null, size = "sm", showBest = true, seatLabel, currentLabel = "" }) {
|
||||
return <section className="nds-panel nebula-team-table" data-size={size} aria-labelledby={titleId}>
|
||||
<img className="nebula-team-table-bg" src={TABLE_ART} alt="" />
|
||||
<div className="nebula-team-table-head">
|
||||
<h3 id={titleId} ref={titleRef} tabIndex={titleRef ? -1 : undefined}>{title}</h3>
|
||||
{status && <p>{status}</p>}
|
||||
{action}
|
||||
</div>
|
||||
<ol className="nebula-team-table-list">{Array.from({ length: Math.max(slots, companions.length) }, (_, index) => {
|
||||
const companion = companions[index];
|
||||
const current = currentLabel && index === companions.length;
|
||||
if (!companion) return <li key={`slot-${index}`}><span className="nebula-team-table-slot" data-current={current || undefined}><strong>{index + 1}</strong>{current ? currentLabel : seatLabel}</span></li>;
|
||||
const fate = powers && fateOf(companion, powers, content);
|
||||
return <li key={companion.cardId}><TeamCompanion catalog={catalog} companion={companion} content={content} statLabels={statLabels} size={size}
|
||||
footer={fate && <span className="nebula-team-fate" data-fate={fate.kind}>{fate.text}</span>} /></li>;
|
||||
})}</ol>
|
||||
{showBest && companions.length > 0 && <div className="nebula-team-table-best"><span>{content.bestLabel}</span><TeamBest companions={companions} content={content} statLabels={statLabels} /></div>}
|
||||
</section>;
|
||||
}
|
||||
47
website/src/features/cards/TeamWelcome.jsx
Normal file
47
website/src/features/cards/TeamWelcome.jsx
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// Rôle : accueil de l'Équipe du jour quand le joueur n'a pas d'équipe (ou qu'elle s'est reposée) : un appel à recruter, cinq places
|
||||
// à pourvoir, puis les trois étapes (recruter, améliorer, partir en quête), chacune avec un visuel. L'équipe n'est liée à aucun jeu.
|
||||
import { CurrencyIcon } from "./Currency.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
|
||||
const TABLE_ART = "/static/img/cards/guild/tavern.webp";
|
||||
|
||||
// Trois personnages du catalogue, pris loin les uns des autres, pour montrer une proposition de recrutement.
|
||||
function sampleCards(catalog) {
|
||||
const cards = catalog.cards.filter((card) => card.image && card.expedition?.profile);
|
||||
const pool = cards.length >= 3 ? cards : catalog.cards.filter((card) => card.image);
|
||||
return pool.length ? [0, Math.floor(pool.length / 2), pool.length - 1].map((index) => pool[index]) : [];
|
||||
}
|
||||
|
||||
const STEP_VISUALS = {
|
||||
recruit: ({ catalog }) => <span className="nebula-team-welcome-fan">{sampleCards(catalog).map((card) => <img key={card.id} src={card.image} alt="" loading="lazy" />)}</span>,
|
||||
improve: () => <span className="nebula-team-welcome-stars">
|
||||
<i data-kind="gold">★</i><i data-kind="gold">★</i><i data-kind="hidden">?</i><i data-kind="black">✖</i><i data-kind="dust"><CurrencyIcon kind="stardust" /></i>
|
||||
</span>,
|
||||
quest: ({ maxDays }) => <span className="nebula-team-welcome-days">{Array.from({ length: maxDays }, (_, index) => <i key={index}>{index + 1}</i>)}</span>
|
||||
};
|
||||
|
||||
export function TeamWelcome({ catalog, team, content, action }) {
|
||||
const expired = team.status === "expired";
|
||||
return <>
|
||||
<section className="nds-panel nebula-team-welcome" aria-labelledby="nebula-team-none-title">
|
||||
<img className="nebula-team-welcome-bg" src={TABLE_ART} alt="" />
|
||||
<div className="nebula-team-welcome-copy">
|
||||
<h3 id="nebula-team-none-title">{expired ? content.expiredTitle : content.noneTitle}</h3>
|
||||
<p>{fillTemplate(expired ? content.expiredText : content.noneText, { max: team.maxDays })}</p>
|
||||
<ol className="nebula-team-welcome-slots" aria-hidden="true">{Array.from({ length: 5 }, (_, index) => <li key={index}>{index + 1}</li>)}</ol>
|
||||
{action}
|
||||
</div>
|
||||
</section>
|
||||
<ol className="nebula-team-welcome-steps" aria-label={content.welcomeStepsLabel}>{content.welcomeSteps.map((step, index) => {
|
||||
const Visual = STEP_VISUALS[step.id];
|
||||
return <li key={step.id} className="nds-card">
|
||||
<div className="nebula-team-welcome-visual" aria-hidden="true"><span className="nebula-team-welcome-number">{index + 1}</span>{Visual && <Visual catalog={catalog} maxDays={team.maxDays} />}</div>
|
||||
<div className="nds-card-body">
|
||||
<h4>{step.title}</h4>
|
||||
<p>{fillTemplate(step.text, { max: team.maxDays })}</p>
|
||||
{step.tip && <p className="nebula-team-welcome-tip">{step.tip}</p>}
|
||||
</div>
|
||||
</li>;
|
||||
})}</ol>
|
||||
</>;
|
||||
}
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
// Rôle : règle les quêtes de la Guilde des Veilleurs, une par onglet (Carte du jour, Équipe du jour, Expéditions), chacun avec son adresse.
|
||||
// Rôle : règle les quêtes de la Guilde des Veilleurs, une par onglet (Carte du jour, Équipe du jour, Course des courants, Expéditions),
|
||||
// chacun avec son adresse.
|
||||
import { useState } from "react";
|
||||
import { Tabs } from "../../../components/Tabs.jsx";
|
||||
import { ApplyActions } from "./adminSettingForm.jsx";
|
||||
import { inRange, MAX_VALUE, parse, shopSettingSaver } from "./adminSettings.js";
|
||||
import { ExpeditionSettings } from "./ExpeditionSettings.jsx";
|
||||
import { RaceSettings } from "./RaceSettings.jsx";
|
||||
import { TeamSettings } from "./TeamSettings.jsx";
|
||||
|
||||
// Carte du jour : la partie du jour (joueurs et gagnants), puis la récompense d'une victoire.
|
||||
|
|
@ -30,7 +32,7 @@ function DailyQuestSettings({ setting, daily, busy, save }) {
|
|||
}
|
||||
|
||||
// Onglets de la Guilde : l'adresse #/cards/admin/guild/<onglet> garde l'onglet ouvert ; sans onglet, la Carte du jour.
|
||||
const GUILD_TABS = [{ id: "daily", label: "Carte du jour" }, { id: "team", label: "Équipe du jour" }, { id: "expeditions", label: "Expéditions" }];
|
||||
const GUILD_TABS = [{ id: "daily", label: "Carte du jour" }, { id: "team", label: "Équipe du jour" }, { id: "race", label: "Course des courants" }, { id: "expeditions", label: "Expéditions" }];
|
||||
|
||||
export function AdminGuild({ dashboard, busy, runMutation, refreshDashboard, tab = "" }) {
|
||||
const setting = dashboard?.shopSetting;
|
||||
|
|
@ -42,6 +44,7 @@ export function AdminGuild({ dashboard, busy, runMutation, refreshDashboard, tab
|
|||
? <>
|
||||
{activeTab === "daily" && <DailyQuestSettings key={setting.dailyReward} setting={setting} daily={dashboard.daily} busy={busy} save={save} />}
|
||||
{activeTab === "team" && dashboard.teamSettings && <TeamSettings dashboard={dashboard} busy={busy} runMutation={runMutation} refreshDashboard={refreshDashboard} />}
|
||||
{activeTab === "race" && dashboard.teamSettings && <RaceSettings dashboard={dashboard} busy={busy} runMutation={runMutation} refreshDashboard={refreshDashboard} />}
|
||||
{activeTab === "expeditions" && dashboard.expeditionSettings && <ExpeditionSettings dashboard={dashboard} busy={busy} runMutation={runMutation} refreshDashboard={refreshDashboard} />}
|
||||
</>
|
||||
: <div className="nds-empty-state" aria-busy="true"><p>Chargement des quêtes…</p></div>}
|
||||
|
|
|
|||
75
website/src/features/cards/admin/RaceSettings.jsx
Normal file
75
website/src/features/cards/admin/RaceSettings.jsx
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// Rôle : règle la Course des courants depuis Administration › Guilde : ouverture, suivi du jour (parcours, courses, places,
|
||||
// poussière, adversaires), récompenses et habileté des Équipes des Veilleurs. Ses règles de jeu restent dans race-rules.js.
|
||||
import { useState } from "react";
|
||||
import { ConfirmModal } from "../../../components/ToolboxModals.jsx";
|
||||
import { updateTeamSettings } from "../cardsApi.js";
|
||||
import { ApplyBar, SettingsGroup } from "./SettingFields.jsx";
|
||||
import { useSettingsDraft, writePath } from "./settingsDraft.js";
|
||||
import { formatTeamSetting, RACE_SETTING_GROUPS, teamSettingLabel } from "./teamSettingFields.js";
|
||||
|
||||
const FIELDS = RACE_SETTING_GROUPS.flatMap((group) => group.fields);
|
||||
const STAT_LABELS = { bravoure: "Bravoure", endurance: "Endurance", fortune: "Fortune", orientation: "Orientation" };
|
||||
const plural = (count, word) => `${word}${count > 1 ? "s" : ""}`;
|
||||
const number = (value) => value.toLocaleString("fr-FR");
|
||||
|
||||
// Ouverture (appliquée tout de suite) et suivi du jour.
|
||||
function RaceStatus({ settings, race, busy, onToggle }) {
|
||||
const [confirming, setConfirming] = useState(false);
|
||||
const open = settings.raceEnabled;
|
||||
const running = race.started - race.finished;
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-expedition-status" data-open={open && settings.enabled} aria-labelledby="nebula-admin-race-status-title">
|
||||
<div className="nebula-admin-expedition-status-head">
|
||||
<div>
|
||||
<h3 id="nebula-admin-race-status-title">Course des courants <span className="nds-badge" data-variant={open && settings.enabled ? "success" : "neutral"}>{!open ? "Fermée aux joueurs" : settings.enabled ? "Ouverte aux joueurs" : "En attente de l’Équipe du jour"}</span></h3>
|
||||
<p className="nebula-admin-guild-today">Aujourd’hui : <strong>{number(race.finished)}</strong> {plural(race.finished, "course")} {plural(race.finished, "finie")}{running > 0 && <>, <strong>{number(running)}</strong> en cours</>} · <strong>{number(race.stardust)}</strong> de poussière versée.</p>
|
||||
</div>
|
||||
<button className="nds-button" data-size="sm" data-variant={open ? "secondary" : "primary"} type="button" disabled={busy} onClick={() => setConfirming(true)}>{open ? "Fermer la Course" : "Ouvrir la Course"}</button>
|
||||
</div>
|
||||
{!settings.enabled && open && <p className="nds-inline-notice" role="status">La Course se court avec une équipe : elle n’apparaîtra aux joueurs qu’une fois l’Équipe du jour ouverte.</p>}
|
||||
{confirming && <ConfirmModal
|
||||
title={open ? "Fermer la Course ?" : "Ouvrir la Course ?"}
|
||||
message={open ? "Plus aucun départ de course. Une course déjà commencée se termine. L’Équipe du jour reste ouverte." : "La tuile de la Course apparaît au tableau de la Guilde dès que l’Équipe du jour est ouverte."}
|
||||
confirmLabel={open ? "Fermer" : "Ouvrir"}
|
||||
onClose={async (confirmed) => {
|
||||
setConfirming(false);
|
||||
if (confirmed) await onToggle(!open);
|
||||
}}
|
||||
/>}
|
||||
</section>;
|
||||
}
|
||||
|
||||
// Le parcours du jour et ce qu'ont donné les courses finies.
|
||||
function RaceToday({ race }) {
|
||||
const opponents = race.opponents.players + race.opponents.watchers;
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-race-today" aria-labelledby="nebula-admin-race-today-title">
|
||||
<h3 id="nebula-admin-race-today-title">Le jour en cours</h3>
|
||||
{race.zones
|
||||
? <ol className="nebula-admin-race-zones" aria-label="Parcours du jour">{race.zones.map((stat, index) => <li key={index} style={{ "--specialty": `var(--color-stat-${stat})` }}><small>{index + 1}</small>{STAT_LABELS[stat] || stat}</li>)}</ol>
|
||||
: <p className="nebula-form-help">Le parcours se tire à la première visite d’un joueur.</p>}
|
||||
<dl className="nebula-admin-race-figures">
|
||||
<div><dt>Places des joueurs</dt><dd>{race.places.map((count, index) => `${index + 1}${index ? "e" : "re"} : ${number(count)}`).join(" · ")}</dd></div>
|
||||
<div><dt>Adversaires</dt><dd>{opponents ? `${number(race.opponents.players)} équipe${race.opponents.players > 1 ? "s" : ""} de joueurs · ${number(race.opponents.watchers)} des Veilleurs` : "Aucune course lancée."}</dd></div>
|
||||
</dl>
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function RaceSettings({ dashboard, busy, runMutation, refreshDashboard }) {
|
||||
const { settings, defaults, race } = dashboard.teamSettings;
|
||||
const draft = useSettingsDraft(settings, FIELDS);
|
||||
const save = async (apply) => {
|
||||
const next = structuredClone(settings);
|
||||
apply(next);
|
||||
const saved = await runMutation(() => updateTeamSettings(next));
|
||||
if (saved) await refreshDashboard();
|
||||
return saved;
|
||||
};
|
||||
const apply = async () => {
|
||||
if (await save((next) => draft.changes.forEach((field) => writePath(next, field.path, draft.value(field.path))))) draft.reset();
|
||||
};
|
||||
return <div className="nebula-admin-expeditions">
|
||||
<RaceStatus settings={settings} race={race} busy={busy} onToggle={(raceEnabled) => save((next) => { next.raceEnabled = raceEnabled; })} />
|
||||
<RaceToday race={race} />
|
||||
{RACE_SETTING_GROUPS.map((group) => <SettingsGroup key={group.id} group={group} fields={group.fields} draft={draft} settings={settings} defaults={defaults} busy={busy} />)}
|
||||
<ApplyBar draft={draft} settings={settings} busy={busy} onApply={apply} message="Les nouveaux réglages valent pour les prochaines courses. Une course commencée garde ses récompenses et ses adversaires." labelOf={teamSettingLabel} formatValue={formatTeamSetting} />
|
||||
</div>;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
// Rôle : règle l'Équipe du jour depuis Administration › Guilde : ouverture et suivi du jour, étoiles, Puissance et récompenses.
|
||||
// Rôle : règle l'Équipe du jour depuis Administration › Guilde : ouverture et suivi du jour, étoiles, Puissance et récompense de la
|
||||
// Carte du jour. La Course des courants a son onglet (RaceSettings.jsx).
|
||||
import { useState } from "react";
|
||||
import { ConfirmModal } from "../../../components/ToolboxModals.jsx";
|
||||
import { updateTeamSettings } from "../cardsApi.js";
|
||||
|
|
@ -16,15 +17,15 @@ function TeamStatus({ enabled, today, busy, onToggle }) {
|
|||
<div className="nebula-admin-expedition-status-head">
|
||||
<div>
|
||||
<h3 id="nebula-admin-team-status-title">Équipe du jour <span className="nds-badge" data-variant={enabled ? "success" : "neutral"}>{enabled ? "Ouverte aux joueurs" : "Fermée aux joueurs"}</span></h3>
|
||||
<p className="nebula-admin-guild-today">Aujourd’hui : <strong>{today.teams}</strong> {plural(today.teams, "équipe")} utilisable{today.teams > 1 ? "s" : ""} · <strong>{today.races}</strong> {plural(today.races, "course")} · <strong>{today.stars}</strong> {plural(today.stars, "étoile")} {plural(today.stars, "dorée")} {plural(today.stars, "choisie")}.</p>
|
||||
<p className="nebula-admin-guild-today">Aujourd’hui : <strong>{today.teams}</strong> {plural(today.teams, "équipe")} utilisable{today.teams > 1 ? "s" : ""} · <strong>{today.stars}</strong> {plural(today.stars, "étoile")} {plural(today.stars, "dorée")} {plural(today.stars, "choisie")}.</p>
|
||||
</div>
|
||||
<button className="nds-button" data-size="sm" data-variant={enabled ? "secondary" : "primary"} type="button" disabled={busy} onClick={() => setConfirming(true)}>{enabled ? "Fermer l’Équipe du jour" : "Ouvrir l’Équipe du jour"}</button>
|
||||
</div>
|
||||
{confirming && <ConfirmModal
|
||||
title={enabled ? "Fermer l’Équipe du jour ?" : "Ouvrir l’Équipe du jour ?"}
|
||||
message={enabled
|
||||
? "Plus aucun recrutement ni départ de course. Un recrutement ou une course déjà commencés se terminent, et la Carte du jour redonne sa poussière aussitôt."
|
||||
: "Les tuiles de l’Équipe du jour et de la Course apparaissent dans la Guilde, et la Carte du jour propose une étoile dorée."}
|
||||
? "Plus aucun recrutement ni départ de course (la Course demande une équipe). Un recrutement ou une course déjà commencés se terminent, et la Carte du jour redonne sa poussière aussitôt."
|
||||
: "L’équipe apparaît dans la Guilde (et la Course, si elle est ouverte), et la Carte du jour propose une étoile dorée."}
|
||||
confirmLabel={enabled ? "Fermer" : "Ouvrir"}
|
||||
onClose={async (confirmed) => {
|
||||
setConfirming(false);
|
||||
|
|
@ -54,7 +55,7 @@ export function TeamSettings({ dashboard, busy, runMutation, refreshDashboard })
|
|||
<TeamStatus enabled={settings.enabled} today={today} busy={busy} onToggle={(enabled) => save((next) => { next.enabled = enabled; })} />
|
||||
{starStardust >= dailyReward && <p className="nds-inline-notice" data-variant="warning" role="status">L’étoile dorée vient avec {starStardust.toLocaleString("fr-FR")} de poussière, autant ou plus que la Carte du jour sans étoile ({dailyReward.toLocaleString("fr-FR")}) : les joueurs n’auraient aucune raison de choisir la poussière seule.</p>}
|
||||
{TEAM_SETTING_GROUPS.map((group) => <SettingsGroup key={group.id} group={group} fields={group.fields} draft={draft} settings={settings} defaults={defaults} busy={busy} />)}
|
||||
<ApplyBar draft={draft} settings={settings} busy={busy} onApply={apply} message="Les nouveaux réglages valent pour les prochains recrutements, courses et victoires à la Carte du jour." labelOf={teamSettingLabel} formatValue={formatTeamSetting}
|
||||
<ApplyBar draft={draft} settings={settings} busy={busy} onApply={apply} message="Les nouveaux réglages valent pour les prochains recrutements et victoires à la Carte du jour." labelOf={teamSettingLabel} formatValue={formatTeamSetting}
|
||||
blocked={teamSettingsConflict({ powers: value("recruitment.powers"), fallPower: value("recruitment.fallPower") })} />
|
||||
</div>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Rôle : décrit les réglages de l'Équipe du jour dans l'administration : libellés, bornes et règles entre plusieurs valeurs.
|
||||
// Rôle : décrit les réglages de l'Équipe du jour et de la Course des courants dans l'administration : libellés, bornes et règles
|
||||
// entre plusieurs valeurs. Les deux sont enregistrés ensemble, mais réglés dans deux onglets.
|
||||
|
||||
export const TEAM_SETTING_GROUPS = [
|
||||
{
|
||||
|
|
@ -19,20 +20,39 @@ export const TEAM_SETTING_GROUPS = [
|
|||
]
|
||||
},
|
||||
{
|
||||
id: "team-rewards", title: "Récompenses", help: "En poussière d’étoiles. Les récompenses d’une course sont celles de son départ.",
|
||||
id: "team-rewards", title: "Carte du jour", help: "En poussière d’étoiles, quand le joueur choisit l’étoile dorée plutôt que la poussière seule.",
|
||||
fields: [
|
||||
{ path: "raceRewards", label: "Course, selon la place", min: 0, max: 100_000, items: ["1re", "2e", "3e", "4e"] },
|
||||
{ path: "starStardust", label: "Avec une étoile dorée (Carte du jour)", min: 0, max: 100_000 }
|
||||
{ path: "starStardust", label: "Avec une étoile dorée", min: 0, max: 100_000 }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const FIELDS = TEAM_SETTING_GROUPS.flatMap((group) => group.fields);
|
||||
const LABELS = new Map([...FIELDS.map((field) => [field.path, field.label]), ["enabled", "Ouverte aux joueurs"]]);
|
||||
export const RACE_SETTING_GROUPS = [
|
||||
{
|
||||
id: "race-rewards", title: "Récompenses", help: "En poussière d’étoiles, selon la place. Les récompenses d’une course sont celles de son départ.",
|
||||
fields: [
|
||||
{ path: "raceRewards", label: "Selon la place", min: 0, max: 100_000, items: ["1re", "2e", "3e", "4e"] }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "race-watchers", title: "Équipes des Veilleurs", help: "Elles complètent une course quand il manque des équipes de joueurs. Habileté : chance de bien choisir chaque compagnon et de bien l’améliorer. L’équipe forte donne aussi ses élans au bon moment.",
|
||||
fields: [
|
||||
{ path: "watcherSkill.strong", label: "Forte", min: 0, max: 100, unit: "%" },
|
||||
{ path: "watcherSkill.medium", label: "Moyenne", min: 0, max: 100, unit: "%" },
|
||||
{ path: "watcherSkill.weak", label: "Faible", min: 0, max: 100, unit: "%" }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const FIELDS = [...TEAM_SETTING_GROUPS, ...RACE_SETTING_GROUPS].flatMap((group) => group.fields);
|
||||
const LABELS = new Map([
|
||||
...FIELDS.map((field) => [field.path, field.path.startsWith("watcherSkill.") ? `Veilleurs, équipe ${field.label.toLowerCase()}` : field.path === "raceRewards" ? "Course, récompenses selon la place" : field.label]),
|
||||
["enabled", "Équipe du jour ouverte aux joueurs"], ["raceEnabled", "Course ouverte aux joueurs"]
|
||||
]);
|
||||
|
||||
export const teamSettingLabel = (path) => LABELS.get(path) || path;
|
||||
export const formatTeamSetting = (value) => (typeof value === "boolean" ? (value ? "oui" : "non") : Array.isArray(value) ? value.join(" / ") : String(value));
|
||||
export const TEAM_SETTING_PATHS = ["enabled", ...FIELDS.map((field) => field.path)];
|
||||
export const TEAM_SETTING_PATHS = ["enabled", "raceEnabled", ...FIELDS.map((field) => field.path)];
|
||||
|
||||
// Règles entre valeurs, que le serveur vérifie aussi.
|
||||
export function teamSettingsConflict({ powers, fallPower }) {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ export function guildQuests(state, now = Date.now()) {
|
|||
// 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 });
|
||||
// La Course attend une équipe ; une course commencée se termine même si l'Équipe du jour ferme.
|
||||
if (team && ((team.enabled && team.status === "ready") || team.race === "running")) quests.push({ id: "race", pending: team.race !== "finished", summary: team });
|
||||
// La Course attend une équipe et sa propre ouverture ; une course commencée se termine même si elle ferme.
|
||||
if (team && ((team.raceEnabled && team.status === "ready") || team.race === "running")) quests.push({ id: "race", pending: team.race !== "finished", 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;
|
||||
|
|
@ -42,7 +42,7 @@ export function guildGreeting(state, now = Date.now()) {
|
|||
if (daily?.status === "playing") return teamOpen && team.status !== "ready" ? "dailyFirst" : "daily";
|
||||
if (teamOpen && team.status === "recruiting") return "recruiting";
|
||||
if (teamOpen && team.status !== "ready") return "recruit";
|
||||
if (teamOpen && team.race !== "finished") return "race";
|
||||
if (teamOpen && team.raceEnabled && team.race !== "finished") return "race";
|
||||
if (expeditions && (expeditions.returned > 0 || (expeditions.nextReturnAt != null && expeditions.nextReturnAt <= now))) return "loot";
|
||||
return "done";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue