Rebuild the Expeditions page around one guided journey: one card, no roles, leave alone or open to a group, follow the trip, keep a Journal
An expedition now opens with a single card. Its creator leaves alone right away, or opens it to the Guild board with an invite link and launches it whenever they want; at the end of recruitment it leaves by itself, alone or as a group, and is never dissolved for lack of players. Stars no longer depend on the number of players, a player has one expedition at a time, and roles are gone: each card brings its stats and a team adds them up, so every requirement is its per-slot share times the number of slots. The page follows the player's path: the offered destination card is revealed once in a modal, then Préparer shows the destinations (stat requirements, condition and dangers coloured for the chosen card, loot effects), a frame with the sent card in large size, its equipment slots and stats, and the duration and departure. Cards and commons are chosen in modals with sorts and highlighted current picks; tags get matching colours on the card and on equipment synergies. Once gone, the trip is shown with a progress bar and moving cards, the loot opens in a modal, and finished expeditions move to a Journal tab with the Grimoire. Power commons get short power names of their own and show their exact effects on hover, a card holds one power at a time, and Coup de folie now draws the real requirements between 80 % and 130 % of the shown ones, revealed on return. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d70ae51265
commit
3720fd01f7
41 changed files with 1807 additions and 894 deletions
|
|
@ -272,6 +272,8 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.powers.stormLantern",
|
||||
"cards.expeditions.powers.fogBell",
|
||||
"cards.expeditions.hiddenRequirements",
|
||||
"cards.expeditions.requirementFactor",
|
||||
"cards.expeditions.requirementsUncertain",
|
||||
"cards.expeditions.hiddenResult",
|
||||
"cards.expeditions.travelTime",
|
||||
"cards.expeditions.rewardCard",
|
||||
|
|
@ -322,11 +324,7 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.grimoireCount",
|
||||
"cards.guild.expeditionsGroups",
|
||||
"cards.guild.expeditionsForming",
|
||||
"cards.expeditions.modeLabel",
|
||||
"cards.expeditions.modeSolo",
|
||||
"cards.expeditions.modeGroup",
|
||||
"cards.expeditions.groupsTitle",
|
||||
"cards.expeditions.groupsEmpty",
|
||||
"cards.expeditions.groupMeta",
|
||||
"cards.expeditions.groupDeadline",
|
||||
"cards.expeditions.groupMembers",
|
||||
|
|
@ -336,17 +334,13 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.cohesion",
|
||||
"cards.expeditions.lootBonus",
|
||||
"cards.expeditions.join",
|
||||
"cards.expeditions.joinRole",
|
||||
"cards.expeditions.joinConfirm",
|
||||
"cards.expeditions.cancel",
|
||||
"cards.expeditions.leave",
|
||||
"cards.expeditions.dissolve",
|
||||
"cards.expeditions.depart",
|
||||
"cards.expeditions.departWait",
|
||||
"cards.expeditions.groupLimit",
|
||||
"cards.expeditions.groupTeamHelp",
|
||||
"cards.expeditions.groupPreviewNote",
|
||||
"cards.expeditions.groupStart",
|
||||
"cards.expeditions.soloKeeper",
|
||||
"cards.expeditions.groupOpened",
|
||||
"cards.expeditions.joined",
|
||||
"cards.expeditions.left",
|
||||
|
|
@ -364,7 +358,6 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.closedText",
|
||||
"cards.expeditions.expired",
|
||||
"cards.expeditions.reload",
|
||||
"cards.expeditions.activeTitle",
|
||||
"cards.expeditions.reportMeta",
|
||||
"cards.expeditions.running",
|
||||
"cards.expeditions.returned",
|
||||
|
|
@ -372,18 +365,96 @@ export function validateSiteContent(site) {
|
|||
"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.unlockedDestinations",
|
||||
"cards.expeditions.profileTitle",
|
||||
"cards.expeditions.requirementsFactTitle",
|
||||
"cards.expeditions.requirementsHelp",
|
||||
"cards.expeditions.requirementsHelpCard",
|
||||
"cards.expeditions.mainStatHelp",
|
||||
"cards.expeditions.requirementMet",
|
||||
"cards.expeditions.requirementUnmet",
|
||||
"cards.expeditions.sortLabel",
|
||||
"cards.expeditions.sortPower",
|
||||
"cards.expeditions.sortSynergy",
|
||||
"cards.expeditions.sortPowers",
|
||||
"cards.expeditions.sortUseful",
|
||||
"cards.expeditions.powerVocation",
|
||||
"cards.expeditions.tagCondition",
|
||||
"cards.expeditions.tagParry",
|
||||
"cards.expeditions.tagAffinity",
|
||||
"cards.expeditions.tagsLabel",
|
||||
"cards.expeditions.tagsNone",
|
||||
"cards.expeditions.tagsTitle",
|
||||
"cards.expeditions.chosenStats",
|
||||
"cards.expeditions.chosenStatsTitle",
|
||||
"cards.expeditions.statBase",
|
||||
"cards.expeditions.chosenPowers",
|
||||
"cards.expeditions.bonusFrom",
|
||||
"cards.expeditions.equipmentTitle",
|
||||
"cards.expeditions.equipmentPickerTitle",
|
||||
"cards.expeditions.equipmentPickerHelp",
|
||||
"cards.expeditions.equipmentHere",
|
||||
"cards.expeditions.equipmentPowerLimit",
|
||||
"cards.expeditions.pickerDone",
|
||||
"cards.expeditions.cardPickerTitle",
|
||||
"cards.expeditions.cardPickerHelp",
|
||||
"cards.expeditions.changeCard",
|
||||
"cards.expeditions.chooseCardSlot",
|
||||
"cards.expeditions.loadoutEmpty",
|
||||
"cards.expeditions.equipmentAdd",
|
||||
"cards.expeditions.equipmentLocked",
|
||||
"cards.expeditions.equipmentReplace",
|
||||
"cards.expeditions.equipmentRemove",
|
||||
"cards.expeditions.equipmentPut",
|
||||
"cards.expeditions.equipmentSynergy",
|
||||
"cards.expeditions.synergyBonus",
|
||||
"cards.expeditions.equipmentElsewhere",
|
||||
"cards.expeditions.equipmentNone",
|
||||
"cards.expeditions.departHelp",
|
||||
"cards.expeditions.departSolo",
|
||||
"cards.expeditions.openGroup",
|
||||
"cards.expeditions.departedSolo",
|
||||
"cards.expeditions.tabPrepare",
|
||||
"cards.expeditions.tabJournal",
|
||||
"cards.expeditions.tabJournalCount",
|
||||
"cards.expeditions.journalTitle",
|
||||
"cards.expeditions.journalEmpty",
|
||||
"cards.expeditions.mineTitle",
|
||||
"cards.expeditions.inviteLabel",
|
||||
"cards.expeditions.inviteCopy",
|
||||
"cards.expeditions.inviteCopied",
|
||||
"cards.expeditions.joinMissing",
|
||||
"cards.expeditions.journeyMeta",
|
||||
"cards.expeditions.journeyAlone",
|
||||
"cards.expeditions.journeyGroup",
|
||||
"cards.expeditions.journeyCards",
|
||||
"cards.expeditions.journeyProgress",
|
||||
"cards.expeditions.claimedTitle",
|
||||
"cards.expeditions.claimedClose",
|
||||
"cards.expeditions.starterEyebrow",
|
||||
"cards.expeditions.starterTitle",
|
||||
"cards.expeditions.starterHint",
|
||||
"cards.expeditions.starterRevealLabel",
|
||||
"cards.expeditions.starterText",
|
||||
"cards.expeditions.starterClose",
|
||||
"cards.expeditions.requirementValue",
|
||||
"cards.expeditions.hazardsTitle",
|
||||
"cards.expeditions.conditionShort",
|
||||
"cards.expeditions.conditionDetail",
|
||||
"cards.expeditions.conditionOk",
|
||||
"cards.expeditions.conditionKo",
|
||||
"cards.expeditions.dangerShort",
|
||||
"cards.expeditions.dangerDetail",
|
||||
"cards.expeditions.dangerOk",
|
||||
"cards.expeditions.dangerKo",
|
||||
"cards.expeditions.lootTitle",
|
||||
"cards.expeditions.lootNeutral",
|
||||
"cards.expeditions.lootEffect",
|
||||
"cards.expeditions.loot.eclats",
|
||||
"cards.expeditions.loot.stardust",
|
||||
|
|
@ -397,24 +468,19 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.starsLabel",
|
||||
"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",
|
||||
|
|
@ -425,7 +491,6 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.dangerActive",
|
||||
"cards.expeditions.durationMalus",
|
||||
"cards.expeditions.expected",
|
||||
"cards.expeditions.start",
|
||||
"cards.expeditions.tiers.struggle",
|
||||
"cards.expeditions.tiers.success",
|
||||
"cards.expeditions.tiers.triumph",
|
||||
|
|
@ -433,14 +498,6 @@ export function validateSiteContent(site) {
|
|||
"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",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// 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).
|
||||
// Rôle : vérifie le service et l'API des Expéditions Sokko TCG (destinations du jour, ouverture et départ seul ou en groupe, retour,
|
||||
// réglages, suppression de compte).
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
|
|
@ -39,7 +40,16 @@ function expeditionService({ start = Date.parse("2026-11-15T09:00:00Z"), random
|
|||
return { clock, database, service, admin, player, open, rares };
|
||||
}
|
||||
|
||||
const soloBody = (view, slots, changes = {}) => ({ day: view.day, destinationId: view.destinations[0].id, durationHours: 2, slots, ...changes });
|
||||
// Ouverture d'une expédition : une destination du jour, une durée et une carte.
|
||||
const soloBody = (view, editionId, changes = {}) => ({ day: view.day, destinationId: view.destinations[0].id, durationHours: 2, editionId, ...changes });
|
||||
|
||||
// Départ seul : l'expédition s'ouvre au tableau de la Guilde, puis son créateur la lance aussitôt.
|
||||
function goSolo(service, playerId, body, key) {
|
||||
const opened = service.expeditions.createGroup(playerId, body, key);
|
||||
const group = opened.expeditions.groups.filter((item) => item.isCreator).at(-1);
|
||||
const departed = service.expeditions.departGroup(playerId, group.id);
|
||||
return { ...departed, expedition: service.expeditions.expeditionView(group.id, playerId) };
|
||||
}
|
||||
|
||||
test("expeditions stay closed until an administrator opens them", () => {
|
||||
const { service, player, open, rares } = expeditionService();
|
||||
|
|
@ -47,18 +57,22 @@ test("expeditions stay closed until an administrator opens them", () => {
|
|||
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.createGroup(player.id, soloBody({ day: closed.day, destinations: [{ id: "light-currents" }] }, rares[0]), "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);
|
||||
// La difficulté est tirée avec les destinations : un niveau de chaque, le groupe une étoile au-dessus du solo.
|
||||
// La difficulté est tirée avec les destinations : un niveau de chaque, les mêmes étoiles seul ou en groupe. Exigences d'une carte
|
||||
// seule (la part d'une place), et du groupe complet (une part par place).
|
||||
assert.deepEqual(view.destinations.map((item) => item.level).sort(), [0, 1, 2, 3]);
|
||||
assert.ok(view.destinations.every((item) => item.groupStar === item.soloStar + 1 && Object.keys(item.stars).join() === String(item.soloStar) && Object.keys(item.groupStars).join() === String(item.groupStar)));
|
||||
assert.equal(view.destinations.find((item) => item.soloStar === 4).stars[4].dangers.length, 1);
|
||||
assert.equal(view.destinations.find((item) => item.soloStar === 2).stars[2].condition, null);
|
||||
assert.ok(view.destinations.every((item) => item.star === item.level + 1 && item.groupRequirements.length === item.requirements.length));
|
||||
const sample = view.destinations.find((item) => item.star === 2);
|
||||
assert.deepEqual(sample.requirements.map((item) => item.value), DEFAULT_EXPEDITION_SETTINGS.requirements.star2);
|
||||
assert.deepEqual(sample.groupRequirements.map((item) => item.value), DEFAULT_EXPEDITION_SETTINGS.requirements.star2.map((value) => value * DEFAULT_GROUP.slots));
|
||||
assert.equal(view.destinations.find((item) => item.star === 4).dangers.length, 1);
|
||||
assert.equal(sample.condition, null);
|
||||
assert.equal(view.cards.length, 4);
|
||||
// Le tirage du jour du joueur est gardé en base.
|
||||
assert.deepEqual(service.expeditions.getExpeditions(player.id).destinations.map((item) => item.id), view.destinations.map((item) => item.id));
|
||||
|
|
@ -79,7 +93,7 @@ test("each player draws the day among the destinations their cards unlock", () =
|
|||
open({ destinations: Object.fromEntries(Object.entries(service.expeditions.settings.destinations).map(([id, value]) => [id, { ...value, active: kept.has(id) }])) });
|
||||
// Première visite : la carte de départ (random() = 0, les Courants) ouvre une seule destination, au niveau le plus facile.
|
||||
const before = service.expeditions.getExpeditions(player.id);
|
||||
assert.deepEqual(before.destinations.map((item) => [item.id, item.level, item.soloStar]), [["light-currents", 0, 1]]);
|
||||
assert.deepEqual(before.destinations.map((item) => [item.id, item.level, item.star]), [["light-currents", 0, 1]]);
|
||||
assert.deepEqual(before.unlocked.count >= 1 && before.unlocked.total, 14);
|
||||
// Sa carte du Cœur du Nuage complète le tirage du jour, avec les niveaux 1 et 2 ; l'autre joueur, sans la carte, ne la voit pas.
|
||||
database.transaction(() => service.addCard(player.id, "cosmic-cloud-heart-standard"));
|
||||
|
|
@ -110,12 +124,11 @@ test("players receive a starter destination card, then find more on expeditions
|
|||
// Un groupe vers les Courants : le second joueur, sans leur carte, la gagne ; le créateur gagne une 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 created = service.expeditions.createGroup(player.id, { day: view.day, destinationId: destination.id, durationHours: 2, editionId: rares[0] }, "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.joinGroup(second.id, groupId, { editionId: arcade[0] });
|
||||
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, la première restante : le Rivage de l'Aube.
|
||||
|
|
@ -134,30 +147,40 @@ test("players receive a starter destination card, then find more on expeditions
|
|||
assert.deepEqual(service.expeditions.rollDestinationCards(player.id, { id: "lost-observatory" }, settings, { group: false, random: () => 0 }), []);
|
||||
});
|
||||
|
||||
test("a solo expedition freezes its team, hides its result until it returns and pays once", () => {
|
||||
test("an expedition launched alone is a solo: one card, its result hidden until it returns, paid once", () => {
|
||||
const { clock, service, player, open, rares, database } = expeditionService();
|
||||
open();
|
||||
open({ group: { ...DEFAULT_GROUP, maxConcurrent: 1 } });
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
// Une difficulté envoyée par un ancien client est ignorée : les étoiles sont celles de la destination.
|
||||
const body = soloBody(view, rares.slice(0, 2), { difficulty: 4, durationHours: 6 });
|
||||
const body = soloBody(view, rares[0], { difficulty: 4, 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.deepEqual(preview.requirements.map((item) => item.value), view.destinations[0].requirements.map((item) => item.value));
|
||||
assert.ok(preview.expected.eclats > 0);
|
||||
|
||||
const started = service.expeditions.startSolo(player.id, body, "start-1");
|
||||
// L'expédition s'ouvre au tableau ; son créateur peut partir tout de suite, seul.
|
||||
const opened = service.expeditions.createGroup(player.id, body, "start-1");
|
||||
const group = opened.expeditions.groups[0];
|
||||
assert.equal(group.canDepart, true);
|
||||
assert.deepEqual(group.requirements, preview.requirements.map(({ stat, main, value }) => ({ stat, main, value })));
|
||||
assert.equal(group.projected.scorePct, preview.scorePct);
|
||||
// Même clé : même expédition ; nouvelle clé : la carte est occupée, puis la limite d'expéditions s'applique.
|
||||
assert.equal(service.expeditions.createGroup(player.id, body, "start-1").expeditions.groups.length, 1);
|
||||
assert.throws(() => service.expeditions.createGroup(player.id, body, "start-2"), (error) => error.code === "EXPEDITION_CARD_BUSY");
|
||||
assert.throws(() => service.expeditions.createGroup(player.id, { ...body, editionId: rares[1] }, "start-3"), (error) => error.code === "EXPEDITION_LIMIT");
|
||||
service.expeditions.departGroup(player.id, group.id);
|
||||
const started = { expedition: service.expeditions.expeditionView(group.id, player.id), state: service.getState(player.id) };
|
||||
assert.equal(started.expedition.mode, "solo");
|
||||
assert.equal(started.expedition.status, "running");
|
||||
assert.equal(started.expedition.stars, view.destinations[0].soloStar);
|
||||
assert.equal(started.expedition.stars, view.destinations[0].star);
|
||||
// Seule, une place : pas de Veilleur de la Guilde.
|
||||
assert.equal(started.expedition.slots.length, 1);
|
||||
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.deepEqual(started.state.expeditions.busyEditions.map((item) => item.editionId), [rares[0]]);
|
||||
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.
|
||||
|
|
@ -167,6 +190,7 @@ test("a solo expedition freezes its team, hides its result until it returns and
|
|||
const returned = service.expeditions.getExpeditions(player.id).expeditions[0];
|
||||
assert.equal(returned.status, "returned");
|
||||
assert.equal(returned.result.tier, preview.tier);
|
||||
assert.equal(returned.result.players, undefined);
|
||||
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);
|
||||
|
|
@ -188,6 +212,36 @@ test("a solo expedition freezes its team, hides its result until it returns and
|
|||
assert.equal(database.db.prepare("SELECT COUNT(*) AS count FROM gift_packs WHERE source = 'expedition'").get().count, 0);
|
||||
});
|
||||
|
||||
// Parcours du joueur : la carte de destination offerte se présente une fois ; « Partir seul maintenant » ouvre et lance l'expédition
|
||||
// d'un coup, sans alerte d'ouverture ; une seule expédition à la fois ; une fois le butin récupéré, elle passe au Journal.
|
||||
test("a player sees the offered destination card once, leaves alone at once, one expedition at a time, then finds it in the Journal", () => {
|
||||
const { clock, service, player, open, rares } = expeditionService({ allDestinations: false });
|
||||
open();
|
||||
const first = service.expeditions.getExpeditions(player.id);
|
||||
assert.equal(first.starterCard, "light-currents-standard");
|
||||
assert.equal(service.expeditions.getExpeditions(player.id).starterCard, "light-currents-standard");
|
||||
assert.equal(service.expeditions.markStarterSeen(player.id).expeditions.starterCard, null);
|
||||
assert.ok(!service.getState(player.id).history.some((entry) => entry.type === "destination_starter_seen"));
|
||||
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
assert.equal(view.group.limit, 1);
|
||||
const departed = service.expeditions.createGroup(player.id, { ...soloBody(view, rares[0]), departNow: true }, "now");
|
||||
assert.deepEqual(departed.expeditions.groups, []);
|
||||
const [running] = departed.expeditions.expeditions;
|
||||
assert.equal(running.mode, "solo");
|
||||
assert.equal(running.status, "running");
|
||||
assert.equal(service.expeditions.pendingAlerts().length, 0);
|
||||
// Une seule expédition à la fois : ni ouvrir ni rejoindre tant que le butin n'est pas récupéré.
|
||||
assert.throws(() => service.expeditions.createGroup(player.id, soloBody(view, rares[1]), "second"), (error) => error.code === "EXPEDITION_LIMIT");
|
||||
assert.deepEqual(departed.expeditions.journal, []);
|
||||
clock.now += 2 * HOUR;
|
||||
const claimed = service.expeditions.claim(player.id, running.id);
|
||||
assert.deepEqual(claimed.expeditions.expeditions, []);
|
||||
assert.deepEqual(claimed.expeditions.journal.map((item) => [item.id, item.status]), [[running.id, "completed"]]);
|
||||
assert.ok(claimed.expeditions.journal[0].reward.eclats >= 0);
|
||||
service.expeditions.createGroup(player.id, soloBody(view, rares[1]), "after");
|
||||
});
|
||||
|
||||
// Une carte rapportée vient des Carnets de la destination ; une destination rattachée à une collection ouverte la tire le plus
|
||||
// souvent dans sa collection (rewardCards.linkedCollectionPct), sinon dans ses Carnets.
|
||||
test("reward cards come from the Carnets, or mostly from the destination's collection when it is open", () => {
|
||||
|
|
@ -244,25 +298,23 @@ test("unlucky rolls keep the average and never hand out a collection card", () =
|
|||
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");
|
||||
const started = goSolo(service, player.id, soloBody(view, rares[0]), "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", () => {
|
||||
test("opening an expedition refuses stale days, unknown destinations, commons 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);
|
||||
const start = (changes, key) => () => service.expeditions.createGroup(player.id, soloBody(view, rares[0], changes), key);
|
||||
assert.throws(start({ destinationId: "nowhere" }, "a"), (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");
|
||||
assert.throws(start({ editionId: editionsOf("common")[0] }, "f"), (error) => error.code === "EXPEDITION_CARD_INVALID");
|
||||
assert.throws(start({ editionId: rares[10] }, "g"), (error) => error.code === "CARD_NOT_OWNED");
|
||||
assert.throws(() => service.expeditions.createGroup(player.id, soloBody(view, rares[0]), ""), (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");
|
||||
|
|
@ -282,7 +334,7 @@ test("administrators tune settings with bounds and history, and can cancel an ex
|
|||
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");
|
||||
const started = goSolo(service, player.id, soloBody(view, rares[0]), "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);
|
||||
|
|
@ -297,10 +349,10 @@ 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");
|
||||
const first = goSolo(service, player.id, soloBody(view, rares[0]), "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");
|
||||
const second = goSolo(service, player.id, soloBody(view, rares[1]), "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");
|
||||
|
|
@ -345,7 +397,7 @@ test("the expeditions API requires a session, CSRF protection, an administrator
|
|||
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 } } } });
|
||||
const invalid = await call(handler, { method: "PUT", path: "/api/cards/admin/expeditions/settings", headers, body: { settings: { ...settings, stars: { ...settings.stars, max: 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 } });
|
||||
|
|
@ -355,20 +407,21 @@ test("the expeditions API requires a session, CSRF protection, an administrator
|
|||
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);
|
||||
assert.ok(view.cards.length > 0, "the development account owns rare or better cards");
|
||||
const body = soloBody(view, view.cards[0].editionId);
|
||||
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 });
|
||||
const created = await call(handler, { method: "POST", path: "/api/cards/expeditions", headers: { ...headers, "idempotency-key": "api-start" }, body });
|
||||
assert.equal(created.status, 201);
|
||||
const expeditionId = created.json.expeditions.groups[0].id;
|
||||
const started = await call(handler, { method: "POST", path: `/api/cards/expeditions/${expeditionId}/depart`, headers });
|
||||
assert.equal(started.json.expeditions.expeditions[0].status, "running");
|
||||
const early = await call(handler, { method: "POST", path: `/api/cards/expeditions/${expeditionId}/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 });
|
||||
const cancelled = await call(handler, { method: "POST", path: `/api/cards/admin/expeditions/${expeditionId}/cancel`, headers });
|
||||
assert.equal(cancelled.status, 200);
|
||||
});
|
||||
|
||||
|
|
@ -388,54 +441,49 @@ function groupService(options) {
|
|||
return { ...context, second, third, arcade };
|
||||
}
|
||||
|
||||
const groupBody = (view, editionId, role, changes = {}) => ({ mode: "group", day: view.day, destinationId: view.destinations[0].id, durationHours: 2, editionId, role, ...changes });
|
||||
const groupBody = soloBody;
|
||||
|
||||
test("a group opens on the Guild board, fills its roles and leaves when its creator launches it", () => {
|
||||
test("a group opens on the Guild board, fills its places and leaves when its creator launches it", () => {
|
||||
const { clock, service, player, second, third, open, rares, arcade, database } = groupService();
|
||||
open();
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
assert.deepEqual(view.group.stars, { min: 2, max: 5 });
|
||||
assert.equal(view.destinations[0].groupRoles.length, 4);
|
||||
assert.deepEqual(Object.keys(view.destinations[0].groupStars), [String(view.destinations[0].groupStar)]);
|
||||
const [mainRole, secondRole] = view.destinations[0].groupRoles;
|
||||
// Aperçu du groupe que le joueur ouvrirait : les trois autres places tenues par le Veilleur.
|
||||
const preview = service.expeditions.preview(player.id, groupBody(view, rares[0], mainRole)).preview;
|
||||
assert.equal(preview.requirements.length, view.destinations[0].groupStars[view.destinations[0].groupStar].requirements.length);
|
||||
assert.throws(() => service.expeditions.createGroup(player.id, groupBody(view, rares[0], "nothing"), "g0"), (error) => error.code === "EXPEDITION_INVALID");
|
||||
assert.deepEqual(view.stars, { min: 1, max: 5, limit: 5 });
|
||||
|
||||
const created = service.expeditions.createGroup(player.id, groupBody(view, rares[0], mainRole), "g1");
|
||||
assert.equal(service.expeditions.createGroup(player.id, groupBody(view, rares[0], mainRole), "g1").expeditions.groups.length, 1);
|
||||
const created = service.expeditions.createGroup(player.id, groupBody(view, rares[0]), "g1");
|
||||
assert.equal(service.expeditions.createGroup(player.id, groupBody(view, rares[0]), "g1").expeditions.groups.length, 1);
|
||||
const group = created.expeditions.groups[0];
|
||||
assert.equal(group.isCreator, true);
|
||||
assert.equal(group.canDepart, false);
|
||||
assert.deepEqual(group.freeRoles, view.destinations[0].groupRoles.slice(1));
|
||||
assert.equal(group.canDepart, true);
|
||||
assert.equal(group.freeSlots, DEFAULT_GROUP.slots - 1);
|
||||
assert.equal(created.state.expeditions.busyEditions[0].editionId, rares[0]);
|
||||
// La carte du créateur est occupée : elle ne peut pas partir en solo en même temps.
|
||||
assert.throws(() => service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2)), "solo-busy"), (error) => error.code === "EXPEDITION_CARD_BUSY");
|
||||
// Seule, l'expédition a les exigences d'une carte ; dès qu'un joueur rejoint, celles du groupe complet.
|
||||
assert.deepEqual(group.requirements.map((item) => item.value), view.destinations[0].requirements.map((item) => item.value));
|
||||
// La carte du créateur est occupée : elle ne peut pas partir dans une autre expédition en même temps.
|
||||
assert.throws(() => service.expeditions.createGroup(player.id, soloBody(view, rares[0], { destinationId: view.destinations[1].id }), "solo-busy"), (error) => error.code === "EXPEDITION_CARD_BUSY");
|
||||
|
||||
// Le tableau est visible des autres joueurs, et la Guilde le signale à ceux qui peuvent rejoindre.
|
||||
assert.equal(service.getState(second.id).expeditions.joinableGroups, 1);
|
||||
const board = service.expeditions.getExpeditions(second.id).groups[0];
|
||||
assert.equal(board.canJoin, true);
|
||||
assert.equal(board.creatorName, "Player");
|
||||
assert.throws(() => service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0], role: mainRole }), (error) => error.code === "EXPEDITION_ROLE_TAKEN");
|
||||
assert.throws(() => service.expeditions.joinGroup(second.id, group.id, { editionId: rares[0], role: secondRole }), (error) => error.code === "CARD_NOT_OWNED");
|
||||
assert.throws(() => service.expeditions.joinGroup(player.id, group.id, { editionId: rares[1], role: secondRole }), (error) => error.code === "EXPEDITION_ALREADY_JOINED");
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0], role: secondRole });
|
||||
assert.throws(() => service.expeditions.joinGroup(second.id, group.id, { editionId: rares[0] }), (error) => error.code === "CARD_NOT_OWNED");
|
||||
assert.throws(() => service.expeditions.joinGroup(player.id, group.id, { editionId: rares[1] }), (error) => error.code === "EXPEDITION_ALREADY_JOINED");
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0] });
|
||||
assert.throws(() => service.expeditions.departGroup(second.id, group.id), (error) => error.code === "EXPEDITION_NOT_CREATOR");
|
||||
|
||||
const before = service.expeditions.getExpeditions(player.id).groups[0];
|
||||
assert.equal(before.members.length, 2);
|
||||
assert.equal(before.canDepart, true);
|
||||
assert.deepEqual(before.requirements.map((item) => item.value), view.destinations[0].groupRequirements.map((item) => item.value));
|
||||
// Collections différentes : bonus de cohésion.
|
||||
assert.equal(before.projected.cohesionPct, 10);
|
||||
service.expeditions.departGroup(player.id, group.id);
|
||||
assert.deepEqual(service.expeditions.getExpeditions(third.id).groups, []);
|
||||
const slots = database.db.prepare("SELECT player_id, role FROM expedition_slots WHERE expedition_id = ? ORDER BY position").all(group.id);
|
||||
const slots = database.db.prepare("SELECT player_id FROM expedition_slots WHERE expedition_id = ? ORDER BY position").all(group.id);
|
||||
assert.equal(slots.length, 4);
|
||||
// Le Veilleur tient les deux places vides, sans rôle.
|
||||
assert.deepEqual(slots.filter((slot) => slot.player_id == null).map((slot) => slot.role), [null, null]);
|
||||
assert.throws(() => service.expeditions.joinGroup(third.id, group.id, { editionId: rares[5], role: view.destinations[0].groupRoles[2] }), (error) => error.code === "EXPEDITION_GROUP_DEPARTED");
|
||||
// Le Veilleur tient les deux places vides.
|
||||
assert.equal(slots.filter((slot) => slot.player_id == null).length, 2);
|
||||
assert.throws(() => service.expeditions.joinGroup(third.id, group.id, { editionId: rares[5] }), (error) => error.code === "EXPEDITION_GROUP_DEPARTED");
|
||||
|
||||
clock.now += 2 * HOUR;
|
||||
const first = service.expeditions.claim(player.id, group.id);
|
||||
|
|
@ -448,36 +496,37 @@ test("a group opens on the Guild board, fills its roles and leaves when its crea
|
|||
assert.equal(last.state.history.find((entry) => entry.type === "expedition_completed").details.mode, "group");
|
||||
});
|
||||
|
||||
test("an unlaunched group departs alone with enough players at the end of recruitment, or dissolves", () => {
|
||||
const { clock, service, player, second, third, open, rares, arcade } = groupService();
|
||||
test("an unlaunched expedition departs by itself at the end of recruitment, alone as a solo or as a group", () => {
|
||||
const { clock, service, player, second, third, open, rares, arcade, database } = groupService();
|
||||
open({ group: { ...DEFAULT_GROUP, recruitHours: 1 } });
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const roles = view.destinations[0].groupRoles;
|
||||
const lonely = service.expeditions.createGroup(third.id, groupBody(view, rares[5], roles[0]), "lonely").expeditions.groups[0];
|
||||
const full = service.expeditions.createGroup(player.id, groupBody(view, rares[0], view.destinations[1].groupRoles[0], { destinationId: view.destinations[1].id }), "full").expeditions.groups.find((group) => group.isCreator);
|
||||
service.expeditions.joinGroup(second.id, full.id, { editionId: arcade[0], role: view.destinations[1].groupRoles[1] });
|
||||
const lonely = service.expeditions.createGroup(third.id, groupBody(view, rares[5]), "lonely").expeditions.groups[0];
|
||||
const full = service.expeditions.createGroup(player.id, groupBody(view, rares[0], { destinationId: view.destinations[1].id }), "full").expeditions.groups.find((group) => group.isCreator);
|
||||
service.expeditions.joinGroup(second.id, full.id, { editionId: arcade[0] });
|
||||
clock.now += HOUR + 1;
|
||||
const state = service.getState(third.id);
|
||||
assert.ok(state.history.some((entry) => entry.type === "expedition_dissolved"));
|
||||
assert.deepEqual(state.expeditions.busyEditions, []);
|
||||
// Seule, elle part en solo, sans Veilleur de la Guilde, et n'est plus dissoute.
|
||||
const alone = service.expeditions.getExpeditions(third.id).expeditions.find((expedition) => expedition.id === lonely.id);
|
||||
assert.equal(alone.mode, "solo");
|
||||
assert.equal(alone.status, "running");
|
||||
assert.equal(database.db.prepare("SELECT COUNT(*) AS count FROM expedition_slots WHERE expedition_id = ?").get(lonely.id).count, 1);
|
||||
assert.ok(!service.getState(third.id).history.some((entry) => entry.type === "expedition_dissolved"));
|
||||
const departed = service.expeditions.getExpeditions(player.id).expeditions.find((expedition) => expedition.id === full.id);
|
||||
assert.equal(departed.mode, "group");
|
||||
assert.equal(departed.status, "running");
|
||||
// Le départ automatique a lieu à la fin de l'inscription, pas à la lecture.
|
||||
assert.equal(departed.departsAt, departed.returnsAt - 2 * HOUR);
|
||||
assert.equal(lonely.id === full.id, false);
|
||||
});
|
||||
|
||||
test("leaving a forming group frees the card, and the creator leaving dissolves it", () => {
|
||||
const { service, player, second, open, rares, arcade } = groupService();
|
||||
open();
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const roles = view.destinations[0].groupRoles;
|
||||
const group = service.expeditions.createGroup(player.id, groupBody(view, rares[0], roles[0]), "leave").expeditions.groups[0];
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0], role: roles[1] });
|
||||
const group = service.expeditions.createGroup(player.id, groupBody(view, rares[0]), "leave").expeditions.groups[0];
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0] });
|
||||
service.expeditions.leaveGroup(second.id, group.id);
|
||||
assert.deepEqual(service.getState(second.id).expeditions.busyEditions, []);
|
||||
assert.equal(service.expeditions.getExpeditions(player.id).groups[0].members.length, 1);
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0], role: roles[1] });
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0] });
|
||||
service.expeditions.leaveGroup(player.id, group.id);
|
||||
assert.deepEqual(service.expeditions.getExpeditions(second.id).groups, []);
|
||||
assert.ok(service.getState(second.id).history.some((entry) => entry.type === "expedition_dissolved" && entry.details.reason === "creator_left"));
|
||||
|
|
@ -488,9 +537,8 @@ test("a player deleted during a group expedition forfeits their share and the ot
|
|||
const { clock, service, player, second, open, rares, arcade, database } = groupService();
|
||||
open();
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const roles = view.destinations[0].groupRoles;
|
||||
const group = service.expeditions.createGroup(player.id, groupBody(view, rares[0], roles[0]), "forfeit").expeditions.groups[0];
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0], role: roles[1] });
|
||||
const group = service.expeditions.createGroup(player.id, groupBody(view, rares[0]), "forfeit").expeditions.groups[0];
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: arcade[0] });
|
||||
service.expeditions.departGroup(player.id, group.id);
|
||||
service.deleteAccount(second.id);
|
||||
clock.now += 2 * HOUR;
|
||||
|
|
@ -513,15 +561,12 @@ test("the group API opens, joins, leaves and launches through dedicated routes",
|
|||
});
|
||||
service.expeditions.updateSettings(devId, { ...service.expeditions.settings, enabled: true });
|
||||
const view = (await call(handler, { path: "/api/cards/expeditions", headers: { cookie } })).json;
|
||||
const roles = view.destinations[0].groupRoles;
|
||||
const created = await call(handler, { method: "POST", path: "/api/cards/expeditions", headers: { ...headers, "idempotency-key": "api-group" }, body: groupBody(view, view.cards[0].editionId, roles[0]) });
|
||||
const created = await call(handler, { method: "POST", path: "/api/cards/expeditions", headers: { ...headers, "idempotency-key": "api-group" }, body: groupBody(view, view.cards[0].editionId) });
|
||||
assert.equal(created.status, 201);
|
||||
const groupId = created.json.expeditions.groups[0].id;
|
||||
const tooSmall = await call(handler, { method: "POST", path: `/api/cards/expeditions/${groupId}/depart`, headers });
|
||||
assert.equal(tooSmall.json.error.code, "EXPEDITION_GROUP_TOO_SMALL");
|
||||
service.expeditions.joinGroup(other.id, groupId, { editionId: editionsOf("rare")[1], role: roles[1] });
|
||||
const unknownRole = await call(handler, { method: "POST", path: `/api/cards/expeditions/${groupId}/join`, headers, body: { editionId: view.cards[0].editionId, role: roles[2] } });
|
||||
assert.equal(unknownRole.json.error.code, "EXPEDITION_ALREADY_JOINED");
|
||||
service.expeditions.joinGroup(other.id, groupId, { editionId: editionsOf("rare")[1] });
|
||||
const again = await call(handler, { method: "POST", path: `/api/cards/expeditions/${groupId}/join`, headers, body: { editionId: view.cards[0].editionId } });
|
||||
assert.equal(again.json.error.code, "EXPEDITION_ALREADY_JOINED");
|
||||
const departed = await call(handler, { method: "POST", path: `/api/cards/expeditions/${groupId}/depart`, headers });
|
||||
assert.equal(departed.status, 200);
|
||||
assert.equal(departed.json.expeditions.expeditions[0].status, "running");
|
||||
|
|
@ -554,12 +599,12 @@ test("cards level up with Éclats or a duplicate, gain field experience and stro
|
|||
// Les expéditions utilisent la Puissance améliorée, et chaque retour donne 10 % de niveau aux cartes envoyées.
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
assert.equal(view.cards.find((item) => item.editionId === card).power, 50);
|
||||
const started = service.expeditions.startSolo(player.id, soloBody(view, [card, rares[1]]), "levelled");
|
||||
const started = goSolo(service, player.id, soloBody(view, card), "levelled");
|
||||
clock.now += 2 * HOUR;
|
||||
service.expeditions.claim(player.id, started.expedition.id);
|
||||
const after = service.getState(player.id).cardProgress;
|
||||
assert.equal(after.find((item) => item.editionId === card).fieldXp, 10);
|
||||
assert.equal(after.find((item) => item.editionId === rares[1]).fieldXp, 10);
|
||||
assert.equal(after.find((item) => item.editionId === rares[1])?.fieldXp ?? 0, 0);
|
||||
|
||||
// Au plafond, plus de niveau ; la suppression du compte efface la progression.
|
||||
database.db.prepare("UPDATE card_progress SET level = 12 WHERE player_id = ? AND edition_id = ?").run(player.id, card);
|
||||
|
|
@ -623,7 +668,7 @@ test("progression plans spread level points by vocation or by hand, and a Parche
|
|||
|
||||
// Le plan d'une carte en expédition ne change pas avant son retour.
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
service.expeditions.startSolo(player.id, soloBody(view, [card, rares[1]]), "planned");
|
||||
goSolo(service, player.id, soloBody(view, card), "planned");
|
||||
assert.throws(() => service.expeditions.setCardPlan(player.id, { editionId: card, plan: "free", allocation: allocation(12, 13) }), (error) => error.code === "EXPEDITION_CARD_BUSY");
|
||||
assert.throws(() => service.expeditions.setCardPlan(player.id, { editionId: editionsOf("common")[0], plan: "guardian" }), (error) => error.code === "CARD_NOT_OWNED");
|
||||
|
||||
|
|
@ -727,7 +772,7 @@ test("commons equip open slots, add stats with synergies, move between cards and
|
|||
// Les stats équipées partent en expédition, et l'équipement d'une carte en route ne change pas.
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
assert.deepEqual(view.cards.find((item) => item.editionId === card).stats, strangerStats.stats);
|
||||
const started = service.expeditions.startSolo(player.id, soloBody(view, [card, other]), "equipped");
|
||||
const started = goSolo(service, player.id, soloBody(view, card), "equipped");
|
||||
assert.throws(() => service.expeditions.equip(player.id, { editionId: card, slot: 0, equipmentEditionId: null }), (error) => error.code === "EXPEDITION_CARD_BUSY");
|
||||
clock.now += 2 * HOUR;
|
||||
service.expeditions.claim(player.id, started.expedition.id);
|
||||
|
|
@ -744,18 +789,26 @@ test("commons equip open slots, add stats with synergies, move between cards and
|
|||
assert.equal(refused.json.error.code, "CARD_NOT_OWNED");
|
||||
});
|
||||
|
||||
test("resonances and destination affinity raise the score and are written to every player's Grimoire", () => {
|
||||
const { service, player, open, database } = expeditionService();
|
||||
// Les Résonances lient les cartes d'une même équipe : seule, une carte n'en a pas ; en groupe, elles comptent et s'inscrivent au
|
||||
// Grimoire de chaque joueur.
|
||||
test("resonances raise a group's score and are written to every player's Grimoire", () => {
|
||||
const { service, player, second, open, database } = groupService();
|
||||
open();
|
||||
// Écho : le hamster de la Nébuleuse et sa version de l'Arcade des Rêves.
|
||||
database.transaction(() => ["solar-seed-hamster-standard", "steel-ball-hamster-standard"].forEach((editionId) => service.addCard(player.id, editionId)));
|
||||
// Écho : le hamster de la Nébuleuse et sa version de l'Arcade des Rêves, apportés par deux joueurs.
|
||||
database.transaction(() => {
|
||||
service.addCard(player.id, "solar-seed-hamster-standard");
|
||||
service.addCard(second.id, "steel-ball-hamster-standard");
|
||||
});
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const body = soloBody(view, ["solar-seed-hamster-standard", "steel-ball-hamster-standard"]);
|
||||
const preview = service.expeditions.preview(player.id, body).preview;
|
||||
assert.ok(preview.resonances.some((resonance) => resonance.type === "echo" && resonance.key === "personnage:hamster"));
|
||||
assert.ok(preview.synergyPct >= 10);
|
||||
service.expeditions.startSolo(player.id, body, "echo");
|
||||
assert.ok(service.expeditions.getExpeditions(player.id).grimoire.some((entry) => entry.id === "resonance:echo:personnage:hamster"));
|
||||
const body = groupBody(view, "solar-seed-hamster-standard");
|
||||
assert.deepEqual(service.expeditions.preview(player.id, body).preview.resonances, []);
|
||||
const group = service.expeditions.createGroup(player.id, body, "echo").expeditions.groups[0];
|
||||
service.expeditions.joinGroup(second.id, group.id, { editionId: "steel-ball-hamster-standard" });
|
||||
const projected = service.expeditions.getExpeditions(player.id).groups[0].projected;
|
||||
assert.ok(projected.resonances.some((resonance) => resonance.type === "echo" && resonance.key === "personnage:hamster"));
|
||||
assert.ok(projected.synergyPct >= 10);
|
||||
service.expeditions.departGroup(player.id, group.id);
|
||||
for (const member of [player, second]) assert.ok(service.expeditions.getExpeditions(member.id).grimoire.some((entry) => entry.id === "resonance:echo:personnage:hamster"));
|
||||
});
|
||||
|
||||
test("Discord alerts stay off until a player opts in, then queue group openings and returns once", async () => {
|
||||
|
|
@ -776,8 +829,7 @@ test("Discord alerts stay off until a player opts in, then queue group openings
|
|||
|
||||
// Groupe ouvert par le joueur : seul l'ami qui a activé l'alerte est prévenu, jamais le créateur ni le joueur silencieux.
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
const roles = view.destinations[0].groupRoles;
|
||||
const group = service.expeditions.createGroup(player.id, groupBody(view, rares[0], roles[0]), "alert-group").expeditions.groups[0];
|
||||
const group = service.expeditions.createGroup(player.id, groupBody(view, rares[0]), "alert-group").expeditions.groups[0];
|
||||
let pending = service.expeditions.pendingAlerts();
|
||||
assert.equal(pending.length, 1);
|
||||
assert.equal(pending[0].discordId, "123456789012345678");
|
||||
|
|
@ -785,7 +837,7 @@ test("Discord alerts stay off until a player opts in, then queue group openings
|
|||
assert.equal(silent.id === friend.id, false);
|
||||
|
||||
// Retours : une alerte par membre qui l'a activée, une seule fois.
|
||||
service.expeditions.joinGroup(friend.id, group.id, { editionId: editionsOf("rare")[8], role: roles[1] });
|
||||
service.expeditions.joinGroup(friend.id, group.id, { editionId: editionsOf("rare")[8] });
|
||||
service.expeditions.departGroup(player.id, group.id);
|
||||
assert.equal(service.expeditions.queueReturnAlerts(), 0);
|
||||
clock.now += 2 * HOUR;
|
||||
|
|
@ -879,7 +931,7 @@ test("objects add bonus destinations, recall an expedition with an anchor and en
|
|||
|
||||
// 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");
|
||||
const started = goSolo(service, player.id, soloBody(view, rares[0], { 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);
|
||||
|
|
@ -908,7 +960,7 @@ 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");
|
||||
const started = goSolo(service, player.id, soloBody(view, rares[0]), "objects");
|
||||
clock.now += 2 * HOUR;
|
||||
const claimed = service.expeditions.claim(player.id, started.expedition.id);
|
||||
assert.equal(claimed.expedition.reward.items.length, 2);
|
||||
|
|
@ -940,12 +992,12 @@ test("the Carnets des Veilleurs never come from packs, and their cards only drop
|
|||
const view = service.expeditions.getExpeditions(player.id);
|
||||
// Sans illustration, aucune carte des Carnets n'est rapportée, même avec une chance pleine.
|
||||
unillustrateLogbooks(service);
|
||||
const first = service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2)), "no-art");
|
||||
const first = goSolo(service, player.id, soloBody(view, rares[0]), "no-art");
|
||||
clock.now += 2 * HOUR;
|
||||
const logbooksOf = (cards) => cards.filter((editionId) => service.catalog.cards.find((card) => card.id === service.index.editions.get(editionId).cardId).collectionId === "watchers-logbooks");
|
||||
assert.deepEqual(logbooksOf(service.expeditions.claim(player.id, first.expedition.id).expedition.reward.cards), []);
|
||||
illustrateLogbooks(service);
|
||||
const second = service.expeditions.startSolo(player.id, soloBody(view, rares.slice(0, 2)), "with-art");
|
||||
const second = goSolo(service, player.id, soloBody(view, rares[0]), "with-art");
|
||||
clock.now += 2 * HOUR;
|
||||
const reward = service.expeditions.claim(player.id, second.expedition.id).expedition.reward;
|
||||
assert.equal(logbooksOf(reward.cards).length, 1);
|
||||
|
|
@ -966,16 +1018,23 @@ test("power commons equip one per card, change travel time and hide requirements
|
|||
assert.throws(() => service.expeditions.equip(player.id, { editionId: rares[0], slot: 1, equipmentEditionId: compass }), (error) => error.code === "POWER_LIMIT");
|
||||
const view = service.expeditions.getExpeditions(player.id);
|
||||
assert.deepEqual(view.cards.find((card) => card.editionId === rares[0]).powers, ["longsight"]);
|
||||
const body = soloBody(view, rares.slice(0, 2), { durationHours: 6 });
|
||||
const body = soloBody(view, rares[0], { durationHours: 6 });
|
||||
assert.equal(service.expeditions.preview(player.id, body).preview.travelHours, 8);
|
||||
const started = service.expeditions.startSolo(player.id, body, "longsight");
|
||||
const started = goSolo(service, player.id, body, "longsight");
|
||||
assert.equal(started.expedition.returnsAt - started.expedition.departsAt, 8 * HOUR);
|
||||
service.expeditions.cancel(service.upsertPlayer({ discordId: "expedition-admin", displayName: "Admin", isAdmin: true }).id, started.expedition.id);
|
||||
// Boussole folle : l'aperçu ne montre ni exigences ni résultat.
|
||||
// Coup de folie : l'aperçu ne montre ni exigences ni résultat, mais la fourchette des exigences réelles.
|
||||
service.expeditions.equip(player.id, { editionId: rares[0], slot: 0, equipmentEditionId: compass });
|
||||
const hidden = service.expeditions.preview(player.id, body).preview;
|
||||
assert.equal(hidden.hiddenRequirements, true);
|
||||
assert.equal(hidden.requirements, undefined);
|
||||
assert.deepEqual(hidden.requirementRange, { min: 80, max: 130 });
|
||||
// Au départ, les exigences réelles sont tirées (random() = 0 : 80 %), et révélées avec le résultat.
|
||||
const daring = goSolo(service, player.id, body, "mad-compass");
|
||||
const settled = service.expeditions.getExpeditions(player.id);
|
||||
assert.ok(settled.expeditions.some((item) => item.id === daring.expedition.id));
|
||||
const stored = JSON.parse(service.db.prepare("SELECT result_json FROM expeditions WHERE id = ?").get(daring.expedition.id).result_json);
|
||||
assert.equal(stored.requirementFactorPct, 80);
|
||||
|
||||
// Atelier : un plan et 3 doublons de communes donnent une commune de pouvoir illustrée.
|
||||
const commons = editionsOf("common").slice(0, 2);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import { prepareVersionedCatalog } from "../services/cards/catalog.js";
|
|||
import { DESTINATION_SPECIALTIES, 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, upgradeCost, gainProgress,
|
||||
equipmentBonus, LINEAGES, resonancesOf, teamSynergy, unlockedSlots, bonusLootPct, pickItems, HIDDEN_ITEMS, teamPowers, travelHours,
|
||||
requirementsFor, resolveDayEntry, rollLoot, roundStochastic, scoreExpedition, splitPower, STAT_IDS, teamStats, upgradeCost, gainProgress,
|
||||
equipmentBonus, LINEAGES, resonancesOf, teamSynergy, unlockedSlots, bonusLootPct, pickItems, HIDDEN_ITEMS, teamPowers, travelHours, rollRequirementFactor,
|
||||
bonusLevel, levelCount, starsForLevel, planStats, vocationProfile, clampAllocation, allocationError, levelPoints, maxStatPoints
|
||||
} from "../services/cards/expedition-rules.js";
|
||||
import { drawCollectionCard } from "../services/cards/game-rules.js";
|
||||
|
|
@ -91,7 +91,7 @@ test("destinations order the four stats and stay satisfiable by rare or better c
|
|||
const visible = destinations.filter((destination) => !destination.hidden);
|
||||
assert.equal(visible.length, 14);
|
||||
assert.deepEqual(destinations.filter((destination) => destination.hidden).map((destination) => destination.id), ["crimson-passage", "lost-observatory"]);
|
||||
// Chaque couple (stat principale, seconde stat) a au moins une destination : chaque paire de rôles du solo existe.
|
||||
// Chaque couple (stat principale, seconde stat) a au moins une destination : les profils restent variés.
|
||||
assert.equal(new Set(visible.map((destination) => destination.stats.slice(0, 2).join("+"))).size, 12);
|
||||
const broken = (change) => {
|
||||
const copy = structuredClone(destinations);
|
||||
|
|
@ -131,7 +131,7 @@ test("expedition settings merge stored values with defaults and validate bounds
|
|||
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("stars", { min: 4, max: 2 }), destinationIds), /étoile minimale/);
|
||||
assert.match(validateExpeditionSettings(withChange("power.rare", 120), destinationIds), /plafond/);
|
||||
assert.match(validateExpeditionSettings(withChange("destinations", { unknown: { active: true, weight: 1 } }), destinationIds), /inconnue/);
|
||||
|
||||
|
|
@ -159,19 +159,18 @@ test("power grows with levels up to the shared cap and splits exactly by profile
|
|||
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", () => {
|
||||
test("requirements scale per slot, cards add their stats, 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 carte seule : la part d'une place ; un groupe : une part par place, Veilleur de la Guilde compris.
|
||||
assert.deepEqual(requirementsFor(destination, 2, 1, settings), [
|
||||
{ stat: "orientation", main: true, value: 11 },
|
||||
{ stat: "bravoure", main: false, value: 10 }
|
||||
]);
|
||||
// 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);
|
||||
assert.deepEqual(requirementsFor(destination, 2, 4, settings).map((item) => item.value), [44, 40]);
|
||||
|
||||
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 });
|
||||
// Pas de rôle : chaque carte apporte ses stats telles quelles.
|
||||
const slot = { stats: { bravoure: 10, endurance: 10, fortune: 10, orientation: 12 }, tags: [], collectionId: "primordial-nebula" };
|
||||
assert.deepEqual(teamStats([slot, slot]), { bravoure: 20, endurance: 20, fortune: 20, orientation: 24 });
|
||||
|
||||
// 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);
|
||||
|
|
@ -198,8 +197,8 @@ test("one more star never raises the score of the same team", () => {
|
|||
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" }
|
||||
{ stats: { bravoure: 40, endurance: 0, fortune: 0, orientation: 4 }, tags: [], collectionId: "primordial-nebula" },
|
||||
{ stats: { bravoure: 40, endurance: 0, fortune: 0, orientation: 4 }, 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);
|
||||
|
|
@ -269,11 +268,12 @@ test("destination specialties raise one or two rewards and lower the others", ()
|
|||
assert.equal(drawCollectionCard({ ...mini, collections: [{ ...mini.collections[0], active: false }] }, "c", () => 0), null);
|
||||
});
|
||||
|
||||
// La difficulté se tire avec les destinations : un niveau de chaque, puis la suite recommence ; solo et groupe en déduisent leurs étoiles.
|
||||
// La difficulté se tire avec les destinations : un niveau de chaque, puis la suite recommence. Un niveau donne les mêmes étoiles,
|
||||
// qu'on parte seul ou en groupe.
|
||||
test("each daily destination draws a difficulty level, one of each", () => {
|
||||
assert.equal(levelCount(settings), 4);
|
||||
assert.deepEqual([0, 1, 2, 3].map((level) => [starsForLevel(level, settings.solo), starsForLevel(level, settings.group)]), [[1, 2], [2, 3], [3, 4], [4, 5]]);
|
||||
assert.equal(starsForLevel(9, settings.solo), settings.solo.maxStars);
|
||||
assert.equal(levelCount(settings), 5);
|
||||
assert.deepEqual([0, 1, 2, 3, 4].map((level) => starsForLevel(level, settings)), [1, 2, 3, 4, 5]);
|
||||
assert.equal(starsForLevel(9, settings), settings.stars.max);
|
||||
for (const random of [() => 0, (max) => max - 1, (max) => Math.floor(max / 2)]) {
|
||||
assert.deepEqual(drawExpeditionDay(destinations, settings, [], random).map((entry) => entry.level).sort(), [0, 1, 2, 3]);
|
||||
}
|
||||
|
|
@ -283,10 +283,11 @@ test("each daily destination draws a difficulty level, one of each", () => {
|
|||
assert.deepEqual(two.map((entry) => entry.level).sort(), [0, 1]);
|
||||
assert.deepEqual(drawExpeditionDay(destinations, settings, [], () => 0, new Set()), []);
|
||||
const six = drawExpeditionDay(destinations, { ...settings, day: { ...settings.day, destinationsPerDay: 6 } }, [], () => 0).map((entry) => entry.level);
|
||||
assert.deepEqual(six.slice(4), six.slice(0, 2));
|
||||
assert.deepEqual(six.slice(0, 5).sort(), [0, 1, 2, 3, 4]);
|
||||
assert.deepEqual(six.slice(5), six.slice(0, 1));
|
||||
// Une destination bonus garde son niveau toute la journée ; un tirage d'avant les niveaux prend celui de sa place.
|
||||
assert.equal(bonusLevel("player:2026-11-15:5:great-void", settings), bonusLevel("player:2026-11-15:5:great-void", settings));
|
||||
assert.ok(bonusLevel("player:2026-11-15:5:great-void", settings) < 4);
|
||||
assert.ok(bonusLevel("player:2026-11-15:5:great-void", settings) < 5);
|
||||
assert.equal(resolveDayEntry(destinations, { destinationId: destinations[0].id, conditionIndex: 0, dangerIndexes: [0, 0] }, 2).level, 2);
|
||||
});
|
||||
|
||||
|
|
@ -316,10 +317,12 @@ test("every server setting has its label in the administration, and nothing else
|
|||
|
||||
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: [] };
|
||||
const summary = { enabled: true, running: 0, returned: 0, nextReturnAt: null, launchedToday: false, eligible: 3, busyEditions: [] };
|
||||
assert.equal(expeditionsPending(summary, now), true);
|
||||
assert.equal(expeditionsPending({ ...summary, launchedToday: true }, now), false);
|
||||
assert.equal(expeditionsPending({ ...summary, eligible: 1 }, now), false);
|
||||
// Une carte jouable suffit pour partir.
|
||||
assert.equal(expeditionsPending({ ...summary, eligible: 1 }, now), true);
|
||||
assert.equal(expeditionsPending({ ...summary, eligible: 0 }, 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);
|
||||
// Un groupe à rejoindre attend le joueur ; son propre groupe en formation ne déclenche pas le rappel quotidien.
|
||||
|
|
@ -418,9 +421,9 @@ test("objects come by weight, hidden ones only with enough Orientation, and bonu
|
|||
test("powers trade an advantage for a cost and count once per team", () => {
|
||||
const destination = destinations[0];
|
||||
const entry = { condition: destination.conditions[0], dangers: destination.dangers };
|
||||
const slot = (powers = []) => ({ stats: { bravoure: 30, endurance: 30, fortune: 30, orientation: 30 }, role: null, tags: [], collectionId: "x", cardId: `c${powers.join()}`, powers });
|
||||
const slot = (powers = []) => ({ stats: { bravoure: 30, endurance: 30, fortune: 30, orientation: 30 }, tags: [], collectionId: "x", cardId: `c${powers.join()}`, powers });
|
||||
assert.deepEqual(teamPowers([slot(["talisman"]), slot(["talisman", "starNet"])]), ["talisman", "starNet"]);
|
||||
const evaluate = (powers, stats) => evaluateTeam({ destination, entry, stars: 2, durationIndex: 0, slots: [{ ...slot(), stats, role: destination.stats[0] }, { ...slot(), stats, role: destination.stats[1] }], powers }, settings);
|
||||
const evaluate = (powers, stats) => evaluateTeam({ destination, entry, stars: 2, durationIndex: 0, slots: [{ ...slot(), stats }, { ...slot(), stats }], powers }, settings);
|
||||
const weak = { bravoure: 1, endurance: 1, fortune: 1, orientation: 1 };
|
||||
const strong = { bravoure: 90, endurance: 90, fortune: 90, orientation: 90 };
|
||||
// Talisman : ni échec ni triomphe.
|
||||
|
|
@ -434,6 +437,14 @@ test("powers trade an advantage for a cost and count once per team", () => {
|
|||
// Butin et trajet : la Boussole folle et les Provisions changent le butin, la Longue-vue et les Provisions le temps de trajet.
|
||||
const loot = (powers) => expectedLoot({ hours: 10, stars: 1, tier: "success", fortune: 0, slotCount: 2, powers }, settings);
|
||||
assert.equal(loot(["madCompass"]).eclats, loot([]).eclats * 1.3);
|
||||
// Coup de folie : les exigences réelles sont tirées entre 80 % et 130 % de celles affichées ; sans lui, elles ne changent pas.
|
||||
assert.equal(rollRequirementFactor([], settings, () => 0), 100);
|
||||
assert.deepEqual([rollRequirementFactor(["madCompass"], settings, () => 0), rollRequirementFactor(["madCompass"], settings, (max) => max - 1)], [80, 130]);
|
||||
const tenStats = { bravoure: 10, endurance: 10, fortune: 10, orientation: 10 };
|
||||
const scaled = (pct) => evaluateTeam({ destination, entry, stars: 2, durationIndex: 0, slots: [{ ...slot(), stats: tenStats }], requirementFactorPct: pct }, settings).perRequirement.map((item) => item.value);
|
||||
const shown = requirementsFor(destination, 2, 1, settings).map((item) => item.value);
|
||||
assert.deepEqual(scaled(100), shown);
|
||||
assert.deepEqual(scaled(130), shown.map((value) => Math.round(value * 1.3)));
|
||||
assert.equal(loot(["rations"]).eclats, loot([]).eclats * 0.85);
|
||||
assert.equal(loot(["longsight"]).cards, loot([]).cards * 1.25);
|
||||
assert.deepEqual([travelHours(6, [], settings), travelHours(6, ["longsight"], settings), travelHours(8, ["rations"], settings)], [6, 8, 6]);
|
||||
|
|
@ -444,7 +455,7 @@ test("powers trade an advantage for a cost and count once per team", () => {
|
|||
const sheltered = applyHazards(exposed, { slotCount: 2, durationIndex: 0, dangers: [danger], dangerReliefPct: settings.powers.stormLanternDangerPct }, settings).dangers[0];
|
||||
assert.ok(struck.factor < 1);
|
||||
assert.ok(Math.abs((1 - sheltered.factor) - (1 - struck.factor) * 0.5) < 1e-9);
|
||||
const stars5 = (powers) => evaluateTeam({ destination, entry, stars: 5, durationIndex: 0, slots: [{ ...slot(), stats: exposed, role: destination.stats[0] }, { ...slot(), stats: exposed, role: destination.stats[1] }], powers }, settings);
|
||||
const stars5 = (powers) => evaluateTeam({ destination, entry, stars: 5, durationIndex: 0, slots: [{ ...slot(), stats: exposed }, { ...slot(), stats: exposed }], powers }, settings);
|
||||
assert.ok(stars5(["stormLantern"]).scorePct >= stars5([]).scorePct);
|
||||
assert.equal(travelHours(6, ["stormLantern"], settings), 7);
|
||||
// Cloche de brume : du butin en moins en solo, rien en groupe ; en groupe, un bonus de synergie.
|
||||
|
|
|
|||
|
|
@ -110,7 +110,9 @@ test("large sass files stay split by stable responsibility", async () => {
|
|||
"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/_nebula-expeditions.scss"
|
||||
"website/src/styles/_nebula-expeditions.scss",
|
||||
"website/src/styles/_nebula-expedition-destinations.scss",
|
||||
"website/src/styles/_nebula-expedition-loadout.scss"
|
||||
];
|
||||
|
||||
for (const path of orchestrators) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue