generated from nhcarrigan/template
feat: debug panel with force unlocks and hard reset (#65)
## Summary - Adds a new **Debug** tab to the game UI with two self-service tools for players with broken save state - **Force Unlocks**: scans the player's save and grants any zones, quests, bosses, and exploration areas they've earned but that are still locked — shows a breakdown of what was unlocked (or reports nothing needed fixing) - **Hard Reset**: wipes progress back to a fresh save (preserving lifetime stats), guarded behind a confirmation modal to prevent accidental clicks ## Files added - `apps/api/src/routes/debug.ts` — two POST endpoints (`/force-unlocks`, `/hard-reset`) - `apps/web/src/components/game/debugPanel.tsx` — the Debug tab UI - `apps/web/src/components/ui/confirmationModal.tsx` — reusable confirmation modal ## Files modified - `apps/api/src/index.ts` — registers the debug router - `packages/types/src/interfaces/api.ts` — adds `ForceUnlocksResponse` type - `packages/types/src/index.ts` — exports the new type - `apps/web/src/api/client.ts` — adds `forceUnlocks()` and `debugHardReset()` API calls - `apps/web/src/context/gameContext.tsx` — wires both functions into game context - `apps/web/src/components/game/gameLayout.tsx` — adds the Debug tab - `apps/web/src/styles.css` — styles for action buttons, cards, result messages, and confirmation modal ✨ This PR was created with help from Hikari~ 🌸 Reviewed-on: #65 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #65.
This commit is contained in:
@@ -21,6 +21,7 @@ import type {
|
||||
ExploreCollectResponse,
|
||||
ExploreStartRequest,
|
||||
ExploreStartResponse,
|
||||
ForceUnlocksResponse,
|
||||
LoadResponse,
|
||||
PrestigeRequest,
|
||||
PrestigeResponse,
|
||||
@@ -256,6 +257,24 @@ const craftRecipe = async(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a request to fix any missing unlocks in the player's game state.
|
||||
* @returns The corrected game state and counts of what was unlocked.
|
||||
*/
|
||||
const forceUnlocks = async(): Promise<ForceUnlocksResponse> => {
|
||||
return await fetchJson<ForceUnlocksResponse>("/debug/force-unlocks", {
|
||||
method: "POST",
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs a complete hard reset of the player's game state via the debug endpoint.
|
||||
* @returns The fresh game state as a LoadResponse.
|
||||
*/
|
||||
const debugHardReset = async(): Promise<LoadResponse> => {
|
||||
return await fetchJson<LoadResponse>("/debug/hard-reset", { method: "POST" });
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches a public player profile by Discord ID.
|
||||
* @param discordId - The Discord ID of the player to look up.
|
||||
@@ -288,6 +307,8 @@ export {
|
||||
challengeBoss,
|
||||
collectExploration,
|
||||
craftRecipe,
|
||||
debugHardReset,
|
||||
forceUnlocks,
|
||||
getAbout,
|
||||
getAuthUrl,
|
||||
getPublicProfile,
|
||||
|
||||
Reference in New Issue
Block a user