2025-03-30 05:10:24 -07:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
|
|
import { getInventory, addEquipment, occupySlot, productCategoryToInventoryBin } from "@/src/services/inventoryService";
|
|
|
|
import { modularWeaponTypes } from "@/src/helpers/modularWeaponHelper";
|
2025-03-30 08:12:46 -07:00
|
|
|
import { ExportWeapons } from "warframe-public-export-plus";
|
|
|
|
import { RequestHandler } from "express";
|
2025-03-30 05:10:24 -07:00
|
|
|
|
|
|
|
export const addModularEquipmentController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
|
|
|
const request = req.body as IAddModularEquipmentRequest;
|
|
|
|
const category = modularWeaponTypes[request.ItemType];
|
|
|
|
const inventoryBin = productCategoryToInventoryBin(category)!;
|
|
|
|
const inventory = await getInventory(accountId, `${category} ${inventoryBin}`);
|
2025-03-30 08:12:46 -07:00
|
|
|
request.ModularParts.forEach(part => {
|
|
|
|
if (ExportWeapons[part].gunType) {
|
|
|
|
if (category == "LongGuns") {
|
|
|
|
request.ItemType = {
|
|
|
|
GT_RIFLE: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary",
|
|
|
|
GT_SHOTGUN: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryShotgun",
|
|
|
|
GT_BEAM: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam"
|
|
|
|
}[ExportWeapons[part].gunType];
|
|
|
|
} else {
|
|
|
|
request.ItemType = {
|
|
|
|
GT_RIFLE: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary",
|
|
|
|
GT_SHOTGUN: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun",
|
|
|
|
GT_BEAM: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam"
|
|
|
|
}[ExportWeapons[part].gunType];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2025-03-30 05:10:24 -07:00
|
|
|
addEquipment(inventory, category, request.ItemType, request.ModularParts);
|
|
|
|
occupySlot(inventory, inventoryBin, true);
|
|
|
|
await inventory.save();
|
|
|
|
res.end();
|
|
|
|
};
|
|
|
|
|
|
|
|
interface IAddModularEquipmentRequest {
|
|
|
|
ItemType: string;
|
|
|
|
ModularParts: string[];
|
|
|
|
}
|