generated from nhcarrigan/template
feat: vampire expansion chunk 2 (wip) — content data and grant-apotheosis debug route
This commit is contained in:
@@ -26,7 +26,7 @@ import { defaultGoddessExplorationAreas } from "../data/goddessExplorations.js";
|
||||
import { defaultGoddessQuests } from "../data/goddessQuests.js";
|
||||
import { defaultGoddessUpgrades } from "../data/goddessUpgrades.js";
|
||||
import { defaultGoddessZones } from "../data/goddessZones.js";
|
||||
import { initialGameState } from "../data/initialState.js";
|
||||
import { initialGameState, initialGoddessState } from "../data/initialState.js";
|
||||
import { defaultQuests } from "../data/quests.js";
|
||||
import { defaultRecipes } from "../data/recipes.js";
|
||||
import { currentSchemaVersion } from "../data/schemaVersion.js";
|
||||
@@ -1271,6 +1271,64 @@ debugRouter.post("/sync-new-content", async(context) => {
|
||||
}
|
||||
});
|
||||
|
||||
debugRouter.post("/grant-apotheosis", async(context) => {
|
||||
try {
|
||||
const discordId = context.get("discordId");
|
||||
|
||||
const record = await prisma.gameState.findUnique({ where: { discordId } });
|
||||
if (!record) {
|
||||
return context.json({ error: "No save found" }, 404);
|
||||
}
|
||||
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Prisma returns JsonValue; cast to GameState */
|
||||
const state = record.state as GameState;
|
||||
|
||||
const updatedState: GameState
|
||||
= (state.apotheosis?.count ?? 0) >= 1
|
||||
? state
|
||||
: {
|
||||
...state,
|
||||
apotheosis: { count: 1 },
|
||||
goddess: initialGoddessState(),
|
||||
};
|
||||
|
||||
if (updatedState !== state) {
|
||||
const now = Date.now();
|
||||
await prisma.gameState.update({
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Prisma requires object */
|
||||
data: { state: updatedState as object, updatedAt: now },
|
||||
where: { discordId },
|
||||
});
|
||||
}
|
||||
|
||||
const secret = process.env.ANTI_CHEAT_SECRET;
|
||||
const signature
|
||||
= secret === undefined
|
||||
? undefined
|
||||
: computeHmac(JSON.stringify(updatedState), secret);
|
||||
|
||||
return context.json({
|
||||
currentSchemaVersion: currentSchemaVersion,
|
||||
loginBonus: null,
|
||||
loginStreak: 0,
|
||||
offlineEssence: 0,
|
||||
offlineGold: 0,
|
||||
offlineSeconds: 0,
|
||||
schemaOutdated: false,
|
||||
signature: signature,
|
||||
state: updatedState,
|
||||
});
|
||||
} catch (error) {
|
||||
void logger.error(
|
||||
"debug_grant_apotheosis",
|
||||
error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)),
|
||||
);
|
||||
return context.json({ error: "Internal server error" }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
debugRouter.post("/hard-reset", async(context) => {
|
||||
try {
|
||||
const discordId = context.get("discordId");
|
||||
|
||||
Reference in New Issue
Block a user