Only mention Sokko TCG while it is enabled and fix shop pack rates

The sidebar and About page advertised the game even when disabled. The admin
rates also warned that the shop pack had no drawable common, rare or epic card
although it draws them from the other collections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-05 19:03:04 +01:00
parent de7e72fb42
commit 09a92de2c5
11 changed files with 61 additions and 23 deletions

View file

@ -192,7 +192,7 @@ function CollectionPage({ catalog, lookup, collection, dashboard, mutateCatalog,
<section className="nds-panel nebula-admin-drop-rates" aria-labelledby="nebula-admin-drop-rates-title">
<h3 id="nebula-admin-drop-rates-title">Taux de tirage</h3>
<p className="nebula-form-help">Chaque carte d’un paquet est tirée indépendamment : d’abord la rareté selon ces poids, puis une variation au hasard parmi celles tirables de cette rareté. Les nouveaux taux s’appliquent immédiatement.</p>
<DropRatesEditor key={JSON.stringify(collection.dropWeights || null)} catalog={catalog} lookup={lookup} collection={collection} busy={busy} mutateCatalog={mutateCatalog} />
<DropRatesEditor key={JSON.stringify(collection.dropWeights || null)} catalog={catalog} collection={collection} busy={busy} mutateCatalog={mutateCatalog} />
</section>
<CollectionOpeningPanel catalog={catalog} lookup={lookup} collection={collection} mutateCatalog={mutateCatalog} busy={busy} />
</div>

View file

@ -6,22 +6,16 @@ import { setCollectionActive, setDropRates, updateRechargeSetting } from "../car
import { formatPercent, rarityPercentages, recommendedWeights } from "../dropRates.js";
import { formatDuration, formatRechargeInterval } from "./adminFormat.js";
function drawableCounts(catalog, lookup, collectionId) {
const counts = Object.fromEntries(catalog.rarities.map((rarity) => [rarity.id, 0]));
for (const edition of catalog.editions) {
if (!edition.promotional && !edition.retired && lookup.cards.get(edition.cardId)?.collectionId === collectionId) counts[edition.rarity] += 1;
}
return counts;
}
export function DropRatesEditor({ catalog, lookup, collection, busy, mutateCatalog }) {
export function DropRatesEditor({ catalog, collection, busy, mutateCatalog }) {
const saved = collection.dropWeights || null;
const toDraft = (weights) => Object.fromEntries(catalog.rarities.map((rarity) => [rarity.id, String(weights?.[rarity.id] ?? 0)]));
const savedDraft = toDraft(saved);
const recommendedDraft = toDraft(recommendedWeights(catalog.rarities));
const [draft, setDraft] = useState(savedDraft);
const [confirming, setConfirming] = useState(false);
const counts = drawableCounts(catalog, lookup, collection.id);
const counts = collection.drawableCounts || {};
// Dans le paquet de la boutique, la part configurée favorise ses propres cartes : une chance moyenne par variation serait fausse.
const perVariation = collection.packCategory !== "shop";
const parsed = Object.fromEntries(Object.entries(draft).map(([rarity, value]) => [rarity, /^\d+$/.test(value) ? Number(value) : NaN]));
const valid = Object.values(parsed).every((value) => Number.isInteger(value) && value >= 0 && value <= 1_000_000) && Object.values(parsed).some((value) => value > 0);
const sameAs = (other) => catalog.rarities.every((rarity) => draft[rarity.id] === other[rarity.id]);
@ -35,14 +29,14 @@ export function DropRatesEditor({ catalog, lookup, collection, busy, mutateCatal
<caption className="sr-only">Taux de tirage de {collection.name}</caption>
<thead><tr><th scope="col">Rareté</th><th scope="col">Poids</th><th scope="col"><Tooltip content="Chance par carte tirée">Par carte</Tooltip></th><th scope="col"><Tooltip content="Variations tirables">Tirables</Tooltip></th><th scope="col"><Tooltip content="Chance d’obtenir une variation précise">Variation</Tooltip></th></tr></thead>
<tbody>{after.map(({ rarity, percent, weight }, index) => {
const count = counts[rarity.id];
const count = counts[rarity.id] || 0;
const previous = before[index].percent;
return <tr key={rarity.id} data-rarity={rarity.id}>
<th scope="row">{rarity.label}</th>
<td><input className="nds-input" data-size="sm" type="number" inputMode="numeric" min="0" max="1000000" step="1" aria-label={`Poids ${rarity.label}`} value={draft[rarity.id]} disabled={busy} onChange={(event) => setDraft({ ...draft, [rarity.id]: event.target.value })} /></td>
<td><strong>{formatPercent(percent)}</strong>{saved && changed && valid && Math.abs(percent - previous) > 0.0001 && <small>avant {formatPercent(previous)}</small>}</td>
<td>{count}</td>
<td>{count && weight ? formatPercent(percent / count, 3) : "—"}{weight > 0 && !count && <span className="nebula-admin-drop-warning" role="status">Aucune carte tirable : ce poids sera ignoré.</span>}</td>
<td>{perVariation && count && weight ? formatPercent(percent / count, 3) : "—"}{weight > 0 && !count && <span className="nebula-admin-drop-warning" role="status">Aucune carte tirable : ce poids sera ignoré.</span>}</td>
</tr>;
})}</tbody>
</table>