Let players compare card stats in the collection, rebalance card profiles with a full refunded reset of upgrades, and fix best boosts that sometimes fired in the previous zone
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4a44306e30
commit
3590df5e1e
31 changed files with 1515 additions and 211 deletions
|
|
@ -228,6 +228,9 @@ export function validateSiteContent(site) {
|
|||
"cards.collection.eyebrow",
|
||||
"cards.collection.title",
|
||||
"cards.collection.resetFilters",
|
||||
...["label", "album", "stats"].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",
|
||||
...["eyebrow", "title", "description", "summaryTitle", "summaryName", "summaryCards", "summaryOpenings", "deleteTitle", "deleteText", "deleteButton", "confirmTitle", "confirmMessage", "confirmLabel", "deleted"].map((key) => `cards.account.${key}`),
|
||||
...["eyebrow", "title", "description", "checking", "singleUseLabel", "singleUseHelp", "create", "cancel", "close", "preparing", "uploading", "linkLabel", "copy", "copied", "expires", "singleUseActive", "reusableActive", "revoke", "revoked", "existing", "limitActive", "limitDailyCount", "limitDailyBytes", "tooLarge", "activeTitle", "exportFallback", "privacy"].map((key) => `toolboxShare.${key}`),
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { buildPublishedCatalog, mythicEditionId, prepareVersionedCatalog } from
|
|||
import { INITIAL_COLLECTION_STATES, INITIAL_DROP_RATES } from "../services/cards/admin-seed.js";
|
||||
import { CardsDatabase, MIGRATIONS } from "../services/cards/database.js";
|
||||
import { CardsService } from "../services/cards/service.js";
|
||||
import { applyProgressReset, planProgressReset } from "../services/cards/progress-reset.js";
|
||||
import { DEFAULT_EXPEDITION_SETTINGS } from "../services/cards/expedition-settings.js";
|
||||
import { createDiscordAlertSender, dispatchAlerts } from "../services/cards/discord-alerts.js";
|
||||
|
||||
|
|
@ -1478,3 +1479,86 @@ test("power commons equip one per card, change travel time and hide requirements
|
|||
assert.equal(crafted.state.items.plan, 0);
|
||||
assert.equal(service.quantityOf(player.id, commons[1]), 1);
|
||||
});
|
||||
|
||||
test("a full progress reset refunds what each upgrade cost, converts field experience to Éclats and clears the old history", () => {
|
||||
const { service, player, open, rares, database } = expeditionService();
|
||||
open();
|
||||
const [card] = rares;
|
||||
const common = editionsOf("common")[0];
|
||||
database.transaction(() => {
|
||||
service.addCard(player.id, card);
|
||||
service.addCard(player.id, card);
|
||||
service.expeditions.addItemsInTx(player.id, ["oblivion"]);
|
||||
});
|
||||
database.db.prepare("UPDATE players SET eclats = 100 WHERE id = ?").run(player.id);
|
||||
// Niveau 1 payé en Éclats (10), niveau 2 par un doublon ; le premier plan est gratuit, le second coûte un Parchemin d'oubli.
|
||||
service.expeditions.upgradeCard(player.id, { editionId: card, method: "eclats" });
|
||||
service.expeditions.upgradeCard(player.id, { editionId: card, method: "duplicate" });
|
||||
service.expeditions.setCardPlan(player.id, { editionId: card, plan: "leader" });
|
||||
service.expeditions.setCardPlan(player.id, { editionId: card, plan: "seeker" });
|
||||
// Puis deux niveaux et demi d'expérience de terrain : niveaux 3 et 4 (30 + 40 Éclats) et la moitié du suivant (25).
|
||||
database.db.prepare("UPDATE card_progress SET level = 4, field_xp = 50 WHERE player_id = ? AND edition_id = ?").run(player.id, card);
|
||||
// À la Puissance de départ, seul le premier emplacement d'équipement reste ouvert.
|
||||
const equip = database.db.prepare("INSERT INTO card_equipment(player_id, edition_id, slot, equipment_edition_id, equipped_at) VALUES (?, ?, ?, ?, 0)");
|
||||
equip.run(player.id, card, 0, common);
|
||||
equip.run(player.id, card, 1, editionsOf("common")[1]);
|
||||
const before = service.getState(player.id);
|
||||
const copies = service.quantityOf(player.id, card);
|
||||
|
||||
// La simulation ne touche à rien.
|
||||
const [dryRun] = applyProgressReset(service);
|
||||
assert.deepEqual({ ...dryRun, playerId: undefined, name: undefined }, { playerId: undefined, name: undefined, eclats: 10, xpEclats: 95, duplicates: [{ editionId: card, count: 1 }], oblivion: 1, cards: 1, unequipped: 1 });
|
||||
assert.equal(service.getState(player.id).cardProgress.find((item) => item.editionId === card).level, 4);
|
||||
|
||||
applyProgressReset(service, { apply: true });
|
||||
const after = service.getState(player.id);
|
||||
const progress = after.cardProgress.find((item) => item.editionId === card);
|
||||
assert.deepEqual([progress.level, progress.fieldXp, progress.plan.id], [0, 0, "collection"]);
|
||||
assert.equal(after.wallet.eclats, before.wallet.eclats + 105);
|
||||
assert.equal(service.quantityOf(player.id, card), copies + 1);
|
||||
assert.equal(after.items.oblivion, 1);
|
||||
assert.deepEqual(database.db.prepare("SELECT slot FROM card_equipment WHERE player_id = ?").all(player.id).map((row) => row.slot), [0]);
|
||||
assert.equal(database.db.prepare("SELECT COUNT(*) AS count FROM audit_log WHERE event_type IN ('card_upgraded', 'card_plan_changed')").get().count, 0);
|
||||
const reset = after.history.filter((entry) => entry.type === "card_progress_reset");
|
||||
assert.deepEqual(reset.map((entry) => entry.details), [{ eclats: 10, xpEclats: 95, duplicates: 1, oblivion: 1, cards: 1, unequipped: 1 }]);
|
||||
// Rien à rembourser deux fois : un second passage ne trouve plus rien.
|
||||
assert.deepEqual(applyProgressReset(service), []);
|
||||
});
|
||||
|
||||
test("a progress reset gives back the duplicates of each awakening and never charges awakening levels as experience", () => {
|
||||
const settings = DEFAULT_EXPEDITION_SETTINGS;
|
||||
const audit = (details) => ({ player_id: "p", event_type: "card_upgraded", entity_id: "rare-a", details_json: JSON.stringify(details) });
|
||||
// Rare au niveau 6 : niveaux 0 à 4 par l'expérience, le palier 5 → 6 par un Éveil de six doublons.
|
||||
const plans = planProgressReset({
|
||||
progress: [{ player_id: "p", edition_id: "rare-a", level: 6, field_xp: 0 }],
|
||||
audits: [audit({ method: "awaken", awakened: 70, used: [{ editionId: "rare-b", count: 4 }, { editionId: "rare-c", count: 2 }], level: 6 })],
|
||||
rarityOf: () => "rare",
|
||||
settings
|
||||
});
|
||||
const plan = plans.get("p");
|
||||
assert.deepEqual([...plan.duplicates], [["rare-b", 4], ["rare-c", 2]]);
|
||||
assert.equal(plan.eclats, 0);
|
||||
assert.equal(plan.xpEclats, 10 + 20 + 30 + 40 + 50);
|
||||
});
|
||||
|
||||
test("a mythic edition follows the mythicProfile of its legendary, which only a legendary may carry", () => {
|
||||
const legendary = editionsOf("legendary")[0];
|
||||
const cardId = published.editions.find((edition) => edition.id === legendary).cardId;
|
||||
const mythicProfile = { bravoure: 25, endurance: 25, fortune: 25, orientation: 25 };
|
||||
const raw = JSON.parse(rawCatalogText);
|
||||
raw.cards.find((card) => card.id === cardId).expedition.mythicProfile = mythicProfile;
|
||||
const { service, player, open, database } = expeditionService({ catalog: prepareVersionedCatalog(raw) });
|
||||
open();
|
||||
const mythic = mythicEditionId(cardId, "spectral-prism-solar");
|
||||
database.db.prepare("INSERT INTO mythic_variations(edition_id, card_id, finish_id, status, updated_at, updated_by) VALUES (?, ?, 'spectral-prism-solar', 'active', 0, NULL)").run(mythic, cardId);
|
||||
service.reloadCatalog();
|
||||
database.transaction(() => { service.addCard(player.id, mythic); service.addCard(player.id, legendary); });
|
||||
const progress = service.getState(player.id).cardProgress;
|
||||
// Puissance 85 répartie à parts égales pour la mythique ; la légendaire garde le profil de sa carte.
|
||||
assert.deepEqual(progress.find((item) => item.editionId === mythic).baseStats, { bravoure: 22, endurance: 21, fortune: 21, orientation: 21 });
|
||||
assert.notDeepEqual(progress.find((item) => item.editionId === legendary).plan.levelBase, { bravoure: 18, endurance: 17, fortune: 18, orientation: 17 });
|
||||
const rare = published.cards.find((card) => rarityOf(card.id) === "rare" && card.kind !== "destination");
|
||||
const invalid = JSON.parse(rawCatalogText);
|
||||
invalid.cards.find((card) => card.id === rare.id).expedition.mythicProfile = mythicProfile;
|
||||
assert.throws(() => prepareVersionedCatalog(invalid), /cannot have a mythicProfile/);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ test("a profile has one specialty, two when its best stats are equal, none when
|
|||
assert.deepEqual(specialtiesOf(profile(20, 30, 20, 30)), ["endurance", "orientation"]);
|
||||
assert.deepEqual(specialtiesOf(profile(25, 25, 20, 30)), []);
|
||||
assert.deepEqual(specialtiesOf(profile(25, 25, 25, 25)), []);
|
||||
// Trois stats à égalité en tête : Équilibré, même avec plus de 10 points d'écart.
|
||||
assert.deepEqual(specialtiesOf(profile(30, 30, 30, 10)), []);
|
||||
});
|
||||
|
||||
test("an offer holds three different profiles and never comes back", () => {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import { calculateRecharge, drawPack, drawShopPack } from "../services/cards/gam
|
|||
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 { 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";
|
||||
|
|
@ -1633,3 +1634,30 @@ test("transfer suggestions rank players by what is missing on each side without
|
|||
assert.deepEqual(rankMatches(matches, { type: "gift", editionId: "mine-b" }).map((match) => match.trader.id), ["cid", "ana", "bob"]);
|
||||
assert.deepEqual(summarizeMatches(matches, (a, b) => a.localeCompare(b)), { trade: { cards: ["new-1"], players: 2 }, gift: { cards: ["mine-a", "mine-b"], players: 2 } });
|
||||
});
|
||||
|
||||
test("collection stats name each profile shape from its clear gaps, like the team's balanced threshold", () => {
|
||||
const shape = (bravoure, endurance, fortune, orientation) => profileShape({ bravoure, endurance, fortune, orientation });
|
||||
assert.deepEqual(shape(45, 20, 20, 15), { shape: "specialist", stats: ["bravoure"] });
|
||||
assert.deepEqual(shape(35, 10, 35, 20), { shape: "duo", stats: ["bravoure", "fortune"] });
|
||||
assert.deepEqual(shape(30, 30, 30, 10), { shape: "trio", stats: ["bravoure", "endurance", "fortune"] });
|
||||
assert.deepEqual(shape(35, 28, 20, 17), { shape: "versatile", stats: [] });
|
||||
// Dix points d'écart au plus entre la plus haute et la plus basse : équilibrée, comme dans l'Équipe du jour.
|
||||
assert.deepEqual(shape(25, 25, 20, 30), { shape: "balanced", stats: [] });
|
||||
});
|
||||
|
||||
test("collection stats list only owned team cards and rank a build by its weakest chosen stat", () => {
|
||||
const owned = ["twilight-red-panda-standard", "starvoid-dragon-standard", "dragon-constellation-standard", "cosmic-cloud-heart-standard"];
|
||||
const state = { collection: owned.map((editionId) => ({ editionId, quantity: 1 })), cardProgress: [{ editionId: "twilight-red-panda-standard", stats: { bravoure: 14, endurance: 14, fortune: 4, orientation: 8 }, power: 40, level: 0, maxLevel: 12 }] };
|
||||
const rows = statRows(catalog, state);
|
||||
// Ni commune (équipement), ni destination : seulement les cartes qui partent en équipe.
|
||||
assert.deepEqual(rows.map((row) => row.edition.id).sort(), ["starvoid-dragon-standard", "twilight-red-panda-standard"]);
|
||||
const byId = new Map(rows.map((item) => [item.edition.id, item]));
|
||||
assert.equal(byId.get("twilight-red-panda-standard").current.bravoure, 14);
|
||||
assert.equal(byId.get("starvoid-dragon-standard").current, null);
|
||||
assert.deepEqual(buildScore({ bravoure: 45, fortune: 5 }, ["bravoure", "fortune"]), { min: 5, sum: 50 });
|
||||
// Pour un build Bravoure + Fortune, la carte forte dans les deux passe devant celle qui n'est forte que dans une.
|
||||
const row = (id, bravoure, fortune, order) => ({ edition: { id }, order, power: 40, profile: { bravoure, endurance: 50 - bravoure, fortune, orientation: 50 - fortune } });
|
||||
const ranked = rankRows([row("lopsided", 45, 5, 0), row("even", 25, 25, 1), row("weak", 20, 20, 2)], ["bravoure", "fortune"], "profile");
|
||||
assert.deepEqual(ranked.map((item) => item.edition.id), ["even", "weak", "lopsided"]);
|
||||
assert.deepEqual(rankRows(ranked, [], "profile").map((item) => item.edition.id), ["lopsided", "even", "weak"]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue