Add group Expeditions with a Guild board to Sokko TCG
- A player opens a group with one card and a chosen role; others join from the board with a free role, and the creator launches it once enough players are in. - At departure the Veilleur de la Guilde holds empty places without a role, each member rolls their own loot multiplied by the number of players, and distinct collections add a cohesion bonus. - An unlaunched group departs on its own at the end of recruitment with enough players, or dissolves and tells its members; leaving, dissolving and deleted accounts free cards or forfeit shares. - The Guild tile flags joinable groups; Administration › Guilde tunes group places, players, stars, recruitment, loot multipliers, keeper stats, cohesion and the score bonus cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8bb1d53d70
commit
6b7605d04e
24 changed files with 858 additions and 99 deletions
|
|
@ -1,7 +1,8 @@
|
|||
// 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 { claimExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, startExpedition } from "./cardsApi.js";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { ExpeditionGroupCard } from "./ExpeditionGroupCard.jsx";
|
||||
import { ExpeditionPlanner } from "./ExpeditionPlanner.jsx";
|
||||
import { ExpeditionReport } from "./ExpeditionReport.jsx";
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
|
|
@ -23,6 +24,7 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content })
|
|||
const [loadError, setLoadError] = useState("");
|
||||
const [reloadKey, setReloadKey] = useState(0);
|
||||
const [notice, setNotice] = useState(null);
|
||||
const [mode, setMode] = useState("solo");
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -53,12 +55,16 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content })
|
|||
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 start = async (body) => handle(await runMutation(expeditionCall(() => startExpedition(body))), body.mode === "group" ? content.groupOpened : content.started);
|
||||
const claim = async (id) => handle(await runMutation(expeditionCall(() => claimExpedition(id))), content.claimed);
|
||||
const join = async (id, choice) => handle(await runMutation(expeditionCall(() => joinExpedition(id, choice))), content.joined);
|
||||
const leave = async (id) => handle(await runMutation(expeditionCall(() => leaveExpedition(id))), content.left);
|
||||
const depart = async (id) => handle(await runMutation(expeditionCall(() => departExpedition(id))), content.departed);
|
||||
|
||||
const expired = view.enabled && now >= view.nextDayAt;
|
||||
const active = view.expeditions.filter((expedition) => expedition.status === "running" && !expedition.claimedAt);
|
||||
const limitReached = active.length >= view.soloLimit;
|
||||
const soloActive = view.expeditions.filter((expedition) => expedition.mode === "solo" && expedition.status === "running" && !expedition.claimedAt);
|
||||
const soloLimitReached = soloActive.length >= view.soloLimit;
|
||||
const groupLimitReached = view.group.active >= view.group.limit;
|
||||
|
||||
return <section className="nebula-expeditions" aria-labelledby="nebula-expeditions-title">
|
||||
<div className="nds-section-heading nebula-section-heading">
|
||||
|
|
@ -77,14 +83,22 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content })
|
|||
<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 || view.groups.length > 0) && <section className="nebula-expedition-active" aria-labelledby="nebula-expedition-groups-title">
|
||||
<h3 id="nebula-expedition-groups-title">{content.groupsTitle}</h3>
|
||||
{view.groups.length ? <div className="nebula-expedition-reports">{view.groups.map((group) => <ExpeditionGroupCard key={group.id} catalog={catalog} group={group} cards={view.cards} content={content} now={now} busy={busy} limitReached={groupLimitReached} minPlayers={view.group.minPlayers} onJoin={join} onLeave={leave} onDepart={depart} />)}</div>
|
||||
: <p className="nebula-form-help">{content.groupsEmpty}</p>}
|
||||
</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} />
|
||||
</>}
|
||||
: !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>
|
||||
<div role="group" aria-label={content.modeLabel} className="nds-toolbar">{[["solo", content.modeSolo], ["group", content.modeGroup]].map(([value, label]) => <button key={value} type="button" className="nds-button" data-size="sm" data-variant={value === mode ? "primary" : "secondary"} aria-pressed={value === mode} onClick={() => setMode(value)}>{label}</button>)}</div>
|
||||
{mode === "solo" && soloLimitReached ? <p className="nds-inline-notice" data-variant="info">{content.limitReached}</p>
|
||||
: mode === "group" && groupLimitReached ? <p className="nds-inline-notice" data-variant="info">{content.groupLimit}</p>
|
||||
: <ExpeditionPlanner key={`${view.day}-${mode}`} catalog={catalog} view={view} mode={mode} content={content} busy={busy} onStart={start} />}
|
||||
</>}
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue