Add solo Expeditions, the second Guilde des Veilleurs quest of Sokko TCG
- Every catalog card carries expedition tags and every collection a stat profile, validated at load; twelve destinations live server-side so hidden ones stay secret. - Pure rules compute card power, per-slot requirements, roles, dangers, the long-trip malus, the score (one more star never raises it) and loot proportional to the chosen duration. - A simulator script and a balance test guard the design thresholds; agent docs and a new-card skill explain how to tag new cards. - Migration 8 adds Éclats d'étoile, expedition settings stored as one validated JSON, daily destinations, expeditions, members and slots, and rebuilds gift_packs so a pack can come from an expedition. - Players launch a solo expedition from the Guild, see an exact preview, and claim their loot when it returns; the card sheet shows cards away on an expedition. - Administration › Guilde tunes every value with server-side bounds, toggles destinations and cancels running expeditions; expeditions stay closed until an administrator opens them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0ef213cf4f
commit
8bb1d53d70
46 changed files with 4752 additions and 213 deletions
90
website/src/features/cards/ExpeditionsPanel.jsx
Normal file
90
website/src/features/cards/ExpeditionsPanel.jsx
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
// Rôle : présente les Expéditions, quête de la Guilde : expéditions du joueur (retour, butin) et préparation d'une expédition solo.
|
||||
import { useEffect, useState } from "react";
|
||||
import { claimExpedition, loadExpeditions, startExpedition } from "./cardsApi.js";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { ExpeditionPlanner } from "./ExpeditionPlanner.jsx";
|
||||
import { ExpeditionReport } from "./ExpeditionReport.jsx";
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
|
||||
const COUNTDOWN_TICK_MS = 30_000;
|
||||
|
||||
// Les refus propres aux Expéditions restent dans ce panneau ; runMutation garde le reste (réseau, session).
|
||||
const expeditionCall = (call) => async () => {
|
||||
try {
|
||||
return await call();
|
||||
} catch (error) {
|
||||
if (String(error.code || "").startsWith("EXPEDITION")) return { expeditionError: error };
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export function ExpeditionsPanel({ catalog, state, runMutation, busy, content }) {
|
||||
const [view, setView] = useState(null);
|
||||
const [loadError, setLoadError] = useState("");
|
||||
const [reloadKey, setReloadKey] = useState(0);
|
||||
const [notice, setNotice] = useState(null);
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
loadExpeditions()
|
||||
.then((result) => { if (active) { setView(result); setLoadError(""); setNow(Date.now()); } })
|
||||
.catch((error) => { if (active) setLoadError(error.message); });
|
||||
return () => { active = false; };
|
||||
}, [reloadKey]);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => setNow(Date.now()), COUNTDOWN_TICK_MS);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
if (loadError) return <section className="nds-empty-state" role="alert"><h2>{content.title}</h2><p>{loadError}</p></section>;
|
||||
if (!view) return <section className="nds-empty-state" aria-busy="true"><h2>{content.title}</h2></section>;
|
||||
|
||||
const reload = () => { setNotice(null); setReloadKey((key) => key + 1); };
|
||||
const handle = (result, success) => {
|
||||
if (result?.expeditions) {
|
||||
setView(result.expeditions);
|
||||
setNow(Date.now());
|
||||
setNotice(success ? { variant: "success", text: success } : null);
|
||||
return true;
|
||||
}
|
||||
if (result?.expeditionError?.code === "EXPEDITION_DAY_EXPIRED") setNow(view.nextDayAt);
|
||||
else if (result?.expeditionError) setNotice({ variant: "warning", text: result.expeditionError.message });
|
||||
return false;
|
||||
};
|
||||
const start = async (body) => handle(await runMutation(expeditionCall(() => startExpedition(body))), content.started);
|
||||
const claim = async (id) => handle(await runMutation(expeditionCall(() => claimExpedition(id))), content.claimed);
|
||||
|
||||
const expired = view.enabled && now >= view.nextDayAt;
|
||||
const active = view.expeditions.filter((expedition) => expedition.status === "running" && !expedition.claimedAt);
|
||||
const limitReached = active.length >= view.soloLimit;
|
||||
|
||||
return <section className="nebula-expeditions" aria-labelledby="nebula-expeditions-title">
|
||||
<div className="nds-section-heading nebula-section-heading">
|
||||
<div><p className="eyebrow">{content.eyebrow}</p><h2 id="nebula-expeditions-title">{content.title}</h2><p className="nebula-guild-intro">{content.intro}</p></div>
|
||||
<div className="nebula-daily-heading-actions">
|
||||
<span className="nds-badge" data-variant="gold" title={content.eclatsHelp}>{fillTemplate(content.eclatsBalance, { value: formatEclats(state.wallet.eclats ?? 0) })}</span>
|
||||
<a className="nds-button" data-size="sm" data-variant="secondary" href="#/cards/guild">{content.back}</a>
|
||||
</div>
|
||||
</div>
|
||||
<p className="nebula-form-help">{content.eclatsHelp}</p>
|
||||
{notice && <p className="nds-inline-notice" data-variant={notice.variant} role="status">{notice.text}</p>}
|
||||
{expired && <div className="nds-inline-notice nebula-daily-expired" data-variant="warning" role="status"><span>{content.expired}</span><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={reload}>{content.reload}</button></div>}
|
||||
|
||||
{view.expeditions.length > 0 && <section className="nebula-expedition-active" aria-labelledby="nebula-expedition-active-title">
|
||||
<h3 id="nebula-expedition-active-title">{content.activeTitle}</h3>
|
||||
<div className="nebula-expedition-reports">{view.expeditions.map((expedition) => <ExpeditionReport key={expedition.id} catalog={catalog} expedition={expedition} content={content} now={now} busy={busy} onClaim={claim} />)}</div>
|
||||
</section>}
|
||||
|
||||
{!view.enabled ? <div className="nds-empty-state"><h3>{content.closedTitle}</h3><p>{content.closedText}</p></div>
|
||||
: limitReached ? <p className="nds-inline-notice" data-variant="info">{content.limitReached}</p>
|
||||
: !expired && <>
|
||||
<div className="nebula-expedition-plan-heading">
|
||||
<h3>{content.planTitle}</h3>
|
||||
<span className="nebula-form-help">{fillTemplate(content.nextDay, { time: formatCountdown(view.nextDayAt - now) })}</span>
|
||||
</div>
|
||||
<ExpeditionPlanner key={view.day} catalog={catalog} view={view} content={content} busy={busy} onStart={start} />
|
||||
</>}
|
||||
</section>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue