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:
parent
994776392f
commit
18bcf435b5
6 changed files with 85 additions and 18 deletions
|
|
@ -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);
|
||||
|
|
|
|||
14
website/src/features/cards/ExpeditionLabels.jsx
Normal file
14
website/src/features/cards/ExpeditionLabels.jsx
Normal 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>;
|
||||
}
|
||||
|
|
@ -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>}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue