Add the daily team administration, recruitment retouches, the Watchers' balm and a new Guild layout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7ed63fff49
commit
b179a40a04
36 changed files with 799 additions and 298 deletions
|
|
@ -428,12 +428,14 @@ export function validateSiteContent(site) {
|
|||
"cards.expeditions.items.anchor",
|
||||
"cards.expeditions.items.guideStar",
|
||||
"cards.expeditions.items.skyChart",
|
||||
"cards.expeditions.items.balm",
|
||||
"cards.expeditions.itemHelp.fragment",
|
||||
"cards.expeditions.itemHelp.engraving",
|
||||
"cards.expeditions.itemHelp.plan",
|
||||
"cards.expeditions.itemHelp.anchor",
|
||||
"cards.expeditions.itemHelp.guideStar",
|
||||
"cards.expeditions.itemHelp.skyChart",
|
||||
"cards.expeditions.itemHelp.balm",
|
||||
"cards.expeditions.useItem",
|
||||
"cards.expeditions.bagShow",
|
||||
"cards.expeditions.bagHide",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { CardsDatabase } from "../services/cards/database.js";
|
|||
import { STAT_IDS } from "../services/cards/expedition-rules.js";
|
||||
import { applyBoost, autoRun, bestRunner, boostsError, canBoost, drawZones, MAX_RACE_MS, placeOf, RACE_STATS, replayRun, startRun, stepRun, ZONE_COUNT } from "../services/cards/race-rules.js";
|
||||
import { CardsService } from "../services/cards/service.js";
|
||||
import { canRevealStar, chooseCharacter, companionStats, DEFAULT_TEAM_SETTINGS, drawOffer, hiddenStars, inventTeam, keepCompanion, lentCharacters, MIN_SPECIALISTS, OFFER_SIZE, profileKey, recruitmentFinished, revealStar, specialtiesOf, startRecruitment, TEAM_SIZE, teamCharacters, teamDay, teamSettingsError, visibleSky, WATCHER_TEAM_LEVELS } from "../services/cards/team-rules.js";
|
||||
import { canRevealStar, chooseCharacter, companionStats, DEFAULT_TEAM_SETTINGS, drawOffer, hiddenStars, inventTeam, keepCompanion, lentCharacters, MIN_SPECIALISTS, OFFER_SIZE, profileKey, recruitmentFinished, rerollOffer, revealStar, specialtiesOf, startRecruitment, TEAM_SIZE, teamCharacters, teamDay, teamSettingsError, visibleSky, WATCHER_TEAM_LEVELS } from "../services/cards/team-rules.js";
|
||||
import { DEFAULT_DAILY_TEAM_SETTINGS, dailyTeamSettingsError, readDailyTeamSettings } from "../services/cards/team-settings.js";
|
||||
|
||||
const baseCatalog = prepareVersionedCatalog(JSON.parse(await readFile("website/public/data/cards/catalog.json", "utf8")));
|
||||
|
|
@ -117,10 +117,41 @@ test("gold stars raise the power, a black star drops it and ends the attempts, d
|
|||
|
||||
assert.deepEqual(visibleSky(fallen.state).map((item) => item.kind), ["gold", "dust", null, "black", null, null]);
|
||||
const kept = keepCompanion(characters, allIds, fallen.state, seeded(4));
|
||||
assert.deepEqual(kept.team, [{ cardId: start.offer[0], profile: byId.get(start.offer[0]).profile, power: 30, step: 1, fallen: true, lent: false }]);
|
||||
assert.deepEqual(kept.team, [{ cardId: start.offer[0], profile: byId.get(start.offer[0]).profile, power: 30, step: 1, fallen: true, healed: false, lent: false }]);
|
||||
assert.deepEqual(kept.revealed, [0, 1, 3]);
|
||||
});
|
||||
|
||||
test("three other characters can be asked for a limited number of times, and owned ones come back before any lent one", () => {
|
||||
const random = seeded(12);
|
||||
const first = startRecruitment(characters, { ownedIds: allIds }, random);
|
||||
const second = rerollOffer(characters, allIds, first, random);
|
||||
assert.equal(second.rerolls, first.rerolls - 1);
|
||||
assert.ok(second.offer.every((id) => !first.offer.includes(id)));
|
||||
assert.deepEqual(second.sky, first.sky);
|
||||
const third = rerollOffer(characters, allIds, second, random);
|
||||
assert.equal(rerollOffer(characters, allIds, third, random), null);
|
||||
assert.equal(rerollOffer(characters, allIds, chooseCharacter(first, first.offer[0]), random), null);
|
||||
|
||||
// Une petite collection qui couvre les quatre spécialités : jamais de prêt, même en redemandant.
|
||||
const owned = new Set(STAT_IDS.flatMap((stat) => {
|
||||
const profiles = new Set();
|
||||
return characters.filter((character) => specialtiesOf(character.profile).join() === stat && !profiles.has(profileKey(character.profile)) && profiles.add(profileKey(character.profile))).slice(0, 4).map((character) => character.id);
|
||||
}));
|
||||
for (let round = 0; round < 30; round += 1) {
|
||||
let state = startRecruitment(characters, { ownedIds: owned }, random);
|
||||
while (!recruitmentFinished(state)) {
|
||||
const next = rerollOffer(characters, owned, state, random);
|
||||
if (next) {
|
||||
assert.ok(next.offer.every((id) => !state.offer.includes(id)));
|
||||
state = next;
|
||||
}
|
||||
assert.ok(state.offer.every((id) => !state.team.some((companion) => companion.cardId === id)));
|
||||
state = keepCompanion(characters, owned, chooseCharacter(state, state.offer[0]), random);
|
||||
}
|
||||
assert.ok(state.team.every((companion) => !companion.lent));
|
||||
}
|
||||
});
|
||||
|
||||
test("the gold reserve is capped and a finished recruitment shows every star", () => {
|
||||
const random = seeded(5);
|
||||
let state = startRecruitment(characters, { ownedIds: new Set(), goldReserve: 9 }, random);
|
||||
|
|
@ -133,7 +164,7 @@ test("the gold reserve is capped and a finished recruitment shows every star", (
|
|||
test("a team serves three days and its settings must keep a real risk", () => {
|
||||
assert.deepEqual(["2026-11-24", "2026-11-25", "2026-11-26", "2026-11-27", "2026-11-28"].map((day) => teamDay("2026-11-25", day)), [0, 1, 2, 3, 0]);
|
||||
assert.equal(teamSettingsError(DEFAULT_TEAM_SETTINGS), null);
|
||||
for (const change of [{ goldStars: 0 }, { blackStars: -1 }, { dustValue: 1.5 }, { powers: [50] }, { powers: [50, 50] }, { fallPower: 50 }]) {
|
||||
for (const change of [{ goldStars: 0 }, { blackStars: -1 }, { dustValue: 1.5 }, { rerolls: -1 }, { powers: [50] }, { powers: [50, 50] }, { fallPower: 50 }]) {
|
||||
assert.ok(teamSettingsError({ ...DEFAULT_TEAM_SETTINGS, ...change }), JSON.stringify(change));
|
||||
}
|
||||
assert.ok(teamSettingsError(null));
|
||||
|
|
@ -296,9 +327,18 @@ test("a recruitment goes from the first offer to a complete team, once per day",
|
|||
refuses("TEAM_RECRUITING", () => team.startRecruitment(player.id, { day: DAY }));
|
||||
refuses("TEAM_EXPIRED", () => team.startRecruitment(player.id, { day: "2026-11-24" }));
|
||||
|
||||
// Redemander trois personnages : un double clic, qui renvoie l'ancienne proposition, n'en consomme pas deux.
|
||||
const shown = started.recruitment.offer.map((companion) => companion.cardId);
|
||||
const rerolled = team.rerollOffer(player.id, { offer: shown }).team.recruitment;
|
||||
assert.equal(rerolled.rerolls, started.recruitment.rerolls - 1);
|
||||
assert.equal(team.rerollOffer(player.id, { offer: shown }).team.recruitment.rerolls, rerolled.rerolls);
|
||||
assert.equal(team.rerollOffer(player.id, { offer: rerolled.offer.map((companion) => companion.cardId) }).team.recruitment.rerolls, 0);
|
||||
refuses("TEAM_REROLL_UNAVAILABLE", () => team.rerollOffer(player.id, { offer: team.view(player.id).recruitment.offer.map((companion) => companion.cardId) }));
|
||||
|
||||
// Recharger la page ne relance aucun tirage.
|
||||
assert.deepEqual(team.view(player.id).recruitment, started.recruitment);
|
||||
const [first, second] = started.recruitment.offer.map((companion) => companion.cardId);
|
||||
const current = team.view(player.id).recruitment;
|
||||
assert.deepEqual(team.view(player.id).recruitment, current);
|
||||
const [first, second] = current.offer.map((companion) => companion.cardId);
|
||||
team.chooseCharacter(player.id, { cardId: first });
|
||||
team.chooseCharacter(player.id, { cardId: first });
|
||||
refuses("TEAM_CHOICE_INVALID", () => team.chooseCharacter(player.id, { cardId: second }));
|
||||
|
|
@ -394,7 +434,7 @@ test("the course of the day is the same for everyone and changes with the day",
|
|||
test("the team API requires a session", async (t) => {
|
||||
const handler = createCardsApiHandler({ projectRoot: resolve("."), enabled: true, devAuth: true, databasePath: ":memory:", env: { NODE_ENV: "test" }, random: () => 0 });
|
||||
t.after(() => handler.close?.());
|
||||
for (const [method, path] of [["GET", ""], ["POST", "/recruit"], ["POST", "/choose"], ["POST", "/stars"], ["POST", "/keep"], ["POST", "/race"], ["POST", "/race/boosts"], ["POST", "/race/finish"]]) {
|
||||
for (const [method, path] of [["GET", ""], ["POST", "/recruit"], ["POST", "/reroll"], ["POST", "/choose"], ["POST", "/stars"], ["POST", "/heal"], ["POST", "/keep"], ["POST", "/race"], ["POST", "/race/boosts"], ["POST", "/race/finish"]]) {
|
||||
const req = Readable.from(method === "POST" ? [Buffer.from("{}")] : []);
|
||||
Object.assign(req, { method, url: `/api/cards/team${path}`, headers: { host: "localhost", origin: "http://localhost", "content-type": "application/json" }, socket: { remoteAddress: "127.0.0.1" } });
|
||||
let status = 0;
|
||||
|
|
@ -552,3 +592,43 @@ test("a full reserve or a closed daily team pays the daily card at once", (t) =>
|
|||
refuses("DAILY_STAR_UNAVAILABLE", () => between.service.chooseDailyReward(between.player.id, { day: DAY, choice: "star" }));
|
||||
assert.equal(between.service.chooseDailyReward(between.player.id, { day: DAY, choice: "stardust" }).state.wallet.stardust, 10);
|
||||
});
|
||||
|
||||
test("only the development server resets a team and its races", (t) => {
|
||||
const context = game(t);
|
||||
const { team, player, service } = context;
|
||||
const { companions } = readyTeam(context);
|
||||
team.startRace(player.id, { day: DAY, cardId: companions[0].cardId });
|
||||
assert.equal(team.view(player.id).devReset, false);
|
||||
refuses("NOT_FOUND", () => team.resetForTests(player.id));
|
||||
service.devPerks = true;
|
||||
const reset = team.resetForTests(player.id).team;
|
||||
assert.deepEqual([reset.devReset, reset.status, reset.race, reset.canRecruit], [true, "none", null, true]);
|
||||
});
|
||||
|
||||
test("a balm brings a weakened companion back to its starting power, once and at once", (t) => {
|
||||
const { team, player, db, service } = game(t);
|
||||
team.startRecruitment(player.id, { day: DAY });
|
||||
const { cardId } = team.view(player.id).recruitment.offer[0];
|
||||
team.chooseCharacter(player.id, { cardId });
|
||||
refuses("TEAM_HEAL_INVALID", () => team.healCompanion(player.id, { cardId }));
|
||||
const { sky } = storedState(db, player.id);
|
||||
team.revealStar(player.id, { index: sky.indexOf("gold") });
|
||||
team.revealStar(player.id, { index: sky.indexOf("black") });
|
||||
refuses("NOT_ENOUGH_ITEMS", () => team.healCompanion(player.id, { cardId }));
|
||||
assert.equal(team.view(player.id).recruitment.current.power, 30);
|
||||
service.expeditions.addItemsInTx(player.id, ["balm", "balm"]);
|
||||
assert.equal(team.view(player.id).recruitment.balms, 2);
|
||||
const healed = team.healCompanion(player.id, { cardId }).team.recruitment;
|
||||
assert.deepEqual([healed.current.power, healed.current.healed, healed.balms], [50, true, 1]);
|
||||
assert.equal(team.healCompanion(player.id, { cardId }).team.recruitment.balms, 1);
|
||||
refuses("TEAM_STAR_INVALID", () => team.revealStar(player.id, { index: sky.lastIndexOf("gold") }));
|
||||
const kept = team.keepCompanion(player.id, { cardId }).team;
|
||||
assert.deepEqual([kept.companions[0].power, kept.companions[0].healed], [50, true]);
|
||||
refuses("TEAM_CHOICE_INVALID", () => team.healCompanion(player.id, { cardId }));
|
||||
assert.ok(service.getState(player.id).history.some((entry) => entry.type === "item_used" && entry.details.item === "balm"));
|
||||
});
|
||||
|
||||
test("a balm only comes from expeditions while the daily team is open", (t) => {
|
||||
assert.equal(game(t).service.expeditions.excludedItems().includes("balm"), false);
|
||||
assert.equal(game(t, { enabled: false }).service.expeditions.excludedItems().includes("balm"), true);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue