From 09a92de2c52a1e85d8484f0246f8ce3a675798a0 Mon Sep 17 00:00:00 2001 From: Shinuwa Date: Thu, 5 Nov 2026 19:03:04 +0100 Subject: [PATCH] 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 --- e2e/nebula-cards.spec.js | 17 +++++++++++++++++ e2e/production/cards-disabled.spec.js | 10 ++++++++++ services/cards/catalog.js | 12 ++++++++---- tests/helpers/data-validation.mjs | 2 ++ tests/nebula-cards.test.mjs | 9 +++++++++ website/public/data/site.json | 6 ++++-- website/src/components/Shell.jsx | 2 +- .../features/cards/admin/AdminCollections.jsx | 2 +- .../src/features/cards/admin/PackSettings.jsx | 18 ++++++------------ website/src/pages/AboutPage.jsx | 4 ++-- website/src/router/RouteContent.jsx | 2 +- 11 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 e2e/production/cards-disabled.spec.js diff --git a/e2e/nebula-cards.spec.js b/e2e/nebula-cards.spec.js index f18ec66..89adea0 100644 --- a/e2e/nebula-cards.spec.js +++ b/e2e/nebula-cards.spec.js @@ -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("—"); +}); diff --git a/e2e/production/cards-disabled.spec.js b/e2e/production/cards-disabled.spec.js new file mode 100644 index 0000000..2b8bb27 --- /dev/null +++ b/e2e/production/cards-disabled.spec.js @@ -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"); +}); diff --git a/services/cards/catalog.js b/services/cards/catalog.js index 61efc45..850d134 100644 --- a/services/cards/catalog.js +++ b/services/cards/catalog.js @@ -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; } diff --git a/tests/helpers/data-validation.mjs b/tests/helpers/data-validation.mjs index 955347c..3ed7837 100644 --- a/tests/helpers/data-validation.mjs +++ b/tests/helpers/data-validation.mjs @@ -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", diff --git a/tests/nebula-cards.test.mjs b/tests/nebula-cards.test.mjs index d1a1304..14b3adc 100644 --- a/tests/nebula-cards.test.mjs +++ b/tests/nebula-cards.test.mjs @@ -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); diff --git a/website/public/data/site.json b/website/public/data/site.json index 037d766..ba9f41c 100644 --- a/website/public/data/site.json +++ b/website/public/data/site.json @@ -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": [ diff --git a/website/src/components/Shell.jsx b/website/src/components/Shell.jsx index 62d2d59..478789b 100644 --- a/website/src/components/Shell.jsx +++ b/website/src/components/Shell.jsx @@ -66,7 +66,7 @@ export function Shell({ route, content, games, drawerGameId = "", drawerVisible
{content.sidebar.badge} -

{content.sidebar.note}

+

{cardsEnabled ? content.sidebar.cardsNote : content.sidebar.note}

{compactSidebar && }{content.toolboxes.autoBackup.sidebarLabel} diff --git a/website/src/features/cards/admin/AdminCollections.jsx b/website/src/features/cards/admin/AdminCollections.jsx index e53482c..5c85fe4 100644 --- a/website/src/features/cards/admin/AdminCollections.jsx +++ b/website/src/features/cards/admin/AdminCollections.jsx @@ -192,7 +192,7 @@ function CollectionPage({ catalog, lookup, collection, dashboard, mutateCatalog,

Taux de tirage

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.

- +
diff --git a/website/src/features/cards/admin/PackSettings.jsx b/website/src/features/cards/admin/PackSettings.jsx index 888fa34..9dbc6a7 100644 --- a/website/src/features/cards/admin/PackSettings.jsx +++ b/website/src/features/cards/admin/PackSettings.jsx @@ -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 Taux de tirage de {collection.name} RaretéPoidsPar carteTirablesVariation {after.map(({ rarity, percent, weight }, index) => { - const count = counts[rarity.id]; + const count = counts[rarity.id] || 0; const previous = before[index].percent; return {rarity.label} setDraft({ ...draft, [rarity.id]: event.target.value })} /> {formatPercent(percent)}{saved && changed && valid && Math.abs(percent - previous) > 0.0001 && avant {formatPercent(previous)}} {count} - {count && weight ? formatPercent(percent / count, 3) : "—"}{weight > 0 && !count && Aucune carte tirable : ce poids sera ignoré.} + {perVariation && count && weight ? formatPercent(percent / count, 3) : "—"}{weight > 0 && !count && Aucune carte tirable : ce poids sera ignoré.} ; })} diff --git a/website/src/pages/AboutPage.jsx b/website/src/pages/AboutPage.jsx index d5759f3..6b8e9a2 100644 --- a/website/src/pages/AboutPage.jsx +++ b/website/src/pages/AboutPage.jsx @@ -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 }) {

{content.eyebrow}

{content.title}

-

+

diff --git a/website/src/router/RouteContent.jsx b/website/src/router/RouteContent.jsx index f4806f0..71cf7c8 100644 --- a/website/src/router/RouteContent.jsx +++ b/website/src/router/RouteContent.jsx @@ -28,7 +28,7 @@ function UnknownRouteRedirect() { export function RouteContent(props) { const { route } = props; if (route === "/") return ; - if (route === "/about") return ; + if (route === "/about") return ; if (route === "/library") return }>; if (route === "/cards" || route.startsWith("/cards/")) { const [, , first = "", second = "", third = ""] = route.split("/");