Let players choose how their cards spend level points with vocations or free points, and sell the Parchemin d'oubli

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-16 23:00:40 +01:00
parent 18bcf435b5
commit 7d331d1a3f
24 changed files with 473 additions and 60 deletions

View file

@ -569,6 +569,71 @@ test("cards level up with Éclats or a duplicate, gain field experience and stro
assert.equal(database.db.prepare("SELECT COUNT(*) AS count FROM card_progress WHERE player_id = ?").get(player.id).count, 0);
});
test("progression plans spread level points by vocation or by hand, and a Parchemin d'oubli pays for each change", () => {
const { service, player, open, rares, database } = expeditionService();
open();
const [card] = rares;
// Niveau 4 d'une rare : Puissance 60, dont 20 points de niveau, 12 au plus dans une stat (60 %).
database.db.prepare("INSERT INTO card_progress(player_id, edition_id, level, field_xp, updated_at) VALUES (?, ?, 4, 0, 0)").run(player.id, card);
const progressOf = () => service.getState(player.id).cardProgress.find((item) => item.editionId === card);
const sum = (stats) => Object.values(stats).reduce((total, value) => total + value, 0);
const before = progressOf();
assert.deepEqual([before.power, before.plan.id, before.plan.points, before.plan.maxStatPoints, before.plan.paid], [60, "collection", 20, 12, false]);
assert.deepEqual(before.stats, before.plan.previews.collection);
assert.equal(sum(before.plan.levelBase), 40);
// Tant que la carte suit sa collection, choisir une vocation est gratuit et s'applique aux points déjà gagnés.
const guardian = service.expeditions.setCardPlan(player.id, { editionId: card, plan: "guardian" }).progress;
const base = before.plan.levelBase;
assert.deepEqual(guardian.stats, { bravoure: base.bravoure + 4, endurance: base.endurance + 12, fortune: base.fortune, orientation: base.orientation + 4 });
assert.deepEqual(guardian.stats, before.plan.previews.guardian);
assert.equal(guardian.plan.paid, true);
assert.deepEqual(service.expeditions.getExpeditions(player.id).cards.find((item) => item.editionId === card).stats, guardian.stats);
// Ensuite, changer de plan consomme un Parchemin d'oubli, acheté en boutique avec de la poussière.
assert.throws(() => service.expeditions.setCardPlan(player.id, { editionId: card, plan: "navigator" }), (error) => error.code === "NOT_ENOUGH_ITEMS");
database.db.prepare("UPDATE players SET stardust = 400 WHERE id = ?").run(player.id);
assert.throws(() => service.expeditions.buyOblivion(player.id, { count: 3 }), (error) => error.code === "NOT_ENOUGH_STARDUST");
assert.throws(() => service.expeditions.buyOblivion(player.id, { count: 0 }), (error) => error.code === "PURCHASE_INVALID");
assert.equal(service.expeditions.buyOblivion(player.id, { count: 2 }).wallet.stardust, 100);
assert.equal(service.expeditions.itemsOf(player.id).oblivion, 2);
assert.equal(service.expeditions.setCardPlan(player.id, { editionId: card, plan: "navigator" }).progress.stats.orientation, base.orientation + 12);
assert.equal(service.expeditions.itemsOf(player.id).oblivion, 1);
// Reprendre le même plan ne coûte rien.
service.expeditions.setCardPlan(player.id, { editionId: card, plan: "navigator" });
assert.equal(service.expeditions.itemsOf(player.id).oblivion, 1);
// En libre : au plus 12 points dans une stat et 20 en tout ; ajouter des points est gratuit, en retirer coûte un Parchemin.
const allocation = (bravoure, fortune) => ({ bravoure, endurance: 0, fortune, orientation: 0 });
assert.throws(() => service.expeditions.setCardPlan(player.id, { editionId: card, plan: "free", allocation: allocation(13, 0) }), (error) => error.code === "ALLOCATION_INVALID");
assert.throws(() => service.expeditions.setCardPlan(player.id, { editionId: card, plan: "free", allocation: { bravoure: 12, fortune: 12 } }), (error) => error.code === "ALLOCATION_INVALID");
assert.throws(() => service.expeditions.setCardPlan(player.id, { editionId: card, plan: "free", allocation: { bravoure: 1.5 } }), (error) => error.code === "ALLOCATION_INVALID");
const free = service.expeditions.setCardPlan(player.id, { editionId: card, plan: "free", allocation: allocation(12, 3) }).progress;
assert.equal(service.expeditions.itemsOf(player.id).oblivion, 0);
assert.deepEqual(free.plan.allocation, allocation(12, 3));
assert.equal(sum(free.stats), 55, "5 points restent à placer");
service.expeditions.setCardPlan(player.id, { editionId: card, plan: "free", allocation: allocation(12, 8) });
assert.equal(sum(progressOf().stats), 60);
assert.throws(() => service.expeditions.setCardPlan(player.id, { editionId: card, plan: "free", allocation: allocation(10, 8) }), (error) => error.code === "NOT_ENOUGH_ITEMS");
assert.throws(() => service.expeditions.setCardPlan(player.id, { editionId: card, plan: "wizard" }), (error) => error.code === "PLAN_INVALID");
// Un niveau de plus en libre : 5 nouveaux points à placer, les anciens restent.
database.db.prepare("UPDATE card_progress SET level = 5 WHERE player_id = ? AND edition_id = ?").run(player.id, card);
assert.deepEqual([progressOf().plan.points, sum(progressOf().stats)], [25, 60]);
// 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");
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");
const history = service.getState(player.id).history;
assert.deepEqual(history.filter((entry) => entry.type === "card_plan_changed").map((entry) => [entry.details.plan, entry.details.oblivion]),
[["guardian", false], ["navigator", true], ["free", true], ["free", false]]);
assert.ok(history.some((entry) => entry.type === "oblivion_bought" && entry.details.count === 2 && entry.details.stardust === 300));
assert.equal(service.getState(player.id).shop.oblivionPrice, 150);
});
test("the one-way bridge turns stardust into Éclats at the configured rate", async (t) => {
const { service, player, admin, database } = expeditionService();
database.db.prepare("UPDATE players SET stardust = 40 WHERE id = ?").run(player.id);

View file

@ -8,7 +8,7 @@ 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,
bonusLevel, levelCount, starsForLevel
bonusLevel, levelCount, starsForLevel, planStats, vocationProfile, clampAllocation, allocationError, levelPoints, maxStatPoints
} from "../services/cards/expedition-rules.js";
import { drawCollectionCard } from "../services/cards/game-rules.js";
import {
@ -435,3 +435,20 @@ test("powers trade an advantage for a cost and count once per team", () => {
assert.equal(groupLoot(["fogBell"]).eclats, groupLoot([]).eclats);
assert.equal(teamSynergy({ destination, slots: [], bellPct: settings.powers.fogBellSynergyPct }, settings).totalPct, 10);
});
test("progression plans: the default keeps today's stats, vocations reach the cap and free points stay within the rules", () => {
const profile = { bravoure: 25, endurance: 25, fortune: 20, orientation: 30 };
for (const level of [0, 3, 12]) assert.deepEqual(planStats("rare", level, profile, null, settings), splitPower(cardPower("rare", level, settings), profile));
assert.deepEqual([levelPoints("rare", 4, settings), levelPoints("legendary", 6, settings), levelPoints("legendary", 9, settings), maxStatPoints(25, settings)], [20, 30, 30, 15]);
assert.deepEqual(vocationProfile("navigator", settings), { bravoure: 0, endurance: 20, fortune: 20, orientation: 60 });
assert.deepEqual(vocationProfile("leader", { ...settings, plans: { maxStatPct: 45 } }), { bravoure: 45, endurance: 28, fortune: 0, orientation: 27 });
// Rare de niveau 4 : base 40 selon le profil, puis 20 points en vocation de Gardien (12 / 4 / 4).
assert.deepEqual(planStats("rare", 4, profile, { plan: "guardian" }, settings), { bravoure: 14, endurance: 22, fortune: 8, orientation: 16 });
assert.deepEqual(planStats("rare", 4, profile, { plan: "free", allocation: { fortune: 7 } }, settings), { bravoure: 10, endurance: 10, fortune: 15, orientation: 12 });
// Une répartition qui ne respecte plus les règles (réglage abaissé) est ramenée dedans, sans erreur.
assert.deepEqual(clampAllocation({ bravoure: 20, endurance: 9 }, 20, settings), { bravoure: 11, endurance: 9, fortune: 0, orientation: 0 });
assert.equal(allocationError({ bravoure: 12, fortune: 8 }, 20, settings), null);
assert.match(allocationError({ bravoure: 13 }, 20, settings), /12 points/);
assert.match(allocationError({ bravoure: 10, fortune: 11 }, 20, settings), /20 points/);
assert.ok(allocationError({ magic: 1 }, 20, settings));
});

View file

@ -497,7 +497,7 @@ test("duplicates become stardust that buys openings kept apart from the recharge
const before = service.getState(player.id);
assert.deepEqual(before.wallet, { stardust: 0, purchasedOpenings: 0, eclats: 0 });
assert.deepEqual(before.shop, { stardustValues: INITIAL_SHOP_SETTING.stardustValues, openingPrice: INITIAL_SHOP_SETTING.openingPrice, shopPackPrice: 60, shopPackShare: 50, dailyReward: 10, stardustPerEclat: 3 });
assert.deepEqual(before.shop, { stardustValues: INITIAL_SHOP_SETTING.stardustValues, openingPrice: INITIAL_SHOP_SETTING.openingPrice, shopPackPrice: 60, shopPackShare: 50, dailyReward: 10, stardustPerEclat: 3, oblivionPrice: 150 });
assert.deepEqual(before.recycling, { count: 2, stardust: 2 * value });
// Une favorite garde son exemplaire : ses doublons se recyclent comme les autres.
service.setFavorite(player.id, editionId, true);