Sort destinations by difficulty and show roles and loot effects as icons

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-16 22:27:03 +01:00
parent 994776392f
commit 18bcf435b5
6 changed files with 85 additions and 18 deletions

View file

@ -2,6 +2,7 @@
import { useState } from "react";
import { fillTemplate, formatCountdown } from "./dailyShare.js";
import { conditionText, coverEntry, dangerText, editionEntry, formatEclats, synergyLabels } from "./expeditionFormat.js";
import { RoleLabel } from "./ExpeditionLabels.jsx";
import { NebulaCard } from "./NebulaCard.jsx";
const TIER_VARIANTS = { struggle: "neutral", success: "success", triumph: "gold" };
@ -13,7 +14,7 @@ function JoinForm({ catalog, group, cards, content, busy, onJoin, onCancel }) {
const available = [...cards].filter((card) => !card.busy).sort((a, b) => (b.stats[role] ?? 0) - (a.stats[role] ?? 0) || b.power - a.power);
return <div className="nebula-expedition-join">
<div role="group" aria-label={content.joinRole} className="nds-toolbar">{group.freeRoles.map((value) => <button key={value} type="button" className="nds-button" data-size="sm" data-variant={value === role ? "primary" : "secondary"} aria-pressed={value === role} onClick={() => setRole(value)}>
{fillTemplate(content.roleBadge, { role: content.roles[value], stat: content.stats[value] })}
<RoleLabel stat={value} content={content} detail />
</button>)}</div>
{available.length ? <ul className="nebula-expedition-cards" aria-label={content.cardsLabel}>{available.map((card) => {
const entry = editionEntry(catalog, card.editionId);

View file

@ -0,0 +1,14 @@
// Rôle : petites étiquettes des Expéditions partagées par la préparation et le tableau des groupes : icônes en masque et rôles.
import { fillTemplate } from "./dailyShare.js";
// Icône monochrome teintée par la couleur du texte (static/icons, en masque) : rôles, cartes et objets.
export function MaskIcon({ name }) {
return <span className="nebula-mask-icon" data-icon={name} aria-hidden="true" />;
}
// Rôle d'une place : icône de sa stat et nom du rôle ; `detail` ajoute la stat doublée (« Bravoure ×2 »).
export function RoleLabel({ stat, content, detail = false }) {
return <span className="nebula-role-label" title={fillTemplate(content.roleBadge, { role: content.roles[stat], stat: content.stats[stat] })}>
<MaskIcon name={stat} />{content.roles[stat]}{detail && <small>{fillTemplate(content.roleDouble, { stat: content.stats[stat] })}</small>}
</span>;
}

View file

@ -4,10 +4,27 @@ import { useEffect, useMemo, useState } from "react";
import { previewExpedition } from "./cardsApi.js";
import { fillTemplate } from "./dailyShare.js";
import { conditionText, coverEntry, dangerText, editionEntry, formatDecimal, formatEclats, STAT_IDS, synergyLabels } from "./expeditionFormat.js";
import { CurrencyIcon } from "./Currency.jsx";
import { MaskIcon, RoleLabel } from "./ExpeditionLabels.jsx";
import { NebulaCard } from "./NebulaCard.jsx";
const PREVIEW_DELAY_MS = 250;
const TIER_VARIANTS = { struggle: "neutral", success: "success", triumph: "gold" };
const LOOT_KINDS = ["eclats", "stardust", "cards", "items"];
// Effet de la spécialité sur le butin : flèche verte sur ce qui augmente, rouge sur ce qui baisse.
function LootEffects({ specialty, pct, content }) {
if (!specialty || !pct) return null;
return <span className="nebula-loot-effects" role="list" aria-label={content.specialties[specialty]} title={content.specialties[specialty]}>{LOOT_KINDS.map((kind) => {
const up = kind === specialty;
const delta = (up ? pct.boostPct : pct.otherPct) - 100;
const label = fillTemplate(content.lootEffect, { loot: content.loot[kind], value: `${delta > 0 ? "+" : "−"}${Math.abs(delta)} %` });
return <span key={kind} role="listitem" className="nebula-loot-effect" data-trend={up ? "up" : "down"} title={label} aria-label={label}>
{kind === "eclats" || kind === "stardust" ? <CurrencyIcon kind={kind} /> : <MaskIcon name={kind} />}
<svg className="nebula-loot-arrow" viewBox="0 0 10 10" aria-hidden="true"><path d={up ? "M5 1 9 5.4H6.4V9H3.6V5.4H1Z" : "M5 9 1 4.6H3.6V1H6.4V4.6H9Z"} /></svg>
</span>;
})}</span>;
}
function StatLine({ stats, content }) {
return <span className="nebula-expedition-stats">{STAT_IDS.map((stat) => <span key={stat} title={content.stats[stat]}>{content.statShort[stat]} {formatDecimal(stats[stat])}</span>)}</span>;
@ -29,7 +46,7 @@ function Requirements({ catalog, option, stars, content }) {
return <div className="nebula-expedition-requirements">
<h4>{content.requirementsTitle} <StarsBadge stars={stars} content={content} /></h4>
<ul>{option.requirements.map((requirement) => <li key={requirement.stat}>
<span>{content.stats[requirement.stat]}{requirement.main && <span className="nds-badge" data-variant="neutral">{content.main}</span>}</span>
<span><MaskIcon name={requirement.stat} />{content.stats[requirement.stat]}{requirement.main && <span className="nds-badge" data-variant="neutral">{content.main}</span>}</span>
<strong>{requirement.value}</strong>
</li>)}</ul>
{option.condition && <p>{conditionText(option.condition, catalog, content)}</p>}
@ -71,13 +88,15 @@ function Preview({ catalog, preview, content, hours }) {
export function ExpeditionPlanner({ catalog, view, mode = "solo", content, busy, onStart }) {
const group = mode === "group";
const slotCount = group ? 1 : view.soloCards;
const [destinationId, setDestinationId] = useState(view.destinations[0]?.id || "");
// Destinations de la plus facile à la plus difficile.
const destinations = useMemo(() => [...view.destinations].sort((a, b) => (a.level ?? 0) - (b.level ?? 0)), [view.destinations]);
const [destinationId, setDestinationId] = useState(destinations[0]?.id || "");
const [hours, setHours] = useState(view.durations[0]);
const [slots, setSlots] = useState(() => Array.from({ length: slotCount }, () => null));
const [groupRole, setGroupRole] = useState(null);
const [activeSlot, setActiveSlot] = useState(0);
const [preview, setPreview] = useState({ key: "", value: null, error: "" });
const destination = view.destinations.find((item) => item.id === destinationId) || view.destinations[0];
const destination = destinations.find((item) => item.id === destinationId) || destinations[0];
const stars = group ? destination?.groupStar : destination?.soloStar;
const option = (group ? destination?.groupStars : destination?.stars)?.[stars];
const chosenRole = group ? (destination?.groupRoles.includes(groupRole) ? groupRole : destination?.groupRoles[0]) : null;
@ -117,17 +136,18 @@ export function ExpeditionPlanner({ catalog, view, mode = "solo", content, busy,
<section className="nds-panel nebula-expedition-step" aria-labelledby="nebula-expedition-destinations-title">
<h3 id="nebula-expedition-destinations-title">{content.destinationsTitle}</h3>
{view.unlocked && view.unlocked.count < view.unlocked.total && <p className="nebula-form-help">{fillTemplate(content.unlockedDestinations, view.unlocked)}</p>}
<div className="nebula-expedition-destinations">{view.destinations.map((item) => {
<div className="nebula-expedition-destinations">{destinations.map((item) => {
const collection = item.rewardCollectionId && (catalog.collections.find((entry) => entry.id === item.rewardCollectionId)?.name || item.rewardCollectionId);
return <button key={item.id} type="button" className="nebula-expedition-destination" data-scene={item.image ? "" : undefined} aria-pressed={item.id === destination.id} onClick={() => setDestinationId(item.id)}>
<DestinationCover catalog={catalog} destination={item} />
<span className="nebula-expedition-destination-copy">
<strong>{item.name}<StarsBadge stars={group ? item.groupStar : item.soloStar} content={content} />{item.bonusSlot && <span className="nds-badge" data-variant="gold">{content.bonusSlots[item.bonusSlot]}</span>}</strong>
<span>{item.description}</span>
<span className="nebula-expedition-destination-roles">{(group ? item.groupRoles : item.roles).map((stat) => <span key={stat} className="nds-badge" data-variant="neutral">{fillTemplate(content.roleBadge, { role: content.roles[stat], stat: content.stats[stat] })}</span>)}</span>
{(item.specialty || item.rewardCollectionId) && <span className="nebula-expedition-destination-roles">
{item.specialty && <span className="nds-badge" data-variant="success">{content.specialties[item.specialty]}</span>}
{item.rewardCollectionId && <span className="nds-badge" data-variant="neutral">{fillTemplate(content.rewardCollection, { collection: catalog.collections.find((collection) => collection.id === item.rewardCollectionId)?.name || item.rewardCollectionId })}</span>}
</span>}
<span className="nebula-expedition-destination-facts">
<span className="nebula-expedition-destination-roles" aria-label={content.rolesLabel}>{(group ? item.groupRoles : item.roles).map((stat) => <RoleLabel key={stat} stat={stat} content={content} />)}</span>
<LootEffects specialty={item.specialty} pct={view.specialty} content={content} />
</span>
{collection && <span className="nebula-expedition-destination-collection" title={fillTemplate(content.rewardCollection, { collection })}><MaskIcon name="cards" />{collection}</span>}
</span>
</button>;
})}</div>
@ -144,15 +164,16 @@ export function ExpeditionPlanner({ catalog, view, mode = "solo", content, busy,
<section className="nds-panel nebula-expedition-step" aria-labelledby="nebula-expedition-team-title">
<h3 id="nebula-expedition-team-title">{content.teamTitle}</h3>
<p className="nebula-form-help">{group ? content.groupTeamHelp : fillTemplate(content.teamHelp, { count: view.soloCards })}</p>
<p className="nebula-form-help">{content.rolesHelp}</p>
{group && <div role="group" aria-label={content.joinRole} className="nds-toolbar">{destination.groupRoles.map((stat) => <button key={stat} type="button" className="nds-button" data-size="sm" data-variant={stat === chosenRole ? "primary" : "secondary"} aria-pressed={stat === chosenRole} onClick={() => setGroupRole(stat)}>
{fillTemplate(content.roleBadge, { role: content.roles[stat], stat: content.stats[stat] })}
<RoleLabel stat={stat} content={content} detail />
</button>)}</div>}
<div className="nebula-expedition-slots">{slots.map((editionId, index) => {
const entry = editionId && editionEntry(catalog, editionId);
const stat = slotRoles[index];
return <div key={index} className="nebula-expedition-slot" data-active={index === activeSlot || undefined}>
<button type="button" className="nds-button" data-size="sm" data-variant={index === activeSlot ? "primary" : "secondary"} aria-pressed={index === activeSlot} onClick={() => setActiveSlot(index)}>
{fillTemplate(content.roleBadge, { role: content.roles[stat], stat: content.stats[stat] })}
<RoleLabel stat={stat} content={content} detail />
</button>
<span>{entry ? entry.card.name : content.slotEmpty}</span>
{entry && <button type="button" className="nds-button" data-size="sm" data-variant="secondary" onClick={() => { setSlots(slots.map((value, position) => (position === index ? null : value))); setActiveSlot(index); }}>{content.remove}</button>}

View file

@ -31,14 +31,39 @@
.nebula-expedition-destination { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--space-3); align-items: start; padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-bg-surface-alt); color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color 160ms var(--ease-standard), background 160ms var(--ease-standard); }
.nebula-expedition-destination:hover { background: var(--color-bg-hover); }
.nebula-expedition-destination[aria-pressed="true"] { border-color: rgba(246, 196, 83, 0.54); background: rgba(246, 196, 83, 0.12); }
.nebula-expedition-destination img { width: 72px; aspect-ratio: 1; border-radius: var(--radius-sm); object-fit: cover; }
.nebula-expedition-destination > img { width: 72px; aspect-ratio: 1; border-radius: var(--radius-sm); object-fit: cover; }
// Paysage d'une destination : bandeau pleine largeur découpé par le coup de pinceau (static/img/expeditions/brush-mask.webp).
.nebula-expedition-destination[data-scene] { grid-template-columns: minmax(0, 1fr); }
.nebula-destination-scene { display: block; width: 100%; aspect-ratio: 499 / 224; mask: url("/static/img/expeditions/brush-mask.webp") center / 100% 100% no-repeat; -webkit-mask: url("/static/img/expeditions/brush-mask.webp") center / 100% 100% no-repeat; }
.nebula-expedition-destination .nebula-destination-scene img { display: block; width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; object-fit: cover; }
.nebula-expedition-destination-copy { display: grid; gap: var(--space-1); min-width: 0; }
.nebula-expedition-destination-copy > span:not(.nebula-expedition-destination-roles) { color: var(--color-text-secondary); font-size: var(--font-size-sm); text-wrap: pretty; }
.nebula-expedition-destination-roles { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.nebula-expedition-destination-copy > span:not(.nebula-expedition-destination-facts) { color: var(--color-text-secondary); font-size: var(--font-size-sm); text-wrap: pretty; }
// Pied de la destination : rôles des places à gauche, effet de sa spécialité sur le butin à droite, puis la collection liée.
.nebula-expedition-destination-facts { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); margin-top: var(--space-1); }
.nebula-expedition-destination-roles { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.nebula-expedition-destination-collection { display: inline-flex; align-items: center; gap: 0.4em; }
// Icônes monochromes (static/icons) en masque, teintées par la couleur du texte.
.nebula-mask-icon { display: inline-block; flex: 0 0 auto; width: 1.15em; height: 1.15em; background-color: currentColor; mask: var(--nebula-icon) center / contain no-repeat; -webkit-mask: var(--nebula-icon) center / contain no-repeat; }
.nebula-mask-icon[data-icon="bravoure"] { --nebula-icon: url("/static/icons/sword.svg"); }
.nebula-mask-icon[data-icon="endurance"] { --nebula-icon: url("/static/icons/shield.svg"); }
.nebula-mask-icon[data-icon="fortune"] { --nebula-icon: url("/static/icons/clover.svg"); }
.nebula-mask-icon[data-icon="orientation"] { --nebula-icon: url("/static/icons/map.svg"); }
.nebula-mask-icon[data-icon="cards"] { --nebula-icon: url("/static/icons/tcg.svg"); }
.nebula-mask-icon[data-icon="items"] { --nebula-icon: url("/static/icons/toolbox.svg"); }
// Rôle : icône de sa stat, nom, et la stat doublée en plus discret sur les places.
.nebula-role-label { display: inline-flex; align-items: center; gap: 0.4em; font-size: var(--font-size-sm); font-weight: 700; white-space: nowrap; }
.nebula-role-label small { padding-left: 0.5em; border-left: 1px solid var(--color-border); color: var(--color-text-secondary); font-size: inherit; font-weight: 600; }
.nds-button[aria-pressed="true"] .nebula-role-label small { color: inherit; opacity: 0.8; }
// Spécialité : l'icône de chaque butin suivie d'une flèche verte (augmente) ou rouge (baisse).
.nebula-loot-effects { display: inline-flex; align-items: center; gap: var(--space-2); }
.nebula-loot-effect { display: inline-flex; align-items: center; gap: 1px; color: var(--color-text-primary); font-size: var(--font-size-md); }
.nebula-loot-effect .nebula-currency-icon { margin-right: 0; vertical-align: baseline; }
.nebula-loot-effect[data-trend="down"] > :not(.nebula-loot-arrow) { opacity: 0.7; }
.nebula-loot-arrow { width: 0.8em; height: 0.8em; fill: var(--color-success); }
.nebula-loot-effect[data-trend="down"] .nebula-loot-arrow { fill: var(--color-danger); }
// Difficulté tirée avec la destination : badge d'étoiles après le nom, et rappelé devant les exigences.
.nebula-expedition-destination-copy > strong { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.nds-badge.nebula-expedition-stars { letter-spacing: 1px; }
@ -75,7 +100,7 @@
.nebula-admin-expedition-status { display: grid; gap: var(--space-3); }
.nebula-admin-expedition-status[data-open="true"] { border-color: color-mix(in srgb, var(--color-success) 40%, transparent); }
.nebula-admin-expedition-status-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.nebula-admin-expedition-status-head h3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-1); font-size: var(--font-size-md, 1rem); }
.nebula-admin-expedition-status-head h3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-1); font-size: var(--font-size-md); }
.nebula-admin-expedition-status-head > .nds-button { width: auto; }
.nebula-admin-setting-input { position: relative; display: block; max-width: 220px; }
.nebula-admin-expedition-items .nebula-admin-setting-input { max-width: none; }