diff --git a/.gitignore b/.gitignore index 05465bae..ee9cbba6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ /build /.env -/static/data/* +/static/data/*.bin yarn.lock diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 6a947c9a..41b22959 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -5,6 +5,7 @@ import { Types } from "mongoose"; import { ISuitResponse } from "@/src/types/inventoryTypes/SuitTypes"; import { SlotType } from "@/src/types/purchaseTypes"; import { IWeaponResponse } from "@/src/types/inventoryTypes/weaponTypes"; +import { FlavourItem } from "@/src/types/inventoryTypes/inventoryTypes"; const createInventory = async (accountOwnerId: Types.ObjectId) => { try { @@ -97,12 +98,12 @@ export const addWeapon = async ( return changedInventory[weaponType][weaponIndex - 1].toJSON(); }; -export const addCustomization = async (customizatonName: string, accountId: string) => { +export const addCustomization = async (customizatonName: string, accountId: string): Promise => { const inventory = await getInventory(accountId); const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizatonName }) - 1; const changedInventory = await inventory.save(); - return changedInventory.FlavourItems[flavourItemIndex].toJSON(); + return changedInventory.FlavourItems[flavourItemIndex].toJSON(); //mongoose bug forces as FlavourItem }; export { createInventory, addPowerSuit }; diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 76d35017..16716573 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -1,7 +1,13 @@ import { getWeaponType } from "@/src/helpers/purchaseHelpers"; import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers"; -import { addCustomization, addPowerSuit, addWeapon, updateSlots } from "@/src/services/inventoryService"; -import { IPurchaseRequest, SlotType } from "@/src/types/purchaseTypes"; +import { + addCustomization, + addPowerSuit, + addWeapon, + updateCurrency, + updateSlots +} from "@/src/services/inventoryService"; +import { IPurchaseRequest, IPurchaseResponse, SlotType } from "@/src/types/purchaseTypes"; export const getStoreItemCategory = (storeItem: string) => { const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/"); diff --git a/src/types/purchaseTypes.ts b/src/types/purchaseTypes.ts index 1add87cc..f6860189 100644 --- a/src/types/purchaseTypes.ts +++ b/src/types/purchaseTypes.ts @@ -1,5 +1,6 @@ /* eslint-disable prettier/prettier */ import { ISuitDatabase } from "@/src/types/inventoryTypes/SuitTypes"; +import { FlavourItem } from "@/src/types/inventoryTypes/inventoryTypes"; import { IWeaponResponse } from "@/src/types/inventoryTypes/weaponTypes"; export interface IPurchaseRequest { @@ -28,6 +29,7 @@ export interface IPurchaseResponse { Melee?: IWeaponResponse[]; PremiumCredits?: number; RegularCredits?: number; + FlavourItems?: FlavourItem[]; }; } diff --git a/static/data/items.ts b/static/data/items.ts new file mode 100644 index 00000000..dd4c6622 --- /dev/null +++ b/static/data/items.ts @@ -0,0 +1,18 @@ +import Items, { Item, Weapon } from "warframe-items"; + +type MinWeapon = Omit; +type MinItem = Omit; + +export const weapons: MinWeapon[] = (new Items({ category: ["Primary", "Secondary", "Melee"] }) as Weapon[]).map( + item => { + const next = { ...item }; + delete next.patchlogs; + return next; + } +); + +export const items: MinItem[] = new Items({ category: ["All"] }).map(item => { + const next = { ...item }; + delete next.patchlogs; + return next; +});