Show each daily tip's part of the game as a coloured badge
A tip now carries its part of the game (section) and an optional short topic. The part shows as a badge with one colour per part: Expéditions green, Paquets violet, Collection grey, Échanges et dons gold, Carte du jour orange. The topic sits beside it as the title, so "Expéditions · Améliorer ses cartes" becomes [Expéditions] Améliorer ses cartes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
99a438ff1d
commit
2e1d10086a
8 changed files with 65 additions and 52 deletions
|
|
@ -221,6 +221,7 @@ export function validateSiteContent(site) {
|
|||
"cards.tips.eyebrow",
|
||||
"cards.tips.label",
|
||||
"cards.tips.next",
|
||||
"cards.tips.sections.expeditions",
|
||||
"cards.packs.eyebrow",
|
||||
"cards.packs.title",
|
||||
"cards.packs.permanent",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { calculateRecharge, drawPack, drawShopPack } from "../services/cards/gam
|
|||
import { CardsService, DEV_DISCORD_ID } from "../services/cards/service.js";
|
||||
import { rarityPercentages } from "../website/src/features/cards/dropRates.js";
|
||||
import { visibleCollections } from "../website/src/features/cards/collectionState.js";
|
||||
import { availableTips, tipOfDay } from "../website/src/features/cards/dailyTips.js";
|
||||
import { availableTips, TIP_SECTION_VARIANTS, tipOfDay } from "../website/src/features/cards/dailyTips.js";
|
||||
import { backupCardsDatabase, restoreCardsDatabase, runScheduledBackup, verifyCardsDatabase } from "../services/cards/backup.js";
|
||||
|
||||
// Catalogue versionné (finitions générées, sans variation mythique) et catalogue publié avec une variation de test.
|
||||
|
|
@ -471,22 +471,24 @@ test("admin dashboard aggregates current player activity without Discord identif
|
|||
|
||||
test("daily tips cite only values from the current settings and hide expedition tips while expeditions are closed", async () => {
|
||||
const site = JSON.parse(await readFile("website/public/data/site.json", "utf8"));
|
||||
const { items } = site.cards.tips;
|
||||
const { items, sections } = site.cards.tips;
|
||||
// Chaque partie du jeu a son libellé et sa couleur de badge.
|
||||
assert.deepEqual(Object.keys(sections).sort(), Object.keys(TIP_SECTION_VARIANTS).sort());
|
||||
const database = new CardsDatabase(":memory:");
|
||||
const service = new CardsService({ database, catalog: baseCatalog, now: () => 1_800_000_000_000 });
|
||||
const values = service.tipValues();
|
||||
assert.ok(items.length >= 30);
|
||||
for (const item of items) {
|
||||
assert.ok(["cards", "expeditions"].includes(item.scope), item.text);
|
||||
// L'intitulé commence par la partie du jeu concernée, pour qui ne la connaît pas encore.
|
||||
assert.match(item.topic, /^(Paquets|Collection|Échanges et dons|Carte du jour|Expéditions)( · .+)?$/, item.text);
|
||||
assert.equal(item.topic.startsWith("Expéditions"), item.scope === "expeditions", item.topic);
|
||||
// La partie du jeu concernée s'affiche en badge, pour qui ne la connaît pas encore ; le sujet est facultatif.
|
||||
assert.ok(Object.hasOwn(sections, item.section), item.text);
|
||||
assert.ok(item.topic == null || (typeof item.topic === "string" && item.topic.length > 0 && item.topic.length <= 30), item.text);
|
||||
for (const [, key] of item.text.matchAll(/\{(\w+)\}/g)) assert.ok(Object.hasOwn(values, key), `${key} : ${item.text}`);
|
||||
assert.ok(item.text.length <= 190, `Astuce trop longue : ${item.text}`);
|
||||
}
|
||||
// Fermées par défaut : seules les astuces générales restent ; ouvertes, toutes.
|
||||
assert.equal(values.expeditions, false);
|
||||
assert.deepEqual(availableTips(items, values).map((item) => item.scope), items.filter((item) => item.scope === "cards").map(() => "cards"));
|
||||
assert.ok(availableTips(items, values).length > 0);
|
||||
assert.ok(availableTips(items, values).every((item) => item.section !== "expeditions"));
|
||||
assert.equal(availableTips(items, { ...values, expeditions: true }).length, items.length);
|
||||
assert.equal(values.rechargeEvery, "chaque heure");
|
||||
assert.equal(values.awakeningLegendary, "1 légendaire");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue