fix: preinstall potatoes on non-crafted equipment #1037
@ -36,7 +36,12 @@ import {
 | 
				
			|||||||
} from "../types/requestTypes";
 | 
					} from "../types/requestTypes";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
import { getExalted, getKeyChainItems } from "@/src/services/itemDataService";
 | 
					import { getExalted, getKeyChainItems } from "@/src/services/itemDataService";
 | 
				
			||||||
import { IEquipmentClient, IEquipmentDatabase, IItemConfig } from "../types/inventoryTypes/commonInventoryTypes";
 | 
					import {
 | 
				
			||||||
 | 
					    EquipmentFeatures,
 | 
				
			||||||
 | 
					    IEquipmentClient,
 | 
				
			||||||
 | 
					    IEquipmentDatabase,
 | 
				
			||||||
 | 
					    IItemConfig
 | 
				
			||||||
 | 
					} from "../types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    ExportArcanes,
 | 
					    ExportArcanes,
 | 
				
			||||||
    ExportBundles,
 | 
					    ExportBundles,
 | 
				
			||||||
@ -325,7 +330,14 @@ export const addItem = async (
 | 
				
			|||||||
    if (typeName in ExportWeapons) {
 | 
					    if (typeName in ExportWeapons) {
 | 
				
			||||||
        const weapon = ExportWeapons[typeName];
 | 
					        const weapon = ExportWeapons[typeName];
 | 
				
			||||||
        if (weapon.totalDamage != 0) {
 | 
					        if (weapon.totalDamage != 0) {
 | 
				
			||||||
            const inventoryChanges = addEquipment(inventory, weapon.productCategory, typeName);
 | 
					            const inventoryChanges = addEquipment(
 | 
				
			||||||
 | 
					                inventory,
 | 
				
			||||||
 | 
					                weapon.productCategory,
 | 
				
			||||||
 | 
					                typeName,
 | 
				
			||||||
 | 
					                [],
 | 
				
			||||||
 | 
					                {},
 | 
				
			||||||
 | 
					                premiumPurchase ? { Features: EquipmentFeatures.DOUBLE_CAPACITY } : {}
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
            if (weapon.additionalItems) {
 | 
					            if (weapon.additionalItems) {
 | 
				
			||||||
                for (const item of weapon.additionalItems) {
 | 
					                for (const item of weapon.additionalItems) {
 | 
				
			||||||
                    combineInventoryChanges(inventoryChanges, (await addItem(inventory, item, 1)).InventoryChanges);
 | 
					                    combineInventoryChanges(inventoryChanges, (await addItem(inventory, item, 1)).InventoryChanges);
 | 
				
			||||||
@ -405,7 +417,12 @@ export const addItem = async (
 | 
				
			|||||||
                default: {
 | 
					                default: {
 | 
				
			||||||
                    return {
 | 
					                    return {
 | 
				
			||||||
                        InventoryChanges: {
 | 
					                        InventoryChanges: {
 | 
				
			||||||
                            ...addPowerSuit(inventory, typeName),
 | 
					                            ...addPowerSuit(
 | 
				
			||||||
 | 
					                                inventory,
 | 
				
			||||||
 | 
					                                typeName,
 | 
				
			||||||
 | 
					                                {},
 | 
				
			||||||
 | 
					                                premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
 | 
				
			||||||
 | 
					                            ),
 | 
				
			||||||
                            ...occupySlot(inventory, InventorySlot.SUITS, premiumPurchase)
 | 
					                            ...occupySlot(inventory, InventorySlot.SUITS, premiumPurchase)
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
@ -413,7 +430,12 @@ export const addItem = async (
 | 
				
			|||||||
                case "Archwing": {
 | 
					                case "Archwing": {
 | 
				
			||||||
                    return {
 | 
					                    return {
 | 
				
			||||||
                        InventoryChanges: {
 | 
					                        InventoryChanges: {
 | 
				
			||||||
                            ...addSpaceSuit(inventory, typeName),
 | 
					                            ...addSpaceSuit(
 | 
				
			||||||
 | 
					                                inventory,
 | 
				
			||||||
 | 
					                                typeName,
 | 
				
			||||||
 | 
					                                {},
 | 
				
			||||||
 | 
					                                premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
 | 
				
			||||||
 | 
					                            ),
 | 
				
			||||||
                            ...occupySlot(inventory, InventorySlot.SPACESUITS, premiumPurchase)
 | 
					                            ...occupySlot(inventory, InventorySlot.SPACESUITS, premiumPurchase)
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
@ -421,7 +443,12 @@ export const addItem = async (
 | 
				
			|||||||
                case "EntratiMech": {
 | 
					                case "EntratiMech": {
 | 
				
			||||||
                    return {
 | 
					                    return {
 | 
				
			||||||
                        InventoryChanges: {
 | 
					                        InventoryChanges: {
 | 
				
			||||||
                            ...addMechSuit(inventory, typeName),
 | 
					                            ...addMechSuit(
 | 
				
			||||||
 | 
					                                inventory,
 | 
				
			||||||
 | 
					                                typeName,
 | 
				
			||||||
 | 
					                                {},
 | 
				
			||||||
 | 
					                                premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
 | 
				
			||||||
 | 
					                            ),
 | 
				
			||||||
                            ...occupySlot(inventory, InventorySlot.MECHSUITS, premiumPurchase)
 | 
					                            ...occupySlot(inventory, InventorySlot.MECHSUITS, premiumPurchase)
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
@ -455,7 +482,12 @@ export const addItem = async (
 | 
				
			|||||||
                case "Sentinels": {
 | 
					                case "Sentinels": {
 | 
				
			||||||
                    return {
 | 
					                    return {
 | 
				
			||||||
                        InventoryChanges: {
 | 
					                        InventoryChanges: {
 | 
				
			||||||
                            ...addSentinel(inventory, typeName),
 | 
					                            ...addSentinel(
 | 
				
			||||||
 | 
					                                inventory,
 | 
				
			||||||
 | 
					                                typeName,
 | 
				
			||||||
 | 
					                                {},
 | 
				
			||||||
 | 
					                                premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined
 | 
				
			||||||
 | 
					                            ),
 | 
				
			||||||
                            ...occupySlot(inventory, InventorySlot.SENTINELS, premiumPurchase)
 | 
					                            ...occupySlot(inventory, InventorySlot.SENTINELS, premiumPurchase)
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
@ -574,7 +606,8 @@ export const applyDefaultUpgrades = (
 | 
				
			|||||||
export const addSentinel = (
 | 
					export const addSentinel = (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    sentinelName: string,
 | 
					    sentinelName: string,
 | 
				
			||||||
    inventoryChanges: IInventoryChanges = {}
 | 
					    inventoryChanges: IInventoryChanges = {},
 | 
				
			||||||
 | 
					    features: number | undefined = undefined
 | 
				
			||||||
): IInventoryChanges => {
 | 
					): IInventoryChanges => {
 | 
				
			||||||
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
				
			||||||
    if (ExportSentinels[sentinelName]?.defaultWeapon) {
 | 
					    if (ExportSentinels[sentinelName]?.defaultWeapon) {
 | 
				
			||||||
@ -584,7 +617,8 @@ export const addSentinel = (
 | 
				
			|||||||
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
				
			||||||
    const configs: IItemConfig[] = applyDefaultUpgrades(inventory, ExportSentinels[sentinelName]?.defaultUpgrades);
 | 
					    const configs: IItemConfig[] = applyDefaultUpgrades(inventory, ExportSentinels[sentinelName]?.defaultUpgrades);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const sentinelIndex = inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0 }) - 1;
 | 
					    const sentinelIndex =
 | 
				
			||||||
 | 
					        inventory.Sentinels.push({ ItemType: sentinelName, Configs: configs, XP: 0, Features: features }) - 1;
 | 
				
			||||||
    inventoryChanges.Sentinels ??= [];
 | 
					    inventoryChanges.Sentinels ??= [];
 | 
				
			||||||
    inventoryChanges.Sentinels.push(inventory.Sentinels[sentinelIndex].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges.Sentinels.push(inventory.Sentinels[sentinelIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -604,7 +638,8 @@ export const addSentinelWeapon = (
 | 
				
			|||||||
export const addPowerSuit = (
 | 
					export const addPowerSuit = (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    powersuitName: string,
 | 
					    powersuitName: string,
 | 
				
			||||||
    inventoryChanges: IInventoryChanges = {}
 | 
					    inventoryChanges: IInventoryChanges = {},
 | 
				
			||||||
 | 
					    features: number | undefined = undefined
 | 
				
			||||||
): IInventoryChanges => {
 | 
					): IInventoryChanges => {
 | 
				
			||||||
    const specialItems = getExalted(powersuitName);
 | 
					    const specialItems = getExalted(powersuitName);
 | 
				
			||||||
    if (specialItems) {
 | 
					    if (specialItems) {
 | 
				
			||||||
@ -612,7 +647,8 @@ export const addPowerSuit = (
 | 
				
			|||||||
            addSpecialItem(inventory, specialItem, inventoryChanges);
 | 
					            addSpecialItem(inventory, specialItem, inventoryChanges);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
					    const suitIndex =
 | 
				
			||||||
 | 
					        inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0, Features: features }) - 1;
 | 
				
			||||||
    inventoryChanges.Suits ??= [];
 | 
					    inventoryChanges.Suits ??= [];
 | 
				
			||||||
    inventoryChanges.Suits.push(inventory.Suits[suitIndex].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges.Suits.push(inventory.Suits[suitIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
@ -621,7 +657,8 @@ export const addPowerSuit = (
 | 
				
			|||||||
export const addMechSuit = (
 | 
					export const addMechSuit = (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    mechsuitName: string,
 | 
					    mechsuitName: string,
 | 
				
			||||||
    inventoryChanges: IInventoryChanges = {}
 | 
					    inventoryChanges: IInventoryChanges = {},
 | 
				
			||||||
 | 
					    features: number | undefined = undefined
 | 
				
			||||||
): IInventoryChanges => {
 | 
					): IInventoryChanges => {
 | 
				
			||||||
    const specialItems = getExalted(mechsuitName);
 | 
					    const specialItems = getExalted(mechsuitName);
 | 
				
			||||||
    if (specialItems) {
 | 
					    if (specialItems) {
 | 
				
			||||||
@ -629,7 +666,9 @@ export const addMechSuit = (
 | 
				
			|||||||
            addSpecialItem(inventory, specialItem, inventoryChanges);
 | 
					            addSpecialItem(inventory, specialItem, inventoryChanges);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
					    const suitIndex =
 | 
				
			||||||
 | 
					        inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0, Features: features }) -
 | 
				
			||||||
 | 
					        1;
 | 
				
			||||||
    inventoryChanges.MechSuits ??= [];
 | 
					    inventoryChanges.MechSuits ??= [];
 | 
				
			||||||
    inventoryChanges.MechSuits.push(inventory.MechSuits[suitIndex].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges.MechSuits.push(inventory.MechSuits[suitIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
@ -658,9 +697,17 @@ export const addSpecialItem = (
 | 
				
			|||||||
export const addSpaceSuit = (
 | 
					export const addSpaceSuit = (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    spacesuitName: string,
 | 
					    spacesuitName: string,
 | 
				
			||||||
    inventoryChanges: IInventoryChanges = {}
 | 
					    inventoryChanges: IInventoryChanges = {},
 | 
				
			||||||
 | 
					    features: number | undefined = undefined
 | 
				
			||||||
): IInventoryChanges => {
 | 
					): IInventoryChanges => {
 | 
				
			||||||
    const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 }) - 1;
 | 
					    const suitIndex =
 | 
				
			||||||
 | 
					        inventory.SpaceSuits.push({
 | 
				
			||||||
 | 
					            ItemType: spacesuitName,
 | 
				
			||||||
 | 
					            Configs: [],
 | 
				
			||||||
 | 
					            UpgradeVer: 101,
 | 
				
			||||||
 | 
					            XP: 0,
 | 
				
			||||||
 | 
					            Features: features
 | 
				
			||||||
 | 
					        }) - 1;
 | 
				
			||||||
    inventoryChanges.SpaceSuits ??= [];
 | 
					    inventoryChanges.SpaceSuits ??= [];
 | 
				
			||||||
    inventoryChanges.SpaceSuits.push(inventory.SpaceSuits[suitIndex].toJSON<IEquipmentClient>());
 | 
					    inventoryChanges.SpaceSuits.push(inventory.SpaceSuits[suitIndex].toJSON<IEquipmentClient>());
 | 
				
			||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user