Let players switch collection views from clear tiles, filter explorer and equipment pickers with a tag and name autocomplete and multi-stat builds, read card stats as gauges with art badges for affinity, tags and worn commons, see short power effects, and save expedition sets that move shared commons between explorers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3590df5e1e
commit
504c709848
36 changed files with 1225 additions and 121 deletions
|
|
@ -228,7 +228,7 @@ export function validateSiteContent(site) {
|
|||
"cards.collection.eyebrow",
|
||||
"cards.collection.title",
|
||||
"cards.collection.resetFilters",
|
||||
...["label", "album", "stats"].map((key) => `cards.collection.views.${key}`),
|
||||
...["label", "album", "albumHelp", "stats", "statsHelp"].map((key) => `cards.collection.views.${key}`),
|
||||
...["label", "modeLabel", "modes.profile", "modes.current", "modeHelp.profile", "modeHelp.current", "build", "buildHelpNone", "buildHelp", "columns.card", "columns.shape", "columns.power", "level", "open", "shapeFilter", "empty", "noMatch"].map((key) => `cards.collection.stats.${key}`),
|
||||
...["specialist", "duo", "trio", "versatile", "balanced"].flatMap((shape) => [`cards.collection.stats.shapes.${shape}`, `cards.collection.stats.shapeHelp.${shape}`]),
|
||||
"cards.history.pendingCards",
|
||||
|
|
@ -636,10 +636,33 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.sortSynergy",
|
||||
"cards.expeditions.sortPowers",
|
||||
"cards.expeditions.sortUseful",
|
||||
"cards.expeditions.pickerSearch",
|
||||
"cards.expeditions.pickerSearchLabel",
|
||||
"cards.expeditions.pickerCount",
|
||||
"cards.expeditions.pickerReset",
|
||||
"cards.expeditions.pickerOptionTag",
|
||||
"cards.expeditions.pickerOptionTagLabel",
|
||||
"cards.expeditions.pickerOptionName",
|
||||
"cards.expeditions.pickerOptionNameLabel",
|
||||
"cards.expeditions.pickerNoOption",
|
||||
"cards.expeditions.pickerUseful",
|
||||
"cards.expeditions.pickerUsefulCondition",
|
||||
"cards.expeditions.pickerUsefulAffinity",
|
||||
"cards.expeditions.pickerUsefulParry",
|
||||
"cards.expeditions.pickerSynergy",
|
||||
"cards.expeditions.pickerActiveTags",
|
||||
"cards.expeditions.pickerTagFilter",
|
||||
"cards.expeditions.pickerTagRemove",
|
||||
"cards.expeditions.pickerBuild",
|
||||
"cards.expeditions.pickerBuildHelpCards",
|
||||
"cards.expeditions.pickerBuildHelpEquipment",
|
||||
"cards.expeditions.pickerNoMatch",
|
||||
...["button", "buttonCount", "title", "help", "nameLabel", "save", "saveHint", "listLabel", "itemsLabel", "empty", "apply", "applyLabel", "update", "updateLabel", "delete", "confirmDelete", "worn", "noEquipment", "cardBusy", "cardMissing", "itemMoves", "itemBusy", "itemMissing", "itemLocked", "reasonBusy", "applied", "appliedMoved", "appliedSkipped", "movedItem", "close"].map((key) => `cards.expeditions.sets.${key}`),
|
||||
"cards.expeditions.powerVocation",
|
||||
"cards.expeditions.tagCondition",
|
||||
"cards.expeditions.tagParry",
|
||||
"cards.expeditions.tagAffinity",
|
||||
"cards.expeditions.tagAffinityHelp",
|
||||
"cards.expeditions.tagsLabel",
|
||||
"cards.expeditions.tagsNone",
|
||||
"cards.expeditions.tagsTitle",
|
||||
|
|
@ -667,6 +690,8 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.equipmentSynergy",
|
||||
"cards.expeditions.synergyBonus",
|
||||
"cards.expeditions.equipmentElsewhere",
|
||||
"cards.expeditions.equipmentElsewhereHelp",
|
||||
"cards.expeditions.equipmentTagsLinked",
|
||||
"cards.expeditions.equipmentNone",
|
||||
"cards.expeditions.departSoloTitle",
|
||||
"cards.expeditions.departSoloHelp",
|
||||
|
|
|
|||
|
|
@ -1103,6 +1103,61 @@ test("commons equip open slots, add stats with synergies and move between cards"
|
|||
assert.equal(refused.json.error.code, "CARD_NOT_OWNED");
|
||||
});
|
||||
|
||||
test("expedition sets save a card and its commons, then put them back, taking shared commons from other cards except on an expedition", async (t) => {
|
||||
const { clock, service, player, open, rares, database } = expeditionService();
|
||||
open();
|
||||
const [card, other] = rares;
|
||||
const [first, second] = editionsOf("common");
|
||||
database.transaction(() => [first, second].forEach((editionId) => service.addCard(player.id, editionId)));
|
||||
const equipmentOf = (state, editionId) => state.cardProgress.find((item) => item.editionId === editionId).equipment.map((item) => item.editionId);
|
||||
service.expeditions.equip(player.id, { editionId: card, slot: 0, equipmentEditionId: first });
|
||||
const saved = service.expeditions.saveSet(player.id, { name: " Ruines rapides ", editionId: card });
|
||||
const [alpha] = saved.state.expeditionSets;
|
||||
assert.deepEqual([alpha.name, alpha.editionId, alpha.equipment], ["Ruines rapides", card, [{ slot: 0, editionId: first }]]);
|
||||
assert.throws(() => service.expeditions.saveSet(player.id, { name: "ruines RAPIDES", editionId: other }), (error) => error.code === "SET_NAME_TAKEN");
|
||||
assert.throws(() => service.expeditions.saveSet(player.id, { name: " ", editionId: other }), (error) => error.code === "SET_NAME_INVALID");
|
||||
assert.throws(() => service.expeditions.saveSet(player.id, { name: "Commune", editionId: first }), (error) => error.code === "EXPEDITION_CARD_INVALID");
|
||||
|
||||
// Un second set partage la même commune : l'appliquer la reprend à la première carte, et inversement.
|
||||
service.expeditions.equip(player.id, { editionId: other, slot: 0, equipmentEditionId: first });
|
||||
const beta = service.expeditions.saveSet(player.id, { name: "Nuit", editionId: other }).state.expeditionSets[1];
|
||||
const back = service.expeditions.applySet(player.id, { id: alpha.id });
|
||||
assert.deepEqual(back.applied.moved, [{ editionId: first, from: other }]);
|
||||
assert.deepEqual([equipmentOf(back.state, card), equipmentOf(back.state, other)], [[first], []]);
|
||||
// Un set remplace tout l'équipement de sa carte : la commune posée à la main hors du set est retirée.
|
||||
service.expeditions.equip(player.id, { editionId: other, slot: 0, equipmentEditionId: second });
|
||||
const swapped = service.expeditions.applySet(player.id, { id: beta.id });
|
||||
assert.deepEqual([equipmentOf(swapped.state, card), equipmentOf(swapped.state, other)], [[], [first]]);
|
||||
|
||||
// Sur une carte partie en expédition, la commune reste : elle n'est pas posée, et la carte du set en expédition ne change pas.
|
||||
const started = goSolo(service, player.id, soloBody(service.expeditions.getExpeditions(player.id), other), "sets");
|
||||
const blocked = service.expeditions.applySet(player.id, { id: alpha.id });
|
||||
assert.deepEqual([blocked.applied.moved, blocked.applied.skipped], [[], [{ editionId: first, reason: "busy" }]]);
|
||||
assert.deepEqual(equipmentOf(blocked.state, other), [first]);
|
||||
assert.throws(() => service.expeditions.applySet(player.id, { id: beta.id }), (error) => error.code === "EXPEDITION_CARD_BUSY");
|
||||
clock.now += 2 * HOUR;
|
||||
service.expeditions.claim(player.id, started.expedition.id);
|
||||
|
||||
// Mise à jour, suppression, limite.
|
||||
service.expeditions.equip(player.id, { editionId: card, slot: 0, equipmentEditionId: second });
|
||||
const updated = service.expeditions.saveSet(player.id, { id: alpha.id, name: "Ruines", editionId: card }).state.expeditionSets[0];
|
||||
assert.deepEqual([updated.id, updated.name, updated.equipment], [alpha.id, "Ruines", [{ slot: 0, editionId: second }]]);
|
||||
service.expeditions.deleteSet(player.id, { id: beta.id });
|
||||
assert.throws(() => service.expeditions.deleteSet(player.id, { id: beta.id }), (error) => error.code === "SET_NOT_FOUND");
|
||||
assert.throws(() => service.expeditions.applySet(player.id, { id: beta.id }), (error) => error.code === "SET_NOT_FOUND");
|
||||
for (let index = 1; index < 30; index += 1) service.expeditions.saveSet(player.id, { name: `Set ${index}`, editionId: card });
|
||||
assert.throws(() => service.expeditions.saveSet(player.id, { name: "Un de trop", editionId: card }), (error) => error.code === "SET_LIMIT");
|
||||
service.deleteAccount(player.id);
|
||||
assert.equal(database.db.prepare("SELECT COUNT(*) AS count FROM expedition_sets WHERE player_id = ?").get(player.id).count, 0);
|
||||
|
||||
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: true, devAuth: true, databasePath: ":memory:", env: { NODE_ENV: "test" }, random: () => 0 });
|
||||
t.after(() => handler.close());
|
||||
const login = await call(handler, { method: "POST", path: "/api/cards/auth/dev", body: {} });
|
||||
const headers = { cookie: login.headers["set-cookie"].split(";")[0], "x-csrf-token": login.json.csrfToken };
|
||||
assert.equal((await call(handler, { method: "POST", path: "/api/cards/expedition-sets/apply", headers, body: { id: "nowhere" } })).json.error.code, "SET_NOT_FOUND");
|
||||
assert.equal((await call(handler, { method: "POST", path: "/api/cards/expedition-sets", headers, body: { name: "", editionId: "nowhere" } })).json.error.code, "SET_NAME_INVALID");
|
||||
});
|
||||
|
||||
// Les Résonances lient les cartes d'une même équipe : seule, une carte n'en a pas ; en groupe, elles comptent dans le score.
|
||||
test("resonances raise a group's score", () => {
|
||||
const { service, player, second, open, database } = groupService();
|
||||
|
|
|
|||
|
|
@ -479,6 +479,11 @@ test("commons carry equipment spread over a fixed budget, and every card has syn
|
|||
assert.ok(texts.powers[power] && texts.powerText[power] && texts.powerEffects[power]?.up?.length, power);
|
||||
// Chaque valeur citée existe dans les réglages.
|
||||
for (const line of [...texts.powerEffects[power].up, ...(texts.powerEffects[power].down ?? [])]) for (const [, key] of line.matchAll(/\{(\w+)\}/g)) assert.ok(key in settings.powers, `${power} : ${key}`);
|
||||
// La version courte (tuiles de la fenêtre de choix) a autant de gains et de contreparties, et des valeurs qui existent.
|
||||
const short = texts.powerEffectsShort[power];
|
||||
assert.equal(short?.up?.length, texts.powerEffects[power].up.length, `${power} : gains courts`);
|
||||
assert.equal(short.down?.length ?? 0, texts.powerEffects[power].down?.length ?? 0, `${power} : contreparties courtes`);
|
||||
for (const line of [...short.up, ...(short.down ?? [])]) for (const [, key] of line.matchAll(/\{(\w+)\}/g)) assert.ok(key in settings.powers, `${power} : ${key}`);
|
||||
}
|
||||
// Deux communes au même effet ne couvrent jamais exactement les mêmes cartes, ou moins : aucune n'est de trop.
|
||||
const team = rawCatalog.cards.filter((card) => isExpeditionCard(catalog, card.id));
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import { CardsService, DEV_DISCORD_ID } from "../services/cards/service.js";
|
|||
import { rarityPercentages } from "../website/src/features/cards/dropRates.js";
|
||||
import { visibleCollections } from "../website/src/features/cards/collectionState.js";
|
||||
import { buildScore, profileShape, rankRows, statRows } from "../website/src/features/cards/cardStats.js";
|
||||
import { compareBuild, equipmentGain, matchesPicker, normalizeSearch, searchOptions, tagSuggestions, usefulTags } from "../website/src/features/cards/expeditions/pickerFilters.js";
|
||||
import { appliedSummary, setStatus } from "../website/src/features/cards/expeditions/expeditionSets.js";
|
||||
import { matchTraders, rankMatches, summarizeMatches } from "../website/src/features/cards/transferSuggestions.js";
|
||||
import { availableTips, TIP_SECTION_VARIANTS, tipOfDay } from "../website/src/features/cards/dailyTips.js";
|
||||
import { backupCardsDatabase, restoreCardsDatabase, runScheduledBackup, verifyCardsDatabase } from "../services/cards/backup.js";
|
||||
|
|
@ -1661,3 +1663,59 @@ test("collection stats list only owned team cards and rank a build by its weakes
|
|||
assert.deepEqual(ranked.map((item) => item.edition.id), ["even", "weak", "lopsided"]);
|
||||
assert.deepEqual(rankRows(ranked, [], "profile").map((item) => item.edition.id), ["lopsided", "even", "weak"]);
|
||||
});
|
||||
|
||||
test("expedition pickers find cards by name or tag, suggest the tags behind a word and rank a build on several stats", () => {
|
||||
assert.equal(normalizeSearch(" L’Écume "), "l ecume");
|
||||
const night = { name: "Lapin des Nuages", itemTags: ["theme:nuit", "theme:voyage"], tagLabels: ["Nuit", "Voyage"] };
|
||||
// Le mot cherche dans le nom et les étiquettes, sans accents ni majuscules ; une étiquette choisie exige la carte qui la porte.
|
||||
assert.ok(matchesPicker(night, { query: "nuit" }));
|
||||
assert.ok(matchesPicker(night, { query: "lapin" }));
|
||||
assert.ok(!matchesPicker(night, { query: "tresor" }));
|
||||
assert.ok(matchesPicker(night, { tags: ["theme:tresor", "theme:nuit"] }));
|
||||
assert.ok(!matchesPicker({ name: "Dragon de la Nuit du Retour", itemTags: ["personnage:dragon"], tagLabels: ["Dragon"] }, { tags: ["theme:nuit"] }));
|
||||
// Suggestions : les étiquettes dont le nom contient le mot, portées par les choix, la plus portée d'abord, sans celles déjà prises.
|
||||
const lists = [["theme:nuit"], ["theme:nuit", "theme:voyage"], ["theme:voyage"], ["theme:voyage"]];
|
||||
assert.deepEqual(tagSuggestions(catalog, lists, "oy").map(({ id, count }) => [id, count]), [["theme:voyage", 3]]);
|
||||
assert.deepEqual(tagSuggestions(catalog, lists, "nuit").map(({ id }) => id), ["theme:nuit"]);
|
||||
assert.deepEqual(tagSuggestions(catalog, lists, "nuit", ["theme:nuit"]), []);
|
||||
assert.deepEqual(tagSuggestions(catalog, lists, ""), []);
|
||||
// Le menu de la recherche : les étiquettes d'abord, puis les noms qui contiennent le mot, sans doublon.
|
||||
const names = ["Lapin des Nuages", "Chouette de Nuit", "Chouette de Nuit", "Renard"];
|
||||
assert.deepEqual(searchOptions(catalog, { tagLists: lists, names, query: "nuit" }).map(({ kind, id, label }) => [kind, id ?? label]),
|
||||
[["tag", "theme:nuit"], ["name", "Chouette de Nuit"]]);
|
||||
assert.deepEqual(searchOptions(catalog, { tagLists: lists, names, query: "nuit", limit: 1 }).map(({ kind }) => kind), ["tag"]);
|
||||
assert.deepEqual(searchOptions(catalog, { tagLists: lists, names, query: "" }), []);
|
||||
// Étiquettes utiles : condition, Affinité, puis celles qui parent un danger ; une étiquette n'y est qu'une fois.
|
||||
const destination = { condition: { type: "tag", tag: "theme:tresor" }, themeTags: ["theme:aventure", "theme:tresor"], dangers: [{ label: "Couloirs", unlessTags: ["personnage:herisson"] }] };
|
||||
assert.deepEqual(usefulTags(destination).map(({ tag, kind }) => [tag, kind]), [["theme:tresor", "condition"], ["theme:aventure", "affinity"], ["personnage:herisson", "parry"]]);
|
||||
assert.deepEqual(usefulTags({ condition: { type: "collection", collectionId: "x" }, themeTags: [], dangers: [] }), []);
|
||||
// Build d'explorateurs : la plus faible des stats choisies d'abord ; communes : la somme de leur apport, malus compris.
|
||||
const card = (id, bravoure, fortune) => ({ id, power: 50, stats: { bravoure, endurance: 10, fortune, orientation: 10 } });
|
||||
const sorted = [card("lopsided", 30, 5), card("even", 18, 18), card("weak", 12, 12)].sort((a, b) => compareBuild(a, b, ["bravoure", "fortune"]));
|
||||
assert.deepEqual(sorted.map(({ id }) => id), ["even", "weak", "lopsided"]);
|
||||
assert.equal(equipmentGain({ stats: { endurance: -2, fortune: 8 } }, ["fortune", "endurance"]), 6);
|
||||
assert.equal(equipmentGain({ power: "adaptation" }, ["fortune"]), 0);
|
||||
});
|
||||
|
||||
test("an expedition set foresees what each common will do and sums up what the server did", () => {
|
||||
const set = { id: "s", name: "Ruines", editionId: "twilight-red-panda-standard", equipment: [
|
||||
{ slot: 0, editionId: "a" }, { slot: 1, editionId: "b" }, { slot: 2, editionId: "c" }, { slot: 0, editionId: "gone" }] };
|
||||
const state = {
|
||||
collection: [{ editionId: "twilight-red-panda-standard" }, { editionId: "starvoid-dragon-standard" }],
|
||||
cardProgress: [{ editionId: "twilight-red-panda-standard", slots: 2, equipment: [{ editionId: "a" }] }],
|
||||
equipment: [{ editionId: "a", equippedOn: "twilight-red-panda-standard" }, { editionId: "b", equippedOn: "starvoid-dragon-standard" }, { editionId: "c", equippedOn: null }]
|
||||
};
|
||||
const free = setStatus(set, { state, cards: [{ editionId: "starvoid-dragon-standard", busy: false }] });
|
||||
assert.equal(free.card, "ready");
|
||||
assert.deepEqual(free.items.map(({ status, on }) => [status, on]), [["here", null], ["moves", "starvoid-dragon-standard"], ["locked", null], ["missing", null]]);
|
||||
assert.equal(free.worn, false);
|
||||
// La carte qui porte la commune est en expédition : elle ne sera pas posée ; la carte du set en expédition ne s'équipe pas.
|
||||
assert.equal(setStatus(set, { state, cards: [{ editionId: "starvoid-dragon-standard", busy: true }] }).items[1].status, "busy");
|
||||
assert.equal(setStatus(set, { state, cards: [{ editionId: "twilight-red-panda-standard", busy: true }] }).card, "busy");
|
||||
assert.equal(setStatus({ ...set, editionId: "nowhere" }, { state, cards: [] }).card, "missing");
|
||||
assert.equal(setStatus({ ...set, equipment: [{ slot: 0, editionId: "a" }] }, { state, cards: [] }).worn, true);
|
||||
const content = { applied: "Set « {name} » équipé.", appliedMoved: "Repris : {items}.", appliedSkipped: "Non posés : {items}.", movedItem: "{item} à {card}", reasonBusy: "en expédition", itemMissing: "perdue", itemLocked: "fermé" };
|
||||
assert.equal(appliedSummary(catalog, set, { moved: [], skipped: [] }, content), "Set « Ruines » équipé.");
|
||||
assert.equal(appliedSummary(catalog, set, { moved: [{ editionId: "twilight-red-panda-standard", from: "starvoid-dragon-standard" }], skipped: [{ editionId: "zzz", reason: "busy" }] }, content),
|
||||
"Set « Ruines » équipé. Repris : Panda Roux du Crépuscule à Dragon du Néant Étoilé. Non posés : zzz (en expédition).");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue