feat: pause research

This commit is contained in:
Sainan 2025-03-14 15:13:09 +01:00
parent 44f77ff929
commit 7e78f8b758
2 changed files with 22 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import {
getGuildVault, getGuildVault,
hasAccessToDojo, hasAccessToDojo,
hasGuildPermission, hasGuildPermission,
removePigmentsFromGuildMembers,
scaleRequiredCount scaleRequiredCount
} from "@/src/services/guildService"; } from "@/src/services/guildService";
import { ExportDojoRecipes, IDojoResearch } from "warframe-public-export-plus"; import { ExportDojoRecipes, IDojoResearch } from "warframe-public-export-plus";
@ -188,6 +189,12 @@ export const guildTechController: RequestHandler = async (req, res) => {
await inventory.save(); await inventory.save();
// Not a mistake: This response uses `inventoryChanges` instead of `InventoryChanges`. // Not a mistake: This response uses `inventoryChanges` instead of `InventoryChanges`.
res.json({ inventoryChanges: inventoryChanges }); res.json({ inventoryChanges: inventoryChanges });
} else if (data.Action == "Pause") {
const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!;
project.State = -2;
await guild.save();
await removePigmentsFromGuildMembers(guild._id);
res.end();
} else { } else {
throw new Error(`unknown guildTech action: ${data.Action}`); throw new Error(`unknown guildTech action: ${data.Action}`);
} }
@ -236,7 +243,7 @@ type TGuildTechRequest =
| IGuildTechContributeRequest; | IGuildTechContributeRequest;
interface IGuildTechBasicRequest { interface IGuildTechBasicRequest {
Action: "Start" | "Fabricate"; Action: "Start" | "Fabricate" | "Pause";
Mode: "Guild"; Mode: "Guild";
RecipeType: string; RecipeType: string;
} }

View File

@ -349,3 +349,17 @@ export const hasGuildPermissionEx = (
const rank = guild.Ranks[member.rank]; const rank = guild.Ranks[member.rank];
return (rank.Permissions & perm) != 0; return (rank.Permissions & perm) != 0;
}; };
export const removePigmentsFromGuildMembers = async (guildId: string | Types.ObjectId): Promise<void> => {
const members = await GuildMember.find({ guildId }, "accountId");
for (const member of members) {
const inventory = await getInventory(member.accountId.toString(), "MiscItems");
const index = inventory.MiscItems.findIndex(
x => x.ItemType == "/Lotus/Types/Items/Research/DojoColors/GenericDojoColorPigment"
);
if (index != -1) {
inventory.MiscItems.splice(index, 1);
await inventory.save();
}
}
};