feat: gardening #1849
@ -2,13 +2,12 @@ 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 { getPersonalRooms } from "@/src/services/personalRoomsService";
 | 
			
		||||
import { createGarden, getPersonalRooms } from "@/src/services/personalRoomsService";
 | 
			
		||||
import { getShip } from "@/src/services/shipService";
 | 
			
		||||
import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { IGetShipResponse } from "@/src/types/shipTypes";
 | 
			
		||||
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
 | 
			
		||||
import { getLoadout } from "@/src/services/loadoutService";
 | 
			
		||||
import { getRandomElement } from "@/src/services/rngService";
 | 
			
		||||
 | 
			
		||||
export const getShipController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -16,64 +15,7 @@ export const getShipController: RequestHandler = async (req, res) => {
 | 
			
		||||
 | 
			
		||||
    // 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) {
 | 
			
		||||
        const plantTypes = [
 | 
			
		||||
            "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantA",
 | 
			
		||||
            "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantB",
 | 
			
		||||
            "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantC",
 | 
			
		||||
            "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantD",
 | 
			
		||||
            "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantE",
 | 
			
		||||
            "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantF"
 | 
			
		||||
        ];
 | 
			
		||||
        const endTime = new Date(Date.now() + 79200_000); // Plants will take 22 hours to grow
 | 
			
		||||
        personalRoomsDb.Apartment.Gardening = {
 | 
			
		||||
            Planters: [
 | 
			
		||||
                {
 | 
			
		||||
                    Name: "Garden0",
 | 
			
		||||
                    Plants: [
 | 
			
		||||
                        {
 | 
			
		||||
                            PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                            EndTime: endTime,
 | 
			
		||||
                            PlotIndex: 0
 | 
			
		||||
                        },
 | 
			
		||||
                        {
 | 
			
		||||
                            PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                            EndTime: endTime,
 | 
			
		||||
                            PlotIndex: 1
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    Name: "Garden1",
 | 
			
		||||
                    Plants: [
 | 
			
		||||
                        {
 | 
			
		||||
                            PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                            EndTime: endTime,
 | 
			
		||||
                            PlotIndex: 0
 | 
			
		||||
                        },
 | 
			
		||||
                        {
 | 
			
		||||
                            PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                            EndTime: endTime,
 | 
			
		||||
                            PlotIndex: 1
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    Name: "Garden2",
 | 
			
		||||
                    Plants: [
 | 
			
		||||
                        {
 | 
			
		||||
                            PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                            EndTime: endTime,
 | 
			
		||||
                            PlotIndex: 0
 | 
			
		||||
                        },
 | 
			
		||||
                        {
 | 
			
		||||
                            PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                            EndTime: endTime,
 | 
			
		||||
                            PlotIndex: 1
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        };
 | 
			
		||||
        personalRoomsDb.Apartment.Gardening = createGarden();
 | 
			
		||||
        await personalRoomsDb.save();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,8 @@
 | 
			
		||||
import { PersonalRooms } from "@/src/models/personalRoomsModel";
 | 
			
		||||
import { addItem, getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { TPersonalRoomsDatabaseDocument } from "../types/personalRoomsTypes";
 | 
			
		||||
import { IGardeningDatabase } from "../types/shipTypes";
 | 
			
		||||
import { getRandomElement } from "./rngService";
 | 
			
		||||
 | 
			
		||||
export const getPersonalRooms = async (accountId: string): Promise<TPersonalRoomsDatabaseDocument> => {
 | 
			
		||||
    const personalRooms = await PersonalRooms.findOne({ personalRoomsOwnerId: accountId });
 | 
			
		||||
@ -25,3 +27,64 @@ export const updateShipFeature = async (accountId: string, shipFeature: string):
 | 
			
		||||
    await addItem(inventory, shipFeature, -1);
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const createGarden = (): IGardeningDatabase => {
 | 
			
		||||
    const plantTypes = [
 | 
			
		||||
        "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantA",
 | 
			
		||||
        "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantB",
 | 
			
		||||
        "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantC",
 | 
			
		||||
        "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantD",
 | 
			
		||||
        "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantE",
 | 
			
		||||
        "/Lotus/Types/Items/Plants/MiscItems/DuvxDuviriGrowingPlantF"
 | 
			
		||||
    ];
 | 
			
		||||
    const endTime = new Date(Date.now() + 79200_000); // Plants will take 22 hours to grow
 | 
			
		||||
    return {
 | 
			
		||||
        Planters: [
 | 
			
		||||
            {
 | 
			
		||||
                Name: "Garden0",
 | 
			
		||||
                Plants: [
 | 
			
		||||
                    {
 | 
			
		||||
                        PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                        EndTime: endTime,
 | 
			
		||||
                        PlotIndex: 0
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                        EndTime: endTime,
 | 
			
		||||
                        PlotIndex: 1
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                Name: "Garden1",
 | 
			
		||||
                Plants: [
 | 
			
		||||
                    {
 | 
			
		||||
                        PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                        EndTime: endTime,
 | 
			
		||||
                        PlotIndex: 0
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                        EndTime: endTime,
 | 
			
		||||
                        PlotIndex: 1
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                Name: "Garden2",
 | 
			
		||||
                Plants: [
 | 
			
		||||
                    {
 | 
			
		||||
                        PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                        EndTime: endTime,
 | 
			
		||||
                        PlotIndex: 0
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        PlantType: getRandomElement(plantTypes),
 | 
			
		||||
                        EndTime: endTime,
 | 
			
		||||
                        PlotIndex: 1
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user