Bring back objects from Sokko TCG Expeditions and open bonus and hidden destinations

- Expeditions bring back objects by weight, proportional to the loot; treasure-map fragments, burins and workshop plans need enough average Orientation.
- A guide star adds a fifth destination to the player's day, a sky chart a sixth with richer loot, and enough fragments open one of two hidden destinations: Le Passage Écarlate and L'Observatoire perdu.
- An anchor recalls a running solo expedition and keeps the Éclats and stardust already earned; a burin engraves a tag on a common to create the synergy a player wants.
- The Veilleur's bag lists objects with their use, reports show brought-back objects, and Administration › Guilde tunes object chances, weights, the Orientation threshold and hidden-destination loot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-15 17:28:05 +01:00
parent 320498d878
commit ae23adfdd9
28 changed files with 532 additions and 73 deletions

View file

@ -255,6 +255,30 @@ export function validateSiteContent(site) {
"cards.guild.expeditionsClaim",
"cards.guild.expeditionsOpen",
"cards.packs.giftFromExpedition",
"cards.expeditions.bagTitle",
"cards.expeditions.bagEmpty",
"cards.expeditions.items.fragment",
"cards.expeditions.items.engraving",
"cards.expeditions.items.plan",
"cards.expeditions.items.anchor",
"cards.expeditions.items.guideStar",
"cards.expeditions.items.skyChart",
"cards.expeditions.itemHelp.fragment",
"cards.expeditions.itemHelp.engraving",
"cards.expeditions.itemHelp.plan",
"cards.expeditions.itemHelp.anchor",
"cards.expeditions.itemHelp.guideStar",
"cards.expeditions.itemHelp.skyChart",
"cards.expeditions.useGuideStar",
"cards.expeditions.useSkyChart",
"cards.expeditions.useFragments",
"cards.expeditions.bonusAdded",
"cards.expeditions.bonusSlots.5",
"cards.expeditions.bonusSlots.6",
"cards.expeditions.bonusSlots.hidden",
"cards.expeditions.recall",
"cards.expeditions.recalled",
"cards.expeditions.recalledShare",
"cards.account.alertsTitle",
"cards.account.alertsText",
"cards.account.alertsGroupOpened",

View file

@ -149,7 +149,7 @@ test("administrators tune settings with bounds and history, and can cancel an ex
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.equal(dashboard.expeditionSettings.destinations.length, 14);
assert.ok(dashboard.expeditionSettings.schema.some((field) => field.path === "loot.eclatsPerHourCents"));
const view = service.expeditions.getExpeditions(player.id);
@ -624,3 +624,65 @@ test("the alerts API saves a player's choices, and the server dispatches queued
await handler.runAlerts();
assert.deepEqual(delivered, [{ discordId: "123456789012345678", content: "Un groupe vous attend." }]);
});
test("objects add bonus destinations, recall an expedition with an anchor and engrave equipment", () => {
const { clock, service, player, open, rares, database } = expeditionService();
open();
const give = (items) => database.transaction(() => service.expeditions.addItemsInTx(player.id, items));
// Étoile guide : une 5e destination, pour ce joueur seulement ; une seule par jour.
give(["guideStar", "guideStar", "anchor", "engraving", "fragment", "fragment", "fragment", "fragment"]);
const before = service.expeditions.getExpeditions(player.id);
assert.equal(before.items.guideStar, 2);
const added = service.expeditions.addBonusDestination(player.id, { item: "guideStar" }).expeditions;
assert.equal(added.destinations.length, 5);
const bonus = added.destinations.find((destination) => destination.bonusSlot === "5");
assert.ok(!before.destinations.some((destination) => destination.id === bonus.id));
assert.throws(() => service.expeditions.addBonusDestination(player.id, { item: "guideStar" }), (error) => error.code === "BONUS_ALREADY_USED");
assert.throws(() => service.expeditions.addBonusDestination(player.id, { item: "skyChart" }), (error) => error.code === "NOT_ENOUGH_ITEMS");
assert.throws(() => service.expeditions.addBonusDestination(player.id, { item: "anchor" }), (error) => error.code === "ITEM_INVALID");
// Carte au trésor : 4 fragments ouvrent une destination cachée, au butin multiplié.
const hidden = service.expeditions.addBonusDestination(player.id, { item: "fragment" }).expeditions.destinations.find((destination) => destination.bonusSlot === "hidden");
assert.ok(["crimson-passage", "lost-observatory"].includes(hidden.id));
assert.equal(service.expeditions.getExpeditions(player.id).items.fragment, 0);
assert.deepEqual(service.expeditions.getExpeditions(service.upsertPlayer({ discordId: "other", displayName: "Other" }).id).destinations.map((destination) => destination.id), before.destinations.map((destination) => destination.id));
// Ancre : rappel à mi-chemin, la moitié des Éclats et de la poussière, sans paquet ni objet.
const view = service.expeditions.getExpeditions(player.id);
const started = service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2), { destinationId: hidden.id, durationHours: 12 }), "hidden-trip");
assert.equal(started.expedition.destination.id, hidden.id);
clock.now += 6 * HOUR;
const recalled = service.expeditions.recallExpedition(player.id, started.expedition.id);
assert.equal(recalled.expedition.status, "returned");
assert.equal(recalled.expedition.reward.recalledPct, 50);
assert.deepEqual([recalled.expedition.reward.packs, recalled.expedition.reward.items], [[], []]);
assert.throws(() => service.expeditions.recallExpedition(player.id, started.expedition.id), (error) => error.code === "EXPEDITION_RETURNED");
service.expeditions.claim(player.id, started.expedition.id);
// Burin : une étiquette gravée crée la synergie avec la carte équipée.
const tagsOf = (editionId) => service.catalog.cards.find((item) => item.id === service.index.editions.get(editionId).cardId).expedition.tags;
const stranger = editionsOf("common").find((editionId) => !tagsOf(editionId).some((tag) => tagsOf(rares[0]).includes(tag)));
database.transaction(() => service.addCard(player.id, stranger));
service.expeditions.equip(player.id, { editionId: rares[0], slot: 0, equipmentEditionId: stranger });
assert.equal(service.getState(player.id).cardProgress.find((item) => item.editionId === rares[0]).equipment[0].synergyTag, null);
assert.throws(() => service.expeditions.engrave(player.id, { editionId: stranger, tag: tagsOf(stranger)[0] }), (error) => error.code === "ENGRAVING_INVALID");
const engraved = service.expeditions.engrave(player.id, { editionId: stranger, tag: tagsOf(rares[0])[0] });
assert.equal(engraved.cardProgress.find((item) => item.editionId === rares[0]).equipment[0].synergyTag, tagsOf(rares[0])[0]);
assert.throws(() => service.expeditions.engrave(player.id, { editionId: stranger, tag: "theme:voyage" }), (error) => error.code === "ENGRAVING_EXISTS");
assert.ok(service.getState(player.id).history.filter((entry) => entry.type === "item_used").length >= 4);
service.deleteAccount(player.id);
for (const table of ["player_items", "equipment_engravings", "player_bonus_destinations"]) assert.equal(database.db.prepare(`SELECT COUNT(*) AS count FROM ${table} WHERE player_id = ?`).get(player.id).count, 0);
});
test("returned expeditions credit the objects they bring back", () => {
const { clock, service, player, open, rares } = expeditionService();
open({ items: { ...DEFAULT_EXPEDITION_SETTINGS.items, chancePerHourPermille: 1000, maxPerExpedition: 2, orientationPerSlot: 0 } });
const view = service.expeditions.getExpeditions(player.id);
const started = service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2)), "objects");
clock.now += 2 * HOUR;
const claimed = service.expeditions.claim(player.id, started.expedition.id);
assert.equal(claimed.expedition.reward.items.length, 2);
// Le plan d'atelier n'est pas rapporté tant que l'atelier n'a pas de commune de pouvoir illustrée.
assert.ok(!claimed.expedition.reward.items.includes("plan"));
const items = service.expeditions.getExpeditions(player.id).items;
assert.equal(Object.values(items).reduce((sum, count) => sum + count, 0), 2);
});

View file

@ -7,7 +7,7 @@ import { loadExpeditionDestinations, validateExpeditionDestinations } from "../s
import {
applyHazards, cardPower, drawExpeditionDay, editionExpeditionData, efficiency, evaluateTeam, expectedLoot, maxLevel,
requirementsFor, resolveDayEntry, rollLoot, roundStochastic, scoreExpedition, soloRoles, splitPower, STAT_IDS, teamStats, upgradeCost, gainProgress,
equipmentBonus, LINEAGES, resonancesOf, teamSynergy, unlockedSlots
equipmentBonus, LINEAGES, resonancesOf, teamSynergy, unlockedSlots, bonusLootPct, pickItems, HIDDEN_ITEMS
} from "../services/cards/expedition-rules.js";
import {
DEFAULT_EXPEDITION_SETTINGS, diffExpeditionSettings, EXPEDITION_SETTINGS_SCHEMA, mergeExpeditionSettings, readPath, validateExpeditionSettings
@ -54,9 +54,11 @@ test("catalog validation refuses broken expedition data", () => {
});
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 visible = destinations.filter((destination) => !destination.hidden);
assert.equal(visible.length, 12);
assert.deepEqual(destinations.filter((destination) => destination.hidden).map((destination) => destination.id), ["crimson-passage", "lost-observatory"]);
// Une destination visible par couple (stat principale, seconde stat) : chaque paire de rôles du solo existe.
assert.equal(new Set(visible.map((destination) => destination.stats.slice(0, 2).join("+"))).size, 12);
const broken = (change) => {
const copy = structuredClone(destinations);
change(copy[0]);
@ -288,3 +290,21 @@ test("equipment opens with power, shared tags add synergy points, and teams earn
assert.equal(synergy.totalPct, 25);
assert.equal(teamSynergy({ destination: { themeTags: ["lieu:vide"] }, slots: [card("a", "x", ["theme:nuit"])] }, settings).totalPct, 0);
});
test("objects come by weight, hidden ones only with enough Orientation, and bonus destinations multiply the loot", () => {
const counts = (orientationPerSlot, excluded = []) => {
const seen = new Set();
let step = 0;
// Hasard parcourant tout l'intervalle : chaque objet permis finit par sortir.
for (let index = 0; index < 200; index += 1) pickItems(1, { orientationPerSlot, excluded }, settings, (max) => (step++ * 7) % max).forEach((id) => seen.add(id));
return seen;
};
const closed = counts(0);
assert.ok(HIDDEN_ITEMS.every((id) => !closed.has(id)));
assert.ok(["anchor", "guideStar", "skyChart"].every((id) => closed.has(id)));
const open = counts(15, ["plan"]);
assert.ok(open.has("fragment") && open.has("engraving") && !open.has("plan"));
assert.deepEqual([null, "5", "6", "hidden"].map((slot) => bonusLootPct(slot, settings)), [100, 100, 125, 150]);
assert.equal(expectedLoot({ hours: 4, stars: 1, tier: "success", fortune: 0, slotCount: 2, bonusSlot: "hidden" }, settings).eclats, 12);
assert.equal(expectedLoot({ hours: 10, stars: 1, tier: "success", fortune: 0, slotCount: 2 }, settings).objects, 0.5);
});