diff --git a/.eslintrc b/.eslintrc index e77dc45d..c7994fc1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,7 +16,6 @@ "@typescript-eslint/restrict-plus-operands": "warn", "@typescript-eslint/no-unsafe-member-access": "warn", "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "caughtErrors": "none" }], - "@typescript-eslint/no-misused-promises": "warn", "@typescript-eslint/no-unsafe-argument": "error", "@typescript-eslint/no-unsafe-call": "warn", "@typescript-eslint/no-unsafe-assignment": "warn", diff --git a/src/controllers/api/giveStartingGearController.ts b/src/controllers/api/giveStartingGearController.ts index 93fa1452..74d45e29 100644 --- a/src/controllers/api/giveStartingGearController.ts +++ b/src/controllers/api/giveStartingGearController.ts @@ -53,7 +53,7 @@ export const addStartingGear = async ( addEquipment(inventory, "LongGuns", LongGuns[0].ItemType, undefined, inventoryChanges); addEquipment(inventory, "Pistols", Pistols[0].ItemType, undefined, inventoryChanges); addEquipment(inventory, "Melee", Melee[0].ItemType, undefined, inventoryChanges); - addPowerSuit(inventory, Suits[0].ItemType, inventoryChanges); + await addPowerSuit(inventory, Suits[0].ItemType, inventoryChanges); addEquipment( inventory, "DataKnives", diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 92543e6f..96203345 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -30,7 +30,7 @@ import { import { IGenericUpdate, IUpdateNodeIntrosResponse } from "../types/genericUpdate"; import { IMissionInventoryUpdateRequest } from "../types/requestTypes"; import { logger } from "@/src/utils/logger"; -import { convertInboxMessage, fromStoreItem, getExalted, getKeyChainItems } from "@/src/services/itemDataService"; +import { convertInboxMessage, fromStoreItem, getKeyChainItems } from "@/src/services/itemDataService"; import { EquipmentFeatures, IEquipmentClient, @@ -55,8 +55,10 @@ import { ExportSentinels, ExportSyndicates, ExportUpgrades, + ExportWarframes, ExportWeapons, IDefaultUpgrade, + IPowersuit, TStandingLimitBin } from "warframe-public-export-plus"; import { createShip } from "./shipService"; @@ -481,12 +483,12 @@ export const addItem = async ( switch (typeName.substr(1).split("/")[2]) { default: { return { - ...addPowerSuit( + ...(await addPowerSuit( inventory, typeName, {}, premiumPurchase ? EquipmentFeatures.DOUBLE_CAPACITY : undefined - ), + )), ...occupySlot(inventory, InventorySlot.SUITS, premiumPurchase) }; } @@ -697,20 +699,33 @@ const addSentinelWeapon = ( inventoryChanges.SentinelWeapons.push(inventory.SentinelWeapons[index].toJSON()); }; -export const addPowerSuit = ( +export const addPowerSuit = async ( inventory: TInventoryDatabaseDocument, powersuitName: string, inventoryChanges: IInventoryChanges = {}, features: number | undefined = undefined -): IInventoryChanges => { - const specialItems = getExalted(powersuitName); - if (specialItems) { - for (const specialItem of specialItems) { - addSpecialItem(inventory, specialItem, inventoryChanges); +): Promise => { + const powersuit = ExportWarframes[powersuitName] as IPowersuit | undefined; + const exalted = powersuit?.exalted ?? []; + for (const specialItem of exalted) { + addSpecialItem(inventory, specialItem, inventoryChanges); + } + if (powersuit?.additionalItems) { + for (const item of powersuit.additionalItems) { + if (exalted.indexOf(item) == -1) { + combineInventoryChanges(inventoryChanges, await addItem(inventory, item, 1)); + } } } const suitIndex = - inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0, Features: features }) - 1; + inventory.Suits.push({ + ItemType: powersuitName, + Configs: [], + UpgradeVer: 101, + XP: 0, + Features: features, + IsNew: true + }) - 1; inventoryChanges.Suits ??= []; inventoryChanges.Suits.push(inventory.Suits[suitIndex].toJSON()); return inventoryChanges; @@ -722,15 +737,21 @@ export const addMechSuit = ( inventoryChanges: IInventoryChanges = {}, features: number | undefined = undefined ): IInventoryChanges => { - const specialItems = getExalted(mechsuitName); - if (specialItems) { - for (const specialItem of specialItems) { + const powersuit = ExportWarframes[mechsuitName] as IPowersuit | undefined; + if (powersuit?.exalted) { + for (const specialItem of powersuit.exalted) { addSpecialItem(inventory, specialItem, inventoryChanges); } } const suitIndex = - inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0, Features: features }) - - 1; + inventory.MechSuits.push({ + ItemType: mechsuitName, + Configs: [], + UpgradeVer: 101, + XP: 0, + Features: features, + IsNew: true + }) - 1; inventoryChanges.MechSuits ??= []; inventoryChanges.MechSuits.push(inventory.MechSuits[suitIndex].toJSON()); return inventoryChanges; @@ -768,7 +789,8 @@ export const addSpaceSuit = ( Configs: [], UpgradeVer: 101, XP: 0, - Features: features + Features: features, + IsNew: true }) - 1; inventoryChanges.SpaceSuits ??= []; inventoryChanges.SpaceSuits.push(inventory.SpaceSuits[suitIndex].toJSON()); diff --git a/src/services/itemDataService.ts b/src/services/itemDataService.ts index 7f91b57e..2fc6c0da 100644 --- a/src/services/itemDataService.ts +++ b/src/services/itemDataService.ts @@ -31,7 +31,6 @@ import { IDefaultUpgrade, IInboxMessage, IMissionReward, - IPowersuit, IRecipe, TReward } from "warframe-public-export-plus"; @@ -56,10 +55,6 @@ export const getRecipeByResult = (resultType: string): IRecipe | undefined => { return Object.values(ExportRecipes).find(x => x.resultType == resultType); }; -export const getExalted = (uniqueName: string): string[] | undefined => { - return getSuitByUniqueName(uniqueName)?.exalted; -}; - export const getItemCategoryByUniqueName = (uniqueName: string): string => { //Lotus/Types/Items/MiscItems/PolymerBundle @@ -76,10 +71,6 @@ export const getItemCategoryByUniqueName = (uniqueName: string): string => { return category; }; -export const getSuitByUniqueName = (uniqueName: string): IPowersuit | undefined => { - return ExportWarframes[uniqueName]; -}; - export const getItemName = (uniqueName: string): string | undefined => { if (uniqueName in ExportArcanes) { return ExportArcanes[uniqueName].name;