fix: update slots where addEquipment is used (#1207)
Reviewed-on: OpenWF/SpaceNinjaServer#1207
This commit is contained in:
parent
651ab5f6f1
commit
c3a9b42fa2
@ -1,7 +1,7 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { getInventory, addMiscItems, addEquipment } from "@/src/services/inventoryService";
|
import { getInventory, addMiscItems, addEquipment, occupySlot } from "@/src/services/inventoryService";
|
||||||
import { IMiscItem, TFocusPolarity, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IMiscItem, TFocusPolarity, TEquipmentKey, InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { ExportFocusUpgrades } from "warframe-public-export-plus";
|
import { ExportFocusUpgrades } from "warframe-public-export-plus";
|
||||||
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||||
@ -105,6 +105,7 @@ export const focusController: RequestHandler = async (req, res) => {
|
|||||||
];
|
];
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const inventoryChanges = addEquipment(inventory, "OperatorAmps", request.StartingWeaponType, parts);
|
const inventoryChanges = addEquipment(inventory, "OperatorAmps", request.StartingWeaponType, parts);
|
||||||
|
occupySlot(inventory, InventorySlot.AMPS, false);
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.json((inventoryChanges.OperatorAmps as IEquipmentClient[])[0]);
|
res.json((inventoryChanges.OperatorAmps as IEquipmentClient[])[0]);
|
||||||
break;
|
break;
|
||||||
|
@ -7,9 +7,12 @@ import {
|
|||||||
updateCurrency,
|
updateCurrency,
|
||||||
addEquipment,
|
addEquipment,
|
||||||
addMiscItems,
|
addMiscItems,
|
||||||
applyDefaultUpgrades
|
applyDefaultUpgrades,
|
||||||
|
occupySlot,
|
||||||
|
productCategoryToInventoryBin
|
||||||
} from "@/src/services/inventoryService";
|
} from "@/src/services/inventoryService";
|
||||||
import { ExportWeapons } from "warframe-public-export-plus";
|
import { ExportWeapons } from "warframe-public-export-plus";
|
||||||
|
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
|
|
||||||
const modularWeaponTypes: Record<string, TEquipmentKey> = {
|
const modularWeaponTypes: Record<string, TEquipmentKey> = {
|
||||||
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": "LongGuns",
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": "LongGuns",
|
||||||
@ -47,7 +50,10 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
|
|||||||
const configs = applyDefaultUpgrades(inventory, ExportWeapons[data.Parts[0]]?.defaultUpgrades);
|
const configs = applyDefaultUpgrades(inventory, ExportWeapons[data.Parts[0]]?.defaultUpgrades);
|
||||||
|
|
||||||
// Give weapon
|
// Give weapon
|
||||||
const inventoryChanges = addEquipment(inventory, category, data.WeaponType, data.Parts, {}, { Configs: configs });
|
const inventoryChanges: IInventoryChanges = {
|
||||||
|
...addEquipment(inventory, category, data.WeaponType, data.Parts, {}, { Configs: configs }),
|
||||||
|
...occupySlot(inventory, productCategoryToInventoryBin(category)!, false)
|
||||||
|
};
|
||||||
|
|
||||||
// Remove credits & parts
|
// Remove credits & parts
|
||||||
const miscItemChanges = [];
|
const miscItemChanges = [];
|
||||||
|
@ -172,6 +172,38 @@ export const getInventory = async (
|
|||||||
return inventory;
|
return inventory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const productCategoryToInventoryBin = (productCategory: string): InventorySlot | undefined => {
|
||||||
|
switch (productCategory) {
|
||||||
|
case "Suits":
|
||||||
|
return InventorySlot.SUITS;
|
||||||
|
case "Pistols":
|
||||||
|
case "LongGuns":
|
||||||
|
case "Melee":
|
||||||
|
return InventorySlot.WEAPONS;
|
||||||
|
case "Sentinels":
|
||||||
|
case "SentinelWeapons":
|
||||||
|
case "KubrowPets":
|
||||||
|
case "MoaPets":
|
||||||
|
return InventorySlot.SENTINELS;
|
||||||
|
case "SpaceSuits":
|
||||||
|
case "Hoverboards":
|
||||||
|
return InventorySlot.SPACESUITS;
|
||||||
|
case "SpaceGuns":
|
||||||
|
case "SpaceMelee":
|
||||||
|
return InventorySlot.SPACEWEAPONS;
|
||||||
|
case "OperatorAmps":
|
||||||
|
return InventorySlot.AMPS;
|
||||||
|
case "CrewShipWeapons":
|
||||||
|
case "CrewShipWeaponSkins":
|
||||||
|
return InventorySlot.RJ_COMPONENT_AND_ARMAMENTS;
|
||||||
|
case "MechSuits":
|
||||||
|
return InventorySlot.MECHSUITS;
|
||||||
|
case "CrewMembers":
|
||||||
|
return InventorySlot.CREWMEMBERS;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
export const occupySlot = (
|
export const occupySlot = (
|
||||||
inventory: TInventoryDatabaseDocument,
|
inventory: TInventoryDatabaseDocument,
|
||||||
bin: InventorySlot,
|
bin: InventorySlot,
|
||||||
|
@ -459,7 +459,8 @@ export enum InventorySlot {
|
|||||||
PVE_LOADOUTS = "PveBonusLoadoutBin",
|
PVE_LOADOUTS = "PveBonusLoadoutBin",
|
||||||
SENTINELS = "SentinelBin",
|
SENTINELS = "SentinelBin",
|
||||||
AMPS = "OperatorAmpBin",
|
AMPS = "OperatorAmpBin",
|
||||||
RJ_COMPONENT_AND_ARMAMENTS = "CrewShipSalvageBin"
|
RJ_COMPONENT_AND_ARMAMENTS = "CrewShipSalvageBin",
|
||||||
|
CREWMEMBERS = "CrewMemberBin"
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISlots {
|
export interface ISlots {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user