Simplify joining a Sokko TCG group and let a test player open one locally
- On the local dev server, a test player can open a group on one of its destinations, with the 20 s test trip; it departs by itself after 5 minutes, since only the creator may launch it. - While a player chooses their card to join, the expedition planner is hidden; Cancel brings it back. - Joining and readying are one button, "Valider et se mettre en prêt", at the bottom right of the loadout frame, also after "Modifier ma préparation", which now sits next to "Quitter l'expédition". - The redundant "you are ready" block is gone: the member list already shows the Ready badge. - The card a player sends is called their explorer in the texts about that role. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
82cebd0fd1
commit
8eb7f2e53e
12 changed files with 196 additions and 88 deletions
|
|
@ -44,13 +44,14 @@ function useJoinPreview(group, card) {
|
|||
// 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 ». La carte seule n'est pas comparée aux exigences de toute l'équipe :
|
||||
// `needs` les rappelle à côté face à l'apport du groupe, `pickerNeeds` dans le choix de la carte.
|
||||
function MemberLoadout({ catalog, state, view, group, card, help, needs, pickerNeeds = needs, content, busy, runMutation, onChooseCard, children }) {
|
||||
// `children` : les boutons, en bas à droite du cadre ; `notice` : un avis sous le cadre.
|
||||
function MemberLoadout({ catalog, state, view, group, card, help, needs, pickerNeeds = needs, content, busy, runMutation, onChooseCard, notice = null, 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} needs={needs} pickerNeeds={pickerNeeds} />
|
||||
<div className="nds-toolbar">{children}</div>
|
||||
<ExpeditionLoadout catalog={catalog} state={state} view={view} destination={destination} card={card} onChooseCard={onChooseCard} content={content} busy={busy} runMutation={runMutation} needs={needs} pickerNeeds={pickerNeeds} actions={children} />
|
||||
{notice}
|
||||
</section>;
|
||||
}
|
||||
|
||||
|
|
@ -60,10 +61,10 @@ function JoinForm({ catalog, state, view, group, card, outlook, content, busy, r
|
|||
const players = group.members.length + 1;
|
||||
const without = { title: fillTemplate(content.needsWithout, { players }), rows: requirementRows(group.joinRequirements || group.requirements, group.projected), missing: true };
|
||||
const needs = outlook.preview ? { title: fillTemplate(content.needsWith, { players }), rows: outlook.rows, stale: outlook.stale } : without;
|
||||
return <MemberLoadout catalog={catalog} state={state} view={view} group={group} card={card} help={content.joinHelp} needs={needs} pickerNeeds={without} content={content} busy={busy} runMutation={runMutation} onChooseCard={onChooseCard}>
|
||||
{outlook.error && <p className="nds-inline-notice" data-variant="warning" role="status">{outlook.error}</p>}
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || !card} onClick={() => onJoin(group.id, { editionId: card.editionId })}>{content.joinConfirm}</button>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" onClick={onCancel}>{content.cancel}</button>
|
||||
return <MemberLoadout catalog={catalog} state={state} view={view} group={group} card={card} help={content.joinHelp} needs={needs} pickerNeeds={without} content={content} busy={busy} runMutation={runMutation} onChooseCard={onChooseCard}
|
||||
notice={outlook.error && <p className="nds-inline-notice" data-variant="warning" role="status">{outlook.error}</p>}>
|
||||
<button className="nds-button" data-variant="secondary" type="button" onClick={onCancel}>{content.cancel}</button>
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || !card} onClick={() => onJoin(group.id, { editionId: card.editionId, ready: true })}>{content.joinConfirm}</button>
|
||||
</MemberLoadout>;
|
||||
}
|
||||
|
||||
|
|
@ -72,20 +73,12 @@ function JoinForm({ catalog, state, view, group, card, outlook, content, busy, r
|
|||
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>;
|
||||
}
|
||||
// Prêt : la liste des membres le montre déjà ; « Modifier ma préparation » est dans les actions du groupe.
|
||||
if (ready) return null;
|
||||
return <MemberLoadout catalog={catalog} state={state} view={view} group={group} card={card} help={content.ownLoadoutHelp}
|
||||
needs={{ title: fillTemplate(content.needsWith, { players: group.members.length }), rows: requirementRows(group.requirements, group.projected) }} 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>
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || !card} onClick={() => onMember(group.id, { ready: true }, content.readyNotice)}>{content.ready}</button>
|
||||
</MemberLoadout>;
|
||||
}
|
||||
|
||||
|
|
@ -160,13 +153,19 @@ 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, state, view, group, content, now, busy, limitReached, runMutation, onJoin, onMember, onLeave, onDepart, onTestPlayer = null, invited = false }) {
|
||||
// `onJoiningChange(groupId, open)` : prévient le panneau quand l'inscription se déplie ou se replie.
|
||||
export function ExpeditionGroupCard({ catalog, state, view, group, content, now, busy, limitReached, runMutation, onJoin, onMember, onLeave, onDepart, onTestPlayer = null, onJoiningChange = null, invited = false }) {
|
||||
const [joining, setJoining] = useState(invited && group.canJoin && !limitReached);
|
||||
const articleRef = useRef(null);
|
||||
useEffect(() => { if (invited) articleRef.current?.scrollIntoView({ block: "center" }); }, [invited]);
|
||||
// Inscription : la carte choisie compte déjà dans le résultat prévu et les exigences.
|
||||
const [editionId, setEditionId] = useState(null);
|
||||
const open = joining && !group.isMember;
|
||||
useEffect(() => {
|
||||
if (!open || !onJoiningChange) return undefined;
|
||||
onJoiningChange(group.id, true);
|
||||
return () => onJoiningChange(group.id, false);
|
||||
}, [open, group.id, onJoiningChange]);
|
||||
const card = (open && view.cards.find((item) => item.editionId === editionId && !item.busy)) || null;
|
||||
const { value: preview, error: previewError, stale } = useJoinPreview(group, card);
|
||||
const projected = preview?.projected || group.projected;
|
||||
|
|
@ -195,7 +194,8 @@ export function ExpeditionGroupCard({ catalog, state, view, group, content, now,
|
|||
</section>
|
||||
<div className="nds-toolbar nebula-expedition-group-actions">
|
||||
{group.canJoin && !joining && <button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || limitReached} onClick={() => setJoining(true)}>{content.join}</button>}
|
||||
{group.isCreator && <button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || !group.canDepart} onClick={() => onDepart(group.id)}>{content.depart}</button>}
|
||||
{group.canDepart && <button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy} onClick={() => onDepart(group.id)}>{content.depart}</button>}
|
||||
{group.ownSlot?.ready && <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>}
|
||||
{group.isMember && <button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => onLeave(group.id)}>{group.isCreator ? content.dissolve : content.leave}</button>}
|
||||
{onTestPlayer && group.isMember && group.freeSlots > 0 && <button className="nds-button" data-size="sm" data-variant="ghost" type="button" disabled={busy} onClick={() => onTestPlayer(group.id)}>{content.testPlayer}</button>}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ function CardPicker({ catalog, view, destination, selectedId, needs, content, on
|
|||
}
|
||||
|
||||
// `needs` et `pickerNeeds` : pour un groupe, ses exigences rappelées au-dessus des équipements et dans le choix de la carte.
|
||||
export function ExpeditionLoadout({ catalog, state, view, destination, card, onChooseCard, content, busy, runMutation, needs = null, pickerNeeds = null }) {
|
||||
// `actions` : boutons du cadre (valider, annuler…), en bas à droite.
|
||||
export function ExpeditionLoadout({ catalog, state, view, destination, card, onChooseCard, content, busy, runMutation, needs = null, pickerNeeds = null, actions = null }) {
|
||||
// Fenêtre ouverte : « card » (choix de la carte) ou le numéro de l'emplacement d'équipement.
|
||||
const [picker, setPicker] = useState(null);
|
||||
// Exigences de la destination choisie pour une carte seule : elles ne donnent que la couleur des totaux.
|
||||
|
|
@ -124,6 +125,7 @@ export function ExpeditionLoadout({ catalog, state, view, destination, card, onC
|
|||
</section>}
|
||||
</div>
|
||||
</div>
|
||||
{actions && <div className="nds-toolbar nebula-loadout-actions">{actions}</div>}
|
||||
{picker?.engrave && progress && <EngraveModal catalog={catalog} state={state} view={view} equipmentId={picker.engrave} characterId={progress.editionId} content={content} busy={busy} runMutation={runMutation} onClose={() => setPicker(null)} />}
|
||||
{picker === "sheet" && card && <CardSheet catalog={catalog} state={state} editionId={card.editionId} content={content.cardSheet} busy={busy} runMutation={runMutation} onClose={() => setPicker(null)} />}
|
||||
{picker === "card" && <CardPicker catalog={catalog} view={view} destination={destination} selectedId={card?.editionId} needs={pickerNeeds} content={content} onChoose={onChooseCard} onClose={() => setPicker(null)} />}
|
||||
|
|
|
|||
|
|
@ -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, updateExpeditionMember } from "./cardsApi.js";
|
||||
import { addBonusDestination, addTestPlayer, claimExpedition, craftPowerCommon, recallExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, markStarterSeen, openTestGroup, rerollDestinations, startExpedition, updateExpeditionMember } from "./cardsApi.js";
|
||||
import { CurrencyAmount } from "./Currency.jsx";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { ExpeditionAtelier } from "./ExpeditionAtelier.jsx";
|
||||
|
|
@ -123,6 +123,9 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
|
||||
// Demande une relecture de la vue. En cas d'échec, la vue déjà affichée reste en place avec un avis et « Réessayer ».
|
||||
const load = useCallback(() => setReloadKey((key) => key + 1), []);
|
||||
// Inscription dépliée sur une expédition du tableau : la préparation d'une expédition se cache le temps de choisir sa carte.
|
||||
const [joiningId, setJoiningId] = useState(null);
|
||||
const joiningChange = useCallback((id, open) => setJoiningId((current) => (open ? id : current === id ? null : current)), []);
|
||||
|
||||
useEffect(() => {
|
||||
const ticket = ++latest.current;
|
||||
|
|
@ -207,6 +210,8 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
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;
|
||||
// Serveur Vite local : un joueur de test ouvre une expédition, pour essayer de la rejoindre.
|
||||
const testGroup = async () => handle(await runMutation(expeditionCall(() => openTestGroup())), content.testGroupOpened);
|
||||
const bonus = async (item) => handle(await runMutation(expeditionCall(() => addBonusDestination(item))), content.bonusAdded);
|
||||
const reroll = async () => handle(await runMutation(expeditionCall(() => rerollDestinations())), content.rerolled);
|
||||
// Atelier : l'erreur s'affiche dans sa fenêtre ; à sa fermeture, la vue est relue pour le compte des plans.
|
||||
|
|
@ -238,6 +243,8 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
const mine = view.groups.filter((group) => group.isMember);
|
||||
const others = view.groups.filter((group) => !group.isMember);
|
||||
const invited = joinId && view.groups.find((group) => group.id === joinId);
|
||||
// Le joueur choisit sa carte pour rejoindre une expédition du tableau : la préparation d'une expédition est cachée.
|
||||
const choosing = Boolean(joiningId) && others.some((group) => group.id === joiningId && group.canJoin);
|
||||
// Lien direct d'une alerte : une expédition du joueur, en route ou revenue, ou déjà rangée au Journal.
|
||||
const linked = joinId && (view.expeditions.some((expedition) => expedition.id === joinId) || view.journal.some((expedition) => expedition.id === joinId));
|
||||
const journalCount = view.journal.length;
|
||||
|
|
@ -254,17 +261,20 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content, j
|
|||
</section>}
|
||||
{!view.enabled ? <div className="nds-empty-state"><h3>{content.closedTitle}</h3><p>{content.closedText}</p></div>
|
||||
: !expired && !limitReached && <>
|
||||
{view.testPlayers && <p><button className="nds-button" data-size="sm" data-variant="ghost" type="button" disabled={busy} onClick={testGroup}>{content.testGroup}</button></p>}
|
||||
{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} 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>
|
||||
runMutation={equipAndRefresh} onJoin={join} onMember={member} onLeave={leave} onDepart={depart} onJoiningChange={joiningChange} invited={group.id === joinId} />)}</div>
|
||||
</section>}
|
||||
<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>
|
||||
<ItemBag catalog={catalog} state={state} view={view} content={content} busy={busy} onBonus={bonus} onCraft={craft} onAtelierClosed={reload} runMutation={equipAndRefresh} />
|
||||
<ExpeditionPlanner key={view.day} catalog={catalog} state={state} view={view} content={content} busy={busy} onStart={start} onReroll={reroll} runMutation={equipAndRefresh} />
|
||||
{!choosing && <>
|
||||
<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>
|
||||
<ItemBag catalog={catalog} state={state} view={view} content={content} busy={busy} onBonus={bonus} onCraft={craft} onAtelierClosed={reload} runMutation={equipAndRefresh} />
|
||||
<ExpeditionPlanner key={view.day} catalog={catalog} state={state} view={view} content={content} busy={busy} onStart={start} onReroll={reroll} runMutation={equipAndRefresh} />
|
||||
</>}
|
||||
</>}
|
||||
{view.enabled && limitReached && invited && !invited.isMember && <p className="nds-inline-notice" data-variant="info">{content.groupLimit}</p>}
|
||||
</>;
|
||||
|
|
|
|||
|
|
@ -310,8 +310,9 @@ export function cancelExpedition(expeditionId) {
|
|||
return request(`/admin/expeditions/${encodeURIComponent(expeditionId)}/cancel`, { method: "POST" });
|
||||
}
|
||||
|
||||
export function joinExpedition(expeditionId, { editionId }) {
|
||||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/join`, { method: "POST", body: JSON.stringify({ editionId }) });
|
||||
// `ready` : le joueur valide sa carte et se dit prêt en rejoignant.
|
||||
export function joinExpedition(expeditionId, { editionId, ready = false }) {
|
||||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/join`, { method: "POST", body: JSON.stringify({ editionId, ready }) });
|
||||
}
|
||||
|
||||
// Aperçu d'une inscription : exigences et résultat attendu du groupe avec la carte choisie.
|
||||
|
|
@ -329,6 +330,11 @@ export function addTestPlayer(expeditionId) {
|
|||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/test-player`, { method: "POST" });
|
||||
}
|
||||
|
||||
// Serveur Vite local uniquement : un joueur de test ouvre une expédition, à rejoindre.
|
||||
export function openTestGroup() {
|
||||
return request("/expeditions/test-group", { method: "POST" });
|
||||
}
|
||||
|
||||
export function leaveExpedition(expeditionId) {
|
||||
return request(`/expeditions/${encodeURIComponent(expeditionId)}/leave`, { method: "POST" });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Rôle : met en page l'étape « Votre carte » des Expéditions de Sokko TCG : le cadre de la carte envoyée (emplacement `lg`, stats,
|
||||
// Rôle : met en page l'étape « Votre explorateur » des Expéditions de Sokko TCG : le cadre de la carte envoyée (emplacement `lg`, stats,
|
||||
// emplacements d'équipement `md`) et les fenêtres de choix de la carte et des communes, dont celle de l'atelier.
|
||||
|
||||
// Cadre : la carte envoyée à gauche, ses stats, pouvoirs et équipements à droite ; empilés en écran étroit.
|
||||
|
|
@ -26,6 +26,8 @@
|
|||
.nebula-loadout-empty span { font-size: 3.4rem; font-weight: 300; line-height: 1; }
|
||||
.nebula-loadout-empty:hover { border-color: rgba(246, 196, 83, 0.8); color: var(--color-accent-gold); }
|
||||
.nebula-loadout-body { display: grid; gap: var(--space-3); min-width: 0; }
|
||||
// Boutons du cadre (valider, annuler), sous la carte et ses détails, en bas à droite.
|
||||
.nebula-loadout-actions { grid-column: 1 / -1; justify-content: flex-end; }
|
||||
.nebula-loadout-body h4, .nebula-loadout-body h5 { margin: 0; }
|
||||
.nebula-loadout-body h5 { color: var(--color-text-secondary); font-size: var(--font-size-xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
|
||||
// Équipements à gauche, à leur largeur (trois emplacements de 175 px au plus) ; stats à droite, dans toute la place restante
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue