as far as I can tell, the ShipAttachments and SkinFlavourItem are just here due to the fact that the type from ShipExterior is being reused, but they aren't actually needed because the interior can't have attachments or flavour items - and if it could, they would be different from the exterior anyway. Reviewed-on: #2022 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
49 lines
2.0 KiB
TypeScript
49 lines
2.0 KiB
TypeScript
import { RequestHandler } from "express";
|
|
import { config } from "@/src/services/configService";
|
|
import allShipFeatures from "@/static/fixed_responses/allShipFeatures.json";
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
import { createGarden, getPersonalRooms } from "@/src/services/personalRoomsService";
|
|
import { toOid } from "@/src/helpers/inventoryHelpers";
|
|
import { IGetShipResponse } from "@/src/types/shipTypes";
|
|
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
|
|
import { getLoadout } from "@/src/services/loadoutService";
|
|
|
|
export const getShipController: RequestHandler = async (req, res) => {
|
|
const accountId = await getAccountIdForRequest(req);
|
|
const personalRoomsDb = await getPersonalRooms(accountId);
|
|
|
|
// Setup gardening if it's missing. Maybe should be done as part of some quest completion in the future.
|
|
if (personalRoomsDb.Apartment.Gardening.Planters.length == 0) {
|
|
personalRoomsDb.Apartment.Gardening = createGarden();
|
|
await personalRoomsDb.save();
|
|
}
|
|
|
|
const personalRooms = personalRoomsDb.toJSON<IPersonalRoomsClient>();
|
|
const loadout = await getLoadout(accountId);
|
|
|
|
const getShipResponse: IGetShipResponse = {
|
|
ShipOwnerId: accountId,
|
|
LoadOutInventory: { LoadOutPresets: loadout.toJSON() },
|
|
Ship: {
|
|
...personalRooms.Ship,
|
|
ShipId: toOid(personalRoomsDb.activeShipId),
|
|
ShipInterior: {
|
|
Colors: personalRooms.ShipInteriorColors,
|
|
ShipAttachments: { HOOD_ORNAMENT: "" },
|
|
SkinFlavourItem: ""
|
|
},
|
|
FavouriteLoadoutId: personalRooms.Ship.FavouriteLoadoutId
|
|
? toOid(personalRooms.Ship.FavouriteLoadoutId)
|
|
: undefined
|
|
},
|
|
Apartment: personalRooms.Apartment,
|
|
TailorShop: personalRooms.TailorShop
|
|
};
|
|
|
|
if (config.unlockAllShipFeatures) {
|
|
getShipResponse.Ship.Features = allShipFeatures;
|
|
}
|
|
|
|
res.json(getShipResponse);
|
|
};
|