feat: infusing abilities (#676)
This commit is contained in:
		
							parent
							
								
									48aa145a20
								
							
						
					
					
						commit
						0c6f6e556f
					
				@ -3,11 +3,13 @@ import { IUpgradesRequest } from "@/src/types/requestTypes";
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
    ArtifactPolarity,
 | 
					    ArtifactPolarity,
 | 
				
			||||||
    IEquipmentDatabase,
 | 
					    IEquipmentDatabase,
 | 
				
			||||||
    EquipmentFeatures
 | 
					    EquipmentFeatures,
 | 
				
			||||||
 | 
					    IAbilityOverride
 | 
				
			||||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
					} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
					import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
 | 
					import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
 | 
				
			||||||
 | 
					import { getRecipeByResult } from "@/src/services/itemDataService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const upgradesController: RequestHandler = async (req, res) => {
 | 
					export const upgradesController: RequestHandler = async (req, res) => {
 | 
				
			||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
@ -28,97 +30,120 @@ export const upgradesController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            ]);
 | 
					            ]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        switch (operation.UpgradeRequirement) {
 | 
					        if (operation.OperationType == "UOT_ABILITY_OVERRIDE") {
 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/OrokinReactor":
 | 
					            console.assert(payload.ItemCategory == "Suits");
 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/OrokinCatalyst":
 | 
					            const suit = inventory.Suits.find(x => x._id.toString() == payload.ItemId.$oid)!;
 | 
				
			||||||
                for (const item of inventory[payload.ItemCategory]) {
 | 
					
 | 
				
			||||||
                    if (item._id.toString() == payload.ItemId.$oid) {
 | 
					            let newAbilityOverride: IAbilityOverride | undefined;
 | 
				
			||||||
                        item.Features ??= 0;
 | 
					            if (operation.UpgradeRequirement != "") {
 | 
				
			||||||
                        item.Features |= EquipmentFeatures.DOUBLE_CAPACITY;
 | 
					                newAbilityOverride = {
 | 
				
			||||||
                        break;
 | 
					                    Ability: operation.UpgradeRequirement,
 | 
				
			||||||
                    }
 | 
					                    Index: operation.PolarizeSlot
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                const recipe = getRecipeByResult(operation.UpgradeRequirement)!;
 | 
				
			||||||
 | 
					                for (const ingredient of recipe.ingredients) {
 | 
				
			||||||
 | 
					                    inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType)!.Count -=
 | 
				
			||||||
 | 
					                        ingredient.ItemCount;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					            }
 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/UtilityUnlocker":
 | 
					
 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/WeaponUtilityUnlocker":
 | 
					            for (const entry of operation.PolarityRemap) {
 | 
				
			||||||
                for (const item of inventory[payload.ItemCategory]) {
 | 
					                suit.Configs[entry.Slot] ??= {};
 | 
				
			||||||
                    if (item._id.toString() == payload.ItemId.$oid) {
 | 
					                suit.Configs[entry.Slot].AbilityOverride = newAbilityOverride;
 | 
				
			||||||
                        item.Features ??= 0;
 | 
					            }
 | 
				
			||||||
                        item.Features |= EquipmentFeatures.UTILITY_SLOT;
 | 
					        } else
 | 
				
			||||||
                        break;
 | 
					            switch (operation.UpgradeRequirement) {
 | 
				
			||||||
                    }
 | 
					                case "/Lotus/Types/Items/MiscItems/OrokinReactor":
 | 
				
			||||||
                }
 | 
					                case "/Lotus/Types/Items/MiscItems/OrokinCatalyst":
 | 
				
			||||||
                break;
 | 
					                    for (const item of inventory[payload.ItemCategory]) {
 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/HeavyWeaponCatalyst":
 | 
					                        if (item._id.toString() == payload.ItemId.$oid) {
 | 
				
			||||||
                console.assert(payload.ItemCategory == "SpaceGuns");
 | 
					                            item.Features ??= 0;
 | 
				
			||||||
                for (const item of inventory[payload.ItemCategory]) {
 | 
					                            item.Features |= EquipmentFeatures.DOUBLE_CAPACITY;
 | 
				
			||||||
                    if (item._id.toString() == payload.ItemId.$oid) {
 | 
					                            break;
 | 
				
			||||||
                        item.Features ??= 0;
 | 
					 | 
				
			||||||
                        item.Features |= EquipmentFeatures.GRAVIMAG_INSTALLED;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/WeaponPrimaryArcaneUnlocker":
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/WeaponSecondaryArcaneUnlocker":
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/WeaponMeleeArcaneUnlocker":
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/WeaponAmpArcaneUnlocker":
 | 
					 | 
				
			||||||
                for (const item of inventory[payload.ItemCategory]) {
 | 
					 | 
				
			||||||
                    if (item._id.toString() == payload.ItemId.$oid) {
 | 
					 | 
				
			||||||
                        item.Features ??= 0;
 | 
					 | 
				
			||||||
                        item.Features |= EquipmentFeatures.ARCANE_SLOT;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/Forma":
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/FormaUmbra":
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/FormaAura":
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/FormaStance":
 | 
					 | 
				
			||||||
                for (const item of inventory[payload.ItemCategory]) {
 | 
					 | 
				
			||||||
                    if (item._id.toString() == payload.ItemId.$oid) {
 | 
					 | 
				
			||||||
                        item.XP = 0;
 | 
					 | 
				
			||||||
                        setSlotPolarity(item, operation.PolarizeSlot, operation.PolarizeValue);
 | 
					 | 
				
			||||||
                        item.Polarized ??= 0;
 | 
					 | 
				
			||||||
                        item.Polarized += 1;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/ModSlotUnlocker":
 | 
					 | 
				
			||||||
                for (const item of inventory[payload.ItemCategory]) {
 | 
					 | 
				
			||||||
                    if (item._id.toString() == payload.ItemId.$oid) {
 | 
					 | 
				
			||||||
                        item.ModSlotPurchases ??= 0;
 | 
					 | 
				
			||||||
                        item.ModSlotPurchases += 1;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            case "/Lotus/Types/Items/MiscItems/CustomizationSlotUnlocker":
 | 
					 | 
				
			||||||
                for (const item of inventory[payload.ItemCategory]) {
 | 
					 | 
				
			||||||
                    if (item._id.toString() == payload.ItemId.$oid) {
 | 
					 | 
				
			||||||
                        item.CustomizationSlotPurchases ??= 0;
 | 
					 | 
				
			||||||
                        item.CustomizationSlotPurchases += 1;
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            case "":
 | 
					 | 
				
			||||||
                console.assert(operation.OperationType == "UOT_SWAP_POLARITY");
 | 
					 | 
				
			||||||
                for (const item of inventory[payload.ItemCategory]) {
 | 
					 | 
				
			||||||
                    if (item._id.toString() == payload.ItemId.$oid) {
 | 
					 | 
				
			||||||
                        for (let i = 0; i != operation.PolarityRemap.length; ++i) {
 | 
					 | 
				
			||||||
                            if (operation.PolarityRemap[i].Slot != i) {
 | 
					 | 
				
			||||||
                                setSlotPolarity(item, i, operation.PolarityRemap[i].Value);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                    break;
 | 
				
			||||||
                break;
 | 
					                case "/Lotus/Types/Items/MiscItems/UtilityUnlocker":
 | 
				
			||||||
            default:
 | 
					                case "/Lotus/Types/Items/MiscItems/WeaponUtilityUnlocker":
 | 
				
			||||||
                throw new Error("Unsupported upgrade: " + operation.UpgradeRequirement);
 | 
					                    for (const item of inventory[payload.ItemCategory]) {
 | 
				
			||||||
        }
 | 
					                        if (item._id.toString() == payload.ItemId.$oid) {
 | 
				
			||||||
 | 
					                            item.Features ??= 0;
 | 
				
			||||||
 | 
					                            item.Features |= EquipmentFeatures.UTILITY_SLOT;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/HeavyWeaponCatalyst":
 | 
				
			||||||
 | 
					                    console.assert(payload.ItemCategory == "SpaceGuns");
 | 
				
			||||||
 | 
					                    for (const item of inventory[payload.ItemCategory]) {
 | 
				
			||||||
 | 
					                        if (item._id.toString() == payload.ItemId.$oid) {
 | 
				
			||||||
 | 
					                            item.Features ??= 0;
 | 
				
			||||||
 | 
					                            item.Features |= EquipmentFeatures.GRAVIMAG_INSTALLED;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/WeaponPrimaryArcaneUnlocker":
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/WeaponSecondaryArcaneUnlocker":
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/WeaponMeleeArcaneUnlocker":
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/WeaponAmpArcaneUnlocker":
 | 
				
			||||||
 | 
					                    for (const item of inventory[payload.ItemCategory]) {
 | 
				
			||||||
 | 
					                        if (item._id.toString() == payload.ItemId.$oid) {
 | 
				
			||||||
 | 
					                            item.Features ??= 0;
 | 
				
			||||||
 | 
					                            item.Features |= EquipmentFeatures.ARCANE_SLOT;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/Forma":
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/FormaUmbra":
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/FormaAura":
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/FormaStance":
 | 
				
			||||||
 | 
					                    for (const item of inventory[payload.ItemCategory]) {
 | 
				
			||||||
 | 
					                        if (item._id.toString() == payload.ItemId.$oid) {
 | 
				
			||||||
 | 
					                            item.XP = 0;
 | 
				
			||||||
 | 
					                            setSlotPolarity(item, operation.PolarizeSlot, operation.PolarizeValue);
 | 
				
			||||||
 | 
					                            item.Polarized ??= 0;
 | 
				
			||||||
 | 
					                            item.Polarized += 1;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/ModSlotUnlocker":
 | 
				
			||||||
 | 
					                    for (const item of inventory[payload.ItemCategory]) {
 | 
				
			||||||
 | 
					                        if (item._id.toString() == payload.ItemId.$oid) {
 | 
				
			||||||
 | 
					                            item.ModSlotPurchases ??= 0;
 | 
				
			||||||
 | 
					                            item.ModSlotPurchases += 1;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "/Lotus/Types/Items/MiscItems/CustomizationSlotUnlocker":
 | 
				
			||||||
 | 
					                    for (const item of inventory[payload.ItemCategory]) {
 | 
				
			||||||
 | 
					                        if (item._id.toString() == payload.ItemId.$oid) {
 | 
				
			||||||
 | 
					                            item.CustomizationSlotPurchases ??= 0;
 | 
				
			||||||
 | 
					                            item.CustomizationSlotPurchases += 1;
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                case "":
 | 
				
			||||||
 | 
					                    console.assert(operation.OperationType == "UOT_SWAP_POLARITY");
 | 
				
			||||||
 | 
					                    for (const item of inventory[payload.ItemCategory]) {
 | 
				
			||||||
 | 
					                        if (item._id.toString() == payload.ItemId.$oid) {
 | 
				
			||||||
 | 
					                            for (let i = 0; i != operation.PolarityRemap.length; ++i) {
 | 
				
			||||||
 | 
					                                if (operation.PolarityRemap[i].Slot != i) {
 | 
				
			||||||
 | 
					                                    setSlotPolarity(item, i, operation.PolarityRemap[i].Value);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                default:
 | 
				
			||||||
 | 
					                    throw new Error("Unsupported upgrade: " + operation.UpgradeRequirement);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    await inventory.save();
 | 
					    await inventory.save();
 | 
				
			||||||
    res.json({ InventoryChanges: {} });
 | 
					    res.json({ InventoryChanges: {} });
 | 
				
			||||||
 | 
				
			|||||||
@ -65,6 +65,10 @@ export const getRecipe = (uniqueName: string): IRecipe | undefined => {
 | 
				
			|||||||
    return ExportRecipes[uniqueName];
 | 
					    return ExportRecipes[uniqueName];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const getRecipeByResult = (resultType: string): IRecipe | undefined => {
 | 
				
			||||||
 | 
					    return Object.values(ExportRecipes).find(x => x.resultType == resultType);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getExalted = (uniqueName: string): string[] | undefined => {
 | 
					export const getExalted = (uniqueName: string): string[] | undefined => {
 | 
				
			||||||
    return getSuitByUniqueName(uniqueName)?.exalted;
 | 
					    return getSuitByUniqueName(uniqueName)?.exalted;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user