Make Sokko TCG's Current Race fairer and explain each race afterwards
Players kept finishing third or fourth: opponents were played better than their owners would (always the best runner, half of them with perfect boosts and no reaction time), and the Watchers recruited knowing the day's circuit, which players never see. - A player who already ran today now comes back as a ghost with their real race; other teams play like an attentive player (best runner, each teammate given in a zone of its best stat after a reaction delay). The Watchers recruit blind; only the strong one plays attentively. The administration counts the ghosts. - The rule that a boost keeps the value of the zone where it was given is now stated before and during the race. - A boosting teammate is greyed at once with "Élan donné", a 1.5 s bar and its locked value; the others dim while the player has to wait. - The result shows the place as a medal, the finish as lanes (with a gold silhouette at the best boosts), the three times, each boost placed on the circuit (dashed in the teammate's best stat when it was worth more elsewhere), a sentence per boost to place better and, when clearly faster, another runner. The best boosts are searched in the browser. - A development-only "Recourir (dev)" button erases the race and keeps the team. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8253f74c90
commit
52df57f781
16 changed files with 603 additions and 102 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Rôle : course en direct : décompte, animation des quatre coureurs, équipiers à cliquer pour donner leurs élans.
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { RACE_LENGTH } from "../../../../services/cards/race-rules.js";
|
||||
import { BOOST_FACTOR, BOOST_MS, RACE_LENGTH } from "../../../../services/cards/race-rules.js";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { activeHelper, advanceRace, advanceToNextChoice, allRuns, canGiveBoost, createRace, giveBoost, imageOf, nameOf, playerZone, raceOver, racerName } from "./raceRun.js";
|
||||
|
|
@ -14,13 +14,15 @@ const MAX_FRAME_MS = 250;
|
|||
|
||||
const reducedMotion = () => Boolean(globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches);
|
||||
|
||||
// Ce que l'écran montre d'une course, hors avancée des coureurs : il ne change que quelques fois par course.
|
||||
// Ce que l'écran montre d'une course, hors avancée des coureurs : il ne change que quelques fois par course. `boostValue` : la stat
|
||||
// figée de l'élan en cours, prise dans la zone du clic.
|
||||
function snapshot(race) {
|
||||
const { run } = race.player;
|
||||
return { zone: playerZone(race), used: run.used, helpers: allRuns(race).map(activeHelper), finished: run.finishedAt !== null, over: raceOver(race) };
|
||||
const helpers = allRuns(race).map(activeHelper);
|
||||
return { zone: playerZone(race), used: run.used, helpers, boostValue: helpers[0] >= 0 ? Math.round(run.boostSpeed / BOOST_FACTOR) : null, finished: run.finishedAt !== null, over: raceOver(race) };
|
||||
}
|
||||
|
||||
const sameSnapshot = (left, right) => left.zone === right.zone && left.finished === right.finished && left.over === right.over && left.used.length === right.used.length && left.helpers.every((helper, index) => helper === right.helpers[index]);
|
||||
const sameSnapshot = (left, right) => left.zone === right.zone && left.boostValue === right.boostValue && left.finished === right.finished && left.over === right.over && left.used.length === right.used.length && left.helpers.every((helper, index) => helper === right.helpers[index]);
|
||||
|
||||
export function RaceLive({ catalog, race, companions, content, teamContent, statLabels, onBoost, onFinish, onOver }) {
|
||||
const [stepped] = useState(reducedMotion);
|
||||
|
|
@ -122,17 +124,21 @@ export function RaceLive({ catalog, race, companions, content, teamContent, stat
|
|||
<span><MaskIcon name={stat} />{fillTemplate(content.zone, { stat: statLabels[stat], value: race.runner.stats[stat] })}</span>
|
||||
<span>{nextStat ? fillTemplate(content.nextZone, { stat: statLabels[nextStat] }) : content.lastZone}</span>
|
||||
</p>
|
||||
<ul className="nebula-race-helpers">{race.helpers.map((helper, index) => {
|
||||
<ul className="nebula-race-helpers" data-boosting={view.helpers[0] >= 0 || undefined}>{race.helpers.map((helper, index) => {
|
||||
const used = view.used.includes(index);
|
||||
const active = view.helpers[0] === index;
|
||||
const blocked = used || !started || view.helpers[0] >= 0;
|
||||
const name = nameOf(catalog, helper.cardId, teamContent);
|
||||
// L'équipier qui donne son élan est tout de suite marqué : sa valeur est figée, une barre montre le temps qui reste.
|
||||
const value = active ? view.boostValue : helper.stats[stat];
|
||||
const label = active ? content.helperActive : used ? content.helperUsed : content.helperLabel;
|
||||
return <li key={helper.cardId}><button className="nebula-race-mate" type="button" data-active={active || undefined} data-used={(used && !active) || undefined} aria-disabled={blocked || undefined}
|
||||
aria-label={fillTemplate(used ? content.helperUsed : content.helperLabel, { card: name, stat: statLabels[stat], value: helper.stats[stat] })} style={{ ...specialtyStyle(companionOf(helper.cardId) || { specialties: [] }), "--specialty": `var(--color-stat-${stat})` }} onClick={() => boost(index)}>
|
||||
<span className="nebula-race-mate-art"><img src={imageOf(catalog, helper.cardId)} alt="" /><kbd aria-hidden="true">{index + 1}</kbd></span>
|
||||
aria-label={fillTemplate(label, { card: name, stat: statLabels[stat], value })} style={{ ...specialtyStyle(companionOf(helper.cardId) || { specialties: [] }), "--specialty": `var(--color-stat-${stat})` }} onClick={() => boost(index)}>
|
||||
<span className="nebula-race-mate-art"><img src={imageOf(catalog, helper.cardId)} alt="" /><kbd aria-hidden="true">{index + 1}</kbd>
|
||||
{active && <span className="nebula-race-mate-boost" aria-hidden="true" style={{ "--boost-ms": `${BOOST_MS}ms` }}>{content.boosting}<i /></span>}</span>
|
||||
<SpecialtyBand companion={companionOf(helper.cardId) || { specialties: [] }} content={teamContent} statLabels={statLabels} />
|
||||
<span className="nebula-race-mate-name">{name}</span>
|
||||
<strong>+{helper.stats[stat]}</strong>
|
||||
<strong>+{value}</strong>
|
||||
</button></li>;
|
||||
})}</ul>
|
||||
<div className="nds-toolbar nebula-race-help">
|
||||
|
|
|
|||
|
|
@ -1,31 +1,11 @@
|
|||
// Rôle : page de la Course des courants : choix du coureur, course en direct, course interrompue et résultat.
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { finishRace, loadTeam, recordRaceBoosts, startRace } from "./cardsApi.js";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { finishRace, loadTeam, recordRaceBoosts, resetRace, startRace } from "./cardsApi.js";
|
||||
import { RaceLive } from "./RaceLive.jsx";
|
||||
import { imageOf, nameOf, racerName, raceRanking } from "./raceRun.js";
|
||||
import { RaceResult } from "./RaceResult.jsx";
|
||||
import { RaceCircuit } from "./RaceTrack.jsx";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
import { TeamCompanion } from "./TeamCompanion.jsx";
|
||||
|
||||
const formatTime = (milliseconds) => `${(milliseconds / 1_000).toLocaleString("fr-FR", { minimumFractionDigits: 2, maximumFractionDigits: 2 })} s`;
|
||||
const placeText = (place, content) => fillTemplate(place === 1 ? content.placeFirst : content.placeOther, { place });
|
||||
|
||||
function RaceResult({ catalog, race, nextAt, content, teamContent, titleRef }) {
|
||||
const [now] = useState(() => Date.now());
|
||||
const ranking = raceRanking(race);
|
||||
return <section className="nds-panel nebula-race-result" aria-labelledby="nebula-race-result-title" data-place={race.place}>
|
||||
<h3 id="nebula-race-result-title" ref={titleRef} tabIndex={-1}>{placeText(race.place, content)}</h3>
|
||||
<p className="nebula-race-reward">{race.reward > 0 ? fillTemplate(content.earned, { reward: formatStardust(race.reward) }) : content.noReward}</p>
|
||||
<ol className="nebula-race-ranking">{ranking.map((entry, index) => <li key={entry.index} data-player={entry.player || undefined}>
|
||||
<span>{index + 1}</span><img src={imageOf(catalog, entry.runner.cardId)} alt="" />
|
||||
<span><strong>{entry.player ? content.you : racerName(entry, content)}</strong><small>{nameOf(catalog, entry.runner.cardId, teamContent)}</small></span>
|
||||
<span>{formatTime(entry.finishedAt)}</span>
|
||||
</li>)}</ol>
|
||||
<p className="nebula-race-next">{fillTemplate(content.next, { time: formatCountdown(nextAt - now) })}</p>
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function RacePanel({ catalog, runMutation, busy, content, teamContent, statLabels }) {
|
||||
const [team, setTeam] = useState(null);
|
||||
const [loadError, setLoadError] = useState("");
|
||||
|
|
@ -94,6 +74,15 @@ export function RacePanel({ catalog, runMutation, busy, content, teamContent, st
|
|||
setLive(null);
|
||||
}
|
||||
|
||||
// Développement : la course du jour s'efface, l'équipe reste.
|
||||
async function rerun() {
|
||||
const next = await play(() => resetRace());
|
||||
if (!next) return;
|
||||
setLive(null);
|
||||
setFinished(null);
|
||||
setTeam(next);
|
||||
}
|
||||
|
||||
async function finishInterrupted() {
|
||||
const next = await finish(null);
|
||||
if (next) setTeam(next);
|
||||
|
|
@ -105,13 +94,13 @@ export function RacePanel({ catalog, runMutation, busy, content, teamContent, st
|
|||
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>
|
||||
<div className="nebula-team-heading-actions"><a className="nds-button" data-size="sm" data-variant="secondary" href="#/cards/guild">{content.back}</a></div>
|
||||
<div className="nebula-team-heading-actions">{team.devReset && <button className="nds-button" data-size="sm" data-variant="danger" type="button" disabled={busy} onClick={rerun}>{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>}
|
||||
{live && <RaceLive key={live.day} catalog={catalog} race={live} companions={team.companions} content={content} teamContent={teamContent} statLabels={statLabels}
|
||||
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} />}
|
||||
{showResult && <RaceResult catalog={catalog} race={race} nextAt={team.nextAt} content={content} teamContent={teamContent} statLabels={statLabels} titleRef={titleRef} />}
|
||||
{!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} />
|
||||
|
|
|
|||
125
website/src/features/cards/RaceResult.jsx
Normal file
125
website/src/features/cards/RaceResult.jsx
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
// Rôle : résultat d'une Course des courants finie : la place et la récompense, l'arrivée en couloirs, puis le bilan (temps, élans
|
||||
// posés sur le circuit, équipiers), pour apprendre après coup sans être guidé pendant la course.
|
||||
import { useMemo, useState } from "react";
|
||||
import { CurrencyIcon } from "./Currency.jsx";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { imageOf, nameOf, racerName, raceRanking, raceReview } from "./raceRun.js";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
const formatTime = (milliseconds) => `${(milliseconds / 1_000).toLocaleString("fr-FR", { minimumFractionDigits: 2, maximumFractionDigits: 2 })} s`;
|
||||
const placeText = (place, content) => fillTemplate(place === 1 ? content.placeFirst : content.placeOther, { place });
|
||||
const ordinal = (place) => `${place}${place === 1 ? "re" : "e"}`;
|
||||
// En dessous, l'écart avec les meilleurs élans ne vaut pas d'être signalé.
|
||||
const NEAR_BEST_MS = 150;
|
||||
|
||||
// Arrivée en couloirs, du premier au dernier : chaque coureur est placé selon son temps, le plus rapide contre la ligne d'arrivée.
|
||||
// Dans le couloir du joueur, une silhouette dorée montre où l'auraient mené les meilleurs élans.
|
||||
function RaceFinish({ catalog, race, review, showBest, content, teamContent }) {
|
||||
const ranking = raceRanking(race);
|
||||
const times = [...ranking.map((entry) => entry.finishedAt), ...(showBest ? [review.best] : [])];
|
||||
const [fastest, slowest] = [Math.min(...times), Math.max(...times)];
|
||||
const at = (time) => (slowest === fastest ? 1 : (slowest - time) / (slowest - fastest));
|
||||
return <ol className="nebula-race-finish">{ranking.map((entry, index) => {
|
||||
const image = imageOf(catalog, entry.runner.cardId);
|
||||
return <li key={entry.index} data-player={entry.player || undefined}>
|
||||
<span className="nebula-race-finish-place">{index + 1}</span>
|
||||
<span className="nebula-race-finish-who"><img src={image} alt="" />
|
||||
<span><strong>{entry.player ? content.you : racerName(entry, content)}</strong><small>{nameOf(catalog, entry.runner.cardId, teamContent)}{entry.ghost && ` · ${content.ghost}`}</small></span></span>
|
||||
<span className="nebula-race-finish-track" aria-hidden="true">
|
||||
{entry.player && showBest && <>
|
||||
<span className="nebula-race-finish-gap" style={{ "--from": at(entry.finishedAt), "--to": at(review.best) }} />
|
||||
<img className="nebula-race-finish-ghost" src={image} alt="" style={{ "--at": at(review.best) }} />
|
||||
</>}
|
||||
<img className="nebula-race-finish-runner" src={image} alt="" style={{ "--at": at(entry.finishedAt) }} />
|
||||
</span>
|
||||
<span className="nebula-race-finish-time">{formatTime(entry.finishedAt)}{entry.player && showBest && <small aria-hidden="true">{fillTemplate(content.reviewBestTime, { time: formatTime(review.best) })}</small>}</span>
|
||||
</li>;
|
||||
})}</ol>;
|
||||
}
|
||||
|
||||
// Remplit un texte dont les valeurs peuvent être des éléments (nom de zone en couleur, nombre en gras).
|
||||
function fillParts(template, values) {
|
||||
return template.split(/(\{\w+\})/).map((part, index) => {
|
||||
const key = part.match(/^\{(\w+)\}$/)?.[1];
|
||||
return key && key in values ? <span key={index}>{values[key]}</span> : part;
|
||||
});
|
||||
}
|
||||
|
||||
// Nom d'une zone, à sa couleur et avec son icône.
|
||||
function ZoneName({ stat, statLabels }) {
|
||||
return <span className="nebula-race-zone-name" style={{ "--specialty": `var(--color-stat-${stat})` }}><MaskIcon name={stat} />{statLabels[stat]}</span>;
|
||||
}
|
||||
|
||||
function RaceReview({ catalog, race, review, content, teamContent, statLabels }) {
|
||||
const gain = review.mine - review.best;
|
||||
const perfect = gain <= NEAR_BEST_MS;
|
||||
// Pas de phrase à part : ce que les temps ne disent pas d'eux-mêmes (écart, place possible, élans presque parfaits) tient sous
|
||||
// le temps des meilleurs élans.
|
||||
const bestNote = perfect
|
||||
? (race.place === 1 ? content.reviewBestPerfect : content.reviewBestPerfectBeaten)
|
||||
: fillTemplate(review.bestPlace < race.place ? content.reviewBestGainPlace : content.reviewBestGain, { gain: formatTime(gain), place: ordinal(review.bestPlace) });
|
||||
const tiles = [
|
||||
{ key: "plain", label: content.reviewPlain, time: review.plain },
|
||||
{ key: "mine", label: content.reviewMine, time: review.mine, note: fillTemplate(content.reviewBoostsGain, { gain: formatTime(review.plain - review.mine) }) },
|
||||
{ key: "best", label: content.reviewBest, time: review.best, note: bestNote, perfect }
|
||||
];
|
||||
const name = (cardId) => nameOf(catalog, cardId, teamContent);
|
||||
const missed = review.boosts.filter((boost) => !boost.stat || boost.value < boost.bestValue);
|
||||
return <section className="nds-panel nebula-race-review" aria-labelledby="nebula-race-review-title">
|
||||
<h3 id="nebula-race-review-title">{content.reviewTitle}</h3>
|
||||
<ol className="nebula-race-review-times">{tiles.map((tile) => <li key={tile.key} data-kind={tile.key} data-perfect={tile.perfect || undefined}>
|
||||
<span>{tile.label}</span><strong>{formatTime(tile.time)}</strong>{tile.note && <small>{tile.note}</small>}
|
||||
</li>)}</ol>
|
||||
{/* Le choix du coureur vient avant les élans : la remarque passe avant le circuit. */}
|
||||
{review.fasterRunner && <p className="nebula-race-review-runner"><img src={imageOf(catalog, review.fasterRunner)} alt="" />
|
||||
<span>{fillParts(content.reviewRunner, { card: <strong>{name(review.fasterRunner)}</strong>, runner: <strong>{name(race.runner.cardId)}</strong> })}</span></p>}
|
||||
|
||||
<h4>{content.reviewBoostsTitle}</h4>
|
||||
<ol className="nebula-race-review-road" aria-label={content.reviewRoadLabel}>{race.zones.map((stat, zone) => {
|
||||
const here = review.boosts.filter((boost) => boost.zone === zone);
|
||||
return <li key={zone} style={{ "--specialty": `var(--color-stat-${stat})` }}>
|
||||
<span className="nebula-race-review-zone"><MaskIcon name={stat} /><span>{statLabels[stat]}</span></span>
|
||||
<span className="nebula-race-review-given">{here.map((boost) => {
|
||||
const missed = boost.value < boost.bestValue;
|
||||
// Élan qui valait plus ailleurs : bordure en pointillés à la couleur de la meilleure stat de l'équipier, pas de la zone.
|
||||
return <span key={boost.cardId} data-missed={missed || undefined} style={missed ? { "--better": `var(--color-stat-${boost.bestStat})` } : undefined}>
|
||||
<img src={imageOf(catalog, boost.cardId)} alt={name(boost.cardId)} title={missed ? fillTemplate(content.reviewBetterBadge, { value: `+${boost.bestValue}`, stat: statLabels[boost.bestStat] }) : name(boost.cardId)} />
|
||||
<b>+{boost.value}</b>
|
||||
</span>;
|
||||
})}</span>
|
||||
</li>;
|
||||
})}</ol>
|
||||
{/* Le circuit montre déjà chaque élan : on ne détaille que ceux qui valaient plus ailleurs, ou qui n'ont pas été donnés. */}
|
||||
{missed.length > 0 && <>
|
||||
<h4>{content.reviewNotesTitle}</h4>
|
||||
<ul className="nebula-race-review-notes">{missed.map((boost) => <li key={boost.cardId}>
|
||||
<img src={imageOf(catalog, boost.cardId)} alt="" style={{ "--better": `var(--color-stat-${boost.bestStat})` }} />
|
||||
<p>{boost.stat
|
||||
? fillParts(content.reviewNoteGiven, { card: <strong>{name(boost.cardId)}</strong>, zone: <ZoneName stat={boost.stat} statLabels={statLabels} />, value: <b>+{boost.value}</b> })
|
||||
: fillParts(content.reviewNoteMissing, { card: <strong>{name(boost.cardId)}</strong> })}
|
||||
{" "}{fillParts(content.reviewNoteBetter, { zone: <ZoneName stat={boost.bestStat} statLabels={statLabels} />, value: <b>+{boost.bestValue}</b> })}</p>
|
||||
</li>)}</ul>
|
||||
</>}
|
||||
</section>;
|
||||
}
|
||||
|
||||
export function RaceResult({ catalog, race, nextAt, content, teamContent, statLabels, titleRef }) {
|
||||
const [now] = useState(() => Date.now());
|
||||
const review = useMemo(() => raceReview(race), [race]);
|
||||
const showBest = review.mine - review.best > NEAR_BEST_MS;
|
||||
return <div className="nebula-race-outcome">
|
||||
<section className="nds-panel nebula-race-result" aria-labelledby="nebula-race-result-title" data-place={race.place}>
|
||||
<div className="nebula-race-result-head">
|
||||
<span className="nebula-race-medal" aria-hidden="true">{race.place}<small>{race.place === 1 ? "re" : "e"}</small></span>
|
||||
<div>
|
||||
<h3 id="nebula-race-result-title" ref={titleRef} tabIndex={-1}>{placeText(race.place, content)}</h3>
|
||||
<p className="nebula-race-reward">{race.reward > 0 ? <><CurrencyIcon kind="stardust" />{fillTemplate(content.earned, { reward: formatStardust(race.reward) })}</> : content.noReward}</p>
|
||||
</div>
|
||||
</div>
|
||||
<RaceFinish catalog={catalog} race={race} review={review} showBest={showBest} content={content} teamContent={teamContent} />
|
||||
<p className="nebula-race-next">{fillTemplate(content.next, { time: formatCountdown(nextAt - now) })}</p>
|
||||
</section>
|
||||
<RaceReview catalog={catalog} race={race} review={review} content={content} teamContent={teamContent} statLabels={statLabels} />
|
||||
</div>;
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ function RaceToday({ race }) {
|
|||
: <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>
|
||||
<div><dt>Adversaires</dt><dd>{opponents ? `${number(race.opponents.players)} équipe${race.opponents.players > 1 ? "s" : ""} de joueurs (dont ${number(race.opponents.ghosts)} avec leur vraie course) · ${number(race.opponents.watchers)} des Veilleurs` : "Aucune course lancée."}</dd></div>
|
||||
</dl>
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ export function recruitTeam(day) {
|
|||
}
|
||||
|
||||
// Serveur de développement seulement.
|
||||
export function resetRace() {
|
||||
return request("/team/race/reset", { method: "POST" });
|
||||
}
|
||||
|
||||
export function resetTeam() {
|
||||
return request("/team/reset", { method: "POST" });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// Rôle : fait avancer une course à l'écran avec les règles du serveur (coureur du joueur, adversaires et leurs élans).
|
||||
import { applyBoost, canBoost, startRun, STEP_MS, stepRun, zoneAt } from "../../../../services/cards/race-rules.js";
|
||||
// Rôle : fait avancer une course à l'écran avec les règles du serveur (coureur du joueur, adversaires et leurs élans), et en fait
|
||||
// le bilan une fois finie.
|
||||
import { applyBoost, autoRun, bestBoosts, canBoost, placeOf, RACE_STATS, replayRun, startRun, STEP_MS, stepRun, zoneAt } from "../../../../services/cards/race-rules.js";
|
||||
|
||||
const entrant = ({ runner, helpers }) => ({ runner: runner.stats, helpers: helpers.map((helper) => helper.stats) });
|
||||
|
||||
|
|
@ -59,6 +60,47 @@ export function raceRanking(race) {
|
|||
.map((entry, index) => ({ ...entry, index })).sort((left, right) => left.finishedAt - right.finishedAt || left.index - right.index);
|
||||
}
|
||||
|
||||
// Bilan d'une course finie, pour apprendre sans être guidé pendant la course : temps sans élan, avec ceux du joueur et avec les
|
||||
// meilleurs trouvés (et la place qu'ils auraient donnée) ; pour chaque équipier, la zone de son élan et sa meilleure stat ; un
|
||||
// coureur nettement plus rapide dans l'équipe, s'il n'a pas couru.
|
||||
const CLEARLY_FASTER_MS = 300;
|
||||
|
||||
export function raceReview(race) {
|
||||
const runner = race.runner.stats;
|
||||
const helpers = race.helpers.map((helper) => helper.stats);
|
||||
const others = race.opponents.map((opponent) => opponent.finishedAt);
|
||||
const replay = (boosts) => replayRun({ runner, helpers, boosts }, race.zones).finishedAt;
|
||||
const mine = replay(race.boosts);
|
||||
const best = Math.min(mine, replay(bestBoosts({ runner, helpers }, race.zones)));
|
||||
// Zone de chaque élan donné, en rejouant la course.
|
||||
const given = new Map();
|
||||
const queue = [...race.boosts].sort((left, right) => left.at - right.at);
|
||||
let run = startRun();
|
||||
while (run.finishedAt === null) {
|
||||
while (queue.length && queue[0].at <= run.time) {
|
||||
const { helper } = queue.shift();
|
||||
const next = applyBoost(run, helpers, race.zones, helper);
|
||||
if (next !== run) given.set(helper, zoneAt(run.position));
|
||||
run = next;
|
||||
}
|
||||
run = stepRun(run, runner, race.zones);
|
||||
}
|
||||
// Chaque compagnon comme coureur, avec des élans bien joués ; un autre n'est signalé que s'il gagne nettement.
|
||||
const team = [runner, ...helpers];
|
||||
const times = team.map((stats, index) => autoRun({ runner: stats, helpers: team.filter((_, other) => other !== index) }, race.zones, "skilled", () => 0).finishedAt);
|
||||
const fastest = times.reduce((best, time, index) => (time < times[best] ? index : best), 0);
|
||||
return {
|
||||
plain: replay([]), mine, best, bestPlace: placeOf(best, others),
|
||||
boosts: race.helpers.map((helper, index) => {
|
||||
const bestStat = RACE_STATS.reduce((top, stat) => (helper.stats[stat] > helper.stats[top] ? stat : top), RACE_STATS[0]);
|
||||
const zone = given.get(index) ?? null;
|
||||
const stat = zone === null ? null : race.zones[zone];
|
||||
return { cardId: helper.cardId, zone, stat, value: stat ? helper.stats[stat] : 0, bestStat, bestValue: helper.stats[bestStat] };
|
||||
}),
|
||||
fasterRunner: times[0] - times[fastest] > CLEARLY_FASTER_MS ? race.helpers[fastest - 1].cardId : null
|
||||
};
|
||||
}
|
||||
|
||||
// Nom d'un adversaire : son pseudo, une Équipe des Veilleurs ou un compte supprimé depuis.
|
||||
export function racerName(entry, content) {
|
||||
return entry.name || (entry.watchers ? content.watchers : content.deletedPlayer);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,15 @@
|
|||
.nebula-race-mate:focus-visible { outline: 2px solid var(--color-text-primary); outline-offset: 2px; }
|
||||
.nebula-race-mate:hover:not([aria-disabled]) { box-shadow: 0 0 0 2px var(--color-text-primary); }
|
||||
.nebula-race-mate[aria-disabled] { cursor: default; }
|
||||
.nebula-race-mate[data-active] { box-shadow: 0 0 0 3px var(--color-text-primary), 0 0 18px rgba(255, 255, 255, 0.55); }
|
||||
// Élan en cours : l'équipier est déjà « dépensé » (grisé), avec son étiquette et le temps qui reste ; les autres attendent.
|
||||
.nebula-race-mate[data-active] { box-shadow: 0 0 0 3px var(--color-text-primary); }
|
||||
.nebula-race-mate[data-active] .nebula-race-mate-art img { filter: grayscale(1) brightness(0.5); }
|
||||
.nebula-race-mate[data-active] strong { color: var(--color-text-primary); }
|
||||
.nebula-race-mate-boost { position: absolute; inset: auto 0 0; display: grid; gap: 4px; padding: var(--space-1) var(--space-2) 0; background: rgba(7, 9, 19, 0.8); color: var(--color-text-primary); font-size: var(--font-size-xs); font-weight: 800; }
|
||||
.nebula-race-mate-boost i { display: block; height: 4px; background: var(--color-text-primary); transform-origin: left; animation: nebula-race-boost-left var(--boost-ms) linear forwards; }
|
||||
@keyframes nebula-race-boost-left { to { transform: scaleX(0); } }
|
||||
@media (prefers-reduced-motion: reduce) { .nebula-race-mate-boost i { animation: none; } }
|
||||
.nebula-race-helpers[data-boosting] .nebula-race-mate:not([data-active], [data-used]) { opacity: 0.55; }
|
||||
.nebula-race-mate[data-used] { filter: grayscale(1) brightness(0.45); }
|
||||
.nebula-race-mate-art { position: relative; display: block; flex: none; overflow: hidden; background: var(--color-bg-deep); aspect-ratio: 1.5; }
|
||||
.nebula-race-mate-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; }
|
||||
|
|
@ -76,20 +84,98 @@
|
|||
.nebula-race-help { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-race-arrived { font-size: var(--font-size-lg); font-weight: 700; }
|
||||
|
||||
.nds-panel.nebula-race-result, .nds-panel.nebula-race-interrupted { display: grid; gap: var(--space-3); justify-items: start; padding: var(--space-5); }
|
||||
.nebula-race-result[data-place="1"] h3 { color: var(--color-success); }
|
||||
.nds-panel.nebula-race-interrupted { display: grid; gap: var(--space-3); justify-items: start; padding: var(--space-5); }
|
||||
|
||||
// Résultat : la place en médaille et la récompense, puis l'arrivée en couloirs. Le bilan suit dans son propre panneau.
|
||||
.nebula-race-outcome { display: grid; gap: var(--space-4); min-width: 0; }
|
||||
.nebula-race-outcome :is(h4, h5) { margin: 0; }
|
||||
.nds-panel.nebula-race-result { display: grid; gap: var(--space-4); padding: var(--space-5); border-color: rgba(246, 196, 83, 0.4); }
|
||||
.nebula-race-result-head { display: flex; align-items: center; gap: var(--space-4); }
|
||||
.nebula-race-result-head > div { display: grid; gap: var(--space-1); }
|
||||
.nebula-race-result h3 { font-size: var(--font-size-2xl); }
|
||||
.nebula-race-reward { color: var(--color-accent-gold); font-weight: 700; }
|
||||
.nebula-race-ranking { display: grid; gap: var(--space-2); width: 100%; }
|
||||
.nebula-race-ranking li { display: grid; grid-template-columns: 28px 44px minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
|
||||
.nebula-race-ranking li[data-player] { border-color: var(--color-text-primary); background: var(--color-bg-elevated); }
|
||||
.nebula-race-ranking li > span:first-child { font-size: var(--font-size-lg); font-weight: 800; text-align: center; }
|
||||
.nebula-race-ranking img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
|
||||
.nebula-race-ranking li > span:nth-of-type(2) { display: grid; min-width: 0; }
|
||||
.nebula-race-ranking small { overflow: hidden; color: var(--color-text-muted); text-overflow: ellipsis; white-space: nowrap; }
|
||||
.nebula-race-ranking li > span:last-child { font-variant-numeric: tabular-nums; }
|
||||
.nebula-race-result[data-place="1"] h3 { color: var(--color-accent-gold); }
|
||||
.nebula-race-medal {
|
||||
--medal: var(--color-text-muted);
|
||||
display: grid; flex: none; grid-auto-flow: column; align-items: baseline; justify-content: center; width: 72px; height: 72px; padding-top: 16px; border: 3px solid var(--medal); border-radius: 50%;
|
||||
background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--medal) 45%, transparent), color-mix(in srgb, var(--medal) 12%, var(--color-bg-deep)) 70%);
|
||||
color: var(--color-text-primary); font-size: 2rem; font-weight: 800; line-height: 1;
|
||||
box-shadow: 0 0 22px color-mix(in srgb, var(--medal) 35%, transparent);
|
||||
}
|
||||
.nebula-race-medal small { font-size: var(--font-size-sm); font-weight: 700; }
|
||||
.nebula-race-result[data-place="1"] .nebula-race-medal { --medal: var(--color-accent-gold); }
|
||||
.nebula-race-result[data-place="2"] .nebula-race-medal { --medal: #c9d1e3; }
|
||||
.nebula-race-result[data-place="3"] .nebula-race-medal { --medal: #d08a52; }
|
||||
.nebula-race-reward { display: flex; align-items: center; color: var(--color-accent-gold); font-weight: 700; }
|
||||
.nebula-race-next { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
|
||||
// Arrivée : un couloir par coureur, du premier au dernier, comme pendant la course. Chacun est placé selon son temps, le plus
|
||||
// rapide contre la ligne d'arrivée en damier ; la silhouette dorée du joueur montre les meilleurs élans.
|
||||
.nebula-race-finish { display: grid; overflow: hidden; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-bg-deep); }
|
||||
.nebula-race-finish li { --marker: 36px; display: grid; grid-template-areas: "place who track time"; grid-template-columns: 32px minmax(150px, 220px) minmax(0, 1fr) 84px; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-3); }
|
||||
.nebula-race-finish li + li { border-top: 1px solid var(--color-border); }
|
||||
.nebula-race-finish li[data-player] { background: var(--color-bg-elevated); box-shadow: inset 4px 0 0 var(--color-text-primary); }
|
||||
.nebula-race-finish-place { grid-area: place; font-size: var(--font-size-lg); font-weight: 800; text-align: center; }
|
||||
.nebula-race-finish li:first-child .nebula-race-finish-place { color: var(--color-accent-gold); }
|
||||
.nebula-race-finish-who { display: flex; grid-area: who; align-items: center; gap: var(--space-2); min-width: 0; }
|
||||
.nebula-race-finish-who img { flex: none; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
|
||||
.nebula-race-finish-who > span { display: grid; min-width: 0; }
|
||||
.nebula-race-finish-who :is(strong, small) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.nebula-race-finish-who small { color: var(--color-text-muted); font-size: var(--font-size-xs); }
|
||||
.nebula-race-finish-track {
|
||||
--span: calc(100% - var(--marker) - 12px);
|
||||
position: relative; grid-area: track; height: 44px; border-radius: var(--radius-md);
|
||||
background: repeating-conic-gradient(rgba(245, 247, 255, 0.3) 0 25%, transparent 0 50%) right / 12px 8px no-repeat, linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05)), rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
.nebula-race-finish-track::before { position: absolute; top: 50%; right: 12px; left: 0; border-top: 1px dashed rgba(255, 255, 255, 0.12); content: ""; }
|
||||
.nebula-race-finish-track img { position: absolute; top: 4px; left: calc(var(--span) * var(--at)); width: var(--marker); height: var(--marker); border-radius: 50%; object-fit: cover; }
|
||||
.nebula-race-finish-runner { border: 3px solid var(--color-text-muted); }
|
||||
li[data-player] .nebula-race-finish-runner { border-color: var(--color-text-primary); }
|
||||
.nebula-race-finish-ghost { border: 2px dashed var(--color-accent-gold); opacity: 0.5; filter: sepia(0.6); }
|
||||
.nebula-race-finish-gap { position: absolute; top: 50%; left: calc(var(--span) * var(--from) + var(--marker) / 2); width: calc(var(--span) * (var(--to) - var(--from))); border-top: 2px dashed var(--color-accent-gold); }
|
||||
.nebula-race-finish-time { display: grid; grid-area: time; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
|
||||
.nebula-race-finish-time small { color: var(--color-accent-gold); font-size: var(--font-size-xs); font-weight: 600; white-space: normal; }
|
||||
|
||||
// Bilan : les trois temps, les élans posés sur le circuit, puis chaque équipier.
|
||||
.nds-panel.nebula-race-review { display: grid; gap: var(--space-4); padding: var(--space-5); }
|
||||
.nebula-race-review h4 { color: var(--color-text-secondary); font-size: var(--font-size-sm); letter-spacing: 0.04em; text-transform: uppercase; }
|
||||
.nebula-race-review-times { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
|
||||
.nebula-race-review-times li { position: relative; display: grid; gap: 2px; align-content: start; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg-deep); }
|
||||
// Une flèche relie chaque temps au suivant.
|
||||
.nebula-race-review-times li + li::before { position: absolute; top: 50%; left: calc(-1 * var(--space-4)); width: var(--space-4); color: var(--color-text-muted); content: "→"; text-align: center; transform: translateY(-50%); }
|
||||
.nebula-race-review-times span { color: var(--color-text-muted); font-size: var(--font-size-sm); }
|
||||
.nebula-race-review-times strong { font-size: var(--font-size-xl); font-variant-numeric: tabular-nums; }
|
||||
.nebula-race-review-times small { font-size: var(--font-size-xs); font-weight: 700; }
|
||||
.nebula-race-review-times li[data-kind="plain"] strong { color: var(--color-text-secondary); }
|
||||
.nebula-race-review-times li[data-kind="mine"] { border-color: var(--color-text-primary); }
|
||||
.nebula-race-review-times li[data-kind="mine"] small { color: var(--color-success); }
|
||||
.nebula-race-review-times li[data-kind="best"] { border: 1px dashed var(--color-accent-gold); }
|
||||
.nebula-race-review-times li[data-kind="best"] :is(strong, small) { color: var(--color-accent-gold); }
|
||||
.nebula-race-review-times li[data-perfect] { border-color: var(--color-success); }
|
||||
.nebula-race-review-times li[data-perfect] :is(strong, small) { color: var(--color-success); }
|
||||
|
||||
// Circuit : les huit zones, et dans chacune les équipiers qui y ont donné leur élan.
|
||||
.nebula-race-review-road { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; }
|
||||
.nebula-race-review-road li { display: grid; grid-template-rows: auto 1fr; min-width: 0; overflow: hidden; border-radius: var(--radius-md); background: color-mix(in srgb, var(--specialty) 10%, var(--color-bg-deep)); }
|
||||
.nebula-race-review-zone { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: var(--space-2) 4px; background: color-mix(in srgb, var(--specialty) 30%, var(--color-bg-deep)); color: var(--specialty); font-size: var(--font-size-xs); font-weight: 700; }
|
||||
.nebula-race-review-zone > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.nebula-race-review-given { display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: var(--space-2); min-height: 72px; padding: var(--space-2) 4px; }
|
||||
.nebula-race-review-given > span { display: grid; justify-items: center; gap: 2px; }
|
||||
.nebula-race-review-given img { width: 40px; height: 40px; border: 2px solid var(--specialty); border-radius: 50%; object-fit: cover; }
|
||||
.nebula-race-review-given b { color: var(--specialty); font-size: var(--font-size-sm); }
|
||||
.nebula-race-review-given [data-missed] img { border: 2px dashed var(--better); }
|
||||
|
||||
// Sous le circuit, une phrase par équipier dont l'élan valait plus ailleurs (ou n'a pas été donné) : où il aurait mieux servi.
|
||||
.nebula-race-review-notes { display: grid; gap: var(--space-2); }
|
||||
.nebula-race-review-notes li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--space-3); align-items: center; }
|
||||
.nebula-race-review-notes p { color: var(--color-text-secondary); font-size: var(--font-size-sm); line-height: 1.5; }
|
||||
.nebula-race-review-notes :is(strong, b) { color: var(--color-text-primary); }
|
||||
.nebula-race-review-notes img { flex: none; width: 32px; height: 32px; border: 2px dashed var(--better); border-radius: 50%; object-fit: cover; }
|
||||
.nebula-race-zone-name { display: inline-flex; align-items: center; gap: 3px; color: var(--specialty); font-weight: 700; white-space: nowrap; vertical-align: bottom; }
|
||||
.nebula-race-zone-name .nebula-mask-icon { width: 15px; height: 15px; }
|
||||
.nebula-race-review-runner { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); border: 1px dashed var(--color-border); border-radius: var(--radius-md); color: var(--color-text-secondary); line-height: 1.5; }
|
||||
.nebula-race-review-runner img { flex: none; width: 64px; height: 64px; border: 2px solid var(--color-accent-gold); border-radius: var(--radius-md); object-fit: cover; object-position: 50% 35%; box-shadow: 0 0 14px rgba(246, 196, 83, 0.25); }
|
||||
.nebula-race-review-runner strong { color: var(--color-text-primary); }
|
||||
|
||||
@container nebula-race (max-width: 760px) {
|
||||
.nebula-race .nebula-team-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||||
.nebula-race-circuit-road { grid-template-columns: minmax(0, 1fr); }
|
||||
|
|
@ -103,6 +189,25 @@
|
|||
.nebula-race-mate .nebula-team-band > span { font-size: var(--font-size-xs); }
|
||||
}
|
||||
|
||||
// Les zones du bilan ne gardent que leur icône : le nom reste lu par les lecteurs d'écran.
|
||||
@container nebula-race (max-width: 900px) {
|
||||
.nebula-race-review-zone > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
||||
.nebula-race-review-zone .nebula-mask-icon { width: 18px; height: 18px; }
|
||||
}
|
||||
|
||||
@container nebula-race (max-width: 640px) {
|
||||
.nebula-race-finish li { grid-template-areas: "place who time" "track track track"; grid-template-columns: 28px minmax(0, 1fr) auto; row-gap: var(--space-1); }
|
||||
.nebula-race-review-times { gap: var(--space-2); }
|
||||
.nebula-race-review-times li { padding: var(--space-2) var(--space-3); }
|
||||
.nebula-race-review-times li + li::before { content: none; }
|
||||
.nebula-race-review-times strong { font-size: var(--font-size-lg); }
|
||||
.nebula-race-review-given img { width: 30px; height: 30px; }
|
||||
}
|
||||
|
||||
@container nebula-race (max-width: 440px) {
|
||||
.nebula-race-review-times { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
|
||||
@container nebula-race (max-width: 520px) {
|
||||
.nebula-race-zones li span { display: none; }
|
||||
.nebula-race-helpers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue