chore: add skin to freestanding inventory
This commit is contained in:
		
							parent
							
								
									f6afdd4869
								
							
						
					
					
						commit
						6e6c07eb02
					
				@ -164,11 +164,10 @@ export const addItem = async (
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (typeName in ExportCustoms) {
 | 
					    if (typeName in ExportCustoms) {
 | 
				
			||||||
        return {
 | 
					        const inventory = await getInventory(accountId);
 | 
				
			||||||
            InventoryChanges: {
 | 
					        const inventoryChanges = addSkin(inventory, typeName);
 | 
				
			||||||
                WeaponSkins: [await addSkin(typeName, accountId)]
 | 
					        await inventory.save();
 | 
				
			||||||
            }
 | 
					        return { InventoryChanges: inventoryChanges };
 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (typeName in ExportFlavour) {
 | 
					    if (typeName in ExportFlavour) {
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
@ -582,11 +581,17 @@ export const addCustomization = async (customizatonName: string, accountId: stri
 | 
				
			|||||||
    return changedInventory.FlavourItems[flavourItemIndex].toJSON();
 | 
					    return changedInventory.FlavourItems[flavourItemIndex].toJSON();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const addSkin = async (typeName: string, accountId: string): Promise<IWeaponSkinClient> => {
 | 
					export const addSkin = (
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
 | 
					    typeName: string,
 | 
				
			||||||
 | 
					    inventoryChanges: IInventoryChanges = {}
 | 
				
			||||||
 | 
					): IInventoryChanges => {
 | 
				
			||||||
    const index = inventory.WeaponSkins.push({ ItemType: typeName }) - 1;
 | 
					    const index = inventory.WeaponSkins.push({ ItemType: typeName }) - 1;
 | 
				
			||||||
    const changedInventory = await inventory.save();
 | 
					    inventoryChanges.WeaponSkins ??= [];
 | 
				
			||||||
    return changedInventory.WeaponSkins[index].toJSON() as object as IWeaponSkinClient;
 | 
					    (inventoryChanges.WeaponSkins as IWeaponSkinClient[]).push(
 | 
				
			||||||
 | 
					        inventory.WeaponSkins[index].toJSON<IWeaponSkinClient>()
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const addCrewShip = (
 | 
					const addCrewShip = (
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user