Add solo Expeditions, the second Guilde des Veilleurs quest of Sokko TCG
- Every catalog card carries expedition tags and every collection a stat profile, validated at load; twelve destinations live server-side so hidden ones stay secret. - Pure rules compute card power, per-slot requirements, roles, dangers, the long-trip malus, the score (one more star never raises it) and loot proportional to the chosen duration. - A simulator script and a balance test guard the design thresholds; agent docs and a new-card skill explain how to tag new cards. - Migration 8 adds Éclats d'étoile, expedition settings stored as one validated JSON, daily destinations, expeditions, members and slots, and rebuilds gift_packs so a pack can come from an expedition. - Players launch a solo expedition from the Guild, see an exact preview, and claim their loot when it returns; the card sheet shows cards away on an expedition. - Administration › Guilde tunes every value with server-side bounds, toggles destinations and cancels running expeditions; expeditions stay closed until an administrator opens them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0ef213cf4f
commit
8bb1d53d70
46 changed files with 4752 additions and 213 deletions
|
|
@ -242,6 +242,94 @@ export function validateSiteContent(site) {
|
|||
"cards.packs.giftDescription",
|
||||
"cards.packs.giftOpen",
|
||||
"cards.packs.noOpening",
|
||||
"cards.guild.expeditionsKind",
|
||||
"cards.guild.expeditionsTitle",
|
||||
"cards.guild.expeditionsDescription",
|
||||
"cards.guild.expeditionsToLaunch",
|
||||
"cards.guild.expeditionsRunning",
|
||||
"cards.guild.expeditionsReturned",
|
||||
"cards.guild.expeditionsIdle",
|
||||
"cards.guild.expeditionsNoCards",
|
||||
"cards.guild.expeditionsClosed",
|
||||
"cards.guild.expeditionsAction",
|
||||
"cards.guild.expeditionsClaim",
|
||||
"cards.guild.expeditionsOpen",
|
||||
"cards.packs.giftFromExpedition",
|
||||
"cards.expeditions.eyebrow",
|
||||
"cards.expeditions.title",
|
||||
"cards.expeditions.intro",
|
||||
"cards.expeditions.back",
|
||||
"cards.expeditions.eclatsBalance",
|
||||
"cards.expeditions.eclatsHelp",
|
||||
"cards.expeditions.closedTitle",
|
||||
"cards.expeditions.closedText",
|
||||
"cards.expeditions.expired",
|
||||
"cards.expeditions.reload",
|
||||
"cards.expeditions.activeTitle",
|
||||
"cards.expeditions.reportMeta",
|
||||
"cards.expeditions.running",
|
||||
"cards.expeditions.returned",
|
||||
"cards.expeditions.completed",
|
||||
"cards.expeditions.cancelled",
|
||||
"cards.expeditions.claim",
|
||||
"cards.expeditions.claimed",
|
||||
"cards.expeditions.started",
|
||||
"cards.expeditions.rewardEclats",
|
||||
"cards.expeditions.rewardStardust",
|
||||
"cards.expeditions.rewardPacks",
|
||||
"cards.expeditions.limitReached",
|
||||
"cards.expeditions.planTitle",
|
||||
"cards.expeditions.nextDay",
|
||||
"cards.expeditions.noDestination",
|
||||
"cards.expeditions.destinationsTitle",
|
||||
"cards.expeditions.difficultyTitle",
|
||||
"cards.expeditions.difficultyLabel",
|
||||
"cards.expeditions.durationLabel",
|
||||
"cards.expeditions.hours",
|
||||
"cards.expeditions.requirementsTitle",
|
||||
"cards.expeditions.main",
|
||||
"cards.expeditions.conditionTag",
|
||||
"cards.expeditions.conditionCollection",
|
||||
"cards.expeditions.dangerText",
|
||||
"cards.expeditions.or",
|
||||
"cards.expeditions.teamTitle",
|
||||
"cards.expeditions.teamHelp",
|
||||
"cards.expeditions.roleBadge",
|
||||
"cards.expeditions.slotEmpty",
|
||||
"cards.expeditions.remove",
|
||||
"cards.expeditions.cardsLabel",
|
||||
"cards.expeditions.chooseCard",
|
||||
"cards.expeditions.power",
|
||||
"cards.expeditions.busy",
|
||||
"cards.expeditions.noRole",
|
||||
"cards.expeditions.noCards",
|
||||
"cards.expeditions.previewTitle",
|
||||
"cards.expeditions.previewEmpty",
|
||||
"cards.expeditions.score",
|
||||
"cards.expeditions.teamVersus",
|
||||
"cards.expeditions.limitedByStars",
|
||||
"cards.expeditions.conditionMet",
|
||||
"cards.expeditions.conditionUnmet",
|
||||
"cards.expeditions.dangerCountered",
|
||||
"cards.expeditions.dangerActive",
|
||||
"cards.expeditions.durationMalus",
|
||||
"cards.expeditions.expected",
|
||||
"cards.expeditions.start",
|
||||
"cards.expeditions.tiers.struggle",
|
||||
"cards.expeditions.tiers.success",
|
||||
"cards.expeditions.tiers.triumph",
|
||||
"cards.expeditions.stats.bravoure",
|
||||
"cards.expeditions.stats.endurance",
|
||||
"cards.expeditions.stats.fortune",
|
||||
"cards.expeditions.stats.orientation",
|
||||
"cards.expeditions.statShort.bravoure",
|
||||
"cards.expeditions.statShort.endurance",
|
||||
"cards.expeditions.statShort.fortune",
|
||||
"cards.expeditions.statShort.orientation",
|
||||
"cards.expeditions.roles.bravoure",
|
||||
"cards.expeditions.roles.endurance",
|
||||
"cards.expeditions.roles.fortune",
|
||||
"cards.expeditions.roles.orientation",
|
||||
"guideChecklist.label",
|
||||
"guideChecklist.selectLabel",
|
||||
"guideChecklist.selectPlaceholder",
|
||||
|
|
|
|||
43
tests/nebula-cards-expedition-balance.test.mjs
Normal file
43
tests/nebula-cards-expedition-balance.test.mjs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// Rôle : garde l'équilibre des Expéditions Sokko TCG avec le simulateur (seuils du document de conception).
|
||||
// En cas d'échec après un ajout de cartes ou un changement de réglages : lancer `node scripts/simulate-expeditions.mjs` pour le détail.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { loadCardsCatalog } from "../services/cards/catalog.js";
|
||||
import { loadExpeditionDestinations } from "../services/cards/expedition-content.js";
|
||||
import { DEFAULT_EXPEDITION_SETTINGS, mergeExpeditionSettings } from "../services/cards/expedition-settings.js";
|
||||
import { simulate } from "../services/cards/expedition-simulation.js";
|
||||
|
||||
const catalog = loadCardsCatalog("website/public/data/cards/catalog.json");
|
||||
const destinations = loadExpeditionDestinations("services/cards/content/expedition-destinations.json", catalog);
|
||||
const settings = mergeExpeditionSettings(DEFAULT_EXPEDITION_SETTINGS, destinations.map((destination) => destination.id));
|
||||
const report = simulate(catalog, destinations, settings);
|
||||
const row = (level, rarity, stars) => report.byRarity.find((item) => item.level === level && item.rarity === rarity && item.stars === stars);
|
||||
|
||||
test("every rare or better card reaches Réussite at 2 stars somewhere at level 0", () => {
|
||||
const weak = report.cardBest.filter((card) => card.scorePct < settings.score.successPct);
|
||||
assert.deepEqual(weak.map((card) => `${card.cardId} (${card.rarity}) ${card.scorePct.toFixed(0)} %`), []);
|
||||
});
|
||||
|
||||
test("expected loot per hour is the same for every duration", () => {
|
||||
for (const { stars, tier, perHour } of report.lootPerHour) {
|
||||
assert.ok(perHour.every((value) => Math.abs(value - perHour[0]) < 1e-9), `${stars} ★ ${tier}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("a rare and a mythic end within 5 % of each other at the cap", () => {
|
||||
const { rare, mythic } = report.rareVsMythicAtMax;
|
||||
assert.ok(Math.abs(rare - mythic) / mythic <= 0.05);
|
||||
});
|
||||
|
||||
test("rarer cards never score lower than commoner ones at the same level and stars", () => {
|
||||
const order = ["rare", "epic", "legendary", "mythic"];
|
||||
for (let stars = 1; stars <= 5; stars += 1) {
|
||||
const medians = order.map((rarity) => row("niveau 0", rarity, stars).median);
|
||||
for (let index = 1; index < medians.length; index += 1) assert.ok(medians[index] >= medians[index - 1], `${order[index]} ${stars} ★`);
|
||||
}
|
||||
});
|
||||
|
||||
test("4 stars stay out of reach for level 0 rares but open to capped cards", () => {
|
||||
assert.ok(row("niveau 0", "rare", 4).max < settings.score.successPct, "a level 0 rare pair reaches Réussite at 4 stars");
|
||||
assert.ok(report.triumphShareAt4 >= 0.5, `only ${(report.triumphShareAt4 * 100).toFixed(0)} % of destinations allow a capped rare pair to triumph at 4 stars`);
|
||||
});
|
||||
240
tests/nebula-cards-expedition-service.test.mjs
Normal file
240
tests/nebula-cards-expedition-service.test.mjs
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
// Rôle : vérifie le service et l'API des Expéditions Sokko TCG (destinations du jour, départ solo, retour, réglages, suppression de compte).
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
import { Readable } from "node:stream";
|
||||
import { test } from "node:test";
|
||||
import { createCardsApiHandler } from "../services/cards/api.js";
|
||||
import { buildPublishedCatalog, prepareVersionedCatalog } from "../services/cards/catalog.js";
|
||||
import { INITIAL_COLLECTION_STATES, INITIAL_DROP_RATES } from "../services/cards/admin-seed.js";
|
||||
import { CardsDatabase } from "../services/cards/database.js";
|
||||
import { CardsService } from "../services/cards/service.js";
|
||||
|
||||
const baseCatalog = prepareVersionedCatalog(JSON.parse(await readFile("website/public/data/cards/catalog.json", "utf8")));
|
||||
const published = buildPublishedCatalog(baseCatalog, { collectionStates: INITIAL_COLLECTION_STATES, dropRates: INITIAL_DROP_RATES });
|
||||
const HOUR = 3_600_000;
|
||||
const rarityOf = (cardId) => published.editions.find((edition) => edition.cardId === cardId && !edition.promotional).rarity;
|
||||
const editionsOf = (rarity, collectionId = "primordial-nebula") => published.editions
|
||||
.filter((edition) => edition.rarity === rarity && published.cards.find((card) => card.id === edition.cardId).collectionId === collectionId)
|
||||
.map((edition) => edition.id);
|
||||
|
||||
function expeditionService({ start = Date.parse("2026-11-15T09:00:00Z"), random = () => 0 } = {}) {
|
||||
const clock = { now: start };
|
||||
const database = new CardsDatabase(":memory:");
|
||||
const service = new CardsService({ database, catalog: baseCatalog, now: () => clock.now, random });
|
||||
const admin = service.upsertPlayer({ discordId: "expedition-admin", displayName: "Admin", isAdmin: true });
|
||||
const player = service.upsertPlayer({ discordId: "expedition-player", displayName: "Player" });
|
||||
const open = (changes = {}) => service.expeditions.updateSettings(admin.id, { ...service.expeditions.settings, enabled: true, ...changes });
|
||||
const rares = editionsOf("rare");
|
||||
database.transaction(() => rares.slice(0, 4).forEach((editionId) => service.addCard(player.id, editionId)));
|
||||
return { clock, database, service, admin, player, open, rares };
|
||||
}
|
||||
|
||||
const soloBody = (view, slots, changes = {}) => ({ day: view.day, destinationId: view.destinations[0].id, difficulty: 1, durationHours: 2, slots, ...changes });
|
||||
|
||||
test("expeditions stay closed until an administrator opens them", () => {
|
||||
const { service, player, open, rares } = expeditionService();
|
||||
const closed = service.expeditions.getExpeditions(player.id);
|
||||
assert.equal(closed.enabled, false);
|
||||
assert.deepEqual(closed.destinations, []);
|
||||
assert.equal(service.getState(player.id).expeditions.enabled, false);
|
||||
assert.throws(() => service.expeditions.startSolo(player.id, soloBody({ day: closed.day, destinations: [{ id: "light-currents" }] }, rares.slice(0, 2)), "k1"), (error) => error.code === "EXPEDITIONS_CLOSED");
|
||||
assert.throws(() => service.expeditions.updateSettings(player.id, { ...service.expeditions.settings, enabled: true }), (error) => error.code === "ADMIN_REQUIRED");
|
||||
open();
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
assert.equal(view.enabled, true);
|
||||
assert.equal(view.day, "2026-11-15");
|
||||
assert.equal(view.destinations.length, 4);
|
||||
assert.deepEqual(Object.keys(view.destinations[0].stars), ["1", "2", "3", "4"]);
|
||||
assert.equal(view.destinations[0].stars[4].dangers.length, 1);
|
||||
assert.equal(view.destinations[0].stars[2].condition, null);
|
||||
assert.equal(view.cards.length, 4);
|
||||
// Le tirage du jour est commun à tous et gardé en base.
|
||||
assert.deepEqual(service.expeditions.getExpeditions(player.id).destinations.map((item) => item.id), view.destinations.map((item) => item.id));
|
||||
});
|
||||
|
||||
test("a solo expedition freezes its team, hides its result until it returns and pays once", () => {
|
||||
const { clock, service, player, open, rares, database } = expeditionService();
|
||||
open();
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const body = soloBody(view, rares.slice(0, 2), { difficulty: 2, durationHours: 6 });
|
||||
const preview = service.expeditions.preview(player.id, body).preview;
|
||||
assert.ok(["struggle", "success", "triumph"].includes(preview.tier));
|
||||
assert.equal(preview.requirements.length, 2);
|
||||
assert.ok(preview.expected.eclats > 0);
|
||||
|
||||
const started = service.expeditions.startSolo(player.id, body, "start-1");
|
||||
assert.equal(started.expedition.status, "running");
|
||||
assert.equal(started.expedition.result, null);
|
||||
assert.equal(started.expedition.reward, null);
|
||||
assert.equal(started.expedition.returnsAt, clock.now + 6 * HOUR);
|
||||
assert.equal(started.state.expeditions.running, 1);
|
||||
assert.equal(started.state.expeditions.launchedToday, true);
|
||||
assert.deepEqual(started.state.expeditions.busyEditions.map((item) => item.editionId).sort(), rares.slice(0, 2).sort());
|
||||
// Même clé : même expédition ; nouvelle clé : la limite solo s'applique, et les cartes sont occupées.
|
||||
assert.equal(service.expeditions.startSolo(player.id, body, "start-1").expedition.id, started.expedition.id);
|
||||
assert.throws(() => service.expeditions.startSolo(player.id, body, "start-2"), (error) => error.code === "EXPEDITION_CARD_BUSY");
|
||||
assert.throws(() => service.expeditions.startSolo(player.id, { ...body, slots: rares.slice(2, 4) }, "start-3"), (error) => error.code === "EXPEDITION_LIMIT");
|
||||
assert.throws(() => service.expeditions.claim(player.id, started.expedition.id), (error) => error.code === "EXPEDITION_NOT_RETURNED");
|
||||
|
||||
// Une amélioration des réglages pendant le trajet ne change rien : tout est figé au départ.
|
||||
clock.now += 6 * HOUR;
|
||||
const before = service.getState(player.id);
|
||||
assert.equal(before.expeditions.returned, 1);
|
||||
const returned = service.expeditions.getExpeditions(player.id).expeditions[0];
|
||||
assert.equal(returned.status, "returned");
|
||||
assert.equal(returned.result.tier, preview.tier);
|
||||
const claimed = service.expeditions.claim(player.id, started.expedition.id);
|
||||
assert.equal(claimed.expedition.status, "completed");
|
||||
assert.equal(claimed.state.wallet.eclats, returned.reward.eclats);
|
||||
assert.equal(claimed.state.wallet.stardust, before.wallet.stardust + returned.reward.stardust);
|
||||
assert.ok(returned.reward.eclats >= Math.floor(preview.expected.eclats));
|
||||
// random() = 0 : tous les tirages réussissent, donc un paquet rapporté, rangé avec les paquets offerts.
|
||||
assert.equal(returned.reward.packs.length, 1);
|
||||
assert.equal(claimed.state.giftPacks.length, 1);
|
||||
assert.equal(claimed.state.giftPacks[0].source, "expedition");
|
||||
assert.equal(claimed.state.giftPacks[0].sourceName, returned.destination.name);
|
||||
const history = claimed.state.history.find((entry) => entry.type === "expedition_completed");
|
||||
assert.equal(history.details.eclats, returned.reward.eclats);
|
||||
// Deuxième retour : même rapport, aucun crédit en plus ; les cartes sont libres.
|
||||
const again = service.expeditions.claim(player.id, started.expedition.id);
|
||||
assert.equal(again.state.wallet.eclats, claimed.state.wallet.eclats);
|
||||
assert.deepEqual(again.state.expeditions.busyEditions, []);
|
||||
assert.equal(database.db.prepare("SELECT COUNT(*) AS count FROM gift_packs WHERE source = 'expedition'").get().count, 1);
|
||||
// Le paquet rapporté s'ouvre comme un paquet offert.
|
||||
const opened = service.openGiftPack(player.id, claimed.state.giftPacks[0].id, "open-expedition-pack");
|
||||
assert.equal(opened.opening.cards.length, 3);
|
||||
});
|
||||
|
||||
test("unlucky rolls keep the average and never hand out a pack", () => {
|
||||
const { clock, service, player, open, rares } = expeditionService({ random: (max) => max - 1 });
|
||||
open();
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const started = service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2)), "unlucky");
|
||||
clock.now += 2 * HOUR;
|
||||
const returned = service.expeditions.claim(player.id, started.expedition.id).expedition;
|
||||
assert.deepEqual(returned.reward.packs, []);
|
||||
assert.equal(returned.reward.eclats, Math.floor(returned.reward.eclats));
|
||||
});
|
||||
|
||||
test("solo departures refuse stale days, unknown destinations, commons, duplicates and cards the player lacks", () => {
|
||||
const { clock, service, player, open, rares } = expeditionService();
|
||||
open();
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const start = (changes, key) => () => service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2), changes), key);
|
||||
assert.throws(start({ destinationId: "nowhere" }, "a"), (error) => error.code === "EXPEDITION_INVALID");
|
||||
assert.throws(start({ difficulty: 5 }, "b"), (error) => error.code === "EXPEDITION_INVALID");
|
||||
assert.throws(start({ durationHours: 3 }, "c"), (error) => error.code === "EXPEDITION_INVALID");
|
||||
assert.throws(start({ slots: [rares[0]] }, "d"), (error) => error.code === "EXPEDITION_CARD_INVALID");
|
||||
assert.throws(start({ slots: [rares[0], rares[0]] }, "e"), (error) => error.code === "EXPEDITION_CARD_INVALID");
|
||||
assert.throws(start({ slots: [rares[0], editionsOf("common")[0]] }, "f"), (error) => error.code === "EXPEDITION_CARD_INVALID");
|
||||
assert.throws(start({ slots: [rares[0], rares[10]] }, "g"), (error) => error.code === "CARD_NOT_OWNED");
|
||||
assert.throws(() => service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2)), ""), (error) => error.code === "IDEMPOTENCY_REQUIRED");
|
||||
clock.now += 24 * HOUR;
|
||||
assert.throws(start({}, "h"), (error) => error.code === "EXPEDITION_DAY_EXPIRED");
|
||||
assert.equal(rarityOf("starvoid-dragon"), "legendary");
|
||||
});
|
||||
|
||||
test("administrators tune settings with bounds and history, and can cancel an expedition", () => {
|
||||
const { service, admin, player, open, rares, database } = expeditionService();
|
||||
assert.throws(() => service.expeditions.updateSettings(admin.id, { ...service.expeditions.settings, score: { ...service.expeditions.settings.score, successPct: 500 } }), (error) => error.code === "EXPEDITION_SETTINGS_INVALID");
|
||||
open();
|
||||
assert.throws(() => open(), (error) => error.code === "EXPEDITION_SETTINGS_UNCHANGED");
|
||||
const audit = database.db.prepare("SELECT details_json FROM audit_log WHERE event_type = 'expedition_settings_updated'").get();
|
||||
assert.deepEqual(JSON.parse(audit.details_json).changes, [{ path: "enabled", previous: false, next: true }]);
|
||||
assert.ok(service.getAdminHistory(admin.id).entries.some((entry) => entry.type === "expedition_settings_updated"));
|
||||
const dashboard = service.getAdminDashboard(admin.id);
|
||||
assert.equal(dashboard.expeditionSettings.settings.enabled, true);
|
||||
assert.equal(dashboard.expeditionSettings.destinations.length, 12);
|
||||
assert.ok(dashboard.expeditionSettings.schema.some((field) => field.path === "loot.eclatsPerHourCents"));
|
||||
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const started = service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2)), "cancel-me");
|
||||
assert.equal(service.getAdminDashboard(admin.id).expeditionsToday.running, 1);
|
||||
assert.throws(() => service.expeditions.cancel(player.id, started.expedition.id), (error) => error.code === "ADMIN_REQUIRED");
|
||||
service.expeditions.cancel(admin.id, started.expedition.id);
|
||||
const state = service.getState(player.id);
|
||||
assert.deepEqual(state.expeditions.busyEditions, []);
|
||||
assert.ok(state.history.some((entry) => entry.type === "expedition_cancelled_by_guild"));
|
||||
assert.throws(() => service.expeditions.claim(player.id, started.expedition.id), (error) => error.code === "EXPEDITION_NOT_FOUND");
|
||||
assert.throws(() => service.expeditions.cancel(admin.id, started.expedition.id), (error) => error.code === "EXPEDITION_FINISHED");
|
||||
});
|
||||
|
||||
test("deleting an account cancels its expeditions and resets its Éclats", () => {
|
||||
const { clock, service, player, open, rares, database } = expeditionService();
|
||||
open();
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const first = service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2)), "first");
|
||||
clock.now += 2 * HOUR;
|
||||
service.expeditions.claim(player.id, first.expedition.id);
|
||||
const second = service.expeditions.startSolo(player.id, soloBody(view, rares.slice(2, 4)), "second");
|
||||
service.deleteAccount(player.id);
|
||||
assert.equal(database.db.prepare("SELECT eclats FROM players WHERE id = ?").get(player.id).eclats, 0);
|
||||
assert.equal(database.db.prepare("SELECT status FROM expeditions WHERE id = ?").get(second.expedition.id).status, "cancelled");
|
||||
});
|
||||
|
||||
function mockRequest({ method = "GET", path, body, headers = {} }) {
|
||||
const req = Readable.from(body == null ? [] : [Buffer.from(JSON.stringify(body))]);
|
||||
req.method = method;
|
||||
req.url = path;
|
||||
req.headers = { host: "localhost:5173", ...headers };
|
||||
req.socket = { remoteAddress: "127.0.0.1" };
|
||||
return req;
|
||||
}
|
||||
|
||||
async function call(handler, options) {
|
||||
const response = { status: 0, headers: {}, chunks: [] };
|
||||
const res = {
|
||||
setHeader(name, value) { response.headers[name.toLowerCase()] = value; },
|
||||
writeHead(status, headers = {}) {
|
||||
response.status = status;
|
||||
for (const [name, value] of Object.entries(headers)) response.headers[name.toLowerCase()] = value;
|
||||
},
|
||||
end(value = "") { response.chunks.push(Buffer.from(value)); }
|
||||
};
|
||||
await handler(mockRequest(options), res);
|
||||
response.raw = Buffer.concat(response.chunks);
|
||||
response.json = response.headers["content-type"]?.startsWith("application/json") && response.raw.length ? JSON.parse(response.raw.toString("utf8")) : null;
|
||||
return response;
|
||||
}
|
||||
|
||||
test("the expeditions API requires a session, CSRF protection, an administrator for settings and an idempotency key to start", async (t) => {
|
||||
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: true, devAuth: true, databasePath: ":memory:", env: { NODE_ENV: "test" }, random: () => 0 });
|
||||
t.after(() => handler.close());
|
||||
assert.equal((await call(handler, { path: "/api/cards/expeditions" })).status, 401);
|
||||
const login = await call(handler, { method: "POST", path: "/api/cards/auth/dev", body: {} });
|
||||
const cookie = login.headers["set-cookie"].split(";")[0];
|
||||
const headers = { cookie, "x-csrf-token": login.json.csrfToken };
|
||||
const closed = await call(handler, { path: "/api/cards/expeditions", headers: { cookie } });
|
||||
assert.equal(closed.status, 200);
|
||||
assert.equal(closed.json.enabled, false);
|
||||
|
||||
assert.equal((await call(handler, { method: "PUT", path: "/api/cards/admin/expeditions/settings", headers: { cookie }, body: {} })).status, 403);
|
||||
const dashboard = await call(handler, { path: "/api/cards/admin/dashboard", headers: { cookie } });
|
||||
const settings = { ...dashboard.json.expeditionSettings.settings, enabled: true };
|
||||
const invalid = await call(handler, { method: "PUT", path: "/api/cards/admin/expeditions/settings", headers, body: { settings: { ...settings, solo: { ...settings.solo, maxStars: 9 } } } });
|
||||
assert.equal(invalid.status, 400);
|
||||
assert.equal(invalid.json.error.code, "EXPEDITION_SETTINGS_INVALID");
|
||||
const opened = await call(handler, { method: "PUT", path: "/api/cards/admin/expeditions/settings", headers, body: { settings } });
|
||||
assert.equal(opened.status, 200);
|
||||
assert.equal(opened.json.expeditionSettings.settings.enabled, true);
|
||||
|
||||
const devId = handler.service.db.prepare("SELECT id FROM players WHERE discord_id = 'dev-admin'").get().id;
|
||||
handler.service.database.transaction(() => editionsOf("rare").slice(0, 2).forEach((editionId) => handler.service.addCard(devId, editionId)));
|
||||
const view = (await call(handler, { path: "/api/cards/expeditions", headers: { cookie } })).json;
|
||||
const slots = view.cards.slice(0, 2).map((card) => card.editionId);
|
||||
assert.equal(slots.length, 2, "the development account owns rare or better cards");
|
||||
const body = soloBody(view, slots);
|
||||
const preview = await call(handler, { method: "POST", path: "/api/cards/expeditions/preview", headers, body });
|
||||
assert.equal(preview.status, 200);
|
||||
const noKey = await call(handler, { method: "POST", path: "/api/cards/expeditions", headers, body });
|
||||
assert.equal(noKey.json.error.code, "IDEMPOTENCY_REQUIRED");
|
||||
const started = await call(handler, { method: "POST", path: "/api/cards/expeditions", headers: { ...headers, "idempotency-key": "api-start" }, body });
|
||||
assert.equal(started.status, 201);
|
||||
assert.equal(started.json.expedition.status, "running");
|
||||
const early = await call(handler, { method: "POST", path: `/api/cards/expeditions/${started.json.expedition.id}/claim`, headers });
|
||||
assert.equal(early.status, 409);
|
||||
assert.equal(early.json.error.code, "EXPEDITION_NOT_RETURNED");
|
||||
const cancelled = await call(handler, { method: "POST", path: `/api/cards/admin/expeditions/${started.json.expedition.id}/cancel`, headers });
|
||||
assert.equal(cancelled.status, 200);
|
||||
});
|
||||
222
tests/nebula-cards-expeditions.test.mjs
Normal file
222
tests/nebula-cards-expeditions.test.mjs
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
// Rôle : vérifie les données, les réglages et les règles pures des Expéditions Sokko TCG.
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { test } from "node:test";
|
||||
import { prepareVersionedCatalog } from "../services/cards/catalog.js";
|
||||
import { loadExpeditionDestinations, validateExpeditionDestinations } from "../services/cards/expedition-content.js";
|
||||
import {
|
||||
applyHazards, cardPower, drawExpeditionDay, editionExpeditionData, efficiency, evaluateTeam, expectedLoot, maxLevel,
|
||||
requirementsFor, resolveDayEntry, rollLoot, roundStochastic, scoreExpedition, soloRoles, splitPower, STAT_IDS, teamStats
|
||||
} from "../services/cards/expedition-rules.js";
|
||||
import {
|
||||
DEFAULT_EXPEDITION_SETTINGS, diffExpeditionSettings, EXPEDITION_SETTINGS_SCHEMA, mergeExpeditionSettings, readPath, validateExpeditionSettings
|
||||
} from "../services/cards/expedition-settings.js";
|
||||
import { EXPEDITION_SETTING_GROUPS, expeditionSettingLabel } from "../website/src/features/cards/admin/expeditionSettingFields.js";
|
||||
import { expeditionsPending, guildQuests } from "../website/src/features/cards/guildQuests.js";
|
||||
|
||||
const rawCatalog = JSON.parse(await readFile("website/public/data/cards/catalog.json", "utf8"));
|
||||
const catalog = prepareVersionedCatalog(rawCatalog);
|
||||
const destinationsPath = "services/cards/content/expedition-destinations.json";
|
||||
const destinations = loadExpeditionDestinations(destinationsPath, catalog);
|
||||
const destinationIds = destinations.map((destination) => destination.id);
|
||||
const settings = mergeExpeditionSettings(DEFAULT_EXPEDITION_SETTINGS, destinationIds);
|
||||
const profile = (bravoure, endurance, fortune, orientation) => ({ bravoure, endurance, fortune, orientation });
|
||||
|
||||
test("every catalog card carries expedition tags and every collection a profile", () => {
|
||||
const tagIds = new Set(rawCatalog.expeditionTags.map((tag) => tag.id));
|
||||
assert.ok(rawCatalog.cards.every((card) => card.expedition.tags.length >= 1 && card.expedition.tags.every((tag) => tagIds.has(tag))));
|
||||
assert.ok(rawCatalog.collections.every((collection) => STAT_IDS.reduce((sum, stat) => sum + collection.expedition.profile[stat], 0) === 100));
|
||||
// Aucune étiquette inutilisée : le vocabulaire reste celui des cartes.
|
||||
const used = new Set(rawCatalog.cards.flatMap((card) => card.expedition.tags));
|
||||
assert.deepEqual(rawCatalog.expeditionTags.filter((tag) => !used.has(tag.id)), []);
|
||||
});
|
||||
|
||||
test("catalog validation refuses broken expedition data", () => {
|
||||
const unknownTag = structuredClone(rawCatalog);
|
||||
unknownTag.cards[0].expedition.tags = ["theme:inconnu"];
|
||||
assert.throws(() => prepareVersionedCatalog(unknownTag), /unknown expedition tag theme:inconnu/);
|
||||
const noTags = structuredClone(rawCatalog);
|
||||
delete noTags.cards[0].expedition;
|
||||
assert.throws(() => prepareVersionedCatalog(noTags), /needs 1 to 8 expedition tags/);
|
||||
const repeated = structuredClone(rawCatalog);
|
||||
repeated.cards[0].expedition.tags = ["theme:voyage", "theme:voyage"];
|
||||
assert.throws(() => prepareVersionedCatalog(repeated), /repeats an expedition tag/);
|
||||
const badProfile = structuredClone(rawCatalog);
|
||||
badProfile.cards[0].expedition.profile = profile(50, 50, 10, 0);
|
||||
assert.throws(() => prepareVersionedCatalog(badProfile), /summing to 100/);
|
||||
const noCollectionProfile = structuredClone(rawCatalog);
|
||||
delete noCollectionProfile.collections[0].expedition;
|
||||
assert.throws(() => prepareVersionedCatalog(noCollectionProfile), /needs an expedition profile/);
|
||||
const badTagId = structuredClone(rawCatalog);
|
||||
badTagId.expeditionTags.push({ id: "Voyage", label: "Voyage" });
|
||||
assert.throws(() => prepareVersionedCatalog(badTagId), /family:name id/);
|
||||
});
|
||||
|
||||
test("destinations order the four stats and stay satisfiable by rare or better cards", () => {
|
||||
assert.equal(destinations.length, 12);
|
||||
// Une destination par couple (stat principale, seconde stat) : chaque paire de rôles du solo existe.
|
||||
assert.equal(new Set(destinations.map((destination) => destination.stats.slice(0, 2).join("+"))).size, 12);
|
||||
const broken = (change) => {
|
||||
const copy = structuredClone(destinations);
|
||||
change(copy[0]);
|
||||
return () => validateExpeditionDestinations(copy, catalog);
|
||||
};
|
||||
assert.throws(broken((destination) => { destination.stats = ["bravoure", "bravoure", "fortune", "orientation"]; }), /order the four stats/);
|
||||
assert.throws(broken((destination) => { destination.conditions = [{ type: "tag", tag: "personnage:ours" }]; }), /fewer than 3/);
|
||||
assert.throws(broken((destination) => { destination.dangers[0].unlessTags = ["theme:inconnu"]; }), /known counter tags/);
|
||||
assert.throws(broken((destination) => { destination.coverCardId = "missing"; }), /unknown cover card/);
|
||||
assert.throws(() => validateExpeditionDestinations(destinations.map((destination) => ({ ...destination, hidden: true })), catalog), /visible destination/);
|
||||
});
|
||||
|
||||
test("expedition settings merge stored values with defaults and validate bounds and cross rules", () => {
|
||||
assert.equal(validateExpeditionSettings(settings, destinationIds), null);
|
||||
assert.equal(settings.enabled, false);
|
||||
assert.deepEqual(settings.destinations[destinationIds[0]], { active: true, weight: 1 });
|
||||
// Champ manquant ou invalide : valeur par défaut, signalée ; clé inconnue : supprimée.
|
||||
const invalid = [];
|
||||
const merged = mergeExpeditionSettings({ power: { rare: 45, cap: "x" }, extra: 1, destinations: { [destinationIds[0]]: { active: false, weight: 3 }, gone: { active: true, weight: 1 } } }, destinationIds, (path) => invalid.push(path));
|
||||
assert.equal(merged.power.rare, 45);
|
||||
assert.equal(merged.power.cap, 100);
|
||||
assert.deepEqual(invalid, ["power.cap"]);
|
||||
assert.equal("extra" in merged, false);
|
||||
assert.equal("gone" in merged.destinations, false);
|
||||
assert.deepEqual(merged.destinations[destinationIds[0]], { active: false, weight: 3 });
|
||||
// Chaque champ du schéma a une valeur par défaut valide.
|
||||
for (const field of EXPEDITION_SETTINGS_SCHEMA) assert.notEqual(readPath(DEFAULT_EXPEDITION_SETTINGS, field.path), undefined, field.path);
|
||||
|
||||
const withChange = (path, value) => {
|
||||
const copy = structuredClone(settings);
|
||||
const keys = path.split(".");
|
||||
keys.slice(0, -1).reduce((node, key) => node[key], copy)[keys.at(-1)] = value;
|
||||
return copy;
|
||||
};
|
||||
assert.match(validateExpeditionSettings(withChange("day.destinationsPerDay", 0), destinationIds), /day\.destinationsPerDay/);
|
||||
assert.match(validateExpeditionSettings(withChange("durations.hours", [6, 2, 12]), destinationIds), /croissantes/);
|
||||
assert.match(validateExpeditionSettings(withChange("requirements.star3", [1, 2]), destinationIds), /3 entiers/);
|
||||
assert.match(validateExpeditionSettings(withChange("score.successPct", 130), destinationIds), /Réussite < Triomphe/);
|
||||
assert.match(validateExpeditionSettings(withChange("solo.minStars", 5), destinationIds), /étoile minimale/);
|
||||
assert.match(validateExpeditionSettings(withChange("power.rare", 120), destinationIds), /plafond/);
|
||||
assert.match(validateExpeditionSettings(withChange("destinations", { unknown: { active: true, weight: 1 } }), destinationIds), /inconnue/);
|
||||
|
||||
const next = withChange("loot.eclatsPerHourCents", 300);
|
||||
next.destinations[destinationIds[1]].weight = 4;
|
||||
assert.deepEqual(diffExpeditionSettings(settings, next), [
|
||||
{ path: "loot.eclatsPerHourCents", previous: 200, next: 300 },
|
||||
{ path: `destinations.${destinationIds[1]}.weight`, previous: 1, next: 4 }
|
||||
]);
|
||||
});
|
||||
|
||||
test("power grows with levels up to the shared cap and splits exactly by profile", () => {
|
||||
assert.equal(cardPower("rare", 0, settings), 40);
|
||||
assert.equal(cardPower("rare", 4, settings), 60);
|
||||
assert.equal(cardPower("rare", 99, settings), 100);
|
||||
assert.equal(cardPower("common", 3, settings), 0);
|
||||
assert.deepEqual(["rare", "epic", "legendary", "mythic"].map((rarity) => maxLevel(rarity, settings)), [12, 9, 6, 3]);
|
||||
assert.deepEqual(splitPower(40, profile(25, 25, 20, 30)), { bravoure: 10, endurance: 10, fortune: 8, orientation: 12 });
|
||||
const odd = splitPower(55, profile(33, 33, 17, 17));
|
||||
assert.equal(Object.values(odd).reduce((sum, value) => sum + value, 0), 55);
|
||||
// Une mythique garde sa propre rareté, mais le profil et les étiquettes de sa carte.
|
||||
const legendary = editionExpeditionData(catalog, "starvoid-dragon-standard", 0, settings);
|
||||
assert.equal(legendary.power, 70);
|
||||
assert.deepEqual(legendary.tags, ["personnage:dragon", "lieu:nebuleuse", "lieu:soleil"]);
|
||||
assert.equal(editionExpeditionData(catalog, "dragon-constellation-standard", 0, settings), null);
|
||||
});
|
||||
|
||||
test("requirements scale per slot, roles double a stat, hazards and conditions weigh on the score", () => {
|
||||
const destination = destinations.find((item) => item.id === "light-currents");
|
||||
const roles = soloRoles(destination, 2);
|
||||
assert.deepEqual(roles, ["orientation", "bravoure"]);
|
||||
assert.deepEqual(requirementsFor(destination, 2, roles, settings), [
|
||||
{ stat: "orientation", main: true, value: 33 },
|
||||
{ stat: "bravoure", main: false, value: 30 }
|
||||
]);
|
||||
// Une place sans rôle (Veilleur de la Guilde) n'ajoute que sa part.
|
||||
assert.equal(requirementsFor(destination, 1, ["orientation", null, null, null], settings)[0].value, 45);
|
||||
|
||||
const slot = { stats: { bravoure: 10, endurance: 10, fortune: 10, orientation: 10 }, tags: [], collectionId: "primordial-nebula" };
|
||||
assert.deepEqual(teamStats([{ ...slot, role: "orientation" }, { ...slot, role: null }], settings), { bravoure: 20, endurance: 20, fortune: 20, orientation: 30 });
|
||||
|
||||
// 12 h sans Endurance : −15 % ; Endurance suffisante : aucun malus. Danger non paré : −20 %, moins le bouclier.
|
||||
assert.equal(applyHazards({ bravoure: 10, endurance: 0, fortune: 10, orientation: 10 }, { slotCount: 2, durationIndex: 2 }, settings).durationFactor, 0.85);
|
||||
assert.equal(applyHazards({ bravoure: 10, endurance: 24, fortune: 10, orientation: 10 }, { slotCount: 2, durationIndex: 2 }, settings).durationFactor, 1);
|
||||
const danger = { id: "d", label: "D", stat: "bravoure", unlessTags: ["theme:hiver"] };
|
||||
assert.equal(applyHazards({ bravoure: 10, endurance: 0, fortune: 0, orientation: 0 }, { slotCount: 2, durationIndex: 0, dangers: [{ ...danger, countered: false }] }, settings).stats.bravoure, 8);
|
||||
assert.equal(applyHazards({ bravoure: 10, endurance: 28, fortune: 0, orientation: 0 }, { slotCount: 2, durationIndex: 0, dangers: [{ ...danger, countered: false }] }, settings).stats.bravoure, 9);
|
||||
assert.equal(applyHazards({ bravoure: 10, endurance: 0, fortune: 0, orientation: 0 }, { slotCount: 2, durationIndex: 0, dangers: [{ ...danger, countered: true }] }, settings).stats.bravoure, 10);
|
||||
|
||||
assert.equal(efficiency(0.5, settings), 0.5);
|
||||
assert.equal(efficiency(1.5, settings), 1.25);
|
||||
assert.equal(efficiency(3, settings), 1.5);
|
||||
const requirements = [{ stat: "bravoure", main: true, value: 10 }, { stat: "fortune", main: false, value: 10 }];
|
||||
const full = scoreExpedition({ requirements, stats: { bravoure: 10, fortune: 10 } }, settings);
|
||||
assert.equal(full.scorePct, 100);
|
||||
assert.equal(full.tier, "success");
|
||||
assert.equal(scoreExpedition({ requirements, stats: { bravoure: 10, fortune: 10 }, conditionMet: false }, settings).scorePct, 75);
|
||||
assert.equal(scoreExpedition({ requirements, stats: { bravoure: 40, fortune: 40 } }, settings).tier, "triumph");
|
||||
assert.equal(scoreExpedition({ requirements, stats: { bravoure: 5, fortune: 5 } }, settings).tier, "struggle");
|
||||
});
|
||||
|
||||
test("one more star never raises the score of the same team", () => {
|
||||
const destination = destinations[0];
|
||||
const entry = { condition: destination.conditions[0], dangers: destination.dangers };
|
||||
// Équipe faible sur la stat principale, forte sur la seconde : sans la règle, 2 ★ ferait mieux que 1 ★.
|
||||
const slots = [
|
||||
{ stats: { bravoure: 40, endurance: 0, fortune: 0, orientation: 4 }, role: destination.stats[0], tags: [], collectionId: "primordial-nebula" },
|
||||
{ stats: { bravoure: 40, endurance: 0, fortune: 0, orientation: 4 }, role: destination.stats[1], tags: [], collectionId: "primordial-nebula" }
|
||||
];
|
||||
const scores = [1, 2, 3, 4].map((stars) => evaluateTeam({ destination, entry, stars, durationIndex: 0, slots }, settings));
|
||||
for (let index = 1; index < scores.length; index += 1) assert.ok(scores[index].scorePct <= scores[index - 1].scorePct);
|
||||
assert.equal(scores[1].limitedByStars, 1);
|
||||
});
|
||||
|
||||
test("loot is proportional to the chosen duration and rounds without changing its average", () => {
|
||||
const short = expectedLoot({ hours: 2, stars: 2, tier: "success", fortune: 0, slotCount: 2 }, settings);
|
||||
const long = expectedLoot({ hours: 12, stars: 2, tier: "success", fortune: 0, slotCount: 2 }, settings);
|
||||
assert.equal(long.eclats / 12, short.eclats / 2);
|
||||
assert.equal(short.eclats, 5.2);
|
||||
// Fortune : +2 % par point moyen par place, plafonné ; destinations bonus : multiplicateur propre.
|
||||
assert.equal(expectedLoot({ hours: 2, stars: 1, tier: "success", fortune: 20, slotCount: 2 }, settings).fortuneBonusPct, 20);
|
||||
assert.equal(expectedLoot({ hours: 2, stars: 1, tier: "success", fortune: 200, slotCount: 2 }, settings).fortuneBonusPct, 50);
|
||||
assert.equal(expectedLoot({ hours: 4, stars: 1, tier: "success", fortune: 0, slotCount: 2, bonusSlot: 6 }, settings).eclats, 10);
|
||||
assert.equal(roundStochastic(2.3, () => 0), 3);
|
||||
assert.equal(roundStochastic(2.3, (max) => max - 1), 2);
|
||||
assert.equal(roundStochastic(4, () => 0), 4);
|
||||
assert.deepEqual(rollLoot({ eclats: 1.5, stardust: 0.2, packs: 5 }, settings, () => 0), { eclats: 2, stardust: 1, packs: 2 });
|
||||
});
|
||||
|
||||
test("the day draw picks active visible destinations and avoids yesterday's when it can", () => {
|
||||
const draw = drawExpeditionDay(destinations, settings, [], () => 0);
|
||||
assert.equal(draw.length, 4);
|
||||
assert.equal(new Set(draw.map((entry) => entry.destinationId)).size, 4);
|
||||
const recent = draw.map((entry) => entry.destinationId);
|
||||
const next = drawExpeditionDay(destinations, settings, recent, () => 0);
|
||||
assert.ok(next.every((entry) => !recent.includes(entry.destinationId)));
|
||||
// Destinations retirées ou de poids nul : jamais tirées.
|
||||
const closed = structuredClone(settings);
|
||||
for (const id of destinationIds.slice(1)) closed.destinations[id].active = false;
|
||||
assert.deepEqual(drawExpeditionDay(destinations, closed, [destinationIds[0]], () => 0).map((entry) => entry.destinationId), [destinationIds[0]]);
|
||||
// Le second danger diffère du premier quand la destination en a deux.
|
||||
assert.ok(draw.every((entry) => entry.dangerIndexes[0] !== entry.dangerIndexes[1]));
|
||||
const resolved = resolveDayEntry(destinations, draw[0]);
|
||||
assert.equal(resolved.entry.dangers.length, 2);
|
||||
assert.equal(resolveDayEntry(destinations, { destinationId: "missing", conditionIndex: 0, dangerIndexes: [0, 0] }), null);
|
||||
});
|
||||
|
||||
test("every server setting has its label in the administration, and nothing else", () => {
|
||||
const labelled = EXPEDITION_SETTING_GROUPS.flatMap((group) => group.fields.map((field) => field.path));
|
||||
assert.deepEqual([...labelled].sort(), EXPEDITION_SETTINGS_SCHEMA.map((field) => field.path).sort());
|
||||
assert.equal(expeditionSettingLabel(`destinations.${destinations[0].id}.weight`, destinations), `${destinations[0].name} · poids`);
|
||||
});
|
||||
|
||||
test("the guild shows expeditions when open and flags them once a day or when one is back", () => {
|
||||
const now = Date.parse("2026-11-15T10:00:00Z");
|
||||
const summary = { enabled: true, running: 0, returned: 0, nextReturnAt: null, launchedToday: false, eligible: 3, soloCards: 2, busyEditions: [] };
|
||||
assert.equal(expeditionsPending(summary, now), true);
|
||||
assert.equal(expeditionsPending({ ...summary, launchedToday: true }, now), false);
|
||||
assert.equal(expeditionsPending({ ...summary, eligible: 1 }, now), false);
|
||||
assert.equal(expeditionsPending({ ...summary, running: 1, launchedToday: true, nextReturnAt: now + 1000 }, now), false);
|
||||
assert.equal(expeditionsPending({ ...summary, running: 1, launchedToday: true, nextReturnAt: now - 1000 }, now), true);
|
||||
// Fermées : la tuile disparaît, sauf tant qu'une expédition du joueur n'est pas terminée.
|
||||
assert.deepEqual(guildQuests({ expeditions: { ...summary, enabled: false } }, now), []);
|
||||
assert.equal(guildQuests({ expeditions: { ...summary, enabled: false, returned: 1 } }, now)[0].pending, true);
|
||||
});
|
||||
|
|
@ -494,7 +494,7 @@ test("duplicates become stardust that buys openings kept apart from the recharge
|
|||
const value = INITIAL_SHOP_SETTING.stardustValues[rarity];
|
||||
|
||||
const before = service.getState(player.id);
|
||||
assert.deepEqual(before.wallet, { stardust: 0, purchasedOpenings: 0 });
|
||||
assert.deepEqual(before.wallet, { stardust: 0, purchasedOpenings: 0, eclats: 0 });
|
||||
assert.deepEqual(before.shop, { stardustValues: INITIAL_SHOP_SETTING.stardustValues, openingPrice: INITIAL_SHOP_SETTING.openingPrice, shopPackPrice: 60, shopPackShare: 50, dailyReward: 10 });
|
||||
assert.deepEqual(before.recycling, { count: 2, stardust: 2 * value });
|
||||
// Une favorite garde son exemplaire : ses doublons se recyclent comme les autres.
|
||||
|
|
@ -520,7 +520,7 @@ test("duplicates become stardust that buys openings kept apart from the recharge
|
|||
// Vide les ouvertures de bienvenue restantes sans changer la collection vérifiée plus bas.
|
||||
database.db.prepare("UPDATE players SET openings_balance = 0 WHERE id = ?").run(player.id);
|
||||
const bought = service.buyOpening(player.id);
|
||||
assert.deepEqual(bought.wallet, { stardust: 0, purchasedOpenings: 1 });
|
||||
assert.deepEqual(bought.wallet, { stardust: 0, purchasedOpenings: 1, eclats: 0 });
|
||||
assert.throws(() => service.buyOpening(player.id), /Pas assez/);
|
||||
|
||||
// La réserve est vide : seule l'ouverture achetée permet d'ouvrir, sans toucher à la réserve.
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ test("large sass files stay split by stable responsibility", async () => {
|
|||
"website/src/styles/toolboxes/calendar/_form-layout.scss",
|
||||
"website/src/styles/toolboxes/calendar/_date-picker.scss",
|
||||
"website/src/styles/toolboxes/calendar/_event-controls.scss",
|
||||
"website/src/styles/toolboxes/calendar/_form-actions.scss"
|
||||
"website/src/styles/toolboxes/calendar/_form-actions.scss",
|
||||
"website/src/styles/_nebula-expeditions.scss"
|
||||
];
|
||||
|
||||
for (const path of orchestrators) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue