2025-02-11 20:11:31 -08:00
|
|
|
import { getDojoClient, getGuildForRequest } from "@/src/services/guildService";
|
2024-06-07 22:01:38 +08:00
|
|
|
import { RequestHandler } from "express";
|
2024-12-23 23:12:21 +01:00
|
|
|
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
2024-06-07 22:01:38 +08:00
|
|
|
|
|
|
|
export const queueDojoComponentDestructionController: RequestHandler = async (req, res) => {
|
|
|
|
const guild = await getGuildForRequest(req);
|
|
|
|
const componentId = req.query.componentId as string;
|
2024-12-23 23:12:21 +01:00
|
|
|
const component = guild.DojoComponents!.splice(
|
2024-06-07 14:02:00 +00:00
|
|
|
guild.DojoComponents!.findIndex(x => x._id.toString() === componentId),
|
|
|
|
1
|
2024-12-23 23:12:21 +01:00
|
|
|
)[0];
|
2025-01-20 12:21:39 +01:00
|
|
|
const room = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == component.pf);
|
|
|
|
if (room) {
|
|
|
|
guild.DojoCapacity -= room.capacity;
|
|
|
|
guild.DojoEnergy -= room.energy;
|
2024-12-23 23:12:21 +01:00
|
|
|
}
|
2024-06-07 22:01:38 +08:00
|
|
|
await guild.save();
|
2025-02-11 20:11:31 -08:00
|
|
|
res.json(getDojoClient(guild, 1));
|
2024-06-07 14:02:00 +00:00
|
|
|
};
|