Let players who join a group set up their card and say when they are ready
Joining a group froze the card's stats at once and locked its equipment, so a joining player could not equip anything. Joining now uses the same card frame as the preparation: card, equipment and "Améliorer la carte". Everything stays editable after joining, and the group counts the card as it is, until the player clicks "Prêt". That freezes the card's stats. "Modifier ma préparation" reopens it. The creator sees each member as "Prêt" or "En préparation", with a ready count, and can still leave at any time. A player who is not ready leaves with their card as it is at departure. A migration marks existing members as ready, since their stats were already frozen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dac0bdd6a7
commit
c73a118ffb
16 changed files with 272 additions and 50 deletions
|
|
@ -1,27 +1,56 @@
|
|||
// Rôle : présente une expédition en préparation sur le tableau de la Guilde : membres, places libres, résultat attendu si elle partait
|
||||
// maintenant (seule ou en groupe), et l'inscription d'une carte.
|
||||
// Rôle : présente une expédition en préparation sur le tableau de la Guilde : membres (prêts ou en préparation), places libres,
|
||||
// résultat attendu si elle partait maintenant (seule ou en groupe), et la carte du joueur qui rejoint : choisie et équipée comme
|
||||
// dans la préparation, jusqu'à « Prêt ».
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { conditionText, dangerText, editionEntry, formatDecimal, formatEclats, helpScore, synergyBadges, tagLabel } from "./expeditionFormat.js";
|
||||
import { ExpeditionCardTile } from "./ExpeditionCardTile.jsx";
|
||||
import { conditionText, dangerText, editionEntry, formatDecimal, formatEclats, synergyBadges, tagLabel } from "./expeditionFormat.js";
|
||||
import { DestinationArt, MainStatMark, MaskIcon } from "./ExpeditionLabels.jsx";
|
||||
import { ExpeditionLoadout } from "./ExpeditionLoadout.jsx";
|
||||
import { BonusBadges, PowerName, TierTile } from "./ExpeditionOutcome.jsx";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
|
||||
// Carte du joueur pour ce groupe, dans le même cadre que la préparation : emplacement de la carte (la liste des cartes jouables
|
||||
// s'ouvre d'un clic), stats et équipements, « Améliorer la carte ». Les exigences du groupe sont dans son rappel : la carte seule
|
||||
// n'est pas comparée à celles de toute l'équipe.
|
||||
function MemberLoadout({ catalog, state, view, group, card, help, content, busy, runMutation, onChooseCard, children }) {
|
||||
const destination = { ...group.destination, requirements: [], condition: group.condition, dangers: group.dangers };
|
||||
return <section className="nebula-expedition-join" aria-labelledby={`nebula-group-loadout-${group.id}`}>
|
||||
<h5 id={`nebula-group-loadout-${group.id}`}>{content.ownLoadoutTitle}</h5>
|
||||
<p className="nebula-form-help">{help}</p>
|
||||
<ExpeditionLoadout catalog={catalog} state={state} view={view} destination={destination} card={card} onChooseCard={onChooseCard} content={content} busy={busy} runMutation={runMutation} />
|
||||
<div className="nds-toolbar">{children}</div>
|
||||
</section>;
|
||||
}
|
||||
|
||||
// Inscription : une carte jouable non occupée ; celles utiles à la destination d'abord (condition, dangers), puis les plus puissantes.
|
||||
function JoinForm({ catalog, group, cards, content, busy, onJoin, onCancel }) {
|
||||
// Inscription : la carte se choisit et s'équipe avant de rejoindre ; tout reste modifiable ensuite, jusqu'à « Prêt ».
|
||||
function JoinForm({ catalog, state, view, group, content, busy, runMutation, onJoin, onCancel }) {
|
||||
const [editionId, setEditionId] = useState(null);
|
||||
const available = [...cards].filter((card) => !card.busy).sort((a, b) => helpScore(b, group) - helpScore(a, group) || b.power - a.power);
|
||||
return <div className="nebula-expedition-join">
|
||||
{available.length ? <ul className="nebula-expedition-cards" aria-label={content.cardsLabel}>{available.map((card) => <ExpeditionCardTile key={card.editionId} catalog={catalog} card={card}
|
||||
destination={group} content={content} selected={card.editionId === editionId} onSelect={() => setEditionId(card.editionId)} />)}</ul>
|
||||
: <p className="nds-inline-notice" data-variant="info">{content.noCards}</p>}
|
||||
<div className="nds-toolbar">
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || !editionId} onClick={() => onJoin(group.id, { editionId })}>{content.joinConfirm}</button>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" onClick={onCancel}>{content.cancel}</button>
|
||||
</div>
|
||||
</div>;
|
||||
const card = view.cards.find((item) => item.editionId === editionId && !item.busy) || null;
|
||||
return <MemberLoadout catalog={catalog} state={state} view={view} group={group} card={card} help={content.joinHelp} content={content} busy={busy} runMutation={runMutation} onChooseCard={setEditionId}>
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || !card} onClick={() => onJoin(group.id, { editionId })}>{content.joinConfirm}</button>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" onClick={onCancel}>{content.cancel}</button>
|
||||
</MemberLoadout>;
|
||||
}
|
||||
|
||||
// Joueur inscrit (pas le créateur) : tant qu'il n'est pas prêt, il change de carte ou d'équipement, et le groupe compte aussitôt sa
|
||||
// carte telle qu'elle est ; « Prêt » la fige et le signale au créateur, « Modifier ma préparation » la rouvre.
|
||||
function OwnSlot({ catalog, state, view, group, content, busy, runMutation, onMember }) {
|
||||
const { editionId, ready } = group.ownSlot;
|
||||
const card = view.cards.find((item) => item.editionId === editionId) || null;
|
||||
if (ready) {
|
||||
const entry = editionEntry(catalog, editionId);
|
||||
return <section className="nebula-expedition-join nebula-expedition-ready" aria-labelledby={`nebula-group-loadout-${group.id}`}>
|
||||
<h5 id={`nebula-group-loadout-${group.id}`}>{content.ownLoadoutTitle}</h5>
|
||||
<p className="nds-inline-notice" data-variant="success">{fillTemplate(content.readyText, { card: entry?.card.name || "" })}</p>
|
||||
<div className="nds-toolbar">
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => onMember(group.id, { ready: false }, content.unreadyNotice)}>{content.unready}</button>
|
||||
</div>
|
||||
</section>;
|
||||
}
|
||||
return <MemberLoadout catalog={catalog} state={state} view={view} group={group} card={card} help={content.ownLoadoutHelp} content={content} busy={busy} runMutation={runMutation}
|
||||
onChooseCard={(id) => onMember(group.id, { editionId: id }, null)}>
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || !card} onClick={() => onMember(group.id, { ready: true }, content.readyNotice)}>{content.ready}</button>
|
||||
</MemberLoadout>;
|
||||
}
|
||||
|
||||
function Thumb({ ok, label }) {
|
||||
|
|
@ -98,7 +127,7 @@ function InviteLink({ groupId, content }) {
|
|||
}
|
||||
|
||||
// `invited` : le joueur arrive par le lien d'invitation de cette expédition : elle est mise en vue, son inscription dépliée.
|
||||
export function ExpeditionGroupCard({ catalog, group, cards, content, now, busy, limitReached, onJoin, onLeave, onDepart, onTestPlayer = null, invited = false }) {
|
||||
export function ExpeditionGroupCard({ catalog, state, view, group, content, now, busy, limitReached, runMutation, onJoin, onMember, onLeave, onDepart, onTestPlayer = null, invited = false }) {
|
||||
const [joining, setJoining] = useState(invited && group.canJoin && !limitReached);
|
||||
const articleRef = useRef(null);
|
||||
useEffect(() => { if (invited) articleRef.current?.scrollIntoView({ block: "center" }); }, [invited]);
|
||||
|
|
@ -115,10 +144,12 @@ export function ExpeditionGroupCard({ catalog, group, cards, content, now, busy,
|
|||
<ul className="nebula-expedition-group-members">
|
||||
{group.members.map((member) => {
|
||||
const entry = editionEntry(catalog, member.editionId);
|
||||
return <li key={member.position}>{entry && <NebulaCard catalog={catalog} entry={entry} size="sm" />}<strong>{member.own ? content.you : member.playerName}</strong></li>;
|
||||
return <li key={member.position}>{entry && <NebulaCard catalog={catalog} entry={entry} size="sm" />}<strong>{member.own ? content.you : member.playerName}</strong>
|
||||
<span className="nds-badge" data-variant={member.ready ? "success" : "warning"}>{member.ready ? content.memberReady : content.memberPreparing}</span></li>;
|
||||
})}
|
||||
{Array.from({ length: group.freeSlots }, (_, index) => <li key={`free-${index}`}><span className="nebula-expedition-group-free">{content.groupFreeRole}</span></li>)}
|
||||
</ul>
|
||||
{group.isCreator && group.members.length > 1 && <p className="nebula-form-help">{fillTemplate(content.readyCount, { ready: group.members.filter((member) => member.ready).length, count: group.members.length })}</p>}
|
||||
{group.freeSlots > 0 && <p className="nebula-form-help">{content.groupScaling}</p>}
|
||||
</section>
|
||||
<div className="nds-toolbar nebula-expedition-group-actions">
|
||||
|
|
@ -148,6 +179,8 @@ export function ExpeditionGroupCard({ catalog, group, cards, content, now, busy,
|
|||
{group.isMember && <InviteLink groupId={group.id} content={content} />}
|
||||
</div>
|
||||
{group.canJoin && limitReached && <p className="nebula-form-help">{content.groupLimit}</p>}
|
||||
{joining && <JoinForm catalog={catalog} group={group} cards={cards} content={content} busy={busy} onJoin={async (...args) => { if (await onJoin(...args)) setJoining(false); }} onCancel={() => setJoining(false)} />}
|
||||
{joining && !group.isMember && <JoinForm catalog={catalog} state={state} view={view} group={group} content={content} busy={busy} runMutation={runMutation}
|
||||
onJoin={async (...args) => { if (await onJoin(...args)) setJoining(false); }} onCancel={() => setJoining(false)} />}
|
||||
{group.ownSlot && <OwnSlot catalog={catalog} state={state} view={view} group={group} content={content} busy={busy} runMutation={runMutation} onMember={onMember} />}
|
||||
</article>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// suivre les autres joueurs (relecture régulière, retour sur l'onglet, échéances d'inscription et de retour).
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { Tabs } from "../../components/Tabs.jsx";
|
||||
import { addBonusDestination, addTestPlayer, claimExpedition, craftPowerCommon, recallExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, markStarterSeen, rerollDestinations, startExpedition } from "./cardsApi.js";
|
||||
import { addBonusDestination, addTestPlayer, claimExpedition, craftPowerCommon, recallExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, markStarterSeen, rerollDestinations, startExpedition, updateExpeditionMember } from "./cardsApi.js";
|
||||
import { CurrencyAmount } from "./Currency.jsx";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { ExpeditionAtelier } from "./ExpeditionAtelier.jsx";
|
||||
|
|
@ -203,6 +203,8 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
const claim = async (id) => handle(await runMutation(expeditionCall(() => claimExpedition(id))), content.claimedNotice);
|
||||
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);
|
||||
// Joueur inscrit : changement de carte (sans avis) ou « Prêt ».
|
||||
const member = async (id, body, success) => handle(await runMutation(expeditionCall(() => updateExpeditionMember(id, body))), success);
|
||||
// Serveur Vite local : un joueur de test rejoint une expédition ouverte au groupe.
|
||||
const testPlayer = view.testPlayers ? async (id) => handle(await runMutation(expeditionCall(() => addTestPlayer(id))), content.testPlayerAdded) : null;
|
||||
const bonus = async (item) => handle(await runMutation(expeditionCall(() => addBonusDestination(item))), content.bonusAdded);
|
||||
|
|
@ -245,13 +247,15 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
: <ExpeditionReturn key={expedition.id} catalog={catalog} expedition={expedition} content={content} busy={busy} onClaim={claim} />))}
|
||||
{mine.length > 0 && <section className="nebula-expedition-active" aria-labelledby="nebula-expedition-mine-title">
|
||||
<h3 id="nebula-expedition-mine-title">{content.mineTitle}</h3>
|
||||
<div className="nebula-expedition-reports">{mine.map((group) => <ExpeditionGroupCard key={group.id} catalog={catalog} group={group} cards={view.cards} content={content} now={now} busy={busy} limitReached={limitReached} onJoin={join} onLeave={leave} onDepart={depart} onTestPlayer={testPlayer} />)}</div>
|
||||
<div className="nebula-expedition-reports">{mine.map((group) => <ExpeditionGroupCard key={group.id} catalog={catalog} state={state} view={view} group={group} content={content} now={now} busy={busy} limitReached={limitReached}
|
||||
runMutation={equipAndRefresh} onJoin={join} onMember={member} onLeave={leave} onDepart={depart} onTestPlayer={testPlayer} />)}</div>
|
||||
</section>}
|
||||
{!view.enabled ? <div className="nds-empty-state"><h3>{content.closedTitle}</h3><p>{content.closedText}</p></div>
|
||||
: !expired && !limitReached && <>
|
||||
{others.length > 0 && <section className="nebula-expedition-active" aria-labelledby="nebula-expedition-groups-title">
|
||||
<h3 id="nebula-expedition-groups-title">{content.groupsTitle}</h3>
|
||||
<div className="nebula-expedition-reports">{others.map((group) => <ExpeditionGroupCard key={group.id} catalog={catalog} group={group} cards={view.cards} content={content} now={now} busy={busy} limitReached={limitReached} onJoin={join} onLeave={leave} onDepart={depart} invited={group.id === joinId} />)}</div>
|
||||
<div className="nebula-expedition-reports">{others.map((group) => <ExpeditionGroupCard key={group.id} catalog={catalog} state={state} view={view} group={group} content={content} now={now} busy={busy} limitReached={limitReached}
|
||||
runMutation={equipAndRefresh} onJoin={join} onMember={member} onLeave={leave} onDepart={depart} invited={group.id === joinId} />)}</div>
|
||||
</section>}
|
||||
<div className="nebula-expedition-plan-heading">
|
||||
<h3>{content.planTitle}</h3>
|
||||
|
|
|
|||
|
|
@ -206,6 +206,11 @@ export function joinExpedition(expeditionId, { editionId, role }) {
|
|||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/join`, { method: "POST", body: JSON.stringify({ editionId, role }) });
|
||||
}
|
||||
|
||||
// Joueur inscrit à un groupe : change de carte (`editionId`) ou se dit prêt (`ready`).
|
||||
export function updateExpeditionMember(expeditionId, { editionId = null, ready = null }) {
|
||||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/member`, { method: "PUT", body: JSON.stringify({ editionId, ready }) });
|
||||
}
|
||||
|
||||
// Serveur Vite local uniquement : un joueur de test rejoint l'expédition.
|
||||
export function addTestPlayer(expeditionId) {
|
||||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/test-player`, { method: "POST" });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue