Let players choose how their cards spend level points with vocations or free points, and sell the Parchemin d'oubli

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-16 23:00:40 +01:00
parent 18bcf435b5
commit 7d331d1a3f
24 changed files with 473 additions and 60 deletions

View file

@ -1,7 +1,7 @@
// 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).
// sont ouvertes, change la poussière en Éclats d'étoile (Pont des Veilleurs) et vend les Parchemins d'oubli.
import { useState } from "react";
import { buyOpening, buyShopPack, convertStardust } from "./cardsApi.js";
import { buyOblivion, buyOpening, buyShopPack, convertStardust } from "./cardsApi.js";
import { DashboardAside } from "./CardsDashboard.jsx";
import { CollectionCardBack } from "./CollectionCardBack.jsx";
import { EclatsBalance, StardustBalance } from "./Currency.jsx";
@ -13,6 +13,7 @@ import { formatStardust } from "./stardustFormat.js";
// 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 MAX_OBLIVION_PER_PURCHASE = 100;
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
@ -54,6 +55,10 @@ 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>;
}
export function ShopOblivionCover() {
return <div className="nds-card-cover nebula-shop-item-cover"><img src="/static/img/cards/shop/oblivion.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}>
@ -116,6 +121,13 @@ export function ShopPanel({ catalog, state, runMutation, busy, content, onOpenPa
return Boolean(result);
}
async function buyScrolls(count) {
setNotice("");
const result = await runMutation(() => buyOblivion(count));
if (result) setNotice(fillTemplate(content.oblivionDone, { count, s: count > 1 ? "s" : "" }));
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>
@ -144,6 +156,10 @@ export function ShopPanel({ catalog, state, runMutation, busy, content, onOpenPa
{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} />}
{/* Parchemin d'oubli : change le plan de progression d'une carte (fiche de la carte), au prix réglé dans la boutique. */}
{showEclats && <QuantityItem id="oblivion" cover={<ShopOblivionCover />} title={content.oblivionTitle} description={fillTemplate(content.oblivionDescription, { count: state.items?.oblivion ?? 0 })}
quantityLabel={content.oblivionLabel} rateLabel={content.unitRate} price={shop.oblivionPrice} limit={MAX_OBLIVION_PER_PURCHASE} actionLabel="Acheter"
stardust={wallet.stardust} busy={busy} onSubmit={buyScrolls} />}
</div>
</section>
</div>;