Give destination cards on the first visit, in expedition loot and to group members
A player with no destination card receives one from the Carnets on their first visit to open expeditions. Expedition loot can hold a Carnets destination card the player does not own yet, and a group member without the card of the group's destination has a strong chance to get it. Both chances are expedition settings, and destination cards never drop as ordinary Carnets cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
06a4ab6d6a
commit
39dbeb9e2b
11 changed files with 115 additions and 13 deletions
|
|
@ -14,7 +14,8 @@ import { createDiscordAlertSender, dispatchAlerts } from "../services/cards/disc
|
|||
|
||||
const DEFAULT_GROUP = DEFAULT_EXPEDITION_SETTINGS.group;
|
||||
|
||||
const baseCatalog = prepareVersionedCatalog(JSON.parse(await readFile("website/public/data/cards/catalog.json", "utf8")));
|
||||
const rawCatalogText = await readFile("website/public/data/cards/catalog.json", "utf8");
|
||||
const baseCatalog = prepareVersionedCatalog(JSON.parse(rawCatalogText));
|
||||
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;
|
||||
|
|
@ -22,10 +23,10 @@ const editionsOf = (rarity, collectionId = "primordial-nebula") => published.edi
|
|||
.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 } = {}) {
|
||||
function expeditionService({ start = Date.parse("2026-11-15T09:00:00Z"), random = () => 0, catalog = baseCatalog } = {}) {
|
||||
const clock = { now: start };
|
||||
const database = new CardsDatabase(":memory:");
|
||||
const service = new CardsService({ database, catalog: baseCatalog, now: () => clock.now, random });
|
||||
const service = new CardsService({ database, catalog, 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 });
|
||||
|
|
@ -87,6 +88,52 @@ test("each player draws the day among the destinations their cards unlock", () =
|
|||
assert.throws(() => service.expeditions.preview(other.id, { day: view.day, destinationId: "cosmic-cloud-heart", durationHours: 2, slots: [] }), (error) => error.code === "EXPEDITION_INVALID");
|
||||
});
|
||||
|
||||
// Catalogue de test : deux cartes de destination illustrées dans les Carnets (les Courants de Lumière et le Grand Vide).
|
||||
const logbookDestinationCatalog = (() => {
|
||||
const raw = JSON.parse(rawCatalogText);
|
||||
for (const [destinationId, file] of [["light-currents", "light_currents"], ["great-void", "great_void"]]) {
|
||||
raw.cards.push({ id: `destination-${destinationId}`, collectionId: "watchers-logbooks", name: destinationId, description: "Une destination.", image: `/static/img/cards/watchers-logbooks/rare/${file}.webp`, kind: "destination", destinationId });
|
||||
raw.editions.push({ id: `destination-${destinationId}-standard`, cardId: `destination-${destinationId}`, rarity: "rare", finishIds: ["standard"], promotional: false });
|
||||
}
|
||||
return prepareVersionedCatalog(raw);
|
||||
})();
|
||||
const destinationCardsOf = (service, playerId) => service.getState(playerId).collection.map((entry) => entry.editionId).filter((id) => id.startsWith("destination-"));
|
||||
|
||||
// Obtention : une carte de destination de départ offerte une fois, une carte non possédée rapportée d'expédition, et la carte de la
|
||||
// destination d'un groupe rejoint sans l'avoir.
|
||||
test("players receive a starter destination card, then find more on expeditions and in groups", () => {
|
||||
const { clock, service, player, open, rares, database, second, arcade } = groupService({ catalog: logbookDestinationCatalog });
|
||||
open({ destinationCards: { dropPct: 100, groupJoinPct: 100 } });
|
||||
// random() = 0 : la carte de départ est la première des Carnets, les Courants de Lumière.
|
||||
service.expeditions.getExpeditions(player.id);
|
||||
assert.deepEqual(destinationCardsOf(service, player.id), ["destination-light-currents-standard"]);
|
||||
service.expeditions.getExpeditions(player.id);
|
||||
assert.equal(destinationCardsOf(service, player.id).length, 1);
|
||||
assert.equal(service.getState(player.id).history.filter((entry) => entry.type === "destination_starter").length, 1);
|
||||
assert.ok(service.expeditions.unlockedDestinationIds(player.id).has("light-currents"));
|
||||
assert.equal(service.expeditions.unlockedDestinationIds(player.id).has("great-void"), false);
|
||||
// Un groupe vers les Courants : le second joueur, sans leur carte, la gagne ; le créateur gagne la carte qu'il n'a pas.
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const destination = view.destinations.find((item) => item.id === "light-currents");
|
||||
const [mainRole, secondRole] = destination.groupRoles;
|
||||
const created = service.expeditions.createGroup(player.id, { mode: "group", day: view.day, destinationId: destination.id, durationHours: 2, editionId: rares[0], role: mainRole }, "dest-group");
|
||||
const groupId = created.expeditions.groups[0].id;
|
||||
// Le second joueur a déjà reçu sa carte de départ, une autre : il n'a pas celle des Courants.
|
||||
database.db.prepare("INSERT INTO audit_log(player_id, event_type, entity_id, details_json, created_at) VALUES (?, 'destination_starter', 'other', '{}', 0)").run(second.id);
|
||||
service.expeditions.joinGroup(second.id, groupId, { editionId: arcade[0], role: secondRole });
|
||||
service.expeditions.departGroup(player.id, groupId);
|
||||
const rewardOf = (playerId) => JSON.parse(database.db.prepare("SELECT reward_json FROM expedition_members WHERE expedition_id = ? AND player_id = ?").get(groupId, playerId).reward_json).cards;
|
||||
// Le second gagne la carte des Courants (groupe rejoint), puis une carte qu'il n'a pas, le Grand Vide.
|
||||
assert.deepEqual(rewardOf(second.id).filter((id) => id.startsWith("destination-")), ["destination-light-currents-standard", "destination-great-void-standard"]);
|
||||
assert.deepEqual(rewardOf(player.id).filter((id) => id.startsWith("destination-")), ["destination-great-void-standard"]);
|
||||
clock.now += 3 * HOUR;
|
||||
service.expeditions.claim(second.id, groupId);
|
||||
assert.ok(destinationCardsOf(service, second.id).includes("destination-light-currents-standard"));
|
||||
// Plus aucune carte de destination à trouver : rien de plus.
|
||||
service.expeditions.claim(player.id, groupId);
|
||||
assert.deepEqual(service.expeditions.rollDestinationCards(player.id, { id: "light-currents" }, service.expeditions.settings, { group: true, random: () => 0 }), []);
|
||||
});
|
||||
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue