sokko-g/website/src/features/cards/AwakeningPicker.jsx
Shinuwa 83ac709907
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 22m11s
Validate and deploy Sokko G / deploy (push) Successful in 13s
Reword bulk recycling and awakening texts, and list only the recycled rarities
The confirmation said "rareté Commun ou plus commune": it now names the recycled rarities ("Vos doublons communs, rares et épiques deviennent …") and its value list keeps only those rarities. The box no longer reads "0 doublon … +0 poussière", and the awakening texts say "6 doublons rares" instead of "doublons de rareté Rare". The history no longer shows "−undefined Éclats" for an awakening with duplicates of the collection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 10:20:42 +01:00

58 lines
4.2 KiB
JavaScript

// Rôle : choix des doublons d'un Éveil de substitution, en fenêtre, comme l'atelier : le joueur pose dans sa sélection autant de
// doublons de la collection et de la rareté de la carte qu'il en faut (cartes illustrées, doublons libres en pastille), puis éveille.
// Rien n'est consommé avant « Éveiller » ; « Annuler » ferme sans rien utiliser.
import { useState } from "react";
import { Modal } from "../../components/Modal.jsx";
import { fillTemplate } from "./dailyShare.js";
import { editionEntry } from "./expeditionFormat.js";
import { NebulaCard } from "./NebulaCard.jsx";
// `awakening` : vue du serveur (needed, candidates) ; `rarityWords(count)` : les raretés acceptées accordées (« rares »,
// « légendaire ou mythique ») ; `onAwaken(editionIds)` renvoie le résultat de la mutation, null en cas d'échec.
export function AwakeningPicker({ catalog, cardName, awakening, rarityWords, collectionName, content, busy, onAwaken, onClose }) {
const [chosen, setChosen] = useState([]);
const { needed, candidates } = awakening;
const plural = needed > 1 ? "s" : "";
const used = (editionId) => chosen.filter((id) => id === editionId).length;
const nameOf = (editionId) => editionEntry(catalog, editionId)?.card.name || "";
const add = (entry) => {
if (chosen.length < needed && used(entry.editionId) < entry.spare) setChosen([...chosen, entry.editionId]);
};
const awaken = async () => {
if (await onAwaken(chosen)) onClose();
};
return <Modal dialogClassName="confirm-modal nds-modal nebula-expedition-picker nebula-atelier nebula-awakening-picker" labelledBy="nebula-awakening-picker-title" onRequestClose={onClose} canClose={!busy}>
<h2 id="nebula-awakening-picker-title">{fillTemplate(content.awakenPickerTitle, { card: cardName, power: awakening.power })}</h2>
<p className="nebula-form-help">{fillTemplate(content.awakenPickerHelp, { count: needed, s: plural, rarity: rarityWords(needed), collection: collectionName })}</p>
{/* Sélection : une place par doublon demandé ; une carte posée se retire d'un clic. */}
<section className="nebula-atelier-selection" aria-labelledby="nebula-awakening-selection-title">
<h3 id="nebula-awakening-selection-title">{fillTemplate(content.awakenSelection, { count: chosen.length, needed })}</h3>
<ol>{Array.from({ length: needed }, (_, index) => {
const editionId = chosen[index];
const entry = editionId && editionEntry(catalog, editionId);
return <li key={index} data-empty={!entry || undefined}>
{entry ? <NebulaCard catalog={catalog} entry={entry} size="sm" onSelect={busy ? undefined : () => setChosen(chosen.filter((_, position) => position !== index))}
selectLabel={fillTemplate(content.awakenRemove, { card: entry.card.name })} /> : <span aria-hidden="true" />}
</li>;
})}</ol>
</section>
{candidates.length ? <ul className="nebula-equipment-choices-grid" aria-label={content.awakenCandidates}>{candidates.map((entry) => {
const card = editionEntry(catalog, entry.editionId);
if (!card) return null;
const left = entry.spare - used(entry.editionId);
const full = chosen.length >= needed || left <= 0;
return <li key={entry.editionId} data-equipped={used(entry.editionId) > 0 || undefined} data-unavailable={(full && !used(entry.editionId)) || undefined}>
<span className="nebula-equipment-choice">
<NebulaCard catalog={catalog} entry={card} size="sm" quantity={left} disabled={busy || full} onSelect={() => add(entry)}
selectLabel={fillTemplate(content.awakenAdd, { card: nameOf(entry.editionId) })} />
</span>
<strong>{card.card.name}</strong>
</li>;
})}</ul> : <p className="nebula-form-help">{fillTemplate(content.awakenNoCandidates, { rarity: rarityWords(1), collection: collectionName })}</p>}
<div className="nds-toolbar nebula-expedition-picker-actions">
<button className="nds-button" data-variant="secondary" type="button" disabled={busy} onClick={onClose}>{content.awakenCancel}</button>
<button className="nds-button" data-variant="primary" type="button" disabled={busy || chosen.length !== needed} onClick={awaken}>{content.awakenConfirm}</button>
</div>
</Modal>;
}