add getDefaultUpgrades
This commit is contained in:
parent
675d445b93
commit
7106a60c64
@ -11,8 +11,8 @@ import {
|
||||
occupySlot,
|
||||
productCategoryToInventoryBin
|
||||
} from "@/src/services/inventoryService";
|
||||
import { ExportWeapons } from "warframe-public-export-plus";
|
||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||
import { getDefaultUpgrades } from "@/src/services/itemDataService";
|
||||
|
||||
const modularWeaponTypes: Record<string, TEquipmentKey> = {
|
||||
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": "LongGuns",
|
||||
@ -46,8 +46,7 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
|
||||
const category = modularWeaponTypes[data.WeaponType];
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
const configs = applyDefaultUpgrades(inventory, ExportWeapons[data.Parts[0]]?.defaultUpgrades);
|
||||
const configs = applyDefaultUpgrades(inventory, getDefaultUpgrades(data.Parts));
|
||||
|
||||
// Give weapon
|
||||
const inventoryChanges: IInventoryChanges = {
|
||||
|
@ -29,6 +29,7 @@ import {
|
||||
ExportSentinels,
|
||||
ExportWarframes,
|
||||
ExportWeapons,
|
||||
IDefaultUpgrade,
|
||||
IInboxMessage,
|
||||
IMissionReward,
|
||||
IPowersuit,
|
||||
@ -256,3 +257,15 @@ export const toStoreItem = (type: string): string => {
|
||||
export const fromStoreItem = (type: string): string => {
|
||||
return "/Lotus/" + type.substring("/Lotus/StoreItems/".length);
|
||||
};
|
||||
|
||||
export const getDefaultUpgrades = (parts: string[]): IDefaultUpgrade[] | undefined => {
|
||||
const allDefaultUpgrades: IDefaultUpgrade[] = [];
|
||||
for (const part of parts) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
const defaultUpgrades = ExportWeapons[part]?.defaultUpgrades;
|
||||
if (defaultUpgrades) {
|
||||
allDefaultUpgrades.push(...defaultUpgrades);
|
||||
}
|
||||
}
|
||||
return allDefaultUpgrades.length == 0 ? undefined : allDefaultUpgrades;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user