generated from nhcarrigan/template
666a5b2d6d
## What changed and why ### Runestone formula (`prestige.ts`) - Swapped `sqrt` for `cbrt` — much stronger diminishing returns for large gold values - Added base cap of **200** (→ ~1,125 max with all upgrades at 5.625× multiplier) - Prevents extended AFK sessions from producing runestone windfalls that allow immediate upgrade purchasing and rapid prestige chaining ### Prestige threshold formula (`prestige.ts`) - Old: `1,000,000 × 5^n` — exponential, grows impossibly fast, prestige 10+ takes years - New: `1,000,000 × (n+1)²` — polynomial, peaks at ~1 day/run around P8–10, then gets *easier* as the production multiplier overtakes it - Removed `thresholdScaleFactor` constant (no longer needed) ### Production multiplier (`prestige.ts`) - Old: `1.15^n` - New: `1.25^n` — compounds faster, ensures the polynomial threshold eventually gets easy in the late game ### Boss prestige requirements (`bosses.ts`) - Rescaled proportionally from 0–88 range to 0–20 range - The Absolute One now requires prestige **20** (was 88), making transcendence reachable in a few weeks of idle play ### Echo formula (`transcendence.ts`) - Constant changed from 853 → **224** - At the target prestige of 20: `floor(224 / sqrt(20)) = 50 echoes` per transcendence (no meta upgrades) - With all echo_meta upgrades (3.75× total): up to **187 echoes** per transcendence ### Transcendence upgrade costs (`transcendenceUpgrades.ts`) - Old total: **866 echoes** → New total: **400 echoes** (roughly halved across all categories) - Apotheosis still requires **all 15 upgrades** purchased ### Balance fixes (closes #141, #142, #143, #144, #145) - Equipment: `philosophers_stone` click multiplier 2.25→2.5, `crystal_shard` 1.55→1.65 (#144) - Recipes: added `primal_omega_lens` cross-zone click_power recipe at 1.38× (#142) - Adventurers: `celestial_guard` base cost adjusted to smooth tier 14→15→16 cost curve (#145) ### Quest reward rebalancing (closes #136, #137) - Shadow Marshes: buffed `shadow_mere`, `witch_coven`, `plague_ruins` rewards to match combat requirements (#136) - Astral Void: added gold to `void_rift`, increased rewards across all Astral Void quests (#137) ### Boss reward additions (closes #138, #139, #140) - Assigned 9 unassigned adventurer-specific upgrades to Crystalline Spire through Eternal Throne bosses that had empty `upgradeRewards` arrays (#140) ### Combat power documentation (closes #153) - Expanded JSDoc on `computePartyCombatPower` to clarify companion `bossDamage` multiplier behaviour ### Effective adventurer stats (closes #154) - Added `computeEffectiveAdventurerStats` to `tick.ts` and updated `AdventurerCard` to display effective post-multiplier stats ### Adventurer upgrade timing (closes #158) - Audited every adventurer-specific upgrade reward — upgrades now land within the same progression window where that adventurer tier is still a meaningful contributor ### Sync and save fixes (closes #147, #148, #151) - Fixed sync new content count to report only genuinely changed items (#147) - Fixed signature mismatch after first auto-boss completion (#148) - Added auto-buy cap (100) on non-max-tier adventurers (#151) ### Auto-adventurer persistence (closes #156) - Auto-buy preference now preserved across prestige resets ### Broken CDN image (closes #159) - Uploaded missing `auto_adventurer.jpg` to CDN ### Codex unlock hints (closes #146) - Locked codex entries now display a hint generated from `sourceType` and `sourceId` ### Exploration bug fixes (closes #160, #161) - Fixed auto-save race condition discarding exploration materials collected mid-tick (#160) - Fixed exploration areas failing to unlock when zone was unlocked via boss kill or quest completion (#161) ### Concurrent prestige fix (closes #162) - Added optimistic locking via `updatedAt` — concurrent prestige requests return 409 ### Prestige UX (closes #163) - Added `reloadSilent` to game context — no loading screen flash after prestige ### Balance adjustments (closes #164, #165, #166, #167) - Reduced `shadow_mere` CP requirement 5,000,000 → 2,000,000 (#164) - Buffed crystal drops from Shadow Marshes bosses and quests (#165) - Increased runestone yield from 10 → 15 per prestige level (#166) - Daily challenge set always includes a clicks challenge (#167) ### Progression QoL (closes #168, #169) - Added `computeProjectedRunestones()` and persistent `+N On Prestige` resource bar row (#168) - Added `enablePrestigeAnnouncements` setting per player (#169) --- ## Comprehensive balance audit (closes #187, #191, #192, #193, #194, #195, #196, #197, #198) ### Crystal economy fixes - Zeroed crystal rewards for all Zone 7+ boss drops (Celestial Reaches onwards) — crystals are an early/mid-game currency and should not flow freely into the endgame (#187) - Zeroed crystal rewards for all Zone 9+ quest rewards (Infernal Court onwards) — same rationale (#191) ### Achievement additions and fixes - Added quest milestone achievements at 75 quests (10,000 crystals) and 100 quests (15,000 crystals) - Added boss milestone achievement at 50 bosses (15,000 crystals) - Added prestige milestone achievements at P50, P100, P150, P200 — rewarding **runestones** rather than crystals to match the late-game economy - Added gold milestone achievements through 1e90 gold earned - Fixed `quest_eternal` condition from 122 → **112** (actual quest count) — was permanently impossible (#197) - Fixed `fully_equipped` condition from 65 → **78** (actual equipment count after new items) (#197) - Fixed `devourer_slayer` description to remove incorrect zone reference ### Upgrade balance - Fixed Essence Guild multiplier 1.5× → **2×** — was identical to the cheaper Merchant Alliance for 5× the cost (#194) - Raised Void Ascendancy crystal cost 10M → **50M** — was trivially cheap compared to the parallel Celestial Mandate upgrade (100B essence + 50T gold) (#195) - Fixed Sunken Temple quest rewards (gold 2M → 60M, essence 1,500 → 25,000, crystals 75 → 400) — was rewarding less than its easier prerequisite Witch Coven (#193) ### Equipment balance - Buffed Eternal Prism stats to click 5×, combat **3×**, gold **2.5×** — was only marginally better than the free Eternity Stone boss drop for 100M crystals (#196) ### Missing content - Created **13 missing equipment items** for Zones 15–18 (primordial_chaos through the_absolute) that were referenced by late-game boss `equipmentRewards` arrays but never existed in `equipment.ts` (#198): - `chaos_mantle`, `titan_core` (Primordial Chaos) - `expanse_blade`, `void_armour_mk2` (Infinite Expanse) - `cosmos_blade`, `reality_plate` (Reality Forge) - `maelstrom_edge`, `cosmic_plate` (Cosmic Maelstrom) - `primeval_blade`, `ancient_aegis` (Primeval Sanctum) - `absolute_blade`, `eternity_plate`, `omniversal_core` (The Absolute) - Stats scale from combat 14× / gold 9× (Zone 15) up to combat 28× / gold 20× for the final boss drops ### Type system - Extended `AchievementReward` type to support `runestones` field - Updated tick engine achievement processing to award both crystals and runestones --- ## Target progression timeline (optimal play, ~16h/day idle) - First cycle to P20: ~375h (~3.3 weeks) - Each subsequent cycle gets faster as echo upgrades boost income/combat/threshold - Expected **~5 transcendences** before apotheosis at 50–187 echoes/transcendence - **~6 months** to apotheosis for a dedicated player ## Test plan - [ ] Lint, build, and test pipeline passes (100% coverage maintained) - [ ] Prestige threshold at P0 is still 1,000,000 gold - [ ] Prestige runs feel ~1 day long around P8–10 and get easier after - [ ] The Absolute One is locked until prestige 20 - [ ] Transcendence at P20 awards 50 echoes (no meta upgrades) - [ ] All 15 transcendence upgrades cost 400 echoes total - [ ] Bosses in Zones 7+ drop 0 crystals; Zones 1–6 retain crystal drops - [ ] Quests in Zones 9+ reward 0 crystals; Zones 1–8 retain crystal rewards - [ ] Sunken Temple rewards more gold/essence/crystals than Witch Coven - [ ] Essence Guild gives 2× income (stronger than Merchant Alliance 1.5×) - [ ] Void Ascendancy costs 50M crystals - [ ] Eternal Prism stats are click 5×, combat 3×, gold 2.5× - [ ] Late-game bosses (primordial_titan through the_absolute_one) drop equipment on kill - [ ] `quest_eternal` achievement requires 112 quests - [ ] `fully_equipped` achievement requires 78 equipment pieces - [ ] P50/P100/P150/P200 prestige achievements reward runestones - [ ] Adventurer cards show effective post-multiplier stats - [ ] Exploration areas unlock correctly when their zone is unlocked - [ ] Concurrent prestige requests return 409 - [ ] No loading screen flash after prestige - [ ] Daily challenge set always includes a clicks challenge - [ ] Resource bar shows `+N On Prestige` runestone preview ✨ This PR was crafted with help from Hikari~ 🌸 Reviewed-on: #135 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
413 lines
15 KiB
TypeScript
413 lines
15 KiB
TypeScript
/* eslint-disable max-lines-per-function -- Test suites naturally have many cases */
|
||
/* eslint-disable max-lines -- Test suites naturally have many cases */
|
||
/* eslint-disable @typescript-eslint/consistent-type-assertions -- Tests build minimal state objects */
|
||
import { describe, expect, it } from "vitest";
|
||
import {
|
||
buildPostPrestigeState,
|
||
calculateMilestoneBonus,
|
||
calculatePrestigeThreshold,
|
||
calculateProductionMultiplier,
|
||
calculateRunestones,
|
||
computeRunestoneMultipliers,
|
||
isEligibleForPrestige,
|
||
} from "../../src/services/prestige.js";
|
||
import type { GameState } from "@elysium/types";
|
||
|
||
const makePlayer = (
|
||
totalGoldEarned: number,
|
||
lifetimeGoldEarned = 0,
|
||
totalClicks = 0,
|
||
) => ({
|
||
avatar: null,
|
||
characterName: "Tester",
|
||
discordId: "test_id",
|
||
discriminator: "0",
|
||
lifetimeAchievementsUnlocked: 0,
|
||
lifetimeAdventurersRecruited: 0,
|
||
lifetimeBossesDefeated: 0,
|
||
lifetimeClicks: 0,
|
||
lifetimeGoldEarned: lifetimeGoldEarned,
|
||
lifetimeQuestsCompleted: 0,
|
||
totalClicks: totalClicks,
|
||
totalGoldEarned: totalGoldEarned,
|
||
username: "testuser",
|
||
});
|
||
|
||
const makeMinimalState = (overrides: Partial<GameState> = {}): GameState =>
|
||
({
|
||
player: makePlayer(0),
|
||
resources: { gold: 0, essence: 0, crystals: 0, runestones: 0 },
|
||
adventurers: [],
|
||
upgrades: [],
|
||
quests: [],
|
||
bosses: [],
|
||
equipment: [],
|
||
achievements: [],
|
||
zones: [],
|
||
exploration: { areas: [], materials: [], craftedRecipeIds: [], craftedGoldMultiplier: 1, craftedEssenceMultiplier: 1, craftedClickMultiplier: 1, craftedCombatMultiplier: 1 },
|
||
companions: { unlockedCompanionIds: [], activeCompanionId: null },
|
||
prestige: { count: 0, runestones: 0, productionMultiplier: 1, purchasedUpgradeIds: [] },
|
||
baseClickPower: 1,
|
||
lastTickAt: 0,
|
||
schemaVersion: 1,
|
||
...overrides,
|
||
} as GameState);
|
||
|
||
describe("calculatePrestigeThreshold", () => {
|
||
it("returns base threshold at count 0", () => {
|
||
// base × (0+1)^2 = 1_000_000 × 1 = 1_000_000
|
||
expect(calculatePrestigeThreshold(0)).toBe(1_000_000);
|
||
});
|
||
|
||
it("returns 4× base at count 1", () => {
|
||
// base × (1+1)^2 = 1_000_000 × 4 = 4_000_000
|
||
expect(calculatePrestigeThreshold(1)).toBe(4_000_000);
|
||
});
|
||
|
||
it("returns 9× base at count 2", () => {
|
||
// base × (2+1)^2 = 1_000_000 × 9 = 9_000_000
|
||
expect(calculatePrestigeThreshold(2)).toBe(9_000_000);
|
||
});
|
||
|
||
it("applies threshold multiplier correctly", () => {
|
||
expect(calculatePrestigeThreshold(0, 2)).toBe(2_000_000);
|
||
});
|
||
});
|
||
|
||
describe("isEligibleForPrestige", () => {
|
||
it("returns true when totalGoldEarned meets threshold", () => {
|
||
const state = makeMinimalState({ player: makePlayer(1_000_000) });
|
||
expect(isEligibleForPrestige(state)).toBe(true);
|
||
});
|
||
|
||
it("returns false when totalGoldEarned is below threshold", () => {
|
||
const state = makeMinimalState({ player: makePlayer(999_999) });
|
||
expect(isEligibleForPrestige(state)).toBe(false);
|
||
});
|
||
|
||
it("uses echoPrestigeThresholdMultiplier from transcendence when present", () => {
|
||
const state = makeMinimalState({
|
||
player: makePlayer(2_000_000),
|
||
transcendence: {
|
||
count: 1, echoes: 0, purchasedUpgradeIds: [],
|
||
echoIncomeMultiplier: 1, echoCombatMultiplier: 1,
|
||
echoPrestigeThresholdMultiplier: 2,
|
||
echoPrestigeRunestoneMultiplier: 1, echoMetaMultiplier: 1,
|
||
},
|
||
});
|
||
// threshold = 1_000_000 × 2 = 2_000_000 — exactly meets
|
||
expect(isEligibleForPrestige(state)).toBe(true);
|
||
});
|
||
});
|
||
|
||
describe("calculateRunestones", () => {
|
||
it("calculates basic runestones formula", () => {
|
||
// floor(cbrt(4_000_000 / 1_000_000)) × 15 = floor(cbrt(4)) × 15 = 1 × 15 = 15
|
||
const result = calculateRunestones({ totalGoldEarned: 4_000_000, prestigeCount: 0, purchasedUpgradeIds: [] });
|
||
expect(result).toBe(15);
|
||
});
|
||
|
||
it("applies echo runestone multiplier", () => {
|
||
// floor(cbrt(4)) × 15 = 15; × 2 = 30
|
||
const result = calculateRunestones({ totalGoldEarned: 4_000_000, prestigeCount: 0, purchasedUpgradeIds: [], echoRunestoneMultiplier: 2 });
|
||
expect(result).toBe(30);
|
||
});
|
||
|
||
it("applies purchased runestone upgrade multiplier", () => {
|
||
// With "runestone_gain_1" purchased (multiplier 1.25): floor(15 × 1.25) = 18
|
||
const result = calculateRunestones({ totalGoldEarned: 4_000_000, prestigeCount: 0, purchasedUpgradeIds: ["runestone_gain_1"] });
|
||
expect(result).toBe(18);
|
||
});
|
||
|
||
it("caps base runestones before multipliers", () => {
|
||
// cbrt(9_261_000_000 / 1_000_000) = cbrt(9261) = 21 → 21 × 10 = 210, capped at 200
|
||
const result = calculateRunestones({ totalGoldEarned: 9_261_000_000, prestigeCount: 0, purchasedUpgradeIds: [] });
|
||
expect(result).toBe(200);
|
||
});
|
||
});
|
||
|
||
describe("calculateProductionMultiplier", () => {
|
||
it("returns 1 at count 0", () => {
|
||
expect(calculateProductionMultiplier(0)).toBe(1);
|
||
});
|
||
|
||
it("returns 1.3 at count 1", () => {
|
||
expect(calculateProductionMultiplier(1)).toBeCloseTo(1.3);
|
||
});
|
||
|
||
it("scales exponentially", () => {
|
||
expect(calculateProductionMultiplier(10)).toBeCloseTo(Math.pow(1.3, 10));
|
||
});
|
||
});
|
||
|
||
describe("calculateMilestoneBonus", () => {
|
||
it("returns 0 for non-milestone prestiges", () => {
|
||
expect(calculateMilestoneBonus(1)).toBe(0);
|
||
expect(calculateMilestoneBonus(3)).toBe(0);
|
||
expect(calculateMilestoneBonus(4)).toBe(0);
|
||
});
|
||
|
||
it("returns 25 at prestige 5", () => {
|
||
expect(calculateMilestoneBonus(5)).toBe(25);
|
||
});
|
||
|
||
it("returns 100 at prestige 10", () => {
|
||
expect(calculateMilestoneBonus(10)).toBe(100);
|
||
});
|
||
|
||
it("returns 225 at prestige 15", () => {
|
||
expect(calculateMilestoneBonus(15)).toBe(225);
|
||
});
|
||
});
|
||
|
||
describe("computeRunestoneMultipliers", () => {
|
||
it("returns all 1s with empty ids", () => {
|
||
const result = computeRunestoneMultipliers([]);
|
||
expect(result.runestonesIncomeMultiplier).toBe(1);
|
||
expect(result.runestonesClickMultiplier).toBe(1);
|
||
expect(result.runestonesEssenceMultiplier).toBe(1);
|
||
expect(result.runestonesCrystalMultiplier).toBe(1);
|
||
});
|
||
|
||
it("applies income upgrade when purchased", () => {
|
||
const result = computeRunestoneMultipliers(["income_1"]);
|
||
expect(result.runestonesIncomeMultiplier).toBeGreaterThan(1);
|
||
expect(result.runestonesClickMultiplier).toBe(1);
|
||
});
|
||
|
||
it("applies click upgrade when purchased", () => {
|
||
const result = computeRunestoneMultipliers(["click_power_1"]);
|
||
expect(result.runestonesClickMultiplier).toBeGreaterThan(1);
|
||
expect(result.runestonesIncomeMultiplier).toBe(1);
|
||
});
|
||
|
||
it("applies essence upgrade when purchased", () => {
|
||
const result = computeRunestoneMultipliers(["essence_1"]);
|
||
expect(result.runestonesEssenceMultiplier).toBeGreaterThan(1);
|
||
});
|
||
|
||
it("applies crystals upgrade when purchased", () => {
|
||
const result = computeRunestoneMultipliers(["crystal_1"]);
|
||
expect(result.runestonesCrystalMultiplier).toBeGreaterThan(1);
|
||
});
|
||
});
|
||
|
||
describe("buildPostPrestigeState", () => {
|
||
it("increments prestige count", () => {
|
||
const state = makeMinimalState({ player: makePlayer(4_000_000) });
|
||
const { prestigeData } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeData.count).toBe(1);
|
||
});
|
||
|
||
it("sums runestones earned", () => {
|
||
const state = makeMinimalState({ player: makePlayer(4_000_000) });
|
||
const { prestigeData, runestonesEarned } = buildPostPrestigeState(state, "Tester");
|
||
expect(runestonesEarned).toBeGreaterThan(0);
|
||
expect(prestigeData.runestones).toBe(runestonesEarned);
|
||
});
|
||
|
||
it("adds milestone runestones at prestige 5", () => {
|
||
const state = makeMinimalState({
|
||
player: makePlayer(100_000_000),
|
||
prestige: { count: 4, runestones: 0, productionMultiplier: 1, purchasedUpgradeIds: [] },
|
||
});
|
||
const { milestoneRunestones } = buildPostPrestigeState(state, "Tester");
|
||
expect(milestoneRunestones).toBe(25);
|
||
});
|
||
|
||
it("persists codex from current state", () => {
|
||
const codex = { entries: [{ id: "e1", unlockedAt: 1000, sourceType: "exploration" as const }] };
|
||
const state = makeMinimalState({ codex });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.codex).toEqual(codex);
|
||
});
|
||
|
||
it("persists story from current state", () => {
|
||
const story = { unlockedChapterIds: ["ch1"], completedChapters: [] };
|
||
const state = makeMinimalState({ story });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.story).toEqual(story);
|
||
});
|
||
|
||
it("persists transcendence from current state", () => {
|
||
const transcendence = {
|
||
count: 1, echoes: 10, purchasedUpgradeIds: [],
|
||
echoIncomeMultiplier: 1, echoCombatMultiplier: 1,
|
||
echoPrestigeThresholdMultiplier: 1,
|
||
echoPrestigeRunestoneMultiplier: 1, echoMetaMultiplier: 1,
|
||
};
|
||
const state = makeMinimalState({ transcendence });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.transcendence).toEqual(transcendence);
|
||
});
|
||
|
||
it("preserves autoPrestigeEnabled when set", () => {
|
||
const state = makeMinimalState({
|
||
prestige: { count: 0, runestones: 0, productionMultiplier: 1, purchasedUpgradeIds: [], autoPrestigeEnabled: true },
|
||
});
|
||
const { prestigeData } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeData.autoPrestigeEnabled).toBe(true);
|
||
});
|
||
|
||
it("omits autoPrestigeEnabled when not set", () => {
|
||
const state = makeMinimalState();
|
||
const { prestigeData } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeData.autoPrestigeEnabled).toBeUndefined();
|
||
});
|
||
|
||
it("preserves apotheosis data across prestige", () => {
|
||
const apotheosis = { count: 2 };
|
||
const state = makeMinimalState({ apotheosis });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.apotheosis).toEqual(apotheosis);
|
||
});
|
||
|
||
it("accumulates current-run gold into lifetime total", () => {
|
||
const state = makeMinimalState({
|
||
player: makePlayer(4_000_000, 1_000_000),
|
||
});
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.player.lifetimeGoldEarned).toBe(5_000_000);
|
||
});
|
||
|
||
it("accumulates current-run clicks into lifetime total", () => {
|
||
const state = makeMinimalState({
|
||
player: makePlayer(4_000_000, 0, 500),
|
||
});
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.player.lifetimeClicks).toBe(500);
|
||
});
|
||
|
||
it("accumulates defeated bosses into lifetime total", () => {
|
||
const defeatedBoss = {
|
||
bountyRunestones: 0,
|
||
crystalReward: 0,
|
||
currentHp: 0,
|
||
damagePerSecond: 10,
|
||
description: "A boss",
|
||
equipmentRewards: [] as string[],
|
||
essenceReward: 0,
|
||
goldReward: 100,
|
||
id: "boss_1",
|
||
maxHp: 100,
|
||
name: "Boss One",
|
||
prestigeRequirement: 0,
|
||
status: "defeated" as const,
|
||
upgradeRewards: [] as string[],
|
||
zoneId: "zone_1",
|
||
};
|
||
const state = makeMinimalState({ bosses: [ defeatedBoss ] });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.player.lifetimeBossesDefeated).toBe(1);
|
||
});
|
||
|
||
it("preserves bountyRunestonesClaimed flag on bosses across prestige", () => {
|
||
const claimedBoss = {
|
||
bountyRunestones: 5,
|
||
bountyRunestonesClaimed: true,
|
||
crystalReward: 0,
|
||
currentHp: 0,
|
||
damagePerSecond: 10,
|
||
description: "A boss",
|
||
equipmentRewards: [] as string[],
|
||
essenceReward: 0,
|
||
goldReward: 100,
|
||
id: "troll_king",
|
||
maxHp: 100,
|
||
name: "Troll King",
|
||
prestigeRequirement: 0,
|
||
status: "defeated" as const,
|
||
upgradeRewards: [] as string[],
|
||
zoneId: "verdant_vale",
|
||
};
|
||
const state = makeMinimalState({ bosses: [ claimedBoss ] as GameState["bosses"] });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
const matchingBoss = prestigeState.bosses.find((boss) => {
|
||
return boss.id === "troll_king";
|
||
});
|
||
expect(matchingBoss?.bountyRunestonesClaimed).toBe(true);
|
||
});
|
||
|
||
it("sets bountyRunestonesClaimed on bosses defeated before the flag was introduced", () => {
|
||
const legacyDefeatedBoss = {
|
||
bountyRunestones: 5,
|
||
crystalReward: 0,
|
||
currentHp: 0,
|
||
damagePerSecond: 10,
|
||
description: "A boss",
|
||
equipmentRewards: [] as string[],
|
||
essenceReward: 0,
|
||
goldReward: 100,
|
||
id: "troll_king",
|
||
maxHp: 100,
|
||
name: "Troll King",
|
||
prestigeRequirement: 0,
|
||
status: "defeated" as const,
|
||
upgradeRewards: [] as string[],
|
||
zoneId: "verdant_vale",
|
||
};
|
||
const state = makeMinimalState({ bosses: [ legacyDefeatedBoss ] as GameState["bosses"] });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
const matchingBoss = prestigeState.bosses.find((boss) => {
|
||
return boss.id === "troll_king";
|
||
});
|
||
expect(matchingBoss?.bountyRunestonesClaimed).toBe(true);
|
||
});
|
||
|
||
it("accumulates completed quests into lifetime total", () => {
|
||
const quest = {
|
||
id: "q_1",
|
||
name: "A Quest",
|
||
description: "Do the thing",
|
||
status: "completed" as const,
|
||
zoneId: "zone_1",
|
||
};
|
||
const state = makeMinimalState({ quests: [ quest ] as GameState["quests"] });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.player.lifetimeQuestsCompleted).toBe(1);
|
||
});
|
||
|
||
it("accumulates recruited adventurers into lifetime total", () => {
|
||
const adventurer = {
|
||
combatPower: 10,
|
||
count: 5,
|
||
essencePerSecond: 0,
|
||
goldPerSecond: 1,
|
||
id: "adv_1",
|
||
level: 1,
|
||
unlocked: true,
|
||
};
|
||
const state = makeMinimalState({ adventurers: [ adventurer ] as GameState["adventurers"] });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.player.lifetimeAdventurersRecruited).toBe(5);
|
||
});
|
||
|
||
it("preserves achievements from current state across prestige", () => {
|
||
const achievement = {
|
||
description: "Did a thing",
|
||
id: "ach_persisted",
|
||
name: "Achiever",
|
||
requirement: 1,
|
||
type: "totalClicks" as const,
|
||
unlockedAt: Date.now(),
|
||
};
|
||
const state = makeMinimalState({ achievements: [ achievement ] as GameState["achievements"] });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.achievements).toEqual([ achievement ]);
|
||
});
|
||
|
||
it("accumulates unlocked achievements into lifetime total", () => {
|
||
const achievement = {
|
||
description: "Did a thing",
|
||
id: "ach_1",
|
||
name: "Achiever",
|
||
requirement: 1,
|
||
type: "totalClicks" as const,
|
||
unlockedAt: Date.now(),
|
||
};
|
||
const state = makeMinimalState({ achievements: [ achievement ] as GameState["achievements"] });
|
||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||
expect(prestigeState.player.lifetimeAchievementsUnlocked).toBe(1);
|
||
});
|
||
});
|