forked from OpenWF/SpaceNinjaServer
		
	fix: removing an archon shard doesn't refund it (#729)
This commit is contained in:
		
							parent
							
								
									82621ebe0f
								
							
						
					
					
						commit
						eb6baa5e15
					
				@ -52,14 +52,33 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            const request = getJSONfromString(String(req.body)) as IShardUninstallRequest;
 | 
					            const request = getJSONfromString(String(req.body)) as IShardUninstallRequest;
 | 
				
			||||||
            const inventory = await getInventory(accountId);
 | 
					            const inventory = await getInventory(accountId);
 | 
				
			||||||
            const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
 | 
					            const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // refund shard
 | 
				
			||||||
 | 
					            const shard = Object.entries(colorToShard).find(
 | 
				
			||||||
 | 
					                ([color]) => color == suit.ArchonCrystalUpgrades![request.Slot].Color
 | 
				
			||||||
 | 
					            )![1];
 | 
				
			||||||
 | 
					            const miscItemChanges = [
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ItemType: shard,
 | 
				
			||||||
 | 
					                    ItemCount: 1
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					            addMiscItems(inventory, miscItemChanges);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // remove from suit
 | 
				
			||||||
            suit.ArchonCrystalUpgrades![request.Slot] = {};
 | 
					            suit.ArchonCrystalUpgrades![request.Slot] = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // remove bile
 | 
				
			||||||
            const bile = inventory.InfestedFoundry!.Resources!.find(
 | 
					            const bile = inventory.InfestedFoundry!.Resources!.find(
 | 
				
			||||||
                x => x.ItemType == "/Lotus/Types/Items/InfestedFoundry/HelminthBile"
 | 
					                x => x.ItemType == "/Lotus/Types/Items/InfestedFoundry/HelminthBile"
 | 
				
			||||||
            )!;
 | 
					            )!;
 | 
				
			||||||
            bile.Count -= 300;
 | 
					            bile.Count -= 300;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await inventory.save();
 | 
					            await inventory.save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            res.json({
 | 
					            res.json({
 | 
				
			||||||
                InventoryChanges: {
 | 
					                InventoryChanges: {
 | 
				
			||||||
 | 
					                    MiscItems: miscItemChanges,
 | 
				
			||||||
                    InfestedFoundry: inventory.toJSON().InfestedFoundry
 | 
					                    InfestedFoundry: inventory.toJSON().InfestedFoundry
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user