Rework the pending expedition card in two columns with a larger landscape, a clear outcome summary, card-sized slots and a one-hour default recruitment

A pending expedition now spans the full width in two columns: the destination landscape, the members as small cards with free slots of the same size, and the departure buttons on the left; the departure countdown with its time and progress bar, the projected outcome, powers and bonuses in small tiles, a recap of the destination's requirements against the team's stats, and the invite link on the right. The outcome tile shows the tier, the score and a sentence on how the tier changes the loot. Pending, running and finished expeditions use the destination landscape instead of the old cover card, and the default recruitment period drops from 12 hours to one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-17 20:16:00 +01:00
parent a38d4fd02a
commit 9b9d64fd01
9 changed files with 229 additions and 44 deletions

View file

@ -1,9 +1,11 @@
// 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.
import { useEffect, useRef, useState } from "react";
import { Tooltip } from "../../components/Tooltip.jsx";
import { fillTemplate, formatCountdown } from "./dailyShare.js";
import { conditionText, coverEntry, dangerText, editionEntry, formatEclats, helpScore, synergyLabels } from "./expeditionFormat.js";
import { conditionText, dangerText, editionEntry, formatDecimal, formatEclats, helpScore, POWER_TEXT, synergyLabels, tagLabel } from "./expeditionFormat.js";
import { ExpeditionCardTile } from "./ExpeditionCardTile.jsx";
import { DestinationArt, MainStatMark, MaskIcon } from "./ExpeditionLabels.jsx";
import { NebulaCard } from "./NebulaCard.jsx";
const TIER_VARIANTS = { struggle: "neutral", success: "success", triumph: "gold" };
@ -23,6 +25,72 @@ function JoinForm({ catalog, group, cards, content, busy, onJoin, onCancel }) {
</div>;
}
// Rappel de ce que demande la destination face à ce qu'apporte l'équipe si elle partait maintenant : une ligne par stat exigée
// (valeur de l'équipe / exigence, en vert ou en rouge), puis la condition et les dangers, chacun avec un pouce vert (remplie, paré)
// ou rouge.
// Avec le Coup de folie, les exigences seules (pas de prévision).
// Effet du palier prévu sur le butin, en une phrase ; le pourcentage en rouge (réduit) ou en vert (augmenté).
function TierLoot({ pct, content }) {
if (pct == null) return null;
const delta = pct - 100;
const value = <strong data-trend={delta > 0 ? "up" : "down"}>{Math.abs(delta)}&nbsp;%</strong>;
const [before, after] = (delta > 0 ? content.groupOutcomeLootUp : content.groupOutcomeLootDown).split("{value}");
return <p className="nebula-group-tier-loot">{delta ? <>{before}{value}{after}</> : content.groupOutcomeLootNormal}</p>;
}
// Nom d'un pouvoir de l'équipe (icône de fiole), sa description au survol.
function PowerName({ power, content }) {
return <Tooltip className="nebula-equipment-power" content={POWER_TEXT[power]} aria-label={`${content.powers[power]} : ${POWER_TEXT[power]}`} tabIndex={0}>
<MaskIcon name="power" /><span aria-hidden="true">{content.powers[power]}</span>
</Tooltip>;
}
function Thumb({ ok, label }) {
return <span className="nebula-destination-hazard-state" data-ok={ok ? "true" : "false"} title={label} aria-hidden="true"><MaskIcon name="thumb" /></span>;
}
function GroupRecap({ catalog, group, content }) {
const projected = group.projected;
const hidden = projected.hiddenRequirements;
const teamOf = new Map((projected.requirements || []).map((item) => [item.stat, item]));
const countered = new Map((projected.dangers || []).map((danger) => [danger.id, danger.countered]));
const tagNames = (tags) => tags.map((tag) => tagLabel(catalog, tag)).join(content.or);
return <section className="nebula-group-recap" aria-label={content.groupRecapTitle}>
<h5>{content.groupRecapTitle}</h5>
<ul className="nebula-group-recap-list">
{group.requirements.map(({ stat, value, main }) => {
const team = teamOf.get(stat);
const ok = team ? team.team >= team.value : null;
const label = [fillTemplate(content.requirementValue, { stat: content.stats[stat], value: team?.value ?? value }),
team && !hidden ? fillTemplate(ok ? content.requirementMet : content.requirementUnmet, { team: formatDecimal(team.team) }) : ""].filter(Boolean).join(" ");
return <li key={stat} className="nebula-group-recap-row" aria-label={label}>
<span className="nebula-group-recap-name" aria-hidden="true"><MaskIcon name={stat} />{content.stats[stat]}{main && <MainStatMark content={content} />}</span>
<strong aria-hidden="true" data-met={hidden || !team ? undefined : String(ok)}>{hidden || !team ? value : fillTemplate(content.teamVersus, { team: formatDecimal(team.team), value: team.value })}</strong>
</li>;
})}
</ul>
{(group.condition || group.dangers.length > 0) && <ul className="nebula-group-recap-list" data-kind="hazards">
{group.condition && (() => {
const name = group.condition.type === "collection" ? catalog.collections.find((item) => item.id === group.condition.collectionId)?.name || group.condition.collectionId : tagLabel(catalog, group.condition.tag);
const ok = projected.conditionMet;
return <li className="nebula-group-recap-row" title={conditionText(group.condition, catalog, content)}
aria-label={`${conditionText(group.condition, catalog, content)}${hidden ? "" : ` ${ok ? content.conditionOk : content.conditionKo}`}`}>
<span className="nebula-group-recap-name" aria-hidden="true">{fillTemplate(content.conditionShort, { name })}</span>
{!hidden && <Thumb ok={ok} label={ok ? content.conditionOk : content.conditionKo} />}
</li>;
})()}
{group.dangers.map((danger) => {
const ok = countered.get(danger.id);
return <li key={danger.id} className="nebula-group-recap-row" title={dangerText(danger, catalog, content)}
aria-label={`${dangerText(danger, catalog, content)}${hidden ? "" : ` ${ok ? content.dangerOk : content.dangerKo}`}`}>
<span className="nebula-group-recap-name" aria-hidden="true">{fillTemplate(content.dangerShort, { label: danger.label })}<small>{fillTemplate(content.dangerDetail, { stat: content.stats[danger.stat], tags: tagNames(danger.unlessTags) })}</small></span>
{!hidden && <Thumb ok={ok} label={ok ? content.dangerOk : content.dangerKo} />}
</li>;
})}
</ul>}
</section>;
}
// Lien d'invitation : il ouvre la page des Expéditions sur cette expédition, son inscription déjà dépliée.
const inviteUrl = (groupId) => `${window.location.origin}/#/cards/expeditions/${encodeURIComponent(groupId)}`;
@ -51,42 +119,57 @@ export function ExpeditionGroupCard({ catalog, group, cards, content, now, busy,
const [joining, setJoining] = useState(invited && group.canJoin && !limitReached);
const articleRef = useRef(null);
useEffect(() => { if (invited) articleRef.current?.scrollIntoView({ block: "center" }); }, [invited]);
const cover = group.destination.coverCardId && coverEntry(catalog, group.destination.coverCardId);
const projected = group.projected;
return <article ref={articleRef} className="nds-card nebula-expedition-report nebula-expedition-group" data-invited={invited || undefined} aria-labelledby={`nebula-group-${group.id}`}>
{cover && <div className="nds-card-cover nebula-expedition-report-cover" aria-hidden="true"><img src={cover.card.image} alt="" /></div>}
<div className="nds-card-body nebula-expedition-report-body">
<p className="eyebrow">{fillTemplate(content.groupMeta, { stars: "★".repeat(group.stars), hours: group.hours, creator: group.isCreator ? content.you : group.creatorName })}</p>
<h4 id={`nebula-group-${group.id}`}>{group.destination.name}</h4>
<p className="nebula-form-help">{fillTemplate(content.groupDeadline, { time: formatCountdown(group.recruitUntil - now) })}</p>
<ul className="nebula-expedition-group-members" aria-label={content.groupMembers}>
{group.members.map((member) => {
const entry = editionEntry(catalog, member.editionId);
return <li key={member.position}>{entry && <NebulaCard catalog={catalog} entry={entry} size="sm" />}<span><strong>{member.own ? content.you : member.playerName}</strong></span></li>;
})}
{Array.from({ length: group.freeSlots }, (_, index) => <li key={`free-${index}`} className="nebula-expedition-group-free"><span>{content.groupFreeRole}</span></li>)}
</ul>
{group.freeSlots > 0 && <p className="nebula-form-help">{group.members.length > 1 ? content.groupKeeper : content.soloKeeper}</p>}
<div className="nebula-expedition-rewards" aria-label={content.groupProjected}>
{projected.hiddenRequirements ? <span className="nds-badge" data-variant="warning">{content.hiddenResult}</span> : <>
<span className="nds-badge" data-variant={TIER_VARIANTS[projected.tier]}>{content.tiers[projected.tier]}</span>
<span className="nds-badge" data-variant="neutral">{fillTemplate(content.score, { score: formatEclats(projected.scorePct) })}</span>
</>}
{(projected.powers || []).map((power) => <span key={power} className="nds-badge" data-variant="gold">{content.powers[power]}</span>)}
{synergyLabels(projected, catalog, content).map((label) => <span key={label} className="nds-badge" data-variant="success">{label}</span>)}
{projected.cohesionPct > 0 && <span className="nds-badge" data-variant="success">{fillTemplate(content.cohesion, { value: projected.cohesionPct })}</span>}
{projected.players > 1 && <span className="nds-badge" data-variant="gold">{fillTemplate(content.lootBonus, { value: formatEclats(projected.lootPct / 100) })}</span>}
</div>
{group.condition && <p className="nebula-form-help">{conditionText(group.condition, catalog, content)}</p>}
{group.dangers.map((danger) => <p key={danger.id} className="nebula-form-help">{dangerText(danger, catalog, content)}</p>)}
<div className="nds-card-actions nebula-expedition-group-actions">
const left = Math.max(0, group.recruitUntil - now);
const span = Math.max(1, group.recruitUntil - (group.openedAt ?? group.recruitUntil - 3_600_000));
const departTime = new Date(group.recruitUntil).toLocaleTimeString("fr-FR", { hour: "2-digit", minute: "2-digit" });
const bonuses = [...synergyLabels(projected, catalog, content), ...(projected.cohesionPct > 0 ? [fillTemplate(content.cohesion, { value: projected.cohesionPct })] : [])];
return <article ref={articleRef} className="nds-card nebula-expedition-group" data-invited={invited || undefined} aria-labelledby={`nebula-group-${group.id}`}>
<div className="nebula-group-side">
<DestinationArt catalog={catalog} destination={group.destination} />
<section className="nebula-group-team" aria-label={content.groupMembers}>
<h5>{content.groupMembers}</h5>
<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>;
})}
{Array.from({ length: group.freeSlots }, (_, index) => <li key={`free-${index}`}><span className="nebula-expedition-group-free">{content.groupFreeRole}</span></li>)}
</ul>
{group.freeSlots > 0 && <p className="nebula-form-help">{group.members.length > 1 ? content.groupKeeper : content.soloKeeper}</p>}
</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.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>}
</div>
{group.isMember && <InviteLink groupId={group.id} content={content} />}
{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)} />}
</div>
<div className="nebula-group-main">
<div className="nebula-group-heading">
<p className="eyebrow">{fillTemplate(content.groupMeta, { stars: "★".repeat(group.stars), hours: group.hours, creator: group.isCreator ? content.you : group.creatorName })}</p>
<h4 id={`nebula-group-${group.id}`}>{group.destination.name}</h4>
</div>
<div className="nebula-group-deadline">
<span>{fillTemplate(content.groupDeadline, { time: formatCountdown(left), at: departTime })}</span>
<div className="nds-progress" data-size="sm" role="progressbar" aria-label={content.groupDeadlineBar} aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round((1 - left / span) * 100)}><span style={{ width: `${Math.min(100, (1 - left / span) * 100)}%` }} /></div>
</div>
<dl className="nebula-group-outcome" aria-label={content.groupProjected}>
<div><dt>{content.groupOutcomeTier}</dt><dd>{projected.hiddenRequirements ? <span className="nds-badge" data-variant="warning">{content.hiddenResult}</span>
: <>
<span className="nebula-group-tier-line">
<span className="nds-badge" data-variant={TIER_VARIANTS[projected.tier]}>{content.tiers[projected.tier]}</span>
<span className="nebula-group-score"><strong>{formatEclats(projected.scorePct)}&nbsp;%</strong><small>{content.groupOutcomeScore}</small></span>
</span>
<TierLoot pct={group.tierLootPct?.[projected.tier]} content={content} />
</>}</dd></div>
{projected.players > 1 && <div><dt>{content.groupOutcomeGroupLoot}</dt><dd>{fillTemplate(content.lootBonus, { value: formatEclats(projected.lootPct / 100) })}</dd></div>}
{(projected.powers || []).length > 0 && <div><dt>{content.groupOutcomePowers}</dt><dd className="nebula-group-powers">{projected.powers.map((power) => <PowerName key={power} power={power} content={content} />)}</dd></div>}
{bonuses.length > 0 && <div><dt>{content.groupOutcomeBonuses}</dt><dd>{bonuses.join(" · ")}</dd></div>}
</dl>
<GroupRecap catalog={catalog} group={group} content={content} />
{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)} />}
</article>;
}