feat: rush repair drones
This commit is contained in:
		
							parent
							
								
									8b0ba0b84a
								
							
						
					
					
						commit
						6e815d0165
					
				@ -360,6 +360,22 @@ export const guildTechController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
        res.json({
 | 
					        res.json({
 | 
				
			||||||
            inventoryChanges: inventoryChanges
 | 
					            inventoryChanges: inventoryChanges
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					    } else if (data.Action == "InstantFinish") {
 | 
				
			||||||
 | 
					        if (data.TechProductCategory != "CrewShipWeapons" && data.TechProductCategory != "CrewShipWeaponSkins") {
 | 
				
			||||||
 | 
					            throw new Error(`unexpected TechProductCategory: ${data.TechProductCategory}`);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        const inventoryChanges = finishComponentRepair(inventory, data.TechProductCategory, data.CategoryItemId!);
 | 
				
			||||||
 | 
					        inventoryChanges.MiscItems = [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                ItemType: "/Lotus/Types/Items/MiscItems/InstantSalvageRepairItem",
 | 
				
			||||||
 | 
					                ItemCount: -1
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					        addMiscItems(inventory, inventoryChanges.MiscItems);
 | 
				
			||||||
 | 
					        await inventory.save();
 | 
				
			||||||
 | 
					        res.json({
 | 
				
			||||||
 | 
					            inventoryChanges: inventoryChanges
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        logger.debug(`data provided to ${req.path}: ${String(req.body)}`);
 | 
					        logger.debug(`data provided to ${req.path}: ${String(req.body)}`);
 | 
				
			||||||
        throw new Error(`unhandled guildTech request`);
 | 
					        throw new Error(`unhandled guildTech request`);
 | 
				
			||||||
@ -372,7 +388,7 @@ type TGuildTechRequest =
 | 
				
			|||||||
    | IGuildTechContributeRequest;
 | 
					    | IGuildTechContributeRequest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IGuildTechBasicRequest {
 | 
					interface IGuildTechBasicRequest {
 | 
				
			||||||
    Action: "Start" | "Fabricate" | "Pause" | "Unpause" | "Cancel" | "Rush";
 | 
					    Action: "Start" | "Fabricate" | "Pause" | "Unpause" | "Cancel" | "Rush" | "InstantFinish";
 | 
				
			||||||
    Mode: "Guild" | "Personal";
 | 
					    Mode: "Guild" | "Personal";
 | 
				
			||||||
    RecipeType: string;
 | 
					    RecipeType: string;
 | 
				
			||||||
    TechProductCategory?: string;
 | 
					    TechProductCategory?: string;
 | 
				
			||||||
@ -406,11 +422,19 @@ const claimSalvagedComponent = (inventory: TInventoryDatabaseDocument, itemId: s
 | 
				
			|||||||
    inventory.PersonalTechProjects.splice(personalTechProjectIndex, 1);
 | 
					    inventory.PersonalTechProjects.splice(personalTechProjectIndex, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const category = personalTechProject.ProductCategory! as "CrewShipWeapons" | "CrewShipWeaponSkins";
 | 
					    const category = personalTechProject.ProductCategory! as "CrewShipWeapons" | "CrewShipWeaponSkins";
 | 
				
			||||||
 | 
					    return finishComponentRepair(inventory, category, itemId);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const finishComponentRepair = (
 | 
				
			||||||
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
 | 
					    category: "CrewShipWeapons" | "CrewShipWeaponSkins",
 | 
				
			||||||
 | 
					    itemId: string
 | 
				
			||||||
 | 
					): IInventoryChanges => {
 | 
				
			||||||
    const salvageCategory = getSalvageCategory(category);
 | 
					    const salvageCategory = getSalvageCategory(category);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // find salved part & delete it
 | 
					    // find salved part & delete it
 | 
				
			||||||
    const salvageIndex = inventory[salvageCategory].findIndex(x => x._id.equals(itemId));
 | 
					    const salvageIndex = inventory[salvageCategory].findIndex(x => x._id.equals(itemId));
 | 
				
			||||||
    const salvageItem = inventory[category][salvageIndex];
 | 
					    const salvageItem = inventory[salvageCategory][salvageIndex];
 | 
				
			||||||
    inventory[salvageCategory].splice(salvageIndex, 1);
 | 
					    inventory[salvageCategory].splice(salvageIndex, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // add final item
 | 
					    // add final item
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user