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>
75 lines
5.4 KiB
JavaScript
75 lines
5.4 KiB
JavaScript
// 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>;
|
||
}
|