feat: goddess sync, sanitize, and apotheosis init (chunk 3)

- initialState: add initialGoddessState() with all goddess sub-objects
- apotheosis: init GoddessState on first apotheosis, preserve on subsequent
- game: add goddessSpread block in validateAndSanitize (server-only fields capped, forward-only boss/quest/achievement enforcement)
- debug: add injectMissingGoddessExplorationAreas helper and inject all 8 goddess content arrays in syncNewContent
- vitest.config.ts: remove 8 goddess data files from coverage exclude (now imported via initialState)
- tests: full coverage for all new code (482 tests, 100% coverage)
This commit is contained in:
2026-04-13 14:23:02 -07:00
committed by Naomi Carrigan
parent c5d1f53eef
commit 7da1f3942d
9 changed files with 666 additions and 32 deletions
+71 -1
View File
@@ -9,14 +9,25 @@ import { defaultAdventurers } from "./adventurers.js";
import { defaultBosses } from "./bosses.js";
import { defaultEquipment } from "./equipment.js";
import { defaultExplorations } from "./explorations.js";
import { defaultGoddessAchievements } from "./goddessAchievements.js";
import { defaultGoddessBosses } from "./goddessBosses.js";
import { defaultGoddessDisciples } from "./goddessDisciples.js";
import { defaultGoddessEquipment } from "./goddessEquipment.js";
import { defaultGoddessExplorationAreas } from "./goddessExplorations.js";
import { defaultGoddessQuests } from "./goddessQuests.js";
import { defaultGoddessUpgrades } from "./goddessUpgrades.js";
import { defaultGoddessZones } from "./goddessZones.js";
import { defaultQuests } from "./quests.js";
import { currentSchemaVersion } from "./schemaVersion.js";
import { defaultUpgrades } from "./upgrades.js";
import { defaultZones } from "./zones.js";
import type {
ApotheosisData,
ConsecrationData,
EnlightenmentData,
ExplorationState,
GameState,
GoddessState,
Player,
PrestigeData,
TranscendenceData,
@@ -62,6 +73,65 @@ const initialExploration: ExplorationState = {
materials: [],
};
const initialConsecration: ConsecrationData = {
count: 0,
divinity: 0,
productionMultiplier: 1,
purchasedUpgradeIds: [],
};
const initialEnlightenment: EnlightenmentData = {
count: 0,
purchasedUpgradeIds: [],
stardust: 0,
stardustCombatMultiplier: 1,
stardustConsecrationDivinityMultiplier: 1,
stardustConsecrationThresholdMultiplier: 1,
stardustMetaMultiplier: 1,
stardustPrayersMultiplier: 1,
};
/**
* Builds a fresh initial goddess state for a player who has just completed their
* first Apotheosis. All goddess content is locked until progressed through the realm.
* @returns A clean GoddessState with all default data.
*/
const initialGoddessState = (): GoddessState => {
return {
achievements: structuredClone(defaultGoddessAchievements),
baseClickPower: 1,
bosses: structuredClone(defaultGoddessBosses),
consecration: { ...initialConsecration },
disciples: structuredClone(defaultGoddessDisciples),
enlightenment: { ...initialEnlightenment },
equipment: structuredClone(defaultGoddessEquipment),
exploration: {
areas: defaultGoddessExplorationAreas.map((area) => {
return {
id: area.id,
status:
area.zoneId === "goddess_celestial_garden"
? ("available" as const)
: ("locked" as const),
};
}),
craftedCombatMultiplier: 1,
craftedDivinityMultiplier: 1,
craftedPrayersMultiplier: 1,
craftedRecipeIds: [],
materials: [],
},
lastTickAt: Date.now(),
lifetimeBossesDefeated: 0,
lifetimePrayersEarned: 0,
lifetimeQuestsCompleted: 0,
quests: structuredClone(defaultGoddessQuests),
totalPrayersEarned: 0,
upgrades: structuredClone(defaultGoddessUpgrades),
zones: structuredClone(defaultGoddessZones),
};
};
/**
* Builds an initial game state for a new player.
* @param player - The player data from Discord OAuth.
@@ -105,4 +175,4 @@ const initialGameState = (
};
};
export { initialExploration, initialGameState };
export { initialExploration, initialGameState, initialGoddessState };