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.note}
+{cardsEnabled ? content.sidebar.cardsNote : content.sidebar.note}
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.
-{content.eyebrow}