feat: pause research
This commit is contained in:
		
							parent
							
								
									44f77ff929
								
							
						
					
					
						commit
						7e78f8b758
					
				@ -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;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user