feat: destroyDojoDeco
All checks were successful
Build / build (22) (push) Successful in 35s
Build / build (18) (push) Successful in 54s
Build / build (18) (pull_request) Successful in 39s
Build / build (20) (pull_request) Successful in 52s
Build / build (22) (pull_request) Successful in 1m6s
Build / build (20) (push) Successful in 1m5s

This commit is contained in:
Sainan 2025-03-04 19:45:45 +01:00
parent 03fee8bd57
commit 6e8ef2d186
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import { getDojoClient, getGuildForRequest } from "@/src/services/guildService";
import { RequestHandler } from "express";
export const destroyDojoDecoController: RequestHandler = async (req, res) => {
const guild = await getGuildForRequest(req);
const request = JSON.parse(String(req.body)) as IDestroyDojoDecoRequest;
const component = guild.DojoComponents.id(request.ComponentId)!;
const decoIndex = component.Decos!.findIndex(x => x._id.equals(request.DecoId));
component.Decos!.splice(decoIndex, 1);
// TODO: The client says this is supposed to refund the resources to the clan vault, so we should probably do that.
await guild.save();
res.json(getDojoClient(guild, 0));
};
interface IDestroyDojoDecoRequest {
DecoType: string;
ComponentId: string;
DecoId: string;
}

View File

@ -16,6 +16,7 @@ import { contributeToDojoComponentController } from "@/src/controllers/api/contr
import { createGuildController } from "@/src/controllers/api/createGuildController";
import { creditsController } from "@/src/controllers/api/creditsController";
import { deleteSessionController } from "@/src/controllers/api/deleteSessionController";
import { destroyDojoDecoController } from "@/src/controllers/api/destroyDojoDecoController";
import { dojoComponentRushController } from "@/src/controllers/api/dojoComponentRushController";
import { dojoController } from "@/src/controllers/api/dojoController";
import { dronesController } from "@/src/controllers/api/dronesController";
@ -151,6 +152,7 @@ apiRouter.post("/clearDialogueHistory.php", clearDialogueHistoryController);
apiRouter.post("/completeRandomModChallenge.php", completeRandomModChallengeController);
apiRouter.post("/contributeToDojoComponent.php", contributeToDojoComponentController);
apiRouter.post("/createGuild.php", createGuildController);
apiRouter.post("/destroyDojoDeco.php", destroyDojoDecoController);
apiRouter.post("/dojoComponentRush.php", dojoComponentRushController);
apiRouter.post("/drones.php", dronesController);
apiRouter.post("/endlessXp.php", endlessXpController);