moveproductCategoryToSlotName to addItems
This commit is contained in:
parent
425ec568ee
commit
463a7d8f14
@ -1,6 +1,7 @@
|
|||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { addEquipment, addPowerSuit, getInventory, updateSlots } from "@/src/services/inventoryService";
|
import { addEquipment, addPowerSuit, getInventory, updateSlots } from "@/src/services/inventoryService";
|
||||||
import { productCategoryToSlotName } from "@/src/helpers/purchaseHelpers";
|
import { SlotNames } from "@/src/types/purchaseTypes";
|
||||||
|
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
export const addItemsController: RequestHandler = async (req, res) => {
|
export const addItemsController: RequestHandler = async (req, res) => {
|
||||||
@ -24,9 +25,22 @@ export const addItemsController: RequestHandler = async (req, res) => {
|
|||||||
res.end();
|
res.end();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const productCategoryToSlotName: Record<ItemType, SlotNames> = {
|
||||||
|
Suits: InventorySlot.SUITS,
|
||||||
|
Pistols: InventorySlot.WEAPONS,
|
||||||
|
Melee: InventorySlot.WEAPONS,
|
||||||
|
LongGuns: InventorySlot.WEAPONS,
|
||||||
|
SpaceSuits: InventorySlot.SPACESUITS,
|
||||||
|
SpaceGuns: InventorySlot.SPACESUITS,
|
||||||
|
SpaceMelee: InventorySlot.SPACESUITS,
|
||||||
|
Sentinels: InventorySlot.SENTINELS,
|
||||||
|
SentinelWeapons: InventorySlot.SENTINELS
|
||||||
|
};
|
||||||
|
|
||||||
enum ItemType {
|
enum ItemType {
|
||||||
Suits = "Suits",
|
Suits = "Suits",
|
||||||
SpaceSuits = "SpaceSuits",
|
SpaceSuits = "SpaceSuits",
|
||||||
|
LongGuns = "LongGuns",
|
||||||
Pistols = "Pistols",
|
Pistols = "Pistols",
|
||||||
Melee = "Melee",
|
Melee = "Melee",
|
||||||
SpaceGuns = "SpaceGuns",
|
SpaceGuns = "SpaceGuns",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { slotPurchaseNameToSlotName } from "@/src/services/purchaseService";
|
import { slotPurchaseNameToSlotName } from "@/src/services/purchaseService";
|
||||||
import { SlotNames, SlotPurchaseName } from "@/src/types/purchaseTypes";
|
import { SlotPurchaseName } from "@/src/types/purchaseTypes";
|
||||||
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
|
|
||||||
|
|
||||||
export const isSlotPurchaseName = (slotPurchaseName: string): slotPurchaseName is SlotPurchaseName => {
|
export const isSlotPurchaseName = (slotPurchaseName: string): slotPurchaseName is SlotPurchaseName => {
|
||||||
return slotPurchaseName in slotPurchaseNameToSlotName;
|
return slotPurchaseName in slotPurchaseNameToSlotName;
|
||||||
@ -10,16 +9,3 @@ export const parseSlotPurchaseName = (slotPurchaseName: string): SlotPurchaseNam
|
|||||||
if (!isSlotPurchaseName(slotPurchaseName)) throw new Error(`invalid slot name ${slotPurchaseName}`);
|
if (!isSlotPurchaseName(slotPurchaseName)) throw new Error(`invalid slot name ${slotPurchaseName}`);
|
||||||
return slotPurchaseName;
|
return slotPurchaseName;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const productCategoryToSlotName: Record<string, SlotNames> = {
|
|
||||||
Suits: InventorySlot.SUITS,
|
|
||||||
Pistols: InventorySlot.WEAPONS,
|
|
||||||
Melee: InventorySlot.WEAPONS,
|
|
||||||
LongGuns: InventorySlot.WEAPONS,
|
|
||||||
SpaceSuits: InventorySlot.SPACESUITS,
|
|
||||||
SpaceGuns: InventorySlot.SPACESUITS,
|
|
||||||
SpaceMelee: InventorySlot.SPACESUITS,
|
|
||||||
Sentinels: InventorySlot.SENTINELS,
|
|
||||||
SentinelWeapons: InventorySlot.SENTINELS,
|
|
||||||
MechSuits: InventorySlot.MECHSUITS
|
|
||||||
};
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user