generated from nhcarrigan/template
feat: add apotheosis third prestige layer and remove IDEAS.md
Apotheosis is the ultimate reset — wipes absolutely everything including prestige and transcendence — in exchange for a pure bragging-rights badge. No mechanical benefit whatsoever. Unlock condition: all 15 Transcendence echo upgrades purchased. Can be achieved multiple times; each cycle requires repurchasing all Transcendence upgrades again. What survives: Codex lore entries and lifetime profile statistics. What is wiped: resources, prestige, runestones, transcendence data (echoes, echo upgrades, multipliers), equipment, upgrades, bosses, quests, zones, adventurers, achievements. New files: Apotheosis.ts type, apotheosis service, apotheosis route, ApotheosisPanel.tsx component. Modified: GameState (apotheosis field), Api.ts, types/index.ts, prestige service (carry apotheosis), transcendence service (carry apotheosis), game.ts anti-cheat (cap apotheosis count), API client, GameContext (apotheosis() function), GameLayout (new tab), ResourceBar (gold apotheosis badge shown above transcendence and prestige badges), styles.css, AboutPanel how-to-play. Also removes IDEAS.md — all planned features are now implemented!
This commit is contained in:
@@ -3,6 +3,7 @@ import { Hono } from "hono";
|
||||
import { cors } from "hono/cors";
|
||||
import { logger } from "hono/logger";
|
||||
import { aboutRouter } from "./routes/about.js";
|
||||
import { apotheosisRouter } from "./routes/apotheosis.js";
|
||||
import { authRouter } from "./routes/auth.js";
|
||||
import { bossRouter } from "./routes/boss.js";
|
||||
import { gameRouter } from "./routes/game.js";
|
||||
@@ -28,6 +29,7 @@ app.route("/game", gameRouter);
|
||||
app.route("/boss", bossRouter);
|
||||
app.route("/prestige", prestigeRouter);
|
||||
app.route("/transcendence", transcendenceRouter);
|
||||
app.route("/apotheosis", apotheosisRouter);
|
||||
app.route("/profile", profileRouter);
|
||||
|
||||
app.get("/health", (context) => context.json({ status: "ok" }));
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { ApotheosisRequest, GameState } from "@elysium/types";
|
||||
import { Hono } from "hono";
|
||||
import type { HonoEnv } from "../types/hono.js";
|
||||
import { prisma } from "../db/client.js";
|
||||
import { authMiddleware } from "../middleware/auth.js";
|
||||
import {
|
||||
buildPostApotheosisState,
|
||||
isEligibleForApotheosis,
|
||||
} from "../services/apotheosis.js";
|
||||
|
||||
export const apotheosisRouter = new Hono<HonoEnv>();
|
||||
|
||||
apotheosisRouter.use("*", authMiddleware);
|
||||
|
||||
apotheosisRouter.post("/", async (context) => {
|
||||
const discordId = context.get("discordId") as string;
|
||||
const body = await context.req.json<ApotheosisRequest>();
|
||||
|
||||
const characterName = body.characterName?.trim();
|
||||
if (!characterName) {
|
||||
return context.json({ error: "characterName is required" }, 400);
|
||||
}
|
||||
|
||||
const record = await prisma.gameState.findUnique({ where: { discordId } });
|
||||
if (!record) {
|
||||
return context.json({ error: "No save found" }, 404);
|
||||
}
|
||||
|
||||
const state = record.state as unknown as GameState;
|
||||
|
||||
if (!isEligibleForApotheosis(state)) {
|
||||
return context.json(
|
||||
{ error: "Not eligible for Apotheosis — purchase all Transcendence upgrades first" },
|
||||
400,
|
||||
);
|
||||
}
|
||||
|
||||
// Capture current-run stats before the nuclear reset
|
||||
const runBossesDefeated = state.bosses.filter((b) => b.status === "defeated").length;
|
||||
const runQuestsCompleted = state.quests.filter((q) => q.status === "completed").length;
|
||||
const runAdventurersRecruited = state.adventurers.reduce((sum, a) => sum + a.count, 0);
|
||||
const runAchievementsUnlocked = (state.achievements ?? []).filter((a) => a.unlockedAt !== null).length;
|
||||
|
||||
const { newState, newApotheosisData } = buildPostApotheosisState(state, characterName);
|
||||
|
||||
const now = Date.now();
|
||||
await prisma.gameState.update({
|
||||
where: { discordId },
|
||||
data: { state: newState as object, updatedAt: now },
|
||||
});
|
||||
|
||||
await prisma.player.update({
|
||||
where: { discordId },
|
||||
data: {
|
||||
characterName,
|
||||
// Reset current-run counters
|
||||
totalGoldEarned: 0,
|
||||
totalClicks: 0,
|
||||
// Accumulate into lifetime totals
|
||||
lifetimeGoldEarned: { increment: state.player.totalGoldEarned },
|
||||
lifetimeClicks: { increment: state.player.totalClicks },
|
||||
lifetimeBossesDefeated: { increment: runBossesDefeated },
|
||||
lifetimeQuestsCompleted: { increment: runQuestsCompleted },
|
||||
lifetimeAdventurersRecruited: { increment: runAdventurersRecruited },
|
||||
lifetimeAchievementsUnlocked: { increment: runAchievementsUnlocked },
|
||||
lastSavedAt: now,
|
||||
},
|
||||
});
|
||||
|
||||
return context.json({ newApotheosisCount: newApotheosisData.count });
|
||||
});
|
||||
@@ -302,7 +302,14 @@ const validateAndSanitize = (incoming: GameState, previous: GameState): GameStat
|
||||
? { transcendence: previous.transcendence }
|
||||
: {};
|
||||
|
||||
return { ...incoming, resources, bosses, quests, achievements, prestige, ...transcendenceSpread };
|
||||
// Apotheosis count can only increase server-side — cap at the previous value.
|
||||
const apotheosisSpread = incoming.apotheosis
|
||||
? { apotheosis: { count: Math.min(incoming.apotheosis.count, previous.apotheosis?.count ?? 0) } }
|
||||
: previous.apotheosis
|
||||
? { apotheosis: previous.apotheosis }
|
||||
: {};
|
||||
|
||||
return { ...incoming, resources, bosses, quests, achievements, prestige, ...transcendenceSpread, ...apotheosisSpread };
|
||||
};
|
||||
|
||||
export const gameRouter = new Hono<HonoEnv>();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { ApotheosisData, GameState } from "@elysium/types";
|
||||
import { INITIAL_GAME_STATE } from "../data/initialState.js";
|
||||
import { DEFAULT_TRANSCENDENCE_UPGRADES } from "../data/transcendenceUpgrades.js";
|
||||
|
||||
/** Total number of echo upgrades — all must be purchased to unlock Apotheosis */
|
||||
const TOTAL_ECHO_UPGRADES = DEFAULT_TRANSCENDENCE_UPGRADES.length;
|
||||
|
||||
/**
|
||||
* Returns true when the player is eligible to achieve Apotheosis:
|
||||
* all Transcendence echo upgrades must be purchased.
|
||||
*/
|
||||
export const isEligibleForApotheosis = (state: GameState): boolean => {
|
||||
const purchasedIds = state.transcendence?.purchasedUpgradeIds ?? [];
|
||||
return purchasedIds.length >= TOTAL_ECHO_UPGRADES &&
|
||||
DEFAULT_TRANSCENDENCE_UPGRADES.every((u) => purchasedIds.includes(u.id));
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds the new game state after Apotheosis — the ultimate nuclear reset.
|
||||
* Wipes absolutely everything including prestige and transcendence.
|
||||
* Only codex lore entries and the apotheosis count itself are preserved.
|
||||
*/
|
||||
export const buildPostApotheosisState = (
|
||||
currentState: GameState,
|
||||
characterName: string,
|
||||
): { newState: GameState; newApotheosisData: ApotheosisData } => {
|
||||
const newCount = (currentState.apotheosis?.count ?? 0) + 1;
|
||||
const newApotheosisData: ApotheosisData = { count: newCount };
|
||||
|
||||
const freshState = INITIAL_GAME_STATE(currentState.player, characterName);
|
||||
const newState: GameState = {
|
||||
...freshState,
|
||||
lastTickAt: Date.now(),
|
||||
// Codex lore persists through all resets — players keep their discovered entries
|
||||
...(currentState.codex ? { codex: currentState.codex } : {}),
|
||||
// Apotheosis data is eternal — never wiped by any reset
|
||||
apotheosis: newApotheosisData,
|
||||
};
|
||||
|
||||
return { newState, newApotheosisData };
|
||||
};
|
||||
@@ -120,6 +120,8 @@ export const buildPostPrestigeState = (
|
||||
...(currentState.codex ? { codex: currentState.codex } : {}),
|
||||
// Transcendence data is permanent — never wiped by prestige
|
||||
...(currentState.transcendence ? { transcendence: currentState.transcendence } : {}),
|
||||
// Apotheosis data is eternal — never wiped by prestige
|
||||
...(currentState.apotheosis ? { apotheosis: currentState.apotheosis } : {}),
|
||||
};
|
||||
|
||||
return { newState, newPrestigeData, runestonesEarned, milestoneRunestones };
|
||||
|
||||
@@ -78,6 +78,8 @@ export const buildPostTranscendenceState = (
|
||||
...(currentState.codex ? { codex: currentState.codex } : {}),
|
||||
// Transcendence data is permanent
|
||||
transcendence: newTranscendenceData,
|
||||
// Apotheosis data is eternal — never wiped by transcendence
|
||||
...(currentState.apotheosis ? { apotheosis: currentState.apotheosis } : {}),
|
||||
};
|
||||
|
||||
return { newState, newTranscendenceData, echoesEarned };
|
||||
|
||||
Reference in New Issue
Block a user