feat: purchase modular weapon from daily special #1217
@ -28,13 +28,15 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
 | 
			
		||||
    const category = modularWeaponTypes[data.WeaponType];
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
 | 
			
		||||
    const configs = applyDefaultUpgrades(inventory, getDefaultUpgrades(data.Parts));
 | 
			
		||||
 | 
			
		||||
    // Give weapon
 | 
			
		||||
    const defaultUpgrades = getDefaultUpgrades(data.Parts);
 | 
			
		||||
    const configs = applyDefaultUpgrades(inventory, defaultUpgrades);
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = {
 | 
			
		||||
        ...addEquipment(inventory, category, data.WeaponType, data.Parts, {}, { Configs: configs }),
 | 
			
		||||
        ...occupySlot(inventory, productCategoryToInventoryBin(category)!, false)
 | 
			
		||||
    };
 | 
			
		||||
    if (defaultUpgrades) {
 | 
			
		||||
        inventoryChanges.RawUpgrades = defaultUpgrades.map(x => ({ ItemType: x.ItemType, ItemCount: 1 }));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Remove credits & parts
 | 
			
		||||
    const miscItemChanges = [];
 | 
			
		||||
 | 
			
		||||
@ -39,7 +39,8 @@ export const modularWeaponSaleController: RequestHandler = async (req, res) => {
 | 
			
		||||
        const weaponInfo = getSaleInfos(partTypeToParts, payload.Revision).find(x => x.Name == payload.SaleName)!
 | 
			
		||||
            .Weapons[payload.ItemIndex];
 | 
			
		||||
        const category = modularWeaponTypes[weaponInfo.ItemType];
 | 
			
		||||
        const configs = applyDefaultUpgrades(inventory, getDefaultUpgrades(weaponInfo.ModularParts));
 | 
			
		||||
        const defaultUpgrades = getDefaultUpgrades(weaponInfo.ModularParts);
 | 
			
		||||
        const configs = applyDefaultUpgrades(inventory, defaultUpgrades);
 | 
			
		||||
        const inventoryChanges: IInventoryChanges = {
 | 
			
		||||
            ...addEquipment(
 | 
			
		||||
                inventory,
 | 
			
		||||
@ -62,6 +63,9 @@ export const modularWeaponSaleController: RequestHandler = async (req, res) => {
 | 
			
		||||
            ...occupySlot(inventory, productCategoryToInventoryBin(category)!, true),
 | 
			
		||||
            ...updateCurrency(inventory, weaponInfo.PremiumPrice, true)
 | 
			
		||||
        };
 | 
			
		||||
        if (defaultUpgrades) {
 | 
			
		||||
            inventoryChanges.RawUpgrades = defaultUpgrades.map(x => ({ ItemType: x.ItemType, ItemCount: 1 }));
 | 
			
		||||
        }
 | 
			
		||||
        await inventory.save();
 | 
			
		||||
        res.json({
 | 
			
		||||
            InventoryChanges: inventoryChanges
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user