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:
parent
de7e72fb42
commit
09a92de2c5
11 changed files with 61 additions and 23 deletions
|
|
@ -189,6 +189,7 @@ test("player opens and reveals a three-card pack", async ({ page }) => {
|
|||
test.setTimeout(60_000);
|
||||
await page.goto("/#/cards");
|
||||
await expect(page.locator(".nav-icon-cards")).toHaveCSS("mask-image", /tcg\.svg/);
|
||||
await expect(page.locator(".sidebar-note")).toContainText("Sokko TCG");
|
||||
await expect(page.getByRole("heading", { name: "Sokko TCG", exact: true })).toBeVisible();
|
||||
await expect(page.getByText("Trading Card Game", { exact: true })).toBeVisible();
|
||||
const loginArt = page.locator('.nebula-login-art img[src="/static/img/cards/login.webp"]');
|
||||
|
|
@ -1514,3 +1515,19 @@ test("a player reads the privacy notice and deletes the account for good", async
|
|||
await expect(login).toBeVisible();
|
||||
expect(await cachedSnapshots()).toBe(0);
|
||||
});
|
||||
|
||||
test("the about page mentions the game while it is enabled", async ({ page }) => {
|
||||
await page.goto("/#/about");
|
||||
await expect(page.locator(".about-page .nds-page-hero")).toContainText("Seul le mini-jeu Sokko TCG utilise un compte Discord");
|
||||
});
|
||||
|
||||
test("the shop pack rates count the cards it draws from the other collections", async ({ page }) => {
|
||||
await page.goto("/#/cards/admin/collections/stardust");
|
||||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||||
const rates = page.locator(".nebula-admin-drop-table");
|
||||
await expect(rates).toBeVisible();
|
||||
await expect(rates.locator("[role=status]")).toHaveCount(0);
|
||||
const commonRow = rates.locator('tr[data-rarity="common"]');
|
||||
await expect(commonRow.locator("td").nth(2)).not.toHaveText("0");
|
||||
await expect(commonRow.locator("td").nth(3)).toHaveText("—");
|
||||
});
|
||||
|
|
|
|||
10
e2e/production/cards-disabled.spec.js
Normal file
10
e2e/production/cards-disabled.spec.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Rôle : vérifie qu'un build dont Sokko TCG est désactivé n'annonce le jeu nulle part.
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("the site does not mention Sokko TCG while the game is disabled", async ({ page }) => {
|
||||
await page.goto("/#/about");
|
||||
await expect(page.locator(".about-page .nds-page-hero h1")).toBeVisible();
|
||||
await expect(page.locator(".nav-icon-cards")).toHaveCount(0);
|
||||
await expect(page.locator(".sidebar-note")).toContainText("Données stockées dans ce navigateur.");
|
||||
await expect(page.locator("body")).not.toContainText("Sokko TCG");
|
||||
});
|
||||
|
|
@ -256,11 +256,15 @@ export function shopPackPools(catalog, collectionId) {
|
|||
};
|
||||
}
|
||||
|
||||
// Raretés qu'un paquet peut réellement donner, quels que soient ses taux.
|
||||
export function drawableRarities(catalog, collection) {
|
||||
// Nombre d'éditions qu'un paquet peut réellement donner par rareté, quels que soient ses taux.
|
||||
export function drawableCounts(catalog, collection) {
|
||||
const pools = collection.packCategory === "shop" ? shopPackPools(catalog, collection.id) : null;
|
||||
const editions = pools ? [...pools.others, ...pools.featured] : collectionDrawableEditions(catalog, collection.id);
|
||||
return catalog.rarities.map((rarity) => rarity.id).filter((rarity) => editions.some((edition) => edition.rarity === rarity));
|
||||
return Object.fromEntries(catalog.rarities.map((rarity) => [rarity.id, editions.filter((edition) => edition.rarity === rarity.id).length]));
|
||||
}
|
||||
|
||||
export function drawableRarities(catalog, collection) {
|
||||
return Object.entries(drawableCounts(catalog, collection)).filter(([, count]) => count > 0).map(([rarity]) => rarity);
|
||||
}
|
||||
|
||||
export function holographicFinishIds(catalog) {
|
||||
|
|
@ -323,6 +327,6 @@ export function buildPublishedCatalog(versionedCatalog, { variations = [], openi
|
|||
|
||||
export function publicCatalog(catalog) {
|
||||
const published = JSON.parse(JSON.stringify(catalog));
|
||||
published.collections = published.collections.map((collection) => ({ ...collection, drawableRarities: drawableRarities(published, collection) }));
|
||||
published.collections = published.collections.map((collection) => ({ ...collection, drawableCounts: drawableCounts(published, collection), drawableRarities: drawableRarities(published, collection) }));
|
||||
return published;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ export function validateSiteContent(site) {
|
|||
"navigation.about",
|
||||
"sidebar.badge",
|
||||
"sidebar.note",
|
||||
"sidebar.cardsNote",
|
||||
"topbar.dashboard",
|
||||
"topbar.toolbox",
|
||||
"topbar.library",
|
||||
|
|
@ -400,6 +401,7 @@ export function validateSiteContent(site) {
|
|||
"about.eyebrow",
|
||||
"about.title",
|
||||
"about.description",
|
||||
"about.cardsDescription",
|
||||
"about.sectionsEyebrow",
|
||||
"about.sectionsTitle",
|
||||
"about.toolsTitle",
|
||||
|
|
|
|||
|
|
@ -692,6 +692,15 @@ test("displayed odds only count the rarities a pack can really give", () => {
|
|||
const retired = buildPublishedCatalog(baseCatalog, { variations: TEST_MYTHIC_VARIATIONS.map((variation) => ({ ...variation, status: "retired" })), collectionStates: states, dropRates: rates });
|
||||
assert.equal(drawableRarities(retired, collectionOf(retired, "astral-genesis")).includes("mythic"), false);
|
||||
|
||||
// Le paquet boutique tire aussi dans les autres collections actives : le décompte ne se limite pas à ses propres cartes.
|
||||
const publishedEmpty = publicCatalog(empty);
|
||||
const shopCounts = publishedEmpty.collections.find((collection) => collection.id === "stardust").drawableCounts;
|
||||
const othersCommon = publishedEmpty.editions.filter((edition) => edition.rarity === "common" && !edition.promotional && publishedEmpty.cards.find((card) => card.id === edition.cardId).collectionId !== "stardust").length;
|
||||
assert.equal(shopCounts.common, othersCommon);
|
||||
assert.ok(othersCommon > 0);
|
||||
assert.equal(shopCounts.mythic, 0);
|
||||
assert.equal(publishedEmpty.collections.find((collection) => collection.id === "primordial-nebula").drawableCounts.common, 36);
|
||||
|
||||
const weights = { common: 64, rare: 24, epic: 8, legendary: 3, mythic: 1 };
|
||||
const percent = (drawable) => Object.fromEntries(rarityPercentages(empty.rarities, weights, drawable).map(({ rarity, percent: value }) => [rarity.id, value]));
|
||||
assert.equal(percent(undefined).mythic, 1);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
},
|
||||
"sidebar": {
|
||||
"badge": "Local first",
|
||||
"note": "Les toolboxes restent locales. Sokko TCG utilise un compte sécurisé."
|
||||
"note": "Données stockées dans ce navigateur.",
|
||||
"cardsNote": "Les toolboxes restent locales. Sokko TCG utilise un compte sécurisé."
|
||||
},
|
||||
"topbar": {
|
||||
"dashboard": "Dashboard",
|
||||
|
|
@ -1889,7 +1890,8 @@
|
|||
"about": {
|
||||
"eyebrow": "À propos",
|
||||
"title": "C'est quoi Sokko G ?",
|
||||
"description": "Sokko G est un espace local pour organiser vos notes, outils et repères de jeu. Il est pensé pour rester ouvert à côté de votre partie : les toolboxes fonctionnent sans compte et sans synchronisation obligatoire. Seul le mini-jeu Sokko TCG utilise un compte Discord et conserve ses données sur le serveur.",
|
||||
"description": "Sokko G est un espace local pour organiser vos notes, outils et repères de jeu. Il est pensé pour rester ouvert à côté de votre partie, sans compte et sans synchronisation obligatoire.",
|
||||
"cardsDescription": "Sokko G est un espace local pour organiser vos notes, outils et repères de jeu. Il est pensé pour rester ouvert à côté de votre partie : les toolboxes fonctionnent sans compte et sans synchronisation obligatoire. Seul le mini-jeu Sokko TCG utilise un compte Discord et conserve ses données sur le serveur.",
|
||||
"sectionsEyebrow": "Concept",
|
||||
"sectionsTitle": "Faciliter vos sessions gaming",
|
||||
"sections": [
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export function Shell({ route, content, games, drawerGameId = "", drawerVisible
|
|||
</div>
|
||||
<div className="sidebar-note">
|
||||
<span className="badge">{content.sidebar.badge}</span>
|
||||
<p>{content.sidebar.note}</p>
|
||||
<p>{cardsEnabled ? content.sidebar.cardsNote : content.sidebar.note}</p>
|
||||
<div className="sidebar-storage-actions" aria-label="Actions globales de stockage">
|
||||
<Tooltip as="button" className="sidebar-action-button sidebar-backup-button nds-button" content={compactSidebar ? content.toolboxes.autoBackup.title : ""} position="right" data-size="sm" data-variant="primary" type="button" onClick={onOpenAutoBackup} aria-label={content.toolboxes.autoBackup.title} title={compactSidebar ? undefined : content.toolboxes.autoBackup.title} data-toolbox-tutorial-target="backup">{compactSidebar && <Icon name="save" />}<span className="sidebar-storage-action-label">{content.toolboxes.autoBackup.sidebarLabel}</span></Tooltip>
|
||||
<ImportButton className="sidebar-action-button nds-icon-button import-icon-button" data-size="sm" ariaLabel="Importer toutes les toolboxes" tooltip="Importer toutes les toolboxes" tooltipPosition="right" onFile={actions.importAllToolboxes} icon="import" />
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Icon } from "../components/Icon.jsx";
|
|||
import { RichText } from "../components/RichText.jsx";
|
||||
import { HomeOnboardingSection } from "./HomeOnboardingSection.jsx";
|
||||
|
||||
export function AboutPage({ siteContent }) {
|
||||
export function AboutPage({ siteContent, cardsEnabled = false }) {
|
||||
const content = siteContent.about;
|
||||
const limits = Array.isArray(content.limits) ? content.limits : [];
|
||||
const toolGroups = Array.isArray(content.toolGroups) ? content.toolGroups : [];
|
||||
|
|
@ -21,7 +21,7 @@ export function AboutPage({ siteContent }) {
|
|||
<div>
|
||||
<p className="eyebrow">{content.eyebrow}</p>
|
||||
<h1>{content.title}</h1>
|
||||
<p><RichText text={content.description} /></p>
|
||||
<p><RichText text={cardsEnabled ? content.cardsDescription : content.description} /></p>
|
||||
</div>
|
||||
</section>
|
||||
<section className="about-story-section nebula-panel nds-panel" aria-labelledby="about-story-title">
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ function UnknownRouteRedirect() {
|
|||
export function RouteContent(props) {
|
||||
const { route } = props;
|
||||
if (route === "/") return <HomePage {...props} />;
|
||||
if (route === "/about") return <AboutPage siteContent={props.siteContent} />;
|
||||
if (route === "/about") return <AboutPage siteContent={props.siteContent} cardsEnabled={props.cardsConfig?.enabled} />;
|
||||
if (route === "/library") return <Suspense fallback={<RouteLoader />}><LibraryPage {...props} /></Suspense>;
|
||||
if (route === "/cards" || route.startsWith("/cards/")) {
|
||||
const [, , first = "", second = "", third = ""] = route.split("/");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue