generated from nhcarrigan/template
feat: v0.6.0 balance pass, quest-gated bosses, and achievement fixes
This commit is contained in:
@@ -9,9 +9,26 @@ import {
|
||||
} from "../../src/services/transcendence.js";
|
||||
import type { GameState } from "@elysium/types";
|
||||
|
||||
const makePlayer = (overrides: Partial<GameState["player"]> = {}) => ({
|
||||
avatar: null,
|
||||
characterName: "T",
|
||||
discordId: "t",
|
||||
discriminator: "0",
|
||||
lifetimeAchievementsUnlocked: 0,
|
||||
lifetimeAdventurersRecruited: 0,
|
||||
lifetimeBossesDefeated: 0,
|
||||
lifetimeClicks: 0,
|
||||
lifetimeGoldEarned: 0,
|
||||
lifetimeQuestsCompleted: 0,
|
||||
totalClicks: 0,
|
||||
totalGoldEarned: 0,
|
||||
username: "u",
|
||||
...overrides,
|
||||
});
|
||||
|
||||
const makeMinimalState = (overrides: Partial<GameState> = {}): GameState =>
|
||||
({
|
||||
player: { discordId: "t", username: "u", discriminator: "0", avatar: null, totalGoldEarned: 0, totalClicks: 0, characterName: "T" },
|
||||
player: makePlayer(),
|
||||
resources: { gold: 0, essence: 0, crystals: 0, runestones: 0 },
|
||||
adventurers: [],
|
||||
upgrades: [],
|
||||
@@ -166,6 +183,19 @@ describe("buildPostTranscendenceState", () => {
|
||||
expect(transcendenceState.apotheosis).toEqual(apotheosis);
|
||||
});
|
||||
|
||||
it("persists active companion selection across transcendence", () => {
|
||||
const companions = { unlockedCompanionIds: ["lyra", "vex"], activeCompanionId: "vex" };
|
||||
const state = makeMinimalState({ companions });
|
||||
const { transcendenceState } = buildPostTranscendenceState(state, "T");
|
||||
expect(transcendenceState.companions).toEqual(companions);
|
||||
});
|
||||
|
||||
it("falls back to fresh companion state when currentState.companions is undefined", () => {
|
||||
const state = makeMinimalState({ companions: undefined });
|
||||
const { transcendenceState } = buildPostTranscendenceState(state, "T");
|
||||
expect(transcendenceState.companions).toEqual({ activeCompanionId: null, unlockedCompanionIds: [] });
|
||||
});
|
||||
|
||||
it("resets prestige to fresh state", () => {
|
||||
const state = makeMinimalState({
|
||||
prestige: { count: 5, runestones: 500, productionMultiplier: 2, purchasedUpgradeIds: [] },
|
||||
@@ -174,4 +204,60 @@ describe("buildPostTranscendenceState", () => {
|
||||
expect(transcendenceState.prestige.count).toBe(0);
|
||||
expect(transcendenceState.prestige.runestones).toBe(0);
|
||||
});
|
||||
|
||||
it("accumulates current-run gold and clicks into lifetime totals", () => {
|
||||
const state = makeMinimalState({
|
||||
player: makePlayer({ totalGoldEarned: 4_000_000, lifetimeGoldEarned: 1_000_000, totalClicks: 500 }),
|
||||
});
|
||||
const { transcendenceState } = buildPostTranscendenceState(state, "T");
|
||||
expect(transcendenceState.player.lifetimeGoldEarned).toBe(5_000_000);
|
||||
expect(transcendenceState.player.lifetimeClicks).toBe(500);
|
||||
});
|
||||
|
||||
it("accumulates defeated bosses, completed quests, and recruited adventurers into lifetime totals", () => {
|
||||
const boss = { id: "boss_1", status: "defeated" as const };
|
||||
const quest = { id: "q_1", status: "completed" as const };
|
||||
const adventurer = { id: "adv_1", count: 5 };
|
||||
const state = makeMinimalState({
|
||||
bosses: [ boss ] as GameState["bosses"],
|
||||
quests: [ quest ] as GameState["quests"],
|
||||
adventurers: [ adventurer ] as GameState["adventurers"],
|
||||
});
|
||||
const { transcendenceState } = buildPostTranscendenceState(state, "T");
|
||||
expect(transcendenceState.player.lifetimeBossesDefeated).toBe(1);
|
||||
expect(transcendenceState.player.lifetimeQuestsCompleted).toBe(1);
|
||||
expect(transcendenceState.player.lifetimeAdventurersRecruited).toBe(5);
|
||||
});
|
||||
|
||||
it("preserves achievements and accumulates newly-unlocked ones into the lifetime total", () => {
|
||||
const achievement = { id: "ach_1", unlockedAt: Date.now() };
|
||||
const state = makeMinimalState({
|
||||
achievements: [ achievement ] as GameState["achievements"],
|
||||
});
|
||||
const { transcendenceState } = buildPostTranscendenceState(state, "T");
|
||||
expect(transcendenceState.achievements).toEqual([ achievement ]);
|
||||
expect(transcendenceState.player.lifetimeAchievementsUnlocked).toBe(1);
|
||||
});
|
||||
|
||||
it("does not re-count achievements already folded into the lifetime total by a previous reset", () => {
|
||||
const achievement = { id: "ach_1", unlockedAt: Date.now() };
|
||||
const state = makeMinimalState({
|
||||
achievements: [ achievement ] as GameState["achievements"],
|
||||
player: makePlayer({ lifetimeAchievementsUnlocked: 1 }),
|
||||
});
|
||||
const { transcendenceState } = buildPostTranscendenceState(state, "T");
|
||||
expect(transcendenceState.player.lifetimeAchievementsUnlocked).toBe(1);
|
||||
});
|
||||
|
||||
it("preserves equipment ownership history across transcendence", () => {
|
||||
const equipment = { id: "rusty_sword", owned: true, everOwned: true };
|
||||
const state = makeMinimalState({
|
||||
equipment: [ equipment ] as GameState["equipment"],
|
||||
});
|
||||
const { transcendenceState } = buildPostTranscendenceState(state, "T");
|
||||
const matchingItem = transcendenceState.equipment.find((item) => {
|
||||
return item.id === "rusty_sword";
|
||||
});
|
||||
expect(matchingItem?.everOwned).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user