fix: acquiring ships
This commit is contained in:
parent
39ac1d8276
commit
0e74968587
@ -41,6 +41,7 @@ import {
|
|||||||
ExportResources,
|
ExportResources,
|
||||||
ExportUpgrades
|
ExportUpgrades
|
||||||
} from "warframe-public-export-plus";
|
} from "warframe-public-export-plus";
|
||||||
|
import { createShip } from "./shipService";
|
||||||
|
|
||||||
export const createInventory = async (
|
export const createInventory = async (
|
||||||
accountOwnerId: Types.ObjectId,
|
accountOwnerId: Types.ObjectId,
|
||||||
@ -129,19 +130,35 @@ export const addItem = async (
|
|||||||
}
|
}
|
||||||
if (typeName in ExportResources) {
|
if (typeName in ExportResources) {
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const miscItemChanges = [
|
if (ExportResources[typeName].productCategory == "Ships") {
|
||||||
{
|
const oid = await createShip(new Types.ObjectId(accountId), typeName);
|
||||||
ItemType: typeName,
|
inventory.Ships.push(oid);
|
||||||
ItemCount: quantity
|
await inventory.save();
|
||||||
} satisfies IMiscItem
|
return {
|
||||||
];
|
InventoryChanges: {
|
||||||
addMiscItems(inventory, miscItemChanges);
|
Ships: [
|
||||||
await inventory.save();
|
{
|
||||||
return {
|
ItemId: { $oid: oid },
|
||||||
InventoryChanges: {
|
ItemType: typeName
|
||||||
MiscItems: miscItemChanges
|
}
|
||||||
}
|
]
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const miscItemChanges = [
|
||||||
|
{
|
||||||
|
ItemType: typeName,
|
||||||
|
ItemCount: quantity
|
||||||
|
} satisfies IMiscItem
|
||||||
|
];
|
||||||
|
addMiscItems(inventory, miscItemChanges);
|
||||||
|
await inventory.save();
|
||||||
|
return {
|
||||||
|
InventoryChanges: {
|
||||||
|
MiscItems: miscItemChanges
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (typeName in ExportCustoms) {
|
if (typeName in ExportCustoms) {
|
||||||
return {
|
return {
|
||||||
|
@ -3,10 +3,13 @@ import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
|
|||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
|
|
||||||
export const createShip = async (accountOwnerId: Types.ObjectId) => {
|
export const createShip = async (
|
||||||
|
accountOwnerId: Types.ObjectId,
|
||||||
|
typeName: string = "/Lotus/Types/Items/Ships/DefaultShip"
|
||||||
|
) => {
|
||||||
try {
|
try {
|
||||||
const ship = new Ship({
|
const ship = new Ship({
|
||||||
ItemType: "/Lotus/Types/Items/Ships/DefaultShip",
|
ItemType: typeName,
|
||||||
ShipOwnerId: accountOwnerId
|
ShipOwnerId: accountOwnerId
|
||||||
});
|
});
|
||||||
const newShip = await ship.save();
|
const newShip = await ship.save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user