forked from OpenWF/SpaceNinjaServer
		
	feat: Ship Customizations, Personal Rooms (Orbiter, Apartment) (#132)
This breaks existing accounts
This commit is contained in:
		
							parent
							
								
									91ced2c75b
								
							
						
					
					
						commit
						a96eea0e63
					
				@ -7,6 +7,8 @@
 | 
				
			|||||||
  "skipStoryModeChoice": true,
 | 
					  "skipStoryModeChoice": true,
 | 
				
			||||||
  "skipTutorial": true,
 | 
					  "skipTutorial": true,
 | 
				
			||||||
  "unlockAllMissions": true,
 | 
					  "unlockAllMissions": true,
 | 
				
			||||||
  "unlockAllQuests": false,
 | 
					  "unlockAllQuests": true,
 | 
				
			||||||
  "infiniteResources": true
 | 
					  "infiniteResources": true,
 | 
				
			||||||
 | 
					  "unlockallShipFeatures": true,
 | 
				
			||||||
 | 
					  "unlockAllShipDecorations": true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,90 +1,60 @@
 | 
				
			|||||||
import { Ship } from "@/src/models/shipModel";
 | 
					 | 
				
			||||||
import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
 | 
					 | 
				
			||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					import config from "@/config.json";
 | 
				
			||||||
 | 
					import allShipFeatures from "@/static/fixed_responses/allShipFeatures.json";
 | 
				
			||||||
 | 
					import { parseString } from "@/src/helpers/general";
 | 
				
			||||||
 | 
					import { getShip } from "@/src/services/shipService";
 | 
				
			||||||
 | 
					import { PersonalRooms } from "@/src/models/personalRoomsModel";
 | 
				
			||||||
 | 
					import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
 | 
				
			||||||
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
 | 
					import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
				
			||||||
 | 
					import { IGetShipResponse } from "@/src/types/shipTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
					// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
				
			||||||
const getShipController: RequestHandler = async (req, res) => {
 | 
					export const getShipController: RequestHandler = async (req, res) => {
 | 
				
			||||||
    const accountId = req.query.accountId;
 | 
					    const accountId = parseString(req.query.accountId);
 | 
				
			||||||
    const ship = await Ship.findOne({ ShipOwnerId: accountId }).populate<{
 | 
					    const personalRooms = await getPersonalRooms(accountId);
 | 
				
			||||||
        LoadOutInventory: { LoadOutPresets: ILoadoutDatabase };
 | 
					    const loadout = await getLoadout(accountId);
 | 
				
			||||||
    }>("LoadOutInventory.LoadOutPresets");
 | 
					    const ship = await getShip(personalRooms.activeShipId, "ShipInteriorColors ShipAttachments SkinFlavourItem");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!ship) {
 | 
					    const getShipResponse: IGetShipResponse = {
 | 
				
			||||||
        res.status(500).json({ error: "error finding a corresponding ship" });
 | 
					        ShipOwnerId: accountId,
 | 
				
			||||||
        return;
 | 
					        LoadOutInventory: { LoadOutPresets: loadout.toJSON() },
 | 
				
			||||||
 | 
					        Ship: {
 | 
				
			||||||
 | 
					            ...personalRooms.toJSON().Ship,
 | 
				
			||||||
 | 
					            ShipId: toOid(personalRooms.activeShipId),
 | 
				
			||||||
 | 
					            ShipInterior: {
 | 
				
			||||||
 | 
					                Colors: ship.ShipInteriorColors,
 | 
				
			||||||
 | 
					                ShipAttachments: ship.ShipAttachments,
 | 
				
			||||||
 | 
					                SkinFlavourItem: ship.SkinFlavourItem
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        Apartment: personalRooms.Apartment
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (config.unlockallShipFeatures) {
 | 
				
			||||||
 | 
					        getShipResponse.Ship.Features = allShipFeatures;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ship.Ship.Features = [
 | 
					    res.json(getShipResponse);
 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/AdvancedOrdisFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/AlchemyRoomFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/AlertsFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/ArsenalFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/CeresNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/ClanFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/EarthNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/EidolonArchwingFoundryUpgradeFeatureBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/EidolonArchwingFoundryUpgradeFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/ErisNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/EuropaNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/FoundryConcurrentBuildFormaFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/FoundryFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/FoundryVesselUpgradeFeatureBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/FoundryVesselUpgradeFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryCatbrowUpgradeFeatureBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryCatbrowUpgradeFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryUpgradeFeatureBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryUpgradeFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryArchonShardBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryArchonShardFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryUpgradeBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryUpgradeFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/JupiterNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/MarketTierOneFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/MarketTierTwoFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/MarsNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/MercuryNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/ModsFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/ModsFusionFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/ModsTransmuteFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/NeptuneNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/PersonalQuartersFeatureBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/PersonalQuartersFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/PhobosNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/PlutoNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackHoodBraceFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackHoodFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackHullFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackNacelleLeftFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackNacelleRightFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackTailFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHoodBraceFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHoodBraceFeatureItemBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHoodFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHoodFeatureItemBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHullFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHullFeatureItemBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackNacelleLeftFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackNacelleLeftFeatureItemBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackNacelleRightFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackNacelleRightFeatureItemBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackTailFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackTailFeatureItemBlueprint",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/RailjackCephalonShipFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/RailjackKeyShipFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/SaturnNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/SednaNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/ShipFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/SocialMenuFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/SolarChartFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/UranusNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/VenusNavigationFeatureItem",
 | 
					 | 
				
			||||||
        "/Lotus/Types/Items/ShipFeatureItems/VoidProjectionFeatureItem"
 | 
					 | 
				
			||||||
    ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    res.json(ship);
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export { getShipController };
 | 
					export const getLoadout = async (accountId: string) => {
 | 
				
			||||||
 | 
					    const loadout = await Loadout.findOne({ loadoutOwnerId: accountId });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!loadout) {
 | 
				
			||||||
 | 
					        logger.error(`loadout not found for account ${accountId}`);
 | 
				
			||||||
 | 
					        throw new Error("loadout not found");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return loadout;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const getPersonalRooms = async (accountId: string) => {
 | 
				
			||||||
 | 
					    const personalRooms = await PersonalRooms.findOne({ personalRoomsOwnerId: accountId });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!personalRooms) {
 | 
				
			||||||
 | 
					        logger.error(`personal rooms not found for account ${accountId}`);
 | 
				
			||||||
 | 
					        throw new Error("personal rooms not found");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return personalRooms;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,9 @@ import { Request, RequestHandler, Response } from "express";
 | 
				
			|||||||
import config from "@/config.json";
 | 
					import config from "@/config.json";
 | 
				
			||||||
import allMissions from "@/static/fixed_responses/allMissions.json";
 | 
					import allMissions from "@/static/fixed_responses/allMissions.json";
 | 
				
			||||||
import allQuestKeys from "@/static/fixed_responses/allQuestKeys.json";
 | 
					import allQuestKeys from "@/static/fixed_responses/allQuestKeys.json";
 | 
				
			||||||
 | 
					import allShipDecorations from "@/static/fixed_responses/shipDecorations.json";
 | 
				
			||||||
import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
 | 
					import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
 | 
				
			||||||
 | 
					import { IShipInventory } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const inventoryController: RequestHandler = async (request: Request, response: Response) => {
 | 
					const inventoryController: RequestHandler = async (request: Request, response: Response) => {
 | 
				
			||||||
    const accountId = request.query.accountId;
 | 
					    const accountId = request.query.accountId;
 | 
				
			||||||
@ -15,9 +17,11 @@ const inventoryController: RequestHandler = async (request: Request, response: R
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const inventory = await Inventory.findOne({ accountOwnerId: accountId }).populate<{
 | 
					    const inventory = await Inventory.findOne({ accountOwnerId: accountId })
 | 
				
			||||||
 | 
					        .populate<{
 | 
				
			||||||
            LoadOutPresets: ILoadoutDatabase;
 | 
					            LoadOutPresets: ILoadoutDatabase;
 | 
				
			||||||
    }>("LoadOutPresets");
 | 
					        }>("LoadOutPresets")
 | 
				
			||||||
 | 
					        .populate<{ Ships: IShipInventory }>("Ships", "-ShipInteriorColors");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!inventory) {
 | 
					    if (!inventory) {
 | 
				
			||||||
        response.status(400).json({ error: "inventory was undefined" });
 | 
					        response.status(400).json({ error: "inventory was undefined" });
 | 
				
			||||||
@ -26,12 +30,17 @@ const inventoryController: RequestHandler = async (request: Request, response: R
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    //TODO: make a function that converts from database representation to client
 | 
					    //TODO: make a function that converts from database representation to client
 | 
				
			||||||
    const inventoryJSON = inventory.toJSON();
 | 
					    const inventoryJSON = inventory.toJSON();
 | 
				
			||||||
 | 
					    console.log(inventoryJSON.Ships);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const inventoryResponse = toInventoryResponse(inventoryJSON);
 | 
					    const inventoryResponse = toInventoryResponse(inventoryJSON);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (config.unlockAllMissions) inventoryResponse.Missions = allMissions;
 | 
					    if (config.unlockAllMissions) inventoryResponse.Missions = allMissions;
 | 
				
			||||||
    if (config.unlockAllQuests) inventoryResponse.QuestKeys = allQuestKeys;
 | 
					    if (config.unlockAllQuests) inventoryResponse.QuestKeys = allQuestKeys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (config.unlockAllShipDecorations) {
 | 
				
			||||||
 | 
					        inventoryResponse.ShipDecorations = allShipDecorations;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    response.json(inventoryResponse);
 | 
					    response.json(inventoryResponse);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -51,7 +51,7 @@ const loginController: RequestHandler = async (request, response) => {
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        } catch (error: unknown) {
 | 
					        } catch (error: unknown) {
 | 
				
			||||||
            if (error instanceof Error) {
 | 
					            if (error instanceof Error) {
 | 
				
			||||||
                throw new Error("error creating account", error);
 | 
					                throw new Error(`error creating account ${error.message}`);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								src/controllers/api/setActiveShipController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/controllers/api/setActiveShipController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					import { getPersonalRooms } from "@/src/controllers/api/getShipController";
 | 
				
			||||||
 | 
					import { parseString } from "@/src/helpers/general";
 | 
				
			||||||
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					import { Types } from "mongoose";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
				
			||||||
 | 
					export const setActiveShipController: RequestHandler = async (req, res) => {
 | 
				
			||||||
 | 
					    const accountId = parseString(req.query.accountId);
 | 
				
			||||||
 | 
					    const shipId = parseString(req.query.shipId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const personalRooms = await getPersonalRooms(accountId);
 | 
				
			||||||
 | 
					    personalRooms.activeShipId = new Types.ObjectId(shipId);
 | 
				
			||||||
 | 
					    await personalRooms.save();
 | 
				
			||||||
 | 
					    res.status(200).end();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										19
									
								
								src/controllers/api/setShipCustomizationsController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/controllers/api/setShipCustomizationsController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					import { setShipCustomizations } from "@/src/services/shipCustomizationsService";
 | 
				
			||||||
 | 
					import { ISetShipCustomizationsRequest } from "@/src/types/shipTypes";
 | 
				
			||||||
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
				
			||||||
 | 
					export const setShipCustomizationsController: RequestHandler = async (req, res) => {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        const setShipCustomizationsRequest = JSON.parse(req.body as string) as ISetShipCustomizationsRequest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const setShipCustomizationsResponse = await setShipCustomizations(setShipCustomizationsRequest);
 | 
				
			||||||
 | 
					        res.json(setShipCustomizationsResponse);
 | 
				
			||||||
 | 
					    } catch (error: unknown) {
 | 
				
			||||||
 | 
					        if (error instanceof Error) {
 | 
				
			||||||
 | 
					            logger.error(`error in setShipCustomizationsController: ${error.message}`);
 | 
				
			||||||
 | 
					            res.status(400).json({ error: error.message });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										21
									
								
								src/controllers/api/shipDecorationsController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/controllers/api/shipDecorationsController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					import { parseString } from "@/src/helpers/general";
 | 
				
			||||||
 | 
					import { IShipDecorationsRequest } from "@/src/types/shipTypes";
 | 
				
			||||||
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					import { handleSetShipDecorations } from "@/src/services/shipCustomizationsService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
				
			||||||
 | 
					export const shipDecorationsController: RequestHandler = async (req, res) => {
 | 
				
			||||||
 | 
					    const accountId = parseString(req.query.accountId);
 | 
				
			||||||
 | 
					    const shipDecorationsRequest = JSON.parse(req.body as string) as IShipDecorationsRequest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        const placedDecoration = await handleSetShipDecorations(accountId, shipDecorationsRequest);
 | 
				
			||||||
 | 
					        res.send(placedDecoration);
 | 
				
			||||||
 | 
					    } catch (error: unknown) {
 | 
				
			||||||
 | 
					        if (error instanceof Error) {
 | 
				
			||||||
 | 
					            logger.error(`error in saveLoadoutController: ${error.message}`);
 | 
				
			||||||
 | 
					            res.status(400).json({ error: error.message });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -6,7 +6,6 @@ import {
 | 
				
			|||||||
    IInventoryDatabase,
 | 
					    IInventoryDatabase,
 | 
				
			||||||
    IBooster,
 | 
					    IBooster,
 | 
				
			||||||
    IInventoryResponse,
 | 
					    IInventoryResponse,
 | 
				
			||||||
    IInventoryDatabaseDocument,
 | 
					 | 
				
			||||||
    ISlots,
 | 
					    ISlots,
 | 
				
			||||||
    IGenericItem,
 | 
					    IGenericItem,
 | 
				
			||||||
    IMailbox,
 | 
					    IMailbox,
 | 
				
			||||||
@ -21,9 +20,7 @@ import {
 | 
				
			|||||||
    IChallengeProgress,
 | 
					    IChallengeProgress,
 | 
				
			||||||
    IStepSequencer,
 | 
					    IStepSequencer,
 | 
				
			||||||
    IAffiliation,
 | 
					    IAffiliation,
 | 
				
			||||||
    IShip,
 | 
					 | 
				
			||||||
    INotePacks,
 | 
					    INotePacks,
 | 
				
			||||||
    IShipExterior,
 | 
					 | 
				
			||||||
    ICompletedJobChain,
 | 
					    ICompletedJobChain,
 | 
				
			||||||
    ISeasonChallengeHistory,
 | 
					    ISeasonChallengeHistory,
 | 
				
			||||||
    IPlayerSkills,
 | 
					    IPlayerSkills,
 | 
				
			||||||
@ -108,7 +105,7 @@ const abilityOverrideSchema = new Schema<IAbilityOverride>({
 | 
				
			|||||||
    Ability: String,
 | 
					    Ability: String,
 | 
				
			||||||
    Index: Number
 | 
					    Index: Number
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
const colorSchema = new Schema<IColor>(
 | 
					export const colorSchema = new Schema<IColor>(
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        t0: Number,
 | 
					        t0: Number,
 | 
				
			||||||
        t1: Number,
 | 
					        t1: Number,
 | 
				
			||||||
@ -457,33 +454,6 @@ const affiliationsSchema = new Schema<IAffiliation>(
 | 
				
			|||||||
    { _id: false }
 | 
					    { _id: false }
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const shipExteriorSchema = new Schema<IShipExterior>(
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        SkinFlavourItem: String,
 | 
					 | 
				
			||||||
        Colors: colorSchema, //TODO: perhaps too many colors here
 | 
					 | 
				
			||||||
        ShipAttachments: { HOOD_ORNAMENT: String }
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    { _id: false }
 | 
					 | 
				
			||||||
);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const shipSchema = new Schema<IShip>({
 | 
					 | 
				
			||||||
    ItemType: String,
 | 
					 | 
				
			||||||
    ShipExterior: shipExteriorSchema,
 | 
					 | 
				
			||||||
    AirSupportPower: String
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
shipSchema.virtual("ItemId").get(function () {
 | 
					 | 
				
			||||||
    return { $oid: this._id.toString() };
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
shipSchema.set("toJSON", {
 | 
					 | 
				
			||||||
    virtuals: true,
 | 
					 | 
				
			||||||
    transform(_document, returnedObject) {
 | 
					 | 
				
			||||||
        delete returnedObject._id;
 | 
					 | 
				
			||||||
        delete returnedObject.__v;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const completedJobChainsSchema = new Schema<ICompletedJobChain>(
 | 
					const completedJobChainsSchema = new Schema<ICompletedJobChain>(
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        LocationTag: String,
 | 
					        LocationTag: String,
 | 
				
			||||||
@ -773,7 +743,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
				
			|||||||
        Horses: [GenericItemSchema],
 | 
					        Horses: [GenericItemSchema],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //LandingCraft like Liset
 | 
					        //LandingCraft like Liset
 | 
				
			||||||
        Ships: [shipSchema],
 | 
					        Ships: { type: [Schema.Types.ObjectId], ref: "Ships" },
 | 
				
			||||||
        // /Lotus/Types/Items/ShipDecos/
 | 
					        // /Lotus/Types/Items/ShipDecos/
 | 
				
			||||||
        ShipDecorations: [typeCountSchema],
 | 
					        ShipDecorations: [typeCountSchema],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -93,4 +93,4 @@ type loadoutDocumentProps = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type loadoutModelType = Model<ILoadoutDatabase, {}, loadoutDocumentProps>;
 | 
					type loadoutModelType = Model<ILoadoutDatabase, {}, loadoutDocumentProps>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const LoadoutModel = model<ILoadoutDatabase, loadoutModelType>("Loadout", loadoutSchema);
 | 
					export const Loadout = model<ILoadoutDatabase, loadoutModelType>("Loadout", loadoutSchema);
 | 
				
			||||||
 | 
				
			|||||||
@ -46,14 +46,4 @@ databaseAccountSchema.set("toJSON", {
 | 
				
			|||||||
    virtuals: true
 | 
					    virtuals: true
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//databaseAccountSchema.set("");
 | 
					export const Account = model<IDatabaseAccountDocument>("Account", databaseAccountSchema);
 | 
				
			||||||
 | 
					 | 
				
			||||||
// Create a virtual property `domain` that's computed from `email`.
 | 
					 | 
				
			||||||
// databaseAccountSchema.virtual("id").get(function () {
 | 
					 | 
				
			||||||
//   //console.log(this);
 | 
					 | 
				
			||||||
//   return this._id;
 | 
					 | 
				
			||||||
// });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const Account = model<IDatabaseAccountDocument>("Account", databaseAccountSchema);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export { Account };
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										60
									
								
								src/models/personalRoomsModel.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								src/models/personalRoomsModel.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
				
			||||||
 | 
					import { IOrbiter, IPersonalRooms, PersonalRoomsModelType } from "@/src/types/personalRoomsTypes";
 | 
				
			||||||
 | 
					import { IApartment, IGardening, IPlacedDecosDatabase } from "@/src/types/shipTypes";
 | 
				
			||||||
 | 
					import { Schema, model } from "mongoose";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const placedDecosSchema = new Schema<IPlacedDecosDatabase>(
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Type: String,
 | 
				
			||||||
 | 
					        Pos: [Number],
 | 
				
			||||||
 | 
					        Rot: [Number]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    { id: false }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					placedDecosSchema.virtual("id").get(function (this: IPlacedDecosDatabase) {
 | 
				
			||||||
 | 
					    return toOid(this._id);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					placedDecosSchema.set("toJSON", {
 | 
				
			||||||
 | 
					    virtuals: true,
 | 
				
			||||||
 | 
					    transform(_document, returnedObject) {
 | 
				
			||||||
 | 
					        delete returnedObject._id;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const roomSchema = new Schema(
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Name: String,
 | 
				
			||||||
 | 
					        MaxCapacity: Number,
 | 
				
			||||||
 | 
					        PlacedDecos: [placedDecosSchema]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    { _id: false }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const gardeningSchema = new Schema<IGardening>({
 | 
				
			||||||
 | 
					    Planters: [Schema.Types.Mixed] //TODO: add when implementing gardening
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const apartmentSchema = new Schema<IApartment>(
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Rooms: [roomSchema],
 | 
				
			||||||
 | 
					        FavouriteLoadouts: [Schema.Types.Mixed],
 | 
				
			||||||
 | 
					        Gardening: gardeningSchema
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    { _id: false }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const orbiterSchema = new Schema<IOrbiter>(
 | 
				
			||||||
 | 
					    { Features: [String], Rooms: [roomSchema], ContentUrlSignature: String },
 | 
				
			||||||
 | 
					    { _id: false }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const personalRoomsSchema = new Schema<IPersonalRooms>({
 | 
				
			||||||
 | 
					    personalRoomsOwnerId: Schema.Types.ObjectId,
 | 
				
			||||||
 | 
					    activeShipId: Schema.Types.ObjectId,
 | 
				
			||||||
 | 
					    Ship: orbiterSchema,
 | 
				
			||||||
 | 
					    Apartment: apartmentSchema
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const PersonalRooms = model<IPersonalRooms, PersonalRoomsModelType>("PersonalRooms", personalRoomsSchema);
 | 
				
			||||||
@ -1,66 +1,50 @@
 | 
				
			|||||||
import { Schema, model } from "mongoose";
 | 
					import { Model, Schema, StringSchemaDefinition, Types, model } from "mongoose";
 | 
				
			||||||
import { IShip } from "../types/shipTypes";
 | 
					import { IApartment, IPlacedDecosDatabase, IRooms, IShipDatabase } from "../types/shipTypes";
 | 
				
			||||||
import { IOid } from "../types/commonTypes";
 | 
					import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
				
			||||||
import { loadoutSchema } from "@/src/models/inventoryModels/loadoutModel";
 | 
					import { colorSchema } from "@/src/models/inventoryModels/inventoryModel";
 | 
				
			||||||
 | 
					import { IShipInventory } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const roomSchema = new Schema(
 | 
					const shipSchema = new Schema<IShipDatabase>(
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Name: String,
 | 
					        ItemType: String,
 | 
				
			||||||
        MaxCapacity: Number
 | 
					        ShipOwnerId: Schema.Types.ObjectId,
 | 
				
			||||||
    },
 | 
					        ShipInteriorColors: colorSchema,
 | 
				
			||||||
    { _id: false }
 | 
					        ShipExteriorColors: colorSchema,
 | 
				
			||||||
);
 | 
					        AirSupportPower: String,
 | 
				
			||||||
 | 
					        ShipAttachments: { HOOD_ORNAMENT: String },
 | 
				
			||||||
const shipSchema = new Schema(
 | 
					        SkinFlavourItem: String
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        Rooms: [roomSchema],
 | 
					 | 
				
			||||||
        Features: [String],
 | 
					 | 
				
			||||||
        ContentUrlSignature: String
 | 
					 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    { id: false }
 | 
					    { id: false }
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
shipSchema.virtual("ShipId").get(function () {
 | 
					shipSchema.virtual("ItemId").get(function () {
 | 
				
			||||||
    return { $oid: this._id.toString() } satisfies IOid;
 | 
					    return toOid(this._id);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
shipSchema.set("toJSON", {
 | 
					shipSchema.set("toJSON", {
 | 
				
			||||||
    virtuals: true,
 | 
					    virtuals: true,
 | 
				
			||||||
    transform(_document, returnedObject) {
 | 
					    transform(_document, returnedObject) {
 | 
				
			||||||
        delete returnedObject._id;
 | 
					        const shipResponse = returnedObject as IShipInventory;
 | 
				
			||||||
    }
 | 
					        const shipDatabase = returnedObject as IShipDatabase;
 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const apartmentSchema = new Schema({
 | 
					 | 
				
			||||||
    Rooms: [roomSchema],
 | 
					 | 
				
			||||||
    FavouriteLoadouts: [Schema.Types.Mixed]
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
apartmentSchema.set("toJSON", {
 | 
					 | 
				
			||||||
    transform(_document, returnedObject) {
 | 
					 | 
				
			||||||
        delete returnedObject._id;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const shipDatabaseSchema = new Schema<IShip>({
 | 
					 | 
				
			||||||
    ShipOwnerId: Schema.Types.ObjectId,
 | 
					 | 
				
			||||||
    Ship: shipSchema,
 | 
					 | 
				
			||||||
    Apartment: apartmentSchema,
 | 
					 | 
				
			||||||
    LoadOutInventory: {
 | 
					 | 
				
			||||||
        LoadOutPresets: {
 | 
					 | 
				
			||||||
            type: Schema.Types.ObjectId,
 | 
					 | 
				
			||||||
            ref: "Loadout"
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
shipDatabaseSchema.set("toJSON", {
 | 
					 | 
				
			||||||
    transform(_document, returnedObject) {
 | 
					 | 
				
			||||||
        delete returnedObject._id;
 | 
					        delete returnedObject._id;
 | 
				
			||||||
        delete returnedObject.__v;
 | 
					        delete returnedObject.__v;
 | 
				
			||||||
 | 
					        delete returnedObject.ShipOwnerId;
 | 
				
			||||||
 | 
					        if (shipDatabase.ShipExteriorColors) {
 | 
				
			||||||
 | 
					            shipResponse.ShipExterior = {
 | 
				
			||||||
 | 
					                Colors: shipDatabase.ShipExteriorColors,
 | 
				
			||||||
 | 
					                ShipAttachments: shipDatabase.ShipAttachments,
 | 
				
			||||||
 | 
					                SkinFlavourItem: shipDatabase.SkinFlavourItem
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            delete shipDatabase.ShipExteriorColors;
 | 
				
			||||||
 | 
					            delete shipDatabase.ShipAttachments;
 | 
				
			||||||
 | 
					            delete shipDatabase.SkinFlavourItem;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const Ship = model<IShip>("Ship", shipDatabaseSchema);
 | 
					shipSchema.set("toObject", {
 | 
				
			||||||
 | 
					    virtuals: true
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export { Ship };
 | 
					export const Ship = model("Ships", shipSchema);
 | 
				
			||||||
 | 
				
			|||||||
@ -37,6 +37,9 @@ import { focusController } from "@/src/controllers/api/focusController";
 | 
				
			|||||||
import { inventorySlotsController } from "@/src/controllers/api/inventorySlotsController";
 | 
					import { inventorySlotsController } from "@/src/controllers/api/inventorySlotsController";
 | 
				
			||||||
import { startRecipeController } from "@/src/controllers/api/startRecipeController";
 | 
					import { startRecipeController } from "@/src/controllers/api/startRecipeController";
 | 
				
			||||||
import { claimCompletedRecipeController } from "@/src/controllers/api/claimCompletedRecipeController";
 | 
					import { claimCompletedRecipeController } from "@/src/controllers/api/claimCompletedRecipeController";
 | 
				
			||||||
 | 
					import { shipDecorationsController } from "@/src/controllers/api/shipDecorationsController";
 | 
				
			||||||
 | 
					import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController";
 | 
				
			||||||
 | 
					import { setActiveShipController } from "@/src/controllers/api/setActiveShipController";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const apiRouter = express.Router();
 | 
					const apiRouter = express.Router();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -62,9 +65,12 @@ apiRouter.get("/modularWeaponSale.php", modularWeaponSaleController);
 | 
				
			|||||||
apiRouter.get("/deleteSession.php", deleteSessionController);
 | 
					apiRouter.get("/deleteSession.php", deleteSessionController);
 | 
				
			||||||
apiRouter.get("/logout.php", logoutController);
 | 
					apiRouter.get("/logout.php", logoutController);
 | 
				
			||||||
apiRouter.get("/setBootLocation.php", setBootLocationController);
 | 
					apiRouter.get("/setBootLocation.php", setBootLocationController);
 | 
				
			||||||
 | 
					apiRouter.get("/setActiveShip.php", setActiveShipController);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// post
 | 
					// post
 | 
				
			||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
					// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
				
			||||||
 | 
					apiRouter.post("/shipDecorations.php", shipDecorationsController);
 | 
				
			||||||
 | 
					apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
 | 
				
			||||||
apiRouter.post("/claimCompletedRecipe.php", claimCompletedRecipeController);
 | 
					apiRouter.post("/claimCompletedRecipe.php", claimCompletedRecipeController);
 | 
				
			||||||
apiRouter.post("/startRecipe.php", startRecipeController);
 | 
					apiRouter.post("/startRecipe.php", startRecipeController);
 | 
				
			||||||
apiRouter.post("/inventorySlots.php", inventorySlotsController);
 | 
					apiRouter.post("/inventorySlots.php", inventorySlotsController);
 | 
				
			||||||
 | 
				
			|||||||
@ -19,12 +19,16 @@ import { IArtifactsRequest, IMissionInventoryUpdateRequest } from "../types/requ
 | 
				
			|||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
import { WeaponTypeInternal } from "@/src/services/itemDataService";
 | 
					import { WeaponTypeInternal } from "@/src/services/itemDataService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const createInventory = async (accountOwnerId: Types.ObjectId, loadOutPresetId: Types.ObjectId) => {
 | 
					export const createInventory = async (
 | 
				
			||||||
 | 
					    accountOwnerId: Types.ObjectId,
 | 
				
			||||||
 | 
					    defaultItemReferences: { loadOutPresetId: Types.ObjectId; ship: Types.ObjectId }
 | 
				
			||||||
 | 
					) => {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        const inventory = new Inventory({
 | 
					        const inventory = new Inventory({
 | 
				
			||||||
            ...new_inventory,
 | 
					            ...new_inventory,
 | 
				
			||||||
            accountOwnerId: accountOwnerId,
 | 
					            accountOwnerId: accountOwnerId,
 | 
				
			||||||
            LoadOutPresets: loadOutPresetId
 | 
					            LoadOutPresets: defaultItemReferences.loadOutPresetId,
 | 
				
			||||||
 | 
					            Ships: [defaultItemReferences.ship]
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        if (config.skipStoryModeChoice) {
 | 
					        if (config.skipStoryModeChoice) {
 | 
				
			||||||
            inventory.StoryModeChoice = "WARFRAME";
 | 
					            inventory.StoryModeChoice = "WARFRAME";
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								src/services/loadoutService.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/services/loadoutService.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
 | 
				
			||||||
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const getLoadout = async (accountId: string) => {
 | 
				
			||||||
 | 
					    const loadout = await Loadout.findOne({ loadoutOwnerId: accountId });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!loadout) {
 | 
				
			||||||
 | 
					        logger.error(`loadout not found for account ${accountId}`);
 | 
				
			||||||
 | 
					        throw new Error("loadout not found");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return loadout;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -3,7 +3,9 @@ import { createInventory } from "@/src/services/inventoryService";
 | 
				
			|||||||
import { IDatabaseAccount } from "@/src/types/loginTypes";
 | 
					import { IDatabaseAccount } from "@/src/types/loginTypes";
 | 
				
			||||||
import { createShip } from "./shipService";
 | 
					import { createShip } from "./shipService";
 | 
				
			||||||
import { Types } from "mongoose";
 | 
					import { Types } from "mongoose";
 | 
				
			||||||
import { LoadoutModel } from "@/src/models/inventoryModels/loadoutModel";
 | 
					import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
 | 
				
			||||||
 | 
					import { PersonalRooms } from "@/src/models/personalRoomsModel";
 | 
				
			||||||
 | 
					import new_personal_rooms from "@/static/fixed_responses/personalRooms.json";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const isCorrectPassword = (requestPassword: string, databasePassword: string): boolean => {
 | 
					const isCorrectPassword = (requestPassword: string, databasePassword: string): boolean => {
 | 
				
			||||||
    return requestPassword === databasePassword;
 | 
					    return requestPassword === databasePassword;
 | 
				
			||||||
@ -14,8 +16,9 @@ const createAccount = async (accountData: IDatabaseAccount) => {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
        await account.save();
 | 
					        await account.save();
 | 
				
			||||||
        const loadoutId = await createLoadout(account._id);
 | 
					        const loadoutId = await createLoadout(account._id);
 | 
				
			||||||
        await createInventory(account._id, loadoutId);
 | 
					        const shipId = await createShip(account._id);
 | 
				
			||||||
        await createShip(account._id, loadoutId);
 | 
					        await createInventory(account._id, { loadOutPresetId: loadoutId, ship: shipId });
 | 
				
			||||||
 | 
					        await createPersonalRooms(account._id, shipId);
 | 
				
			||||||
        return account.toJSON();
 | 
					        return account.toJSON();
 | 
				
			||||||
    } catch (error) {
 | 
					    } catch (error) {
 | 
				
			||||||
        if (error instanceof Error) {
 | 
					        if (error instanceof Error) {
 | 
				
			||||||
@ -28,7 +31,16 @@ const createAccount = async (accountData: IDatabaseAccount) => {
 | 
				
			|||||||
export { isCorrectPassword, createAccount };
 | 
					export { isCorrectPassword, createAccount };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const createLoadout = async (accountId: Types.ObjectId) => {
 | 
					export const createLoadout = async (accountId: Types.ObjectId) => {
 | 
				
			||||||
    const loadout = new LoadoutModel({ loadoutOwnerId: accountId });
 | 
					    const loadout = new Loadout({ loadoutOwnerId: accountId });
 | 
				
			||||||
    const savedLoadout = await loadout.save();
 | 
					    const savedLoadout = await loadout.save();
 | 
				
			||||||
    return savedLoadout._id;
 | 
					    return savedLoadout._id;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const createPersonalRooms = async (accountId: Types.ObjectId, shipId: Types.ObjectId) => {
 | 
				
			||||||
 | 
					    const personalRooms = new PersonalRooms({
 | 
				
			||||||
 | 
					        ...new_personal_rooms,
 | 
				
			||||||
 | 
					        personalRoomsOwnerId: accountId,
 | 
				
			||||||
 | 
					        activeShipId: shipId
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    await personalRooms.save();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								src/services/personalRoomsService.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/services/personalRoomsService.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					import { PersonalRooms } from "@/src/models/personalRoomsModel";
 | 
				
			||||||
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const getPersonalRooms = async (accountId: string) => {
 | 
				
			||||||
 | 
					    const personalRooms = await PersonalRooms.findOne({ personalRoomsOwnerId: accountId });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!personalRooms) {
 | 
				
			||||||
 | 
					        logger.error(`personal rooms not found for account ${accountId}`);
 | 
				
			||||||
 | 
					        throw new Error("personal rooms not found");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return personalRooms;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -5,7 +5,7 @@ import {
 | 
				
			|||||||
    IOperatorConfigEntry,
 | 
					    IOperatorConfigEntry,
 | 
				
			||||||
    ISaveLoadoutRequestNoUpgradeVer
 | 
					    ISaveLoadoutRequestNoUpgradeVer
 | 
				
			||||||
} from "@/src/types/saveLoadoutTypes";
 | 
					} from "@/src/types/saveLoadoutTypes";
 | 
				
			||||||
import { LoadoutModel } from "@/src/models/inventoryModels/loadoutModel";
 | 
					import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
 | 
				
			||||||
import { getInventory } from "@/src/services/inventoryService";
 | 
					import { getInventory } from "@/src/services/inventoryService";
 | 
				
			||||||
import { IOid } from "@/src/types/commonTypes";
 | 
					import { IOid } from "@/src/types/commonTypes";
 | 
				
			||||||
import { Types } from "mongoose";
 | 
					import { Types } from "mongoose";
 | 
				
			||||||
@ -60,7 +60,7 @@ export const handleInventoryItemConfigChange = async (
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            case "LoadOuts": {
 | 
					            case "LoadOuts": {
 | 
				
			||||||
                logger.debug("loadout received");
 | 
					                logger.debug("loadout received");
 | 
				
			||||||
                const loadout = await LoadoutModel.findOne({ loadoutOwnerId: accountId });
 | 
					                const loadout = await Loadout.findOne({ loadoutOwnerId: accountId });
 | 
				
			||||||
                if (!loadout) {
 | 
					                if (!loadout) {
 | 
				
			||||||
                    throw new Error("loadout not found");
 | 
					                    throw new Error("loadout not found");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										68
									
								
								src/services/shipCustomizationsService.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								src/services/shipCustomizationsService.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					import { getPersonalRooms } from "@/src/services/personalRoomsService";
 | 
				
			||||||
 | 
					import { getShip } from "@/src/services/shipService";
 | 
				
			||||||
 | 
					import {
 | 
				
			||||||
 | 
					    ISetShipCustomizationsRequest,
 | 
				
			||||||
 | 
					    IShipDatabase,
 | 
				
			||||||
 | 
					    IShipDecorationsRequest,
 | 
				
			||||||
 | 
					    IShipDecorationsResponse
 | 
				
			||||||
 | 
					} from "@/src/types/shipTypes";
 | 
				
			||||||
 | 
					import { Types } from "mongoose";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const setShipCustomizations = async (shipCustomization: ISetShipCustomizationsRequest) => {
 | 
				
			||||||
 | 
					    const ship = await getShip(new Types.ObjectId(shipCustomization.ShipId));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let shipChanges: Partial<IShipDatabase>;
 | 
				
			||||||
 | 
					    if (shipCustomization.IsExterior) {
 | 
				
			||||||
 | 
					        shipChanges = {
 | 
				
			||||||
 | 
					            ShipExteriorColors: shipCustomization.Customization.Colors,
 | 
				
			||||||
 | 
					            SkinFlavourItem: shipCustomization.Customization.SkinFlavourItem,
 | 
				
			||||||
 | 
					            ShipAttachments: shipCustomization.Customization.ShipAttachments,
 | 
				
			||||||
 | 
					            AirSupportPower: shipCustomization.AirSupportPower!
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        shipChanges = {
 | 
				
			||||||
 | 
					            ShipInteriorColors: shipCustomization.Customization.Colors
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    ship.set(shipChanges);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    await ship.save();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const handleSetShipDecorations = async (
 | 
				
			||||||
 | 
					    accountId: string,
 | 
				
			||||||
 | 
					    placedDecoration: IShipDecorationsRequest
 | 
				
			||||||
 | 
					): Promise<IShipDecorationsResponse> => {
 | 
				
			||||||
 | 
					    const personalRooms = await getPersonalRooms(accountId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const rooms = placedDecoration.IsApartment ? personalRooms.Apartment.Rooms : personalRooms.Ship.Rooms;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const room = rooms.find(room => room.Name === placedDecoration.Room);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //TODO: check whether to remove from shipitems
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (placedDecoration.RemoveId) {
 | 
				
			||||||
 | 
					        room?.PlacedDecos?.pull({ _id: placedDecoration.RemoveId });
 | 
				
			||||||
 | 
					        await personalRooms.save();
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            DecoId: placedDecoration.RemoveId,
 | 
				
			||||||
 | 
					            Room: placedDecoration.Room,
 | 
				
			||||||
 | 
					            IsApartment: placedDecoration.IsApartment,
 | 
				
			||||||
 | 
					            MaxCapacityIncrease: 0
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // TODO: handle capacity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const decoId = new Types.ObjectId();
 | 
				
			||||||
 | 
					    room?.PlacedDecos?.push({
 | 
				
			||||||
 | 
					        Type: placedDecoration.Type,
 | 
				
			||||||
 | 
					        Pos: placedDecoration.Pos,
 | 
				
			||||||
 | 
					        Rot: placedDecoration.Rot,
 | 
				
			||||||
 | 
					        _id: decoId
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    await personalRooms.save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return { DecoId: decoId.toString(), Room: placedDecoration.Room, IsApartment: placedDecoration.IsApartment };
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -1,15 +1,16 @@
 | 
				
			|||||||
import { Ship } from "@/src/models/shipModel";
 | 
					import { Ship } from "@/src/models/shipModel";
 | 
				
			||||||
import new_ship from "@/static/fixed_responses/ship.json";
 | 
					import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
 | 
				
			||||||
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
import { Types } from "mongoose";
 | 
					import { Types } from "mongoose";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const createShip = async (accountOwnerId: Types.ObjectId, loadoutId: Types.ObjectId) => {
 | 
					export const createShip = async (accountOwnerId: Types.ObjectId) => {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        const ship = new Ship({
 | 
					        const ship = new Ship({
 | 
				
			||||||
            ...new_ship,
 | 
					            ItemType: "/Lotus/Types/Items/Ships/DefaultShip",
 | 
				
			||||||
            ShipOwnerId: accountOwnerId,
 | 
					            ShipOwnerId: accountOwnerId
 | 
				
			||||||
            LoadOutInventory: { LoadOutPresets: loadoutId }
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        await ship.save();
 | 
					        const newShip = await ship.save();
 | 
				
			||||||
 | 
					        return newShip._id;
 | 
				
			||||||
    } catch (error) {
 | 
					    } catch (error) {
 | 
				
			||||||
        if (error instanceof Error) {
 | 
					        if (error instanceof Error) {
 | 
				
			||||||
            throw new Error(`error creating ship" ${error.message}`);
 | 
					            throw new Error(`error creating ship" ${error.message}`);
 | 
				
			||||||
@ -18,4 +19,26 @@ const createShip = async (accountOwnerId: Types.ObjectId, loadoutId: Types.Objec
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export { createShip };
 | 
					export const getShip = async (shipId: Types.ObjectId, fieldSelection: string = "") => {
 | 
				
			||||||
 | 
					    const ship = await Ship.findOne({ _id: shipId }, fieldSelection);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!ship) {
 | 
				
			||||||
 | 
					        logger.error(`error finding a ship for account ${shipId}`);
 | 
				
			||||||
 | 
					        throw new Error(`error finding a ship for account ${shipId}`);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return ship;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const getShipLean = async (shipOwnerId: string) => {
 | 
				
			||||||
 | 
					    const ship = await Ship.findOne({ ShipOwnerId: shipOwnerId }).lean().populate<{
 | 
				
			||||||
 | 
					        LoadOutInventory: { LoadOutPresets: ILoadoutDatabase };
 | 
				
			||||||
 | 
					    }>("LoadOutInventory.LoadOutPresets");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!ship) {
 | 
				
			||||||
 | 
					        logger.error(`error finding a ship for account ${shipOwnerId}`);
 | 
				
			||||||
 | 
					        throw new Error(`error finding a ship for account ${shipOwnerId}`);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return ship;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -11,13 +11,21 @@ import {
 | 
				
			|||||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
					} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
import { ISuitDatabase } from "@/src/types/inventoryTypes/SuitTypes";
 | 
					import { ISuitDatabase } from "@/src/types/inventoryTypes/SuitTypes";
 | 
				
			||||||
import { IOperatorLoadOutSigcol, IWeaponDatabase } from "@/src/types/inventoryTypes/weaponTypes";
 | 
					import { IOperatorLoadOutSigcol, IWeaponDatabase } from "@/src/types/inventoryTypes/weaponTypes";
 | 
				
			||||||
 | 
					import { Colour } from "warframe-items";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//Document extends will be deleted soon. TODO: delete and migrate uses to ...
 | 
					//Document extends will be deleted soon. TODO: delete and migrate uses to ...
 | 
				
			||||||
export interface IInventoryDatabaseDocument extends IInventoryDatabase, Document {}
 | 
					export interface IInventoryDatabaseDocument extends IInventoryDatabase, Document {}
 | 
				
			||||||
export interface IInventoryDatabase
 | 
					export interface IInventoryDatabase
 | 
				
			||||||
    extends Omit<
 | 
					    extends Omit<
 | 
				
			||||||
        IInventoryResponse,
 | 
					        IInventoryResponse,
 | 
				
			||||||
        "TrainingDate" | "LoadOutPresets" | "Mailbox" | "PendingRecipes" | "Created" | "QuestKeys" | "BlessingCooldown"
 | 
					        | "TrainingDate"
 | 
				
			||||||
 | 
					        | "LoadOutPresets"
 | 
				
			||||||
 | 
					        | "Mailbox"
 | 
				
			||||||
 | 
					        | "PendingRecipes"
 | 
				
			||||||
 | 
					        | "Created"
 | 
				
			||||||
 | 
					        | "QuestKeys"
 | 
				
			||||||
 | 
					        | "BlessingCooldown"
 | 
				
			||||||
 | 
					        | "Ships"
 | 
				
			||||||
    > {
 | 
					    > {
 | 
				
			||||||
    accountOwnerId: Types.ObjectId;
 | 
					    accountOwnerId: Types.ObjectId;
 | 
				
			||||||
    Created: Date;
 | 
					    Created: Date;
 | 
				
			||||||
@ -27,6 +35,7 @@ export interface IInventoryDatabase
 | 
				
			|||||||
    PendingRecipes: IPendingRecipe[];
 | 
					    PendingRecipes: IPendingRecipe[];
 | 
				
			||||||
    QuestKeys: IQuestKeyDatabase[];
 | 
					    QuestKeys: IQuestKeyDatabase[];
 | 
				
			||||||
    BlessingCooldown: Date;
 | 
					    BlessingCooldown: Date;
 | 
				
			||||||
 | 
					    Ships: Types.ObjectId[];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IInventoryResponseDocument extends IInventoryResponse, Document {}
 | 
					export interface IInventoryResponseDocument extends IInventoryResponse, Document {}
 | 
				
			||||||
@ -140,7 +149,7 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    LongGuns: IWeaponDatabase[];
 | 
					    LongGuns: IWeaponDatabase[];
 | 
				
			||||||
    Pistols: IWeaponDatabase[];
 | 
					    Pistols: IWeaponDatabase[];
 | 
				
			||||||
    Melee: IWeaponDatabase[];
 | 
					    Melee: IWeaponDatabase[];
 | 
				
			||||||
    Ships: IShip[];
 | 
					    Ships: IShipInventory[];
 | 
				
			||||||
    QuestKeys: IQuestKeyResponse[];
 | 
					    QuestKeys: IQuestKeyResponse[];
 | 
				
			||||||
    FlavourItems: IFlavourItem[];
 | 
					    FlavourItems: IFlavourItem[];
 | 
				
			||||||
    Scoops: IGenericItem[];
 | 
					    Scoops: IGenericItem[];
 | 
				
			||||||
@ -449,8 +458,8 @@ export interface ICustomization {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IShipExterior {
 | 
					export interface IShipExterior {
 | 
				
			||||||
    SkinFlavourItem: string;
 | 
					    SkinFlavourItem?: string;
 | 
				
			||||||
    Colors: IShipExteriorColors;
 | 
					    Colors: IColor;
 | 
				
			||||||
    ShipAttachments?: IShipAttachments;
 | 
					    ShipAttachments?: IShipAttachments;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1016,7 +1025,7 @@ export interface ISettings {
 | 
				
			|||||||
    TradingRulesConfirmed: boolean;
 | 
					    TradingRulesConfirmed: boolean;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IShip {
 | 
					export interface IShipInventory {
 | 
				
			||||||
    ItemType: string;
 | 
					    ItemType: string;
 | 
				
			||||||
    ShipExterior: IShipExterior;
 | 
					    ShipExterior: IShipExterior;
 | 
				
			||||||
    AirSupportPower: string;
 | 
					    AirSupportPower: string;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										28
									
								
								src/types/personalRoomsTypes.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/types/personalRoomsTypes.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					import { IApartment, IRooms } from "@/src/types/shipTypes";
 | 
				
			||||||
 | 
					import { Model, Types } from "mongoose";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IOrbiter {
 | 
				
			||||||
 | 
					    Features: string[];
 | 
				
			||||||
 | 
					    Rooms: IRooms[];
 | 
				
			||||||
 | 
					    ContentUrlSignature: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IPersonalRooms {
 | 
				
			||||||
 | 
					    personalRoomsOwnerId: Types.ObjectId;
 | 
				
			||||||
 | 
					    activeShipId: Types.ObjectId;
 | 
				
			||||||
 | 
					    Ship: IOrbiter;
 | 
				
			||||||
 | 
					    Apartment: IApartment;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export type RoomsType = { Name: string; MaxCapacity: number; PlacedDecos: Types.DocumentArray<IPlacedDecosDatabase> };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export type PersonalRoomsDocumentProps = {
 | 
				
			||||||
 | 
					    Ship: Omit<IOrbiter, "Rooms"> & {
 | 
				
			||||||
 | 
					        Rooms: RoomsType[];
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    Apartment: Omit<IApartment, "Rooms"> & {
 | 
				
			||||||
 | 
					        Rooms: RoomsType[];
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export type PersonalRoomsModelType = Model<IPersonalRooms, {}, PersonalRoomsDocumentProps>;
 | 
				
			||||||
@ -1,30 +1,108 @@
 | 
				
			|||||||
import { Types } from "mongoose";
 | 
					import { Schema, Types } from "mongoose";
 | 
				
			||||||
import { IOid } from "@/src/types/commonTypes";
 | 
					import { IOid } from "@/src/types/commonTypes";
 | 
				
			||||||
 | 
					import { IColor } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IShip {
 | 
					export interface IGetShipResponse {
 | 
				
			||||||
    ShipOwnerId: Types.ObjectId;
 | 
					    ShipOwnerId: string;
 | 
				
			||||||
    Ship: IShipResponse;
 | 
					    Ship: IShip;
 | 
				
			||||||
    Apartment: IApartment;
 | 
					    Apartment: IApartment;
 | 
				
			||||||
    LoadOutInventory: { LoadOutPresets: Types.ObjectId };
 | 
					    LoadOutInventory: { LoadOutPresets: Types.ObjectId };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IShipResponse extends IShipDatabase {
 | 
					export interface IShipAttachments {
 | 
				
			||||||
    ShipId: IOid;
 | 
					    HOOD_ORNAMENT: string;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IShipDatabase {
 | 
					export interface IShipInterior {
 | 
				
			||||||
    Rooms: IRooms[];
 | 
					    Colors?: IColor;
 | 
				
			||||||
 | 
					    ShipAttachments?: IShipAttachments;
 | 
				
			||||||
 | 
					    SkinFlavourItem?: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IShip {
 | 
				
			||||||
    Features: string[];
 | 
					    Features: string[];
 | 
				
			||||||
 | 
					    ShipId: IOid;
 | 
				
			||||||
 | 
					    ShipInterior: IShipInterior;
 | 
				
			||||||
 | 
					    Rooms: IRooms[];
 | 
				
			||||||
    ContentUrlSignature: string;
 | 
					    ContentUrlSignature: string;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: add Apartment.Gardening
 | 
					export interface IShipDatabase {
 | 
				
			||||||
 | 
					    ItemType: string;
 | 
				
			||||||
 | 
					    ShipOwnerId: Schema.Types.ObjectId;
 | 
				
			||||||
 | 
					    ShipInteriorColors?: IColor;
 | 
				
			||||||
 | 
					    ShipExteriorColors?: IColor;
 | 
				
			||||||
 | 
					    AirSupportPower: string;
 | 
				
			||||||
 | 
					    ShipAttachments?: IShipAttachments;
 | 
				
			||||||
 | 
					    SkinFlavourItem?: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IRooms {
 | 
					export interface IRooms {
 | 
				
			||||||
    Name: string;
 | 
					    Name: string;
 | 
				
			||||||
    MaxCapacity: number;
 | 
					    MaxCapacity: number;
 | 
				
			||||||
 | 
					    PlacedDecos?: IPlacedDecosDatabase[];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IPlants {
 | 
				
			||||||
 | 
					    PlantType: string;
 | 
				
			||||||
 | 
					    EndTime: IOid;
 | 
				
			||||||
 | 
					    PlotIndex: number;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					export interface IPlanters {
 | 
				
			||||||
 | 
					    Name: string;
 | 
				
			||||||
 | 
					    Plants: IPlants[];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IGardening {
 | 
				
			||||||
 | 
					    Planters: IPlanters[];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
export interface IApartment {
 | 
					export interface IApartment {
 | 
				
			||||||
 | 
					    Gardening: IGardening;
 | 
				
			||||||
    Rooms: IRooms[];
 | 
					    Rooms: IRooms[];
 | 
				
			||||||
    FavouriteLoadouts: string[];
 | 
					    FavouriteLoadouts: string[];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IPlacedDecosDatabase {
 | 
				
			||||||
 | 
					    Type: string;
 | 
				
			||||||
 | 
					    Pos: [number, number, number];
 | 
				
			||||||
 | 
					    Rot: [number, number, number];
 | 
				
			||||||
 | 
					    _id: Types.ObjectId;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IPlacedDecosClient extends Omit<IPlacedDecosDatabase, "_id"> {
 | 
				
			||||||
 | 
					    id: IOid;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface ISetShipCustomizationsRequest {
 | 
				
			||||||
 | 
					    ShipId: string;
 | 
				
			||||||
 | 
					    Customization: Customization;
 | 
				
			||||||
 | 
					    IsExterior: boolean;
 | 
				
			||||||
 | 
					    AirSupportPower?: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface Customization {
 | 
				
			||||||
 | 
					    SkinFlavourItem: string;
 | 
				
			||||||
 | 
					    Colors: IColor;
 | 
				
			||||||
 | 
					    ShipAttachments: ShipAttachments;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//TODO: check for more attachments
 | 
				
			||||||
 | 
					export interface ShipAttachments {
 | 
				
			||||||
 | 
					    HOOD_ORNAMENT: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IShipDecorationsRequest {
 | 
				
			||||||
 | 
					    Type: string;
 | 
				
			||||||
 | 
					    Pos: [number, number, number];
 | 
				
			||||||
 | 
					    Rot: [number, number, number];
 | 
				
			||||||
 | 
					    Room: string;
 | 
				
			||||||
 | 
					    IsApartment: boolean;
 | 
				
			||||||
 | 
					    RemoveId: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IShipDecorationsResponse {
 | 
				
			||||||
 | 
					    DecoId: string;
 | 
				
			||||||
 | 
					    Room: string;
 | 
				
			||||||
 | 
					    IsApartment: boolean;
 | 
				
			||||||
 | 
					    MaxCapacityIncrease?: number;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										69
									
								
								static/fixed_responses/allShipFeatures.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								static/fixed_responses/allShipFeatures.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,69 @@
 | 
				
			|||||||
 | 
					[
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/AdvancedOrdisFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/AlchemyRoomFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/AlertsFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/ArsenalFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/CeresNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/ClanFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/EarthNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/EidolonArchwingFoundryUpgradeFeatureBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/EidolonArchwingFoundryUpgradeFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/ErisNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/EuropaNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/FoundryConcurrentBuildFormaFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/FoundryFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/FoundryVesselUpgradeFeatureBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/FoundryVesselUpgradeFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryCatbrowUpgradeFeatureBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryCatbrowUpgradeFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryUpgradeFeatureBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/GeneticFoundryUpgradeFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryArchonShardBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryArchonShardFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryUpgradeBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/InfestedFoundryUpgradeFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/JupiterNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/MarketTierOneFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/MarketTierTwoFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/MarsNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/MercuryNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/ModsFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/ModsFusionFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/ModsTransmuteFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/NeptuneNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/PersonalQuartersFeatureBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/PersonalQuartersFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/PhobosNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/PlutoNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackHoodBraceFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackHoodFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackHullFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackNacelleLeftFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackNacelleRightFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/DamagedRailjackTailFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHoodBraceFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHoodBraceFeatureItemBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHoodFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHoodFeatureItemBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHullFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackHullFeatureItemBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackNacelleLeftFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackNacelleLeftFeatureItemBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackNacelleRightFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackNacelleRightFeatureItemBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackTailFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/Railjack/RailjackTailFeatureItemBlueprint",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/RailjackCephalonShipFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/RailjackKeyShipFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/SaturnNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/SednaNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/ShipFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/SocialMenuFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/SolarChartFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/UranusNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/VenusNavigationFeatureItem",
 | 
				
			||||||
 | 
					  "/Lotus/Types/Items/ShipFeatureItems/VoidProjectionFeatureItem"
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
@ -8,7 +8,6 @@
 | 
				
			|||||||
      "/Lotus/Types/Items/ShipFeatureItems/FoundryFeatureItem",
 | 
					      "/Lotus/Types/Items/ShipFeatureItems/FoundryFeatureItem",
 | 
				
			||||||
      "/Lotus/Types/Items/ShipFeatureItems/MercuryNavigationFeatureItem"
 | 
					      "/Lotus/Types/Items/ShipFeatureItems/MercuryNavigationFeatureItem"
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "ShipId": { "$oid": "removed" },
 | 
					 | 
				
			||||||
    "Rooms": [
 | 
					    "Rooms": [
 | 
				
			||||||
      { "Name": "AlchemyRoom", "MaxCapacity": 1600 },
 | 
					      { "Name": "AlchemyRoom", "MaxCapacity": 1600 },
 | 
				
			||||||
      { "Name": "BridgeRoom", "MaxCapacity": 1600 },
 | 
					      { "Name": "BridgeRoom", "MaxCapacity": 1600 },
 | 
				
			||||||
@ -27,6 +26,7 @@
 | 
				
			|||||||
      { "Name": "ApartmentRoomC", "MaxCapacity": 1600 },
 | 
					      { "Name": "ApartmentRoomC", "MaxCapacity": 1600 },
 | 
				
			||||||
      { "Name": "DuviriHallway", "MaxCapacity": 1600 }
 | 
					      { "Name": "DuviriHallway", "MaxCapacity": 1600 }
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "FavouriteLoadouts": []
 | 
					    "FavouriteLoadouts": [],
 | 
				
			||||||
 | 
					    "Gardening": []
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										18
									
								
								static/fixed_responses/shipDecorations.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								static/fixed_responses/shipDecorations.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					[
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    "ItemCount": 1,
 | 
				
			||||||
 | 
					    "ItemType": "/Lotus/Types/Items/ShipDecos/Vignettes/Warframes/WarframeAFItem"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    "ItemCount": 1,
 | 
				
			||||||
 | 
					    "ItemType": "/Lotus/Types/Items/ShipDecos/KavatBust"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    "ItemCount": 1,
 | 
				
			||||||
 | 
					    "ItemType": "/Lotus/Types/Items/ShipDecos/Plushies/PlushyTiger"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    "ItemCount": 1,
 | 
				
			||||||
 | 
					    "ItemType": "/Lotus/Types/Items/ShipDecos/Venus/PrideCommunityDisplay"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user