generated from nhcarrigan/template
5d2d71983a
Introduces a schema version field to GameState. Saves without the current schema version are flagged on load (showing a modal prompting reset or proceed), and cloud saves from outdated clients are rejected server-side. Removes all backfill code now that outdated saves are handled via the reset flow instead. New POST /game/reset endpoint creates a fresh save for players who choose to reset. Save version and current schema version are displayed in the sidebar below the app version.
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import type { ApotheosisData, ExplorationState, GameState, Player, PrestigeData, TranscendenceData } from "@elysium/types";
|
|
import { DEFAULT_ACHIEVEMENTS } from "./achievements.js";
|
|
import { CURRENT_SCHEMA_VERSION } from "./schemaVersion.js";
|
|
import { DEFAULT_ADVENTURERS } from "./adventurers.js";
|
|
import { DEFAULT_BOSSES } from "./bosses.js";
|
|
import { DEFAULT_EQUIPMENT } from "./equipment.js";
|
|
import { DEFAULT_EXPLORATIONS } from "./explorations.js";
|
|
import { DEFAULT_QUESTS } from "./quests.js";
|
|
import { DEFAULT_UPGRADES } from "./upgrades.js";
|
|
import { DEFAULT_ZONES } from "./zones.js";
|
|
|
|
export const INITIAL_PRESTIGE: PrestigeData = {
|
|
count: 0,
|
|
runestones: 0,
|
|
productionMultiplier: 1,
|
|
purchasedUpgradeIds: [],
|
|
};
|
|
|
|
export const INITIAL_TRANSCENDENCE: TranscendenceData = {
|
|
count: 0,
|
|
echoes: 0,
|
|
purchasedUpgradeIds: [],
|
|
echoIncomeMultiplier: 1,
|
|
echoCombatMultiplier: 1,
|
|
echoPrestigeThresholdMultiplier: 1,
|
|
echoPrestigeRunestoneMultiplier: 1,
|
|
echoMetaMultiplier: 1,
|
|
};
|
|
|
|
export const INITIAL_APOTHEOSIS: ApotheosisData = {
|
|
count: 0,
|
|
};
|
|
|
|
export const INITIAL_EXPLORATION: ExplorationState = {
|
|
areas: DEFAULT_EXPLORATIONS.map((area) => ({
|
|
id: area.id,
|
|
status: area.zoneId === "verdant_vale" ? "available" as const : "locked" as const,
|
|
})),
|
|
materials: [],
|
|
craftedRecipeIds: [],
|
|
craftedGoldMultiplier: 1,
|
|
craftedEssenceMultiplier: 1,
|
|
craftedClickMultiplier: 1,
|
|
craftedCombatMultiplier: 1,
|
|
};
|
|
|
|
export const INITIAL_GAME_STATE = (player: Player, characterName: string): GameState => ({
|
|
player: {
|
|
...player,
|
|
characterName,
|
|
totalGoldEarned: 0,
|
|
totalClicks: 0,
|
|
},
|
|
resources: {
|
|
gold: 0,
|
|
essence: 0,
|
|
crystals: 0,
|
|
runestones: 0,
|
|
},
|
|
adventurers: structuredClone(DEFAULT_ADVENTURERS),
|
|
upgrades: structuredClone(DEFAULT_UPGRADES),
|
|
quests: structuredClone(DEFAULT_QUESTS),
|
|
bosses: structuredClone(DEFAULT_BOSSES),
|
|
equipment: structuredClone(DEFAULT_EQUIPMENT),
|
|
achievements: structuredClone(DEFAULT_ACHIEVEMENTS),
|
|
prestige: INITIAL_PRESTIGE,
|
|
zones: structuredClone(DEFAULT_ZONES),
|
|
baseClickPower: 1,
|
|
lastTickAt: Date.now(),
|
|
transcendence: { ...INITIAL_TRANSCENDENCE },
|
|
apotheosis: { ...INITIAL_APOTHEOSIS },
|
|
exploration: structuredClone(INITIAL_EXPLORATION),
|
|
companions: { unlockedCompanionIds: [], activeCompanionId: null },
|
|
schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
});
|