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,6 +130,21 @@ export const addItem = async (
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    if (typeName in ExportResources) {
 | 
					    if (typeName in ExportResources) {
 | 
				
			||||||
        const inventory = await getInventory(accountId);
 | 
					        const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					        if (ExportResources[typeName].productCategory == "Ships") {
 | 
				
			||||||
 | 
					            const oid = await createShip(new Types.ObjectId(accountId), typeName);
 | 
				
			||||||
 | 
					            inventory.Ships.push(oid);
 | 
				
			||||||
 | 
					            await inventory.save();
 | 
				
			||||||
 | 
					            return {
 | 
				
			||||||
 | 
					                InventoryChanges: {
 | 
				
			||||||
 | 
					                    Ships: [
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            ItemId: { $oid: oid },
 | 
				
			||||||
 | 
					                            ItemType: typeName
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    ]
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
            const miscItemChanges = [
 | 
					            const miscItemChanges = [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    ItemType: typeName,
 | 
					                    ItemType: typeName,
 | 
				
			||||||
@ -143,6 +159,7 @@ export const addItem = async (
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (typeName in ExportCustoms) {
 | 
					    if (typeName in ExportCustoms) {
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
            InventoryChanges: {
 | 
					            InventoryChanges: {
 | 
				
			||||||
 | 
				
			|||||||
@ -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