Split the Guild administration into tabs and sell Éclats and openings by quantity in the shop
The Guild administration now has a tab per quest. The expedition settings sit behind a status band (open or close, today's activity) and four themed tabs, with units inside the fields, the default value shown, and one sticky apply bar that lists every change before confirming. The Pont des Veilleurs leaves the expedition page and becomes the « Éclats d’étoile » shop item, priced from Administration › Boutique. Openings and Éclats are bought by quantity: a number field capped by the stardust the player actually has, and a full-width button that shows the total cost. Stardust and Éclats get their own SVG icons, aligned with the text around them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
beef966337
commit
4d05d812c5
28 changed files with 676 additions and 258 deletions
|
|
@ -2,6 +2,7 @@
|
|||
import { Modal } from "../../components/Modal.jsx";
|
||||
import { recycleDuplicates, setFavorite, upgradeCard } from "./cardsApi.js";
|
||||
import { CardEquipment } from "./CardEquipment.jsx";
|
||||
import { CurrencyAmount } from "./Currency.jsx";
|
||||
import { readCollection } from "./collectionState.js";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
|
|
@ -17,7 +18,7 @@ function CardProgress({ catalog, state, progress, eclats, busy, runMutation }) {
|
|||
<p><strong>Puissance {progress.power}</strong> · {STATS.map(([stat, label]) => `${label} ${progress.stats[stat]}`).join(" · ")}</p>
|
||||
{!atCap && <div className="nds-progress" data-size="sm" role="progressbar" aria-label="Expérience de terrain" aria-valuemin={0} aria-valuemax={100} aria-valuenow={progress.fieldXp}><span style={{ width: `${progress.fieldXp}%` }} /></div>}
|
||||
{atCap ? <p className="nebula-form-help">Puissance maximale atteinte.</p> : <div className="nds-toolbar">
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || eclats < progress.nextCost} onClick={() => runMutation(() => upgradeCard(progress.editionId, "eclats"))}>Améliorer · {formatEclats(progress.nextCost)} Éclats</button>
|
||||
<button className="nds-button" data-variant="primary" type="button" disabled={busy || eclats < progress.nextCost} onClick={() => runMutation(() => upgradeCard(progress.editionId, "eclats"))}>Améliorer · <CurrencyAmount kind="eclats">{formatEclats(progress.nextCost)} Éclats</CurrencyAmount></button>
|
||||
{progress.spare > 0 && <button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={() => runMutation(() => upgradeCard(progress.editionId, "duplicate"))}>Améliorer avec un doublon</button>}
|
||||
</div>}
|
||||
{!atCap && <p className="nebula-form-help">Vous avez {formatEclats(eclats)} Éclats. Chaque retour d’expédition donne de l’expérience de terrain ({progress.fieldXp} % du niveau suivant).</p>}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { NebulaCard } from "./NebulaCard.jsx";
|
|||
import { OpeningReserve } from "./OpeningReserve.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { pendingQuestCount } from "./guildQuests.js";
|
||||
import { StardustBalance } from "./ShopPanel.jsx";
|
||||
import { StardustBalance } from "./Currency.jsx";
|
||||
|
||||
// Le dragon des Veilleurs, parchemin de quête en main : l'emblème de la Guilde, propre à elle et non à l'une de ses quêtes.
|
||||
const GUILD_ILLUSTRATION = "/static/img/cards/guild-veilleurs.webp";
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { DashboardAside } from "./CardsDashboard.jsx";
|
|||
import { recycleDuplicates } from "./cardsApi.js";
|
||||
import { readCollection, visibleCollections } from "./collectionState.js";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
import { StardustBalance } from "./ShopPanel.jsx";
|
||||
import { StardustBalance } from "./Currency.jsx";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
const OWNERSHIP_OPTIONS = [{ value: "owned", label: "Possédées" }, { value: "missing", label: "Manquantes" }, { value: "duplicates", label: "Doublons" }];
|
||||
|
|
|
|||
23
website/src/features/cards/Currency.jsx
Normal file
23
website/src/features/cards/Currency.jsx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Rôle : affiche les deux monnaies de Sokko TCG, la poussière d'étoiles et les Éclats d'étoile, avec leur icône.
|
||||
// Les icônes sont des images (static/icons) : leurs dégradés SVG ne peuvent pas entrer en conflit avec la page.
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
const ICONS = { stardust: "/static/icons/stardust.svg", eclats: "/static/icons/eclat.svg" };
|
||||
|
||||
export function CurrencyIcon({ kind }) {
|
||||
return <img className="nebula-currency-icon" data-currency={kind} src={ICONS[kind]} alt="" aria-hidden="true" />;
|
||||
}
|
||||
|
||||
// Icône suivie d'un texte libre (« 70 Éclats ») dans un bouton ou un badge : un seul bloc en ligne, aligné sur le texte.
|
||||
export function CurrencyAmount({ kind, children }) {
|
||||
return <span className="nebula-currency-amount"><CurrencyIcon kind={kind} />{children}</span>;
|
||||
}
|
||||
|
||||
export function StardustBalance({ value }) {
|
||||
return <span className="nebula-stardust" aria-label={`${formatStardust(value)} d’étoiles`}><CurrencyIcon kind="stardust" />{value.toLocaleString("fr-FR")}</span>;
|
||||
}
|
||||
|
||||
export function EclatsBalance({ value }) {
|
||||
return <span className="nebula-eclats" aria-label={`${formatEclats(value)} Éclats d’étoile`}><CurrencyIcon kind="eclats" />{formatEclats(value)}</span>;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
// Rôle : présente une expédition du joueur : en route (compte à rebours), revenue (butin à récupérer), terminée ou annulée.
|
||||
import { CurrencyAmount } from "./Currency.jsx";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { coverEntry, editionEntry, formatEclats, synergyLabels } from "./expeditionFormat.js";
|
||||
import { NebulaCard } from "./NebulaCard.jsx";
|
||||
|
|
@ -8,7 +9,7 @@ const TIER_VARIANTS = { struggle: "neutral", success: "success", triumph: "gold"
|
|||
|
||||
function RewardBadges({ catalog, reward, content }) {
|
||||
return <div className="nebula-expedition-rewards">
|
||||
<span className="nds-badge" data-variant="gold">{fillTemplate(content.rewardEclats, { value: formatEclats(reward.eclats) })}</span>
|
||||
<span className="nds-badge" data-variant="gold"><CurrencyAmount kind="eclats">{fillTemplate(content.rewardEclats, { value: formatEclats(reward.eclats) })}</CurrencyAmount></span>
|
||||
{reward.stardust > 0 && <span className="nds-badge" data-variant="neutral">{fillTemplate(content.rewardStardust, { value: formatStardust(reward.stardust) })}</span>}
|
||||
{reward.packs.length > 0 && <span className="nds-badge" data-variant="success">{fillTemplate(content.rewardPacks, { count: reward.packs.length, s: reward.packs.length > 1 ? "s" : "" })}</span>}
|
||||
{(reward.cards || []).map((editionId, index) => <span key={`${editionId}-${index}`} className="nds-badge" data-variant="gold">{fillTemplate(content.rewardCard, { card: editionEntry(catalog, editionId)?.card.name || editionId })}</span>)}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
// Rôle : présente les Expéditions, quête de la Guilde : expéditions du joueur (retour, butin) et préparation d'une expédition solo.
|
||||
import { useEffect, useState } from "react";
|
||||
import { addBonusDestination, claimExpedition, convertStardust, craftPowerCommon, recallExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, startExpedition } from "./cardsApi.js";
|
||||
import { addBonusDestination, claimExpedition, craftPowerCommon, recallExpedition, departExpedition, joinExpedition, leaveExpedition, loadExpeditions, startExpedition } from "./cardsApi.js";
|
||||
import { CurrencyAmount } from "./Currency.jsx";
|
||||
import { fillTemplate, formatCountdown } from "./dailyShare.js";
|
||||
import { ExpeditionGroupCard } from "./ExpeditionGroupCard.jsx";
|
||||
import { ExpeditionPlanner } from "./ExpeditionPlanner.jsx";
|
||||
import { ExpeditionReport } from "./ExpeditionReport.jsx";
|
||||
import { formatEclats, grimoireLabel } from "./expeditionFormat.js";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
const COUNTDOWN_TICK_MS = 30_000;
|
||||
|
||||
|
|
@ -58,22 +58,6 @@ function ItemBag({ catalog, state, view, content, busy, onBonus, onCraft }) {
|
|||
</section>;
|
||||
}
|
||||
|
||||
// Pont des Veilleurs : de la poussière vers les Éclats, au taux réglé ; la conversion inverse n'existe pas.
|
||||
function BridgeForm({ rate, stardust, busy, content, onConvert }) {
|
||||
const [amount, setAmount] = useState("1");
|
||||
const eclats = /^\d+$/.test(amount) ? Number(amount) : 0;
|
||||
const cost = eclats * rate;
|
||||
return <form className="nds-panel nebula-expedition-bridge" aria-labelledby="nebula-expedition-bridge-title" onSubmit={async (event) => { event.preventDefault(); if (await onConvert(eclats)) setAmount("1"); }}>
|
||||
<h3 id="nebula-expedition-bridge-title">{content.bridgeTitle}</h3>
|
||||
<p className="nebula-form-help">{fillTemplate(content.bridgeHelp, { rate })}</p>
|
||||
<div className="nebula-expedition-bridge-row">
|
||||
<label><span>{content.bridgeLabel}</span><input className="nds-input" type="number" inputMode="numeric" min="1" max="10000" step="1" value={amount} disabled={busy} onChange={(event) => setAmount(event.target.value)} /></label>
|
||||
<span className="nebula-form-help">{fillTemplate(content.bridgeCost, { cost: formatStardust(cost) })}</span>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="submit" disabled={busy || eclats < 1 || cost > stardust}>{content.bridgeAction}</button>
|
||||
</div>
|
||||
</form>;
|
||||
}
|
||||
|
||||
export function ExpeditionsPanel({ catalog, state, runMutation, busy, content }) {
|
||||
const [view, setView] = useState(null);
|
||||
const [loadError, setLoadError] = useState("");
|
||||
|
|
@ -114,11 +98,6 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content })
|
|||
const claim = async (id) => handle(await runMutation(expeditionCall(() => claimExpedition(id))), content.claimed);
|
||||
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);
|
||||
const convert = async (eclats) => {
|
||||
const result = await runMutation(() => convertStardust(eclats));
|
||||
if (result) setNotice({ variant: "success", text: fillTemplate(content.bridged, { eclats: formatEclats(eclats) }) });
|
||||
return Boolean(result);
|
||||
};
|
||||
const bonus = async (item) => handle(await runMutation(expeditionCall(() => addBonusDestination(item))), content.bonusAdded);
|
||||
const craft = async (editionIds) => {
|
||||
const result = await runMutation(expeditionCall(() => craftPowerCommon(editionIds)));
|
||||
|
|
@ -138,13 +117,12 @@ export function ExpeditionsPanel({ catalog, state, runMutation, busy, content })
|
|||
<div className="nds-section-heading nebula-section-heading">
|
||||
<div><p className="eyebrow">{content.eyebrow}</p><h2 id="nebula-expeditions-title">{content.title}</h2><p className="nebula-guild-intro">{content.intro}</p></div>
|
||||
<div className="nebula-daily-heading-actions">
|
||||
<span className="nds-badge" data-variant="gold" title={content.eclatsHelp}>{fillTemplate(content.eclatsBalance, { value: formatEclats(state.wallet.eclats ?? 0) })}</span>
|
||||
<span className="nds-badge" data-variant="gold" title={content.eclatsHelp}><CurrencyAmount kind="eclats">{fillTemplate(content.eclatsBalance, { value: formatEclats(state.wallet.eclats ?? 0) })}</CurrencyAmount></span>
|
||||
<a className="nds-button" data-size="sm" data-variant="secondary" href="#/cards/guild">{content.back}</a>
|
||||
</div>
|
||||
</div>
|
||||
<p className="nebula-form-help">{content.eclatsHelp}</p>
|
||||
<ItemBag catalog={catalog} state={state} view={view} content={content} busy={busy} onBonus={bonus} onCraft={craft} />
|
||||
<BridgeForm rate={view.progression.stardustPerEclat} stardust={state.wallet.stardust} busy={busy} content={content} onConvert={convert} />
|
||||
{notice && <p className="nds-inline-notice" data-variant={notice.variant} role="status">{notice.text}</p>}
|
||||
{expired && <div className="nds-inline-notice nebula-daily-expired" data-variant="warning" role="status"><span>{content.expired}</span><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={reload}>{content.reload}</button></div>}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ function HistoryDetail({ entry, catalog }) {
|
|||
return <span>{[name, detail].filter(Boolean).join(" · ")}</span>;
|
||||
}
|
||||
if (entry.type === "eclats_converted") return <span>+{details.eclats} Éclats · −{formatStardust(details.stardust)} d’étoiles</span>;
|
||||
if (entry.type === "opening_purchased") return <span>−{formatStardust(details.price)} d’étoiles</span>;
|
||||
if (entry.type === "opening_purchased") return <span>{details.count > 1 && `${details.count} ouvertures · `}−{formatStardust(details.stardust ?? details.price)} d’étoiles</span>;
|
||||
if (!details.collectionId) return null;
|
||||
const name = catalog.collections.find((item) => item.id === details.collectionId)?.name;
|
||||
if (details.price) return <span>{name} · −{formatStardust(details.price)}</span>;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,43 @@
|
|||
// Rôle : boutique du joueur ; affiche le solde de poussière d'étoiles et achète des ouvertures de paquet.
|
||||
// Rôle : boutique du joueur ; affiche le solde de poussière d'étoiles, achète des ouvertures de paquet et, quand les Expéditions
|
||||
// sont ouvertes, change la poussière en Éclats d'étoile (Pont des Veilleurs).
|
||||
import { useState } from "react";
|
||||
import { buyOpening, buyShopPack } from "./cardsApi.js";
|
||||
import { buyOpening, buyShopPack, convertStardust } from "./cardsApi.js";
|
||||
import { DashboardAside } from "./CardsDashboard.jsx";
|
||||
import { CollectionCardBack } from "./CollectionCardBack.jsx";
|
||||
import { EclatsBalance, StardustBalance } from "./Currency.jsx";
|
||||
import { fillTemplate } from "./dailyShare.js";
|
||||
import { formatEclats } from "./expeditionFormat.js";
|
||||
import { formatStardust } from "./stardustFormat.js";
|
||||
|
||||
export function StardustBalance({ value }) {
|
||||
return <span className="nebula-stardust" aria-label={`${formatStardust(value)} d’étoiles`}><span aria-hidden="true">✦</span>{value.toLocaleString("fr-FR")}</span>;
|
||||
|
||||
// Bornes du serveur par achat (service.js et expedition-progress.js) : la quantité ne dépasse ni elles, ni ce que la poussière paie.
|
||||
const MAX_OPENINGS_PER_PURCHASE = 100;
|
||||
const MAX_ECLATS_PER_CONVERSION = 10_000;
|
||||
const affordable = (stardust, price, limit) => (price > 0 ? Math.min(Math.floor(stardust / price), limit) : limit);
|
||||
|
||||
// Quantité saisie (texte du champ) : jamais au-dessus du maximum payable. Si le solde baisse (un autre achat), la valeur
|
||||
// enregistrée est ramenée au nouveau maximum pendant le rendu, et y reste si le solde remonte.
|
||||
// Un champ vide vaut un seul achat.
|
||||
function useQuantity(max) {
|
||||
const [raw, setRaw] = useState("");
|
||||
const parsed = Number.parseInt(raw, 10);
|
||||
const value = Number.isNaN(parsed) ? raw : String(Math.min(parsed, Math.max(max, 0)));
|
||||
if (value !== raw) setRaw(value);
|
||||
return { value, quantity: Number.parseInt(value, 10) || 1, set: setRaw, reset: () => setRaw("") };
|
||||
}
|
||||
|
||||
function StardustWallet({ wallet }) {
|
||||
// Champ nombre borné, vide au départ avec le maximum en indication : au-delà du maximum, la saisie devient le maximum ;
|
||||
// nulle ou négative à la sortie du champ, elle est effacée (donc un seul achat).
|
||||
function QuantityInput({ value, max, label, busy, onChange }) {
|
||||
return <input className="nds-input nebula-shop-quantity" type="number" inputMode="numeric" min="1" max={Math.max(max, 1)} step="1" value={value} placeholder={max >= 1 ? `max. ${max.toLocaleString("fr-FR")}` : ""} disabled={busy || max < 1} aria-label={label}
|
||||
onChange={(event) => { const next = event.target.value; onChange(next !== "" && Number(next) > max ? String(max) : next); }}
|
||||
onBlur={() => { if (value !== "" && !(Number.parseInt(value, 10) >= 1)) onChange(""); }} />;
|
||||
}
|
||||
|
||||
function StardustWallet({ wallet, showEclats, content }) {
|
||||
return <div className="nds-panel nebula-shop-wallet">
|
||||
<div><span>Votre poussière d’étoiles</span><StardustBalance value={wallet.stardust} /></div>
|
||||
{showEclats && <div><span>{content.eclatsBalance}</span><EclatsBalance value={wallet.eclats ?? 0} /></div>}
|
||||
</div>;
|
||||
}
|
||||
|
||||
|
|
@ -24,11 +50,47 @@ export function ShopOpeningCover() {
|
|||
return <div className="nds-card-cover nebula-shop-item-cover"><img src="/static/img/cards/shop/pack.webp" alt="" loading="lazy" /></div>;
|
||||
}
|
||||
|
||||
export function ShopEclatsCover() {
|
||||
return <div className="nds-card-cover nebula-shop-item-cover"><img src="/static/img/cards/shop/eclats.webp" alt="" loading="lazy" /></div>;
|
||||
}
|
||||
|
||||
// Bouton d'achat pleine largeur : l'action et le coût total en poussière.
|
||||
function BuyButton({ label, total, disabled, type = "submit", onClick }) {
|
||||
return <button className="nds-button nebula-shop-buy" data-variant="primary" type={type} disabled={disabled} aria-label={`${label} · ${formatStardust(total)}`} onClick={onClick}>
|
||||
<span>{label}</span><StardustBalance value={total} />
|
||||
</button>;
|
||||
}
|
||||
|
||||
// Article vendu à l'unité : quantité de 1 au maximum payable avec le prix unitaire à côté, puis le bouton au coût total.
|
||||
// Le maximum se recalcule à chaque changement de solde, achats des autres articles compris.
|
||||
function QuantityItem({ id, cover, title, description, quantityLabel, rateLabel, price, limit, actionLabel, stardust, busy, onSubmit }) {
|
||||
const max = affordable(stardust, price, limit);
|
||||
const { value, quantity, set, reset } = useQuantity(max);
|
||||
const titleId = `nebula-shop-${id}-title`;
|
||||
return <article className="nds-card nebula-shop-item" data-item={id} aria-labelledby={titleId}>
|
||||
{cover}
|
||||
<form className="nds-card-body nebula-shop-item-body" aria-labelledby={titleId} onSubmit={async (event) => { event.preventDefault(); if (await onSubmit(quantity)) reset(); }}>
|
||||
<h4 id={titleId}>{title}</h4>
|
||||
<p className="nebula-form-help">{description}</p>
|
||||
<div className="nebula-shop-item-actions">
|
||||
{/* Pas de libellé visible : le champ porte son nom (aria-label) et le maximum en indication. */}
|
||||
<div className="nebula-shop-quantity-row">
|
||||
<QuantityInput value={value} max={max} label={quantityLabel} busy={busy} onChange={set} />
|
||||
<span className="nebula-shop-item-rate"><StardustBalance value={price} /> {rateLabel}</span>
|
||||
</div>
|
||||
<BuyButton label={actionLabel} total={quantity * price} disabled={busy || max < 1} />
|
||||
{max < 1 && <p className="nebula-form-help" role="status">Il vous manque {formatStardust(price - stardust)}.</p>}
|
||||
</div>
|
||||
</form>
|
||||
</article>;
|
||||
}
|
||||
|
||||
export function ShopPanel({ catalog, state, runMutation, busy, content, onOpenPacks }) {
|
||||
const [notice, setNotice] = useState("");
|
||||
const { wallet, shop } = state;
|
||||
const price = shop.openingPrice;
|
||||
const missing = Math.max(0, price - wallet.stardust);
|
||||
|
||||
// Les Éclats ne servent qu'aux Expéditions : le Pont n'est proposé que lorsqu'elles sont ouvertes.
|
||||
const showEclats = Boolean(state.expeditions?.enabled);
|
||||
|
||||
const shopPack = catalog.collections.find((collection) => collection.packCategory === "shop" && collection.active);
|
||||
const packMissing = Math.max(0, shop.shopPackPrice - wallet.stardust);
|
||||
|
|
@ -40,17 +102,25 @@ export function ShopPanel({ catalog, state, runMutation, busy, content, onOpenPa
|
|||
if (result?.opening) onOpenPacks();
|
||||
}
|
||||
|
||||
async function buy() {
|
||||
async function buy(count) {
|
||||
setNotice("");
|
||||
const result = await runMutation(() => buyOpening());
|
||||
if (result?.player) setNotice("Ouverture achetée : utilisez-la depuis la section Paquets.");
|
||||
const result = await runMutation(() => buyOpening(count));
|
||||
if (result?.player) setNotice(count > 1 ? `${count} ouvertures achetées : utilisez-les depuis la section Paquets.` : "Ouverture achetée : utilisez-la depuis la section Paquets.");
|
||||
return Boolean(result?.player);
|
||||
}
|
||||
|
||||
async function convert(eclats) {
|
||||
setNotice("");
|
||||
const result = await runMutation(() => convertStardust(eclats));
|
||||
if (result) setNotice(fillTemplate(content.eclatsDone, { eclats: formatEclats(eclats) }));
|
||||
return Boolean(result);
|
||||
}
|
||||
|
||||
return <div className="nebula-shop">
|
||||
<div className="nds-section-heading nebula-section-heading">
|
||||
<div><p className="eyebrow">Poussière d’étoiles</p><h2>Boutique</h2></div>
|
||||
</div>
|
||||
<DashboardAside><StardustWallet wallet={wallet} /></DashboardAside>
|
||||
<DashboardAside><StardustWallet wallet={wallet} showEclats={showEclats} content={content} /></DashboardAside>
|
||||
{notice && <p className="nds-inline-notice" data-variant="success" role="status">{notice}</p>}
|
||||
|
||||
<section aria-label="Articles de la boutique">
|
||||
|
|
@ -60,26 +130,20 @@ export function ShopPanel({ catalog, state, runMutation, busy, content, onOpenPa
|
|||
<div className="nds-card-body nebula-shop-item-body">
|
||||
<h4>{shopPack.name}</h4>
|
||||
<p className="nebula-form-help">{content.packDescription}</p>
|
||||
<div className="nds-card-actions nebula-shop-item-actions">
|
||||
<StardustBalance value={shop.shopPackPrice} />
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || packMissing > 0 || Boolean(state.pendingOpening)} onClick={buyPack}>{content.packAction}</button>
|
||||
<div className="nebula-shop-item-actions">
|
||||
<BuyButton label={content.packAction} total={shop.shopPackPrice} type="button" disabled={busy || packMissing > 0 || Boolean(state.pendingOpening)} onClick={buyPack} />
|
||||
{packMissing > 0 && <p className="nebula-form-help">Il vous manque {formatStardust(packMissing)}.</p>}
|
||||
{state.pendingOpening && <p className="nebula-form-help">{content.packPending}</p>}
|
||||
</div>
|
||||
{packMissing > 0 && <p className="nebula-form-help">Il vous manque {formatStardust(packMissing)}.</p>}
|
||||
{state.pendingOpening && <p className="nebula-form-help">{content.packPending}</p>}
|
||||
</div>
|
||||
</article>}
|
||||
<article className="nds-card nebula-shop-item">
|
||||
<ShopOpeningCover />
|
||||
<div className="nds-card-body nebula-shop-item-body">
|
||||
<h4>Ouverture de paquet</h4>
|
||||
<p className="nebula-form-help">À utiliser sur le paquet de votre choix, en plus de votre réserve.</p>
|
||||
<div className="nds-card-actions nebula-shop-item-actions">
|
||||
<StardustBalance value={price} />
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || missing > 0} onClick={buy}>Acheter</button>
|
||||
</div>
|
||||
{missing > 0 && <p className="nebula-form-help">Il vous manque {formatStardust(missing)}.</p>}
|
||||
</div>
|
||||
</article>
|
||||
<QuantityItem id="opening" cover={<ShopOpeningCover />} title="Ouverture de paquet" description="À utiliser sur le paquet de votre choix, en plus de votre réserve."
|
||||
quantityLabel={content.openingLabel} rateLabel={content.unitRate} price={shop.openingPrice} limit={MAX_OPENINGS_PER_PURCHASE} actionLabel="Acheter"
|
||||
stardust={wallet.stardust} busy={busy} onSubmit={buy} />
|
||||
{/* Pont des Veilleurs : de la poussière vers les Éclats, au taux réglé dans les Expéditions ; la conversion inverse n'existe pas. */}
|
||||
{showEclats && <QuantityItem id="eclats" cover={<ShopEclatsCover />} title={content.eclatsTitle} description={content.eclatsDescription}
|
||||
quantityLabel={content.eclatsLabel} rateLabel={content.unitRate} price={shop.stardustPerEclat} limit={MAX_ECLATS_PER_CONVERSION} actionLabel={content.eclatsAction}
|
||||
stardust={wallet.stardust} busy={busy} onSubmit={convert} />}
|
||||
</div>
|
||||
</section>
|
||||
</div>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// Rôle : règle les quêtes de la Guilde des Veilleurs, chacune dans son panneau ; aujourd'hui la Carte du jour.
|
||||
// Rôle : règle les quêtes de la Guilde des Veilleurs, une par onglet (Carte du jour, Expéditions), chacun avec son adresse.
|
||||
import { useState } from "react";
|
||||
import { Tabs } from "../../../components/Tabs.jsx";
|
||||
import { ApplyActions } from "./adminSettingForm.jsx";
|
||||
import { inRange, MAX_VALUE, parse, shopSettingSaver } from "./adminSettings.js";
|
||||
import { ExpeditionSettings } from "./ExpeditionSettings.jsx";
|
||||
|
|
@ -27,14 +28,19 @@ function DailyQuestSettings({ setting, daily, busy, save }) {
|
|||
</section>;
|
||||
}
|
||||
|
||||
export function AdminGuild({ dashboard, busy, runMutation, refreshDashboard }) {
|
||||
// Onglets de la Guilde : l'adresse #/cards/admin/guild/<onglet> garde l'onglet ouvert ; sans onglet, la Carte du jour.
|
||||
const GUILD_TABS = [{ id: "daily", label: "Carte du jour" }, { id: "expeditions", label: "Expéditions" }];
|
||||
|
||||
export function AdminGuild({ dashboard, busy, runMutation, refreshDashboard, tab = "" }) {
|
||||
const setting = dashboard?.shopSetting;
|
||||
const save = shopSettingSaver(setting, runMutation, refreshDashboard);
|
||||
const activeTab = GUILD_TABS.some((item) => item.id === tab) ? tab : GUILD_TABS[0].id;
|
||||
return <div className="nebula-admin-shop-page">
|
||||
<Tabs className="nebula-admin-guild-tabs" size="md" tabs={GUILD_TABS} activeTab={activeTab} onChange={(id) => { window.location.hash = `#/cards/admin/guild/${id}`; }} />
|
||||
{setting
|
||||
? <>
|
||||
<DailyQuestSettings key={setting.dailyReward} setting={setting} daily={dashboard.daily} busy={busy} save={save} />
|
||||
{dashboard.expeditionSettings && <ExpeditionSettings dashboard={dashboard} busy={busy} runMutation={runMutation} refreshDashboard={refreshDashboard} />}
|
||||
{activeTab === "daily" && <DailyQuestSettings key={setting.dailyReward} setting={setting} daily={dashboard.daily} busy={busy} save={save} />}
|
||||
{activeTab === "expeditions" && dashboard.expeditionSettings && <ExpeditionSettings dashboard={dashboard} busy={busy} runMutation={runMutation} refreshDashboard={refreshDashboard} />}
|
||||
</>
|
||||
: <div className="nds-empty-state" aria-busy="true"><p>Chargement des quêtes…</p></div>}
|
||||
</div>;
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ export function AdminPanel({ catalog, state, runMutation, busy, section, subsect
|
|||
{activeSection === "history" && <AdminHistory catalog={catalog} refreshedAt={dashboard?.generatedAt} />}
|
||||
{activeSection === "codes" && <AdminDistributions {...shared} mutateCampaigns={mutateCampaigns} />}
|
||||
{activeSection === "shop" && <AdminShop {...shared} refreshDashboard={refresh} />}
|
||||
{activeSection === "guild" && <AdminGuild {...shared} refreshDashboard={refresh} />}
|
||||
{activeSection === "guild" && <AdminGuild {...shared} refreshDashboard={refresh} tab={subsection} />}
|
||||
</CardsDashboardLayout>
|
||||
</section>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { Tooltip } from "../../../components/Tooltip.jsx";
|
|||
import { SelectDropdown } from "../../../components/SelectDropdown.jsx";
|
||||
import { useState } from "react";
|
||||
import { formatShortRelative } from "./adminFormat.js";
|
||||
import { StardustBalance } from "../Currency.jsx";
|
||||
import { DateValue } from "./DateValue.jsx";
|
||||
|
||||
const SORTS = {
|
||||
|
|
@ -79,7 +80,7 @@ export function AdminPlayers({ catalog, dashboard, dashboardLoading, now }) {
|
|||
<td><strong>{player.totalCards}</strong><RareCounts catalog={catalog} counts={player.rarityCounts} /></td>
|
||||
<td><strong>{player.transfersCount}</strong></td>
|
||||
<td><Reserve player={player} maxOpenings={maxOpenings} now={now} /></td>
|
||||
<td><strong className="nebula-stardust"><span aria-hidden="true">✦</span>{player.stardust.toLocaleString("fr-FR")}</strong></td>
|
||||
<td><StardustBalance value={player.stardust} /></td>
|
||||
</tr>;
|
||||
})}</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
// Rôle : règle la boutique ; poussière d'étoiles gagnée par doublon recyclé et prix des articles achetables.
|
||||
// Rôle : règle la boutique ; poussière d'étoiles gagnée par doublon recyclé et prix des articles achetables, dont l'Éclat
|
||||
// d'étoile (Pont des Veilleurs), enregistré avec les réglages des Expéditions.
|
||||
import { useState } from "react";
|
||||
import { ShopOpeningCover, ShopPackCover } from "../ShopPanel.jsx";
|
||||
import { updateExpeditionSettings } from "../cardsApi.js";
|
||||
import { ShopEclatsCover, ShopOpeningCover, ShopPackCover } from "../ShopPanel.jsx";
|
||||
import { formatStardust } from "../stardustFormat.js";
|
||||
import { ApplyActions } from "./adminSettingForm.jsx";
|
||||
import { ECLAT_PRICE_PATH } from "./expeditionSettingFields.js";
|
||||
import { inRange, MAX_VALUE, parse, shopSettingSaver } from "./adminSettings.js";
|
||||
|
||||
function RecyclingForm({ catalog, setting, busy, save }) {
|
||||
|
|
@ -32,13 +35,26 @@ function RecyclingForm({ catalog, setting, busy, save }) {
|
|||
</section>;
|
||||
}
|
||||
|
||||
function ArticlesForm({ catalog, setting, busy, save }) {
|
||||
const toDraft = () => ({ openingPrice: String(setting.openingPrice), packPrice: String(setting.shopPackPrice) });
|
||||
// Éclat d'étoile : prix, bornes du schéma des Expéditions, ouverture des Expéditions et coût du premier niveau d'une légendaire.
|
||||
function eclatArticle(expedition) {
|
||||
if (!expedition) return null;
|
||||
const { settings, schema } = expedition;
|
||||
const field = schema.find((item) => item.path === ECLAT_PRICE_PATH);
|
||||
const legendaryLevel = settings.progression.costFactor * (settings.power.legendary - settings.progression.costOffset);
|
||||
return { price: settings.progression.stardustPerEclat, min: field.min, max: field.max, open: settings.enabled, legendaryLevel };
|
||||
}
|
||||
|
||||
function ArticlesForm({ catalog, setting, eclat, busy, save, saveEclatPrice }) {
|
||||
const toDraft = () => ({ openingPrice: String(setting.openingPrice), packPrice: String(setting.shopPackPrice), eclatPrice: eclat ? String(eclat.price) : "" });
|
||||
const [draft, setDraft] = useState(toDraft);
|
||||
const openingPrice = parse(draft.openingPrice);
|
||||
const shopPackPrice = parse(draft.packPrice);
|
||||
const valid = inRange(openingPrice, 1, MAX_VALUE) && inRange(shopPackPrice, 1, MAX_VALUE);
|
||||
const changed = valid && (openingPrice !== setting.openingPrice || shopPackPrice !== setting.shopPackPrice);
|
||||
const eclatPrice = parse(draft.eclatPrice);
|
||||
const eclatValid = !eclat || inRange(eclatPrice, eclat.min, eclat.max);
|
||||
const valid = inRange(openingPrice, 1, MAX_VALUE) && inRange(shopPackPrice, 1, MAX_VALUE) && eclatValid;
|
||||
const shopChanged = openingPrice !== setting.openingPrice || shopPackPrice !== setting.shopPackPrice;
|
||||
const eclatChanged = Boolean(eclat) && eclatPrice !== eclat.price;
|
||||
const changed = valid && (shopChanged || eclatChanged);
|
||||
const shopPack = catalog.collections.find((collection) => collection.packCategory === "shop");
|
||||
// Repère : combien de doublons communs il faut recycler pour une ouverture, selon le barème en vigueur.
|
||||
const commonValue = setting.stardustValues.common;
|
||||
|
|
@ -66,13 +82,28 @@ function ArticlesForm({ catalog, setting, busy, save }) {
|
|||
{inRange(openingPrice, 1, MAX_VALUE) && <p className="nebula-form-help" role="status">{commons ? `Une ouverture = ${commons.toLocaleString("fr-FR")} doublon${commons > 1 ? "s" : ""} commun${commons > 1 ? "s" : ""} recyclé${commons > 1 ? "s" : ""}.` : "Les doublons communs ne rapportent rien."}</p>}
|
||||
</div>
|
||||
</article>
|
||||
{eclat && <article className="nds-card nebula-shop-item" data-item="eclats">
|
||||
<ShopEclatsCover />
|
||||
<div className="nds-card-body nebula-shop-item-body nebula-admin-shop-item-fields">
|
||||
<h4>Éclats d’étoile</h4>
|
||||
{!eclat.open && <span className="nds-badge" data-variant="neutral">Fermé aux joueurs</span>}
|
||||
<label><span>Prix d’un Éclat</span><input className="nds-input" aria-label="Prix d’un Éclat d’étoile" type="number" inputMode="numeric" min={eclat.min} max={eclat.max} step="1" {...field("eclatPrice")} /></label>
|
||||
{eclatValid
|
||||
? <p className="nebula-form-help">Premier niveau d’une légendaire ({eclat.legendaryLevel.toLocaleString("fr-FR")} Éclats) = {formatStardust(eclat.legendaryLevel * eclatPrice)}.</p>
|
||||
: <p className="nebula-form-help" role="alert">Prix d’un Éclat : entier de {eclat.min} à {eclat.max.toLocaleString("fr-FR")}.</p>}
|
||||
{!eclat.open && <p className="nebula-form-help">Proposé aux joueurs quand les Expéditions sont ouvertes.</p>}
|
||||
</div>
|
||||
</article>}
|
||||
</div>
|
||||
{!valid && <p className="nebula-form-help" role="alert">Prix entiers de 1 à {MAX_VALUE.toLocaleString("fr-FR")}.</p>}
|
||||
{!(inRange(openingPrice, 1, MAX_VALUE) && inRange(shopPackPrice, 1, MAX_VALUE)) && <p className="nebula-form-help" role="alert">Prix entiers de 1 à {MAX_VALUE.toLocaleString("fr-FR")}.</p>}
|
||||
<ApplyActions
|
||||
busy={busy}
|
||||
changed={changed}
|
||||
onCancel={() => setDraft(toDraft())}
|
||||
onApply={() => save({ openingPrice, shopPackPrice })}
|
||||
onApply={async () => {
|
||||
if (shopChanged) await save({ openingPrice, shopPackPrice });
|
||||
if (eclatChanged) await saveEclatPrice(eclatPrice);
|
||||
}}
|
||||
confirmTitle="Appliquer les nouveaux prix ?"
|
||||
confirmMessage="Les prix s’appliquent immédiatement à tous les joueurs. Les ouvertures déjà achetées ne changent pas."
|
||||
/>
|
||||
|
|
@ -85,6 +116,14 @@ export function AdminShop({ catalog, dashboard, busy, runMutation, refreshDashbo
|
|||
const stardust = players.reduce((total, player) => total + player.stardust, 0);
|
||||
const purchased = players.reduce((total, player) => total + player.purchasedOpenings, 0);
|
||||
const save = shopSettingSaver(setting, runMutation, refreshDashboard);
|
||||
const expedition = dashboard?.expeditionSettings;
|
||||
const eclat = eclatArticle(expedition);
|
||||
// Le prix d'un Éclat vit dans les réglages des Expéditions : on renvoie ces réglages avec ce seul prix changé.
|
||||
const saveEclatPrice = async (price) => {
|
||||
const next = structuredClone(expedition.settings);
|
||||
next.progression.stardustPerEclat = price;
|
||||
if (await runMutation(() => updateExpeditionSettings(next))) await refreshDashboard();
|
||||
};
|
||||
return <div className="nebula-admin-shop-page">
|
||||
<div className="nebula-dashboard-stats">
|
||||
<article className="nds-panel nebula-dashboard-stat"><span className="nebula-dashboard-stat-label">Poussière en circulation</span><strong>{stardust.toLocaleString("fr-FR")}</strong><small>{formatStardust(stardust)} d’étoiles chez les joueurs</small></article>
|
||||
|
|
@ -93,7 +132,7 @@ export function AdminShop({ catalog, dashboard, busy, runMutation, refreshDashbo
|
|||
{setting
|
||||
? <>
|
||||
<RecyclingForm key={JSON.stringify(setting.stardustValues)} catalog={catalog} setting={setting} busy={busy} save={save} />
|
||||
<ArticlesForm key={`${setting.openingPrice}-${setting.shopPackPrice}`} catalog={catalog} setting={setting} busy={busy} save={save} />
|
||||
<ArticlesForm key={`${setting.openingPrice}-${setting.shopPackPrice}-${eclat?.price}`} catalog={catalog} setting={setting} eclat={eclat} busy={busy} save={save} saveEclatPrice={saveEclatPrice} />
|
||||
</>
|
||||
: <div className="nds-empty-state" aria-busy="true"><p>Chargement de la boutique…</p></div>}
|
||||
</div>;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
// Rôle : règle les Expéditions depuis Administration › Guilde : un panneau par groupe de réglages, les destinations, et le suivi du jour.
|
||||
// Rôle : règle les Expéditions depuis Administration › Guilde › Expéditions : bandeau d'état (ouverture et suivi du jour),
|
||||
// puis les réglages rangés en onglets thématiques, avec un seul brouillon et une barre d'application commune.
|
||||
import { useState } from "react";
|
||||
import { Tabs } from "../../../components/Tabs.jsx";
|
||||
import { ConfirmModal } from "../../../components/ToolboxModals.jsx";
|
||||
import { cancelExpedition, updateExpeditionSettings } from "../cardsApi.js";
|
||||
import { DATE_FORMATTER } from "./adminFormat.js";
|
||||
import { ApplyActions } from "./adminSettingForm.jsx";
|
||||
import { inRange, parse } from "./adminSettings.js";
|
||||
import { EXPEDITION_SETTING_GROUPS } from "./expeditionSettingFields.js";
|
||||
import { EXPEDITION_OPEN_PATH, EXPEDITION_SETTING_GROUPS, EXPEDITION_SETTING_THEMES, expeditionSettingLabel, formatSettingValue } from "./expeditionSettingFields.js";
|
||||
|
||||
const DESTINATION_WEIGHT = { min: 0, max: 100 };
|
||||
|
||||
const readPath = (source, path) => path.split(".").reduce((value, key) => value?.[key], source);
|
||||
|
||||
|
|
@ -14,115 +17,216 @@ function writePath(target, path, value) {
|
|||
keys.slice(0, -1).reduce((node, key) => node[key], target)[keys.at(-1)] = value;
|
||||
}
|
||||
|
||||
const same = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
||||
const toDraft = (value) => (typeof value === "boolean" ? value : Array.isArray(value) ? value.map(String) : String(value));
|
||||
const fromDraft = (value) => (typeof value === "boolean" ? value : Array.isArray(value) ? value.map(parse) : parse(value));
|
||||
const validValue = (field, value) => (field.kind === "bool" ? typeof value === "boolean" : (Array.isArray(value) ? value : [value]).every((item) => inRange(item, field.min, field.max)));
|
||||
const withUnit = (value, unit) => (unit ? `${value} ${unit}` : String(value));
|
||||
const formatDefault = (value, unit) => (typeof value === "boolean" ? (value ? "oui" : "non") : Array.isArray(value) ? value.map((item) => withUnit(item, unit)).join(" / ") : withUnit(value, unit));
|
||||
|
||||
// Un panneau : brouillon de ses réglages, vérifiés avec les bornes du serveur ; les contraintes entre réglages sont vérifiées par le serveur.
|
||||
function SettingsGroup({ group, settings, schema, busy, save }) {
|
||||
const fields = group.fields.map((field) => ({ ...field, ...schema.find((item) => item.path === field.path) }));
|
||||
const initial = () => Object.fromEntries(fields.map((field) => [field.path, toDraft(readPath(settings, field.path))]));
|
||||
const [draft, setDraft] = useState(initial);
|
||||
const values = Object.fromEntries(fields.map((field) => [field.path, fromDraft(draft[field.path])]));
|
||||
const invalid = fields.filter((field) => !validValue(field, values[field.path]));
|
||||
const changed = !invalid.length && fields.some((field) => JSON.stringify(values[field.path]) !== JSON.stringify(readPath(settings, field.path)));
|
||||
const set = (path, value) => setDraft((current) => ({ ...current, [path]: value }));
|
||||
// Tous les réglages modifiables ici : ceux des groupes rangés dans un onglet (bornes du schéma) et ceux de chaque destination.
|
||||
// L'ouverture (bandeau d'état) et le prix d'un Éclat (Boutique) se règlent ailleurs.
|
||||
function editableFields(schema, destinations) {
|
||||
const fromGroups = EXPEDITION_SETTING_GROUPS.filter((group) => PANEL_THEME.has(group.id)).flatMap((group) => group.fields
|
||||
.map((field) => ({ ...field, ...schema.find((item) => item.path === field.path), panel: group.id })));
|
||||
const fromDestinations = destinations.flatMap((destination) => [
|
||||
{ path: `destinations.${destination.id}.active`, kind: "bool", panel: "destinations" },
|
||||
{ path: `destinations.${destination.id}.weight`, kind: "int", ...DESTINATION_WEIGHT, panel: "destinations" }
|
||||
]);
|
||||
return [...fromGroups, ...fromDestinations];
|
||||
}
|
||||
|
||||
const PANEL_THEME = new Map(EXPEDITION_SETTING_THEMES.flatMap((theme) => theme.panels.map((panel) => [panel, theme.id])));
|
||||
|
||||
// Brouillon commun à tous les onglets : seules les valeurs touchées y figurent, le reste se lit dans les réglages enregistrés.
|
||||
function useSettingsDraft(settings, fields) {
|
||||
const [draft, setDraft] = useState({});
|
||||
const value = (path) => (path in draft ? fromDraft(draft[path]) : readPath(settings, path));
|
||||
const raw = (path) => (path in draft ? draft[path] : toDraft(readPath(settings, path)));
|
||||
const touched = fields.filter((field) => field.path in draft);
|
||||
const invalid = touched.filter((field) => !validValue(field, value(field.path)));
|
||||
const changes = touched.filter((field) => validValue(field, value(field.path)) && !same(value(field.path), readPath(settings, field.path)));
|
||||
const set = (path, next) => setDraft((current) => ({ ...current, [path]: next }));
|
||||
const reset = () => setDraft({});
|
||||
return { value, raw, invalid, changes, set, reset };
|
||||
}
|
||||
|
||||
function DefaultHint({ field, value, defaults, busy, onReset }) {
|
||||
const fallback = readPath(defaults, field.path);
|
||||
if (fallback === undefined || same(value, fallback)) return null;
|
||||
return <button className="nebula-admin-setting-default" type="button" disabled={busy} title="Rétablir la valeur par défaut" onClick={onReset}>
|
||||
Défaut : {formatDefault(fallback, field.unit)} <span aria-hidden="true">↺</span>
|
||||
</button>;
|
||||
}
|
||||
|
||||
function NumberInput({ field, value, label, busy, onChange }) {
|
||||
return <span className="nebula-admin-setting-input" data-unit={field.unit || undefined}>
|
||||
<input className="nds-input" type="number" inputMode="numeric" min={field.min} max={field.max} step="1" value={value} disabled={busy} aria-label={label} aria-invalid={!inRange(parse(value), field.min, field.max) || undefined} onChange={(event) => onChange(event.target.value)} />
|
||||
{field.unit && <span aria-hidden="true">{field.unit}</span>}
|
||||
</span>;
|
||||
}
|
||||
|
||||
// Un réglage : interrupteur, nombre ou suite de nombres, avec son état (modifié, invalide) et la valeur par défaut s'il s'en écarte.
|
||||
function SettingField({ field, draft, settings, defaults, busy }) {
|
||||
const value = draft.value(field.path);
|
||||
const raw = draft.raw(field.path);
|
||||
const changed = !same(value, readPath(settings, field.path));
|
||||
const invalid = !validValue(field, value);
|
||||
const label = field.unit ? `${field.label} (${field.unit})` : field.label;
|
||||
const state = { "data-changed": changed || undefined, "data-invalid": invalid || undefined };
|
||||
const hint = <DefaultHint field={field} value={value} defaults={defaults} busy={busy} onReset={() => draft.set(field.path, toDraft(readPath(defaults, field.path)))} />;
|
||||
const error = invalid && <small role="alert">Entier de {field.min.toLocaleString("fr-FR")} à {field.max.toLocaleString("fr-FR")}</small>;
|
||||
if (field.kind === "bool") return <div className="nebula-admin-expedition-field" {...state}>
|
||||
<span className="nebula-admin-setting-label">{field.label}</span>
|
||||
<button className="nds-button" data-size="sm" data-variant={raw ? "primary" : "secondary"} type="button" aria-pressed={raw} aria-label={field.label} disabled={busy} onClick={() => draft.set(field.path, !raw)}>{raw ? "Oui" : "Non"}</button>
|
||||
{hint}
|
||||
</div>;
|
||||
if (Array.isArray(raw)) return <fieldset className="nebula-admin-expedition-field" {...state}>
|
||||
<legend>{field.label}</legend>
|
||||
<div className="nebula-admin-expedition-items">{raw.map((item, index) => <label key={index}><span>{field.items?.[index] ?? index + 1}</span>
|
||||
<NumberInput field={field} value={item} label={`${label} · ${field.items?.[index] ?? index + 1}`} busy={busy} onChange={(next) => draft.set(field.path, raw.map((current, position) => (position === index ? next : current)))} />
|
||||
</label>)}</div>
|
||||
{error}{hint}
|
||||
</fieldset>;
|
||||
return <label className="nebula-admin-expedition-field" {...state}><span className="nebula-admin-setting-label">{field.label}</span>
|
||||
<NumberInput field={field} value={raw} label={label} busy={busy} onChange={(next) => draft.set(field.path, next)} />
|
||||
{error}{hint}
|
||||
</label>;
|
||||
}
|
||||
|
||||
function SettingsGroup({ group, fields, ...props }) {
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-expedition-group" aria-labelledby={`nebula-admin-expedition-${group.id}`}>
|
||||
<div className="nds-section-heading nebula-admin-panel-heading"><h3 id={`nebula-admin-expedition-${group.id}`}>{group.title}</h3></div>
|
||||
<p className="nebula-form-help">{group.help}</p>
|
||||
<div className="nebula-admin-expedition-fields">{fields.map((field) => {
|
||||
const value = draft[field.path];
|
||||
if (field.kind === "bool") return <div key={field.path} className="nebula-admin-expedition-field">
|
||||
<span>{field.label}</span>
|
||||
<button className="nds-button" data-size="sm" data-variant={value ? "primary" : "secondary"} type="button" aria-pressed={value} aria-label={field.label} disabled={busy} onClick={() => set(field.path, !value)}>{value ? "Oui" : "Non"}</button>
|
||||
</div>;
|
||||
if (Array.isArray(value)) return <fieldset key={field.path} className="nebula-admin-expedition-field">
|
||||
<legend>{field.label}</legend>
|
||||
<div className="nebula-admin-expedition-items">{value.map((item, index) => <label key={index}><span>{field.items?.[index] ?? index + 1}</span>
|
||||
<input className="nds-input" type="number" inputMode="numeric" min={field.min} max={field.max} step="1" value={item} disabled={busy} onChange={(event) => set(field.path, value.map((current, position) => (position === index ? event.target.value : current)))} />
|
||||
</label>)}</div>
|
||||
</fieldset>;
|
||||
return <label key={field.path} className="nebula-admin-expedition-field"><span>{field.label}</span>
|
||||
<input className="nds-input" type="number" inputMode="numeric" min={field.min} max={field.max} step="1" value={value} disabled={busy} onChange={(event) => set(field.path, event.target.value)} />
|
||||
</label>;
|
||||
})}</div>
|
||||
{invalid.length > 0 && <p className="nebula-form-help" role="alert">{invalid.map((field) => `${field.label} : entier de ${field.min.toLocaleString("fr-FR")} à ${field.max.toLocaleString("fr-FR")}`).join(" · ")}</p>}
|
||||
<ApplyActions
|
||||
busy={busy}
|
||||
changed={changed}
|
||||
onCancel={() => setDraft(initial())}
|
||||
onApply={() => save((next) => fields.forEach((field) => writePath(next, field.path, values[field.path])))}
|
||||
confirmTitle={`Appliquer les réglages « ${group.title} » ?`}
|
||||
confirmMessage="Les nouveaux réglages s’appliquent aux prochains départs. Les expéditions en route gardent ceux de leur départ."
|
||||
/>
|
||||
<div className="nebula-admin-expedition-fields">{fields.map((field) => <SettingField key={field.path} field={field} {...props} />)}</div>
|
||||
</section>;
|
||||
}
|
||||
|
||||
// Destinations : proposées ou non, et poids dans le tirage du jour. Leurs textes vivent dans le fichier du serveur.
|
||||
function DestinationSettings({ settings, destinations, busy, save }) {
|
||||
const initial = () => Object.fromEntries(destinations.map((destination) => [destination.id, { active: settings.destinations[destination.id].active, weight: String(settings.destinations[destination.id].weight) }]));
|
||||
const [draft, setDraft] = useState(initial);
|
||||
const invalid = destinations.filter((destination) => !inRange(parse(draft[destination.id].weight), 0, 100));
|
||||
const changed = !invalid.length && destinations.some((destination) => draft[destination.id].active !== settings.destinations[destination.id].active || parse(draft[destination.id].weight) !== settings.destinations[destination.id].weight);
|
||||
const set = (id, changes) => setDraft((current) => ({ ...current, [id]: { ...current[id], ...changes } }));
|
||||
function DestinationSettings({ destinations, draft, settings, defaults, busy }) {
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-expedition-group" aria-labelledby="nebula-admin-expedition-destinations">
|
||||
<div className="nds-section-heading nebula-admin-panel-heading"><h3 id="nebula-admin-expedition-destinations">Destinations</h3></div>
|
||||
<p className="nebula-form-help">Une destination retirée n’est plus tirée ; le poids règle sa fréquence parmi les destinations proposées. Les destinations cachées ne sont jamais tirées.</p>
|
||||
<ul className="nebula-admin-expedition-destinations">{destinations.map((destination) => <li key={destination.id} className="nds-list-row">
|
||||
<strong>{destination.name}{destination.hidden && <span className="nds-badge" data-variant="neutral">Cachée</span>}</strong>
|
||||
<button className="nds-button" data-size="sm" data-variant={draft[destination.id].active ? "primary" : "secondary"} type="button" aria-pressed={draft[destination.id].active} aria-label={`${destination.name} proposée`} disabled={busy} onClick={() => set(destination.id, { active: !draft[destination.id].active })}>{draft[destination.id].active ? "Proposée" : "Retirée"}</button>
|
||||
<label><span>Poids</span><input className="nds-input" type="number" inputMode="numeric" min="0" max="100" step="1" value={draft[destination.id].weight} disabled={busy} aria-label={`Poids de ${destination.name}`} onChange={(event) => set(destination.id, { weight: event.target.value })} /></label>
|
||||
</li>)}</ul>
|
||||
{invalid.length > 0 && <p className="nebula-form-help" role="alert">Poids : entier de 0 à 100.</p>}
|
||||
<ApplyActions
|
||||
busy={busy}
|
||||
changed={changed}
|
||||
onCancel={() => setDraft(initial())}
|
||||
onApply={() => save((next) => destinations.forEach((destination) => { next.destinations[destination.id] = { active: draft[destination.id].active, weight: parse(draft[destination.id].weight) }; }))}
|
||||
confirmTitle="Appliquer les destinations ?"
|
||||
confirmMessage="Le changement vaut pour les prochains tirages : les destinations déjà proposées aujourd’hui restent jusqu’à minuit."
|
||||
/>
|
||||
<p className="nebula-form-help">Une destination retirée n’est plus tirée ; le poids règle sa fréquence parmi les destinations proposées. Les destinations cachées ne sont jamais tirées. Le changement vaut pour les prochains tirages : celles déjà proposées aujourd’hui restent jusqu’à minuit.</p>
|
||||
<ul className="nebula-admin-expedition-destinations">{destinations.map((destination) => {
|
||||
const activePath = `destinations.${destination.id}.active`;
|
||||
const weightField = { path: `destinations.${destination.id}.weight`, ...DESTINATION_WEIGHT };
|
||||
const active = draft.raw(activePath);
|
||||
const weight = draft.raw(weightField.path);
|
||||
const changed = !same(draft.value(activePath), readPath(settings, activePath)) || !same(draft.value(weightField.path), readPath(settings, weightField.path));
|
||||
return <li key={destination.id} className="nds-list-row" data-changed={changed || undefined}>
|
||||
<strong>{destination.name}{destination.hidden && <span className="nds-badge" data-variant="neutral">Cachée</span>}</strong>
|
||||
<button className="nds-button" data-size="sm" data-variant={active ? "primary" : "secondary"} type="button" aria-pressed={active} aria-label={`${destination.name} proposée`} disabled={busy} onClick={() => draft.set(activePath, !active)}>{active ? "Proposée" : "Retirée"}</button>
|
||||
<label><span>Poids</span><NumberInput field={weightField} value={weight} label={`Poids de ${destination.name}`} busy={busy} onChange={(next) => draft.set(weightField.path, next)} /></label>
|
||||
<DefaultHint field={weightField} value={draft.value(weightField.path)} defaults={defaults} busy={busy} onReset={() => draft.set(weightField.path, toDraft(readPath(defaults, weightField.path)))} />
|
||||
</li>;
|
||||
})}</ul>
|
||||
</section>;
|
||||
}
|
||||
|
||||
function ExpeditionsToday({ today, destinations, busy, onCancel }) {
|
||||
const [cancelling, setCancelling] = useState(null);
|
||||
// Bandeau d'état : ouverture (appliquée tout de suite, sans toucher au brouillon) et activité du jour, avec l'annulation d'une expédition.
|
||||
function ExpeditionsStatus({ enabled, today, destinations, busy, onToggle, onCancel }) {
|
||||
const [confirming, setConfirming] = useState(null);
|
||||
const name = (id) => destinations.find((destination) => destination.id === id)?.name || id;
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-expedition-group" aria-labelledby="nebula-admin-expedition-today">
|
||||
<div className="nds-section-heading nebula-admin-panel-heading"><h3 id="nebula-admin-expedition-today">Aujourd’hui</h3></div>
|
||||
<p className="nebula-admin-guild-today"><strong>{today.launches}</strong> départ{today.launches > 1 ? "s" : ""} · <strong>{today.running}</strong> en route · <strong>{today.returnedUnclaimed}</strong> butin{today.returnedUnclaimed > 1 ? "s" : ""} à récupérer.</p>
|
||||
return <section className="nds-panel nebula-admin-shop nebula-admin-expedition-status" data-open={enabled} aria-labelledby="nebula-admin-expedition-status-title">
|
||||
<div className="nebula-admin-expedition-status-head">
|
||||
<div>
|
||||
<h3 id="nebula-admin-expedition-status-title">Expéditions <span className="nds-badge" data-variant={enabled ? "success" : "neutral"}>{enabled ? "Ouvertes aux joueurs" : "Fermées aux joueurs"}</span></h3>
|
||||
<p className="nebula-admin-guild-today">Aujourd’hui : <strong>{today.launches}</strong> départ{today.launches > 1 ? "s" : ""} · <strong>{today.running}</strong> en route · <strong>{today.returnedUnclaimed}</strong> butin{today.returnedUnclaimed > 1 ? "s" : ""} à récupérer.</p>
|
||||
</div>
|
||||
<button className="nds-button" data-size="sm" data-variant={enabled ? "secondary" : "primary"} type="button" disabled={busy} onClick={() => setConfirming("toggle")}>{enabled ? "Fermer les Expéditions" : "Ouvrir les Expéditions"}</button>
|
||||
</div>
|
||||
{today.runningList.length > 0 && <ul className="nebula-admin-expedition-destinations">{today.runningList.map((expedition) => <li key={expedition.id} className="nds-list-row">
|
||||
<strong>{name(expedition.destinationId)} · {"★".repeat(expedition.stars)}</strong>
|
||||
<span>{expedition.creatorName} · retour le {DATE_FORMATTER.format(expedition.returnsAt)}</span>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => setCancelling(expedition)}>Annuler</button>
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} onClick={() => setConfirming(expedition)}>Annuler</button>
|
||||
</li>)}</ul>}
|
||||
{cancelling && <ConfirmModal
|
||||
{confirming === "toggle" && <ConfirmModal
|
||||
title={enabled ? "Fermer les Expéditions ?" : "Ouvrir les Expéditions ?"}
|
||||
message={enabled
|
||||
? "Plus aucun départ ni inscription à un groupe. Les expéditions en route reviennent normalement et leur butin reste à récupérer."
|
||||
: "La tuile des Expéditions apparaît dans la Guilde et les joueurs peuvent partir dès maintenant."}
|
||||
confirmLabel={enabled ? "Fermer" : "Ouvrir"}
|
||||
onClose={async (confirmed) => {
|
||||
setConfirming(null);
|
||||
if (confirmed) await onToggle(!enabled);
|
||||
}}
|
||||
/>}
|
||||
{confirming && confirming !== "toggle" && <ConfirmModal
|
||||
title="Annuler cette expédition ?"
|
||||
message={`L’expédition vers ${name(cancelling.destinationId)} de ${cancelling.creatorName} s’arrête : les cartes sont libérées, sans butin.`}
|
||||
message={`L’expédition vers ${name(confirming.destinationId)} de ${confirming.creatorName} s’arrête : les cartes sont libérées, sans butin.`}
|
||||
confirmLabel="Annuler l’expédition"
|
||||
onClose={async (confirmed) => {
|
||||
const target = cancelling;
|
||||
setCancelling(null);
|
||||
const target = confirming;
|
||||
setConfirming(null);
|
||||
if (confirmed) await onCancel(target.id);
|
||||
}}
|
||||
/>}
|
||||
</section>;
|
||||
}
|
||||
|
||||
// Barre commune : nombre de réglages modifiés ou invalides, puis confirmation avec la liste des changements.
|
||||
function ApplyBar({ draft, settings, destinations, busy, onApply }) {
|
||||
const [confirming, setConfirming] = useState(false);
|
||||
const { changes, invalid } = draft;
|
||||
if (!changes.length && !invalid.length) return null;
|
||||
const count = (total, word) => `${total} réglage${total > 1 ? "s" : ""} ${word}${total > 1 ? "s" : ""}`;
|
||||
return <div className="nds-panel nebula-admin-apply-bar" role="region" aria-label="Modifications en attente">
|
||||
<p role="status">{[changes.length && count(changes.length, "modifié"), invalid.length && count(invalid.length, "invalide")].filter(Boolean).join(" · ")}</p>
|
||||
<div className="nds-toolbar">
|
||||
<button className="nds-button" data-size="sm" data-variant="secondary" type="button" disabled={busy} aria-label="Annuler les modifications" onClick={draft.reset}>Annuler</button>
|
||||
<button className="nds-button" data-size="sm" data-variant="primary" type="button" disabled={busy || !changes.length || invalid.length > 0} onClick={() => setConfirming(true)}>Appliquer</button>
|
||||
</div>
|
||||
{confirming && <ConfirmModal
|
||||
title={`Appliquer ${count(changes.length, "modifié")} ?`}
|
||||
message="Les nouveaux réglages s’appliquent aux prochains départs. Les expéditions en route gardent ceux de leur départ."
|
||||
confirmLabel="Appliquer"
|
||||
onClose={async (confirmed) => {
|
||||
setConfirming(false);
|
||||
if (confirmed) await onApply();
|
||||
}}
|
||||
>
|
||||
<ul className="nebula-admin-apply-changes">{changes.map((field) => <li key={field.path}>
|
||||
<span>{expeditionSettingLabel(field.path, destinations)}</span> : {formatSettingValue(readPath(settings, field.path))} → <strong>{formatSettingValue(draft.value(field.path))}</strong>
|
||||
</li>)}</ul>
|
||||
</ConfirmModal>}
|
||||
</div>;
|
||||
}
|
||||
|
||||
export function ExpeditionSettings({ dashboard, busy, runMutation, refreshDashboard }) {
|
||||
const { settings, schema, destinations, updatedAt } = dashboard.expeditionSettings;
|
||||
const { settings, defaults, schema, destinations } = dashboard.expeditionSettings;
|
||||
const [themeId, setThemeId] = useState(EXPEDITION_SETTING_THEMES[0].id);
|
||||
const fields = editableFields(schema, destinations);
|
||||
const draft = useSettingsDraft(settings, fields);
|
||||
const save = async (apply) => {
|
||||
const next = structuredClone(settings);
|
||||
apply(next);
|
||||
if (await runMutation(() => updateExpeditionSettings(next))) await refreshDashboard();
|
||||
const saved = await runMutation(() => updateExpeditionSettings(next));
|
||||
if (saved) await refreshDashboard();
|
||||
return saved;
|
||||
};
|
||||
const apply = async () => {
|
||||
if (await save((next) => draft.changes.forEach((field) => writePath(next, field.path, draft.value(field.path))))) draft.reset();
|
||||
};
|
||||
const cancel = async (id) => {
|
||||
if (await runMutation(() => cancelExpedition(id))) await refreshDashboard();
|
||||
};
|
||||
return <div className="nebula-admin-expeditions" aria-labelledby="nebula-admin-expeditions-title">
|
||||
<h2 id="nebula-admin-expeditions-title">Expéditions</h2>
|
||||
<ExpeditionsToday today={dashboard.expeditionsToday} destinations={destinations} busy={busy} onCancel={cancel} />
|
||||
{EXPEDITION_SETTING_GROUPS.map((group) => <SettingsGroup key={`${group.id}-${updatedAt}`} group={group} settings={settings} schema={schema} busy={busy} save={save} />)}
|
||||
<DestinationSettings key={`destinations-${updatedAt}`} settings={settings} destinations={destinations} busy={busy} save={save} />
|
||||
const pendingIn = (theme) => [...draft.changes, ...draft.invalid].filter((field) => PANEL_THEME.get(field.panel) === theme.id).length;
|
||||
const theme = EXPEDITION_SETTING_THEMES.find((item) => item.id === themeId);
|
||||
const props = { draft, settings, defaults, busy };
|
||||
return <div className="nebula-admin-expeditions">
|
||||
<ExpeditionsStatus enabled={settings[EXPEDITION_OPEN_PATH]} today={dashboard.expeditionsToday} destinations={destinations} busy={busy} onToggle={(open) => save((next) => { next[EXPEDITION_OPEN_PATH] = open; })} onCancel={cancel} />
|
||||
<Tabs
|
||||
className="nebula-admin-expedition-themes"
|
||||
tabs={EXPEDITION_SETTING_THEMES.map((item) => {
|
||||
const pending = pendingIn(item);
|
||||
return { id: item.id, label: pending ? `${item.title} (${pending})` : item.title };
|
||||
})}
|
||||
activeTab={themeId}
|
||||
onChange={setThemeId}
|
||||
/>
|
||||
{theme.panels.map((panel) => (panel === "destinations"
|
||||
? <DestinationSettings key={panel} destinations={destinations} {...props} />
|
||||
: <SettingsGroup key={panel} group={EXPEDITION_SETTING_GROUPS.find((group) => group.id === panel)} fields={fields.filter((field) => field.panel === panel)} {...props} />))}
|
||||
<ApplyBar draft={draft} settings={settings} destinations={destinations} busy={busy} onApply={apply} />
|
||||
</div>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,47 @@
|
|||
// Rôle : libellés et regroupement des réglages des Expéditions pour l'administration et son historique.
|
||||
// Rôle : libellés, unités et regroupement des réglages des Expéditions pour l'administration et son historique.
|
||||
// Les bornes viennent du schéma du serveur (tableau de bord) ; un test vérifie que chaque réglage du schéma a ici son libellé.
|
||||
// L'unité s'affiche dans le champ ; l'historique la remet entre parenthèses après le libellé.
|
||||
|
||||
const STARS = ["1 ★", "2 ★", "3 ★", "4 ★", "5 ★"];
|
||||
const STATS_IN_ORDER = ["principale", "2e stat", "3e stat", "4e stat"];
|
||||
|
||||
// L'ouverture se règle à part, dans le bandeau d'état, et s'applique tout de suite.
|
||||
export const EXPEDITION_OPEN_PATH = "enabled";
|
||||
// Le prix d'un Éclat (Pont des Veilleurs) se règle dans Administration › Boutique, avec les autres articles.
|
||||
export const ECLAT_PRICE_PATH = "progression.stardustPerEclat";
|
||||
|
||||
// Onglets de l'administration : chacun réunit des panneaux (groupes de réglages, ou « destinations », la liste des destinations).
|
||||
export const EXPEDITION_SETTING_THEMES = [
|
||||
{ id: "flow", title: "Déroulement", panels: ["general", "group", "destinations"] },
|
||||
{ id: "cards", title: "Cartes", panels: ["power", "progression", "equipment"] },
|
||||
{ id: "rewards", title: "Récompenses", panels: ["loot", "items", "powers"] },
|
||||
{ id: "balance", title: "Équilibrage", panels: ["requirements", "score"] }
|
||||
];
|
||||
|
||||
export const EXPEDITION_SETTING_GROUPS = [
|
||||
{
|
||||
id: "opening",
|
||||
title: "Ouverture",
|
||||
fields: [{ path: EXPEDITION_OPEN_PATH, label: "Expéditions ouvertes aux joueurs" }]
|
||||
},
|
||||
{
|
||||
id: "shop",
|
||||
title: "Boutique",
|
||||
fields: [{ path: ECLAT_PRICE_PATH, label: "Prix d’un Éclat d’étoile en boutique", unit: "poussières" }]
|
||||
},
|
||||
{
|
||||
id: "general",
|
||||
title: "Général",
|
||||
help: "Ouverture, destinations proposées chaque jour, durées et règles du solo.",
|
||||
help: "Alertes, destinations proposées chaque jour, durées et règles du solo. Chaque destination du jour tire un niveau, un de chaque niveau par jour : au plus bas, le solo part avec son étoile minimale, puis une étoile de plus par niveau, sans dépasser son étoile maximale. La destination cachée prend le niveau le plus haut.",
|
||||
fields: [
|
||||
{ path: "enabled", label: "Expéditions ouvertes aux joueurs" },
|
||||
{ path: "alerts.enabled", label: "Alertes Discord envoyées" },
|
||||
{ path: "day.destinationsPerDay", label: "Destinations proposées par jour" },
|
||||
{ path: "day.avoidRepeatDays", label: "Jours avant qu’une destination revienne" },
|
||||
{ path: "durations.hours", label: "Durées proposées (heures)", items: ["Courte", "Moyenne", "Longue"] },
|
||||
{ path: "day.avoidRepeatDays", label: "Délai avant qu’une destination revienne", unit: "j" },
|
||||
{ path: "durations.hours", label: "Durées proposées", unit: "h", items: ["Courte", "Moyenne", "Longue"] },
|
||||
{ path: "solo.cards", label: "Cartes en solo" },
|
||||
{ path: "solo.maxConcurrent", label: "Expéditions solo en même temps" },
|
||||
{ path: "solo.minStars", label: "Étoile minimale en solo" },
|
||||
{ path: "solo.maxStars", label: "Étoile maximale en solo" }
|
||||
{ path: "solo.minStars", label: "Étoiles en solo au niveau le plus bas" },
|
||||
{ path: "solo.maxStars", label: "Étoiles en solo au plus" }
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -29,12 +52,12 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
{ path: "group.slots", label: "Places par groupe" },
|
||||
{ path: "group.minPlayers", label: "Joueurs minimum pour partir" },
|
||||
{ path: "group.maxConcurrent", label: "Groupes en même temps par joueur" },
|
||||
{ path: "group.minStars", label: "Étoile minimale en groupe" },
|
||||
{ path: "group.maxStars", label: "Étoile maximale en groupe" },
|
||||
{ path: "group.recruitHours", label: "Période d’inscription maximale (heures)" },
|
||||
{ path: "group.lootPct", label: "Multiplicateur de butin par joueur (%)", items: ["2 joueurs", "3 joueurs", "4 joueurs"] },
|
||||
{ path: "group.minStars", label: "Étoiles en groupe au niveau le plus bas" },
|
||||
{ path: "group.maxStars", label: "Étoiles en groupe au plus" },
|
||||
{ path: "group.recruitHours", label: "Période d’inscription maximale", unit: "h" },
|
||||
{ path: "group.lootPct", label: "Multiplicateur de butin selon les joueurs", unit: "%", items: ["2 joueurs", "3 joueurs", "4 joueurs"] },
|
||||
{ path: "group.npcStat", label: "Stats du Veilleur de la Guilde (chacune)" },
|
||||
{ path: "group.cohesionPct", label: "Bonus de cohésion, collections toutes différentes (%)" }
|
||||
{ path: "group.cohesionPct", label: "Bonus de cohésion, collections toutes différentes", unit: "%" }
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -48,19 +71,18 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
{ path: "power.mythic", label: "Puissance de base d’une mythique" },
|
||||
{ path: "power.perLevel", label: "Gain de Puissance par niveau" },
|
||||
{ path: "power.cap", label: "Plafond de Puissance" },
|
||||
{ path: "roles.multiplierPct", label: "Multiplicateur du rôle (%)" }
|
||||
{ path: "roles.multiplierPct", label: "Multiplicateur du rôle", unit: "%" }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "progression",
|
||||
title: "Améliorations",
|
||||
help: "Coût d’un niveau en Éclats selon la Puissance actuelle, niveaux donnés par un doublon de la même carte, expérience gagnée à chaque retour et taux du pont depuis la poussière.",
|
||||
help: "Coût d’un niveau en Éclats selon la Puissance actuelle, niveaux donnés par un doublon de la même carte et expérience gagnée à chaque retour. Le prix d’un Éclat se règle dans la Boutique.",
|
||||
fields: [
|
||||
{ path: "progression.costFactor", label: "Éclats par point de Puissance au-dessus du décalage" },
|
||||
{ path: "progression.costOffset", label: "Décalage du coût (Puissance)" },
|
||||
{ path: "progression.duplicateLevels", label: "Niveaux donnés par un doublon" },
|
||||
{ path: "progression.fieldXpPct", label: "Expérience de terrain par retour (% d’un niveau)" },
|
||||
{ path: "progression.stardustPerEclat", label: "Poussières pour 1 Éclat (pont)" }
|
||||
{ path: "progression.fieldXpPct", label: "Expérience de terrain par retour, en part d’un niveau", unit: "%" }
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -72,8 +94,8 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
{ path: "equipment.secondSlotPower", label: "Puissance qui ouvre le 2e emplacement" },
|
||||
{ path: "equipment.thirdSlotPower", label: "Puissance qui ouvre le 3e emplacement" },
|
||||
{ path: "equipment.synergyBonus", label: "Points ajoutés par une synergie d’équipement" },
|
||||
{ path: "synergy.affinityPct", label: "Affinité avec la destination (% de score)" },
|
||||
{ path: "synergy.resonancePct", label: "Valeur d’une Résonance (% de score)" },
|
||||
{ path: "synergy.affinityPct", label: "Affinité avec la destination, en score", unit: "%" },
|
||||
{ path: "synergy.resonancePct", label: "Valeur d’une Résonance, en score", unit: "%" },
|
||||
{ path: "synergy.maxResonances", label: "Résonances actives au plus" },
|
||||
{ path: "synergy.sistersCount", label: "Cartes d’un même thème pour les Étoiles sœurs" }
|
||||
]
|
||||
|
|
@ -83,19 +105,19 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
title: "Pouvoirs et Carnets des Veilleurs",
|
||||
help: "Avantage et contrepartie de chaque pouvoir des communes des Carnets (chaque pouvoir compte une fois par équipe), et chance de rapporter une carte des Carnets.",
|
||||
fields: [
|
||||
{ path: "powers.longsightPackPct", label: "Longue-vue : chance de paquet en plus (%)" },
|
||||
{ path: "powers.longsightExtraHours", label: "Longue-vue : heures de trajet en plus" },
|
||||
{ path: "powers.rationsTimePct", label: "Provisions : temps de trajet en moins (%)" },
|
||||
{ path: "powers.rationsLootPct", label: "Provisions : butin en moins (%)" },
|
||||
{ path: "powers.treasureMapScorePct", label: "Carte au trésor : score en moins (%)" },
|
||||
{ path: "powers.madCompassLootPct", label: "Boussole folle : butin en plus (%)" },
|
||||
{ path: "powers.starNetCardPct", label: "Filet à étoiles filantes : chance d’une carte des Carnets (%)" },
|
||||
{ path: "powers.longsightPackPct", label: "Longue-vue : chance de paquet en plus", unit: "%" },
|
||||
{ path: "powers.longsightExtraHours", label: "Longue-vue : trajet en plus", unit: "h" },
|
||||
{ path: "powers.rationsTimePct", label: "Provisions : temps de trajet en moins", unit: "%" },
|
||||
{ path: "powers.rationsLootPct", label: "Provisions : butin en moins", unit: "%" },
|
||||
{ path: "powers.treasureMapScorePct", label: "Carte au trésor : score en moins", unit: "%" },
|
||||
{ path: "powers.madCompassLootPct", label: "Boussole folle : butin en plus", unit: "%" },
|
||||
{ path: "powers.starNetCardPct", label: "Filet à étoiles filantes : chance d’une carte des Carnets", unit: "%" },
|
||||
{ path: "powers.starNetFortune", label: "Filet à étoiles filantes : Fortune en moins (équipe)" },
|
||||
{ path: "powers.stormLanternDangerPct", label: "Lanterne de tempête : malus des dangers en moins (%)" },
|
||||
{ path: "powers.stormLanternExtraHours", label: "Lanterne de tempête : heures de trajet en plus" },
|
||||
{ path: "powers.fogBellSynergyPct", label: "Cloche de brume : synergie en plus, en groupe (%)" },
|
||||
{ path: "powers.fogBellSoloLootPct", label: "Cloche de brume : butin en moins, en solo (%)" },
|
||||
{ path: "carnets.cardPerHourPermille", label: "Carte des Carnets par heure (‰)" },
|
||||
{ path: "powers.stormLanternDangerPct", label: "Lanterne de tempête : malus des dangers en moins", unit: "%" },
|
||||
{ path: "powers.stormLanternExtraHours", label: "Lanterne de tempête : trajet en plus", unit: "h" },
|
||||
{ path: "powers.fogBellSynergyPct", label: "Cloche de brume : synergie en plus, en groupe", unit: "%" },
|
||||
{ path: "powers.fogBellSoloLootPct", label: "Cloche de brume : butin en moins, en solo", unit: "%" },
|
||||
{ path: "carnets.cardPerHourPermille", label: "Chance d’une carte des Carnets par heure", unit: "‰" },
|
||||
{ path: "carnets.maxCards", label: "Cartes des Carnets au plus par expédition" }
|
||||
]
|
||||
},
|
||||
|
|
@ -104,11 +126,11 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
title: "Objets",
|
||||
help: "Chance de rapporter un objet (proportionnelle au butin), poids de chaque objet, Orientation qui ouvre la partie cachée (fragments, burins, plans) et butin des destinations cachées.",
|
||||
fields: [
|
||||
{ path: "items.chancePerHourPermille", label: "Chance d’objet par heure (‰)" },
|
||||
{ path: "items.chancePerHourPermille", label: "Chance d’objet par heure", unit: "‰" },
|
||||
{ path: "items.maxPerExpedition", label: "Objets au plus par expédition" },
|
||||
{ path: "items.orientationPerSlot", label: "Orientation par place pour la partie cachée" },
|
||||
{ path: "items.fragmentsForMap", label: "Fragments pour une carte au trésor" },
|
||||
{ path: "items.hiddenLootPct", label: "Multiplicateur de butin des destinations cachées (%)" },
|
||||
{ path: "items.hiddenLootPct", label: "Multiplicateur de butin des destinations cachées", unit: "%" },
|
||||
{ path: "items.weights.fragment", label: "Poids : fragment de carte au trésor" },
|
||||
{ path: "items.weights.engraving", label: "Poids : burin de graveur" },
|
||||
{ path: "items.weights.plan", label: "Poids : plan d’atelier" },
|
||||
|
|
@ -123,7 +145,7 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
help: "Exigence d’une stat par place : elle est multipliée par le nombre de places, plus les places dont le rôle double cette stat.",
|
||||
fields: [
|
||||
...STARS.map((stars, index) => ({ path: `requirements.star${index + 1}`, label: `Exigences par place en ${stars}`, items: STATS_IN_ORDER })),
|
||||
{ path: "requirements.conditionMissPct", label: "Baisse du score si la condition de 3 ★ manque (%)" }
|
||||
{ path: "requirements.conditionMissPct", label: "Baisse du score si la condition de 3 ★ manque", unit: "%" }
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -131,18 +153,18 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
title: "Score, durée et dangers",
|
||||
help: "Paliers, rendement au-delà de 100 %, malus des longues expéditions et des dangers, et ce que l’Endurance en efface.",
|
||||
fields: [
|
||||
{ path: "score.successPct", label: "Seuil de Réussite (%)" },
|
||||
{ path: "score.triumphPct", label: "Seuil de Triomphe (%)" },
|
||||
{ path: "score.capPct", label: "Plafond du score (%)" },
|
||||
{ path: "score.successPct", label: "Seuil de Réussite", unit: "%" },
|
||||
{ path: "score.triumphPct", label: "Seuil de Triomphe", unit: "%" },
|
||||
{ path: "score.capPct", label: "Plafond du score", unit: "%" },
|
||||
{ path: "score.mainWeight", label: "Poids de la stat principale" },
|
||||
{ path: "score.otherWeight", label: "Poids des autres stats" },
|
||||
{ path: "score.overflowPct", label: "Valeur d’un point au-delà de 100 % (%)" },
|
||||
{ path: "score.overflowSpanPct", label: "Dépassement pris en compte (%)" },
|
||||
{ path: "score.synergyCapPct", label: "Plafond des bonus de score (%)" },
|
||||
{ path: "durations.malusPct", label: "Malus de durée (%)", items: ["Courte", "Moyenne", "Longue"] },
|
||||
{ path: "score.overflowPct", label: "Valeur d’un point au-delà de 100 %", unit: "%" },
|
||||
{ path: "score.overflowSpanPct", label: "Dépassement pris en compte", unit: "%" },
|
||||
{ path: "score.synergyCapPct", label: "Plafond des bonus de score", unit: "%" },
|
||||
{ path: "durations.malusPct", label: "Malus de durée", unit: "%", items: ["Courte", "Moyenne", "Longue"] },
|
||||
{ path: "durations.endurancePerSlot", label: "Endurance par place qui efface le malus de durée" },
|
||||
{ path: "danger.malusPct", label: "Malus d’un danger (%)" },
|
||||
{ path: "danger.shieldMaxPct", label: "Part du malus que l’Endurance peut effacer (%)" },
|
||||
{ path: "danger.malusPct", label: "Malus d’un danger", unit: "%" },
|
||||
{ path: "danger.shieldMaxPct", label: "Part du malus que l’Endurance peut effacer", unit: "%" },
|
||||
{ path: "danger.endurancePerSlot", label: "Endurance par place pour le bouclier complet" }
|
||||
]
|
||||
},
|
||||
|
|
@ -153,18 +175,18 @@ export const EXPEDITION_SETTING_GROUPS = [
|
|||
fields: [
|
||||
{ path: "loot.eclatsPerHourCents", label: "Éclats par heure (en centièmes : 200 = 2)" },
|
||||
{ path: "loot.stardustPerHourCents", label: "Poussière par heure (en centièmes : 25 = 0,25)" },
|
||||
{ path: "loot.packPerHourPermille", label: "Chance de paquet par heure (‰)" },
|
||||
{ path: "loot.packPerHourPermille", label: "Chance de paquet par heure", unit: "‰" },
|
||||
{ path: "loot.maxPacks", label: "Paquets au plus par expédition" },
|
||||
{ path: "loot.difficultyPct", label: "Multiplicateur de difficulté (%)", items: STARS },
|
||||
{ path: "loot.tierPct", label: "Multiplicateur du palier (%)", items: ["Retour difficile", "Réussite", "Triomphe"] },
|
||||
{ path: "loot.fortunePerPointPct", label: "Bonus de paquet par point de Fortune par place (%)" },
|
||||
{ path: "loot.fortuneCapPct", label: "Bonus de Fortune maximal (%)" },
|
||||
{ path: "loot.bonusSlotPct", label: "Multiplicateur des destinations bonus (%)", items: ["5e destination", "6e destination"] }
|
||||
{ path: "loot.difficultyPct", label: "Multiplicateur de difficulté", unit: "%", items: STARS },
|
||||
{ path: "loot.tierPct", label: "Multiplicateur du palier", unit: "%", items: ["Retour difficile", "Réussite", "Triomphe"] },
|
||||
{ path: "loot.fortunePerPointPct", label: "Bonus de paquet par point de Fortune par place", unit: "%" },
|
||||
{ path: "loot.fortuneCapPct", label: "Bonus de Fortune maximal", unit: "%" },
|
||||
{ path: "loot.bonusSlotPct", label: "Multiplicateur des destinations bonus", unit: "%", items: ["5e destination", "6e destination"] }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const LABELS = new Map(EXPEDITION_SETTING_GROUPS.flatMap((group) => group.fields.map((field) => [field.path, field.label])));
|
||||
const LABELS = new Map(EXPEDITION_SETTING_GROUPS.flatMap((group) => group.fields.map((field) => [field.path, field.unit ? `${field.label} (${field.unit})` : field.label])));
|
||||
|
||||
// Libellé d'un réglage dans l'historique ; une destination se nomme par son nom.
|
||||
export function expeditionSettingLabel(path, destinations = []) {
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ export function buyShopPack() {
|
|||
return request("/shop/pack", { method: "POST", headers: { "Idempotency-Key": crypto.randomUUID() } });
|
||||
}
|
||||
|
||||
export function buyOpening() {
|
||||
return request("/shop/openings", { method: "POST" });
|
||||
export function buyOpening(count = 1) {
|
||||
return request("/shop/openings", { method: "POST", body: JSON.stringify({ count }) });
|
||||
}
|
||||
|
||||
export function openGiftPack(giftPackId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue