fix: create NORMAL loadout with post-tutorial accounts
All checks were successful
Build / build (pull_request) Successful in 2m10s
All checks were successful
Build / build (pull_request) Successful in 2m10s
There are some strange client bugs resulting from logging in to an account without a loadout in post-tutorial state.
This commit is contained in:
@@ -93,9 +93,11 @@ import type {
|
||||
import { EquipmentFeatures, Status } from "../types/equipmentTypes.ts";
|
||||
import type { ITypeCount } from "../types/commonTypes.ts";
|
||||
import { skinLookupTable } from "../helpers/skinLookupTable.ts";
|
||||
import type { TLoadoutDatabaseDocument } from "../models/inventoryModels/loadoutModel.ts";
|
||||
|
||||
export const createInventory = async (
|
||||
accountOwnerId: Types.ObjectId,
|
||||
loadout: TLoadoutDatabaseDocument,
|
||||
defaultItemReferences: { loadOutPresetId: Types.ObjectId; ship: Types.ObjectId }
|
||||
): Promise<void> => {
|
||||
try {
|
||||
@@ -115,10 +117,29 @@ export const createInventory = async (
|
||||
|
||||
if (config.skipTutorial) {
|
||||
inventory.PlayedParkourTutorial = true;
|
||||
await addStartingGear(inventory);
|
||||
const startingGear = await addStartingGear(inventory);
|
||||
await completeQuest(inventory, "/Lotus/Types/Keys/VorsPrize/VorsPrizeQuestKeyChain", undefined);
|
||||
await completeQuest(inventory, "/Lotus/Types/Keys/ModQuest/ModQuestKeyChain", undefined);
|
||||
|
||||
loadout.NORMAL.push({
|
||||
s: {
|
||||
ItemId: new Types.ObjectId(fromOid(startingGear.Suits![0].ItemId))
|
||||
},
|
||||
l: {
|
||||
ItemId: new Types.ObjectId(fromOid(startingGear.LongGuns![0].ItemId))
|
||||
},
|
||||
p: {
|
||||
ItemId: new Types.ObjectId(fromOid(startingGear.Pistols![0].ItemId))
|
||||
},
|
||||
m: {
|
||||
ItemId: new Types.ObjectId(fromOid(startingGear.Melee![0].ItemId))
|
||||
},
|
||||
a: {
|
||||
ItemId: new Types.ObjectId(fromOid(startingGear.SpecialItems![0].ItemId))
|
||||
}
|
||||
});
|
||||
await loadout.save();
|
||||
|
||||
const completedMissions = ["SolNode27", "SolNode89", "SolNode63", "SolNode85", "SolNode15", "SolNode79"];
|
||||
|
||||
inventory.Missions.push(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createInventory } from "./inventoryService.ts";
|
||||
import type { IDatabaseAccountJson, IDatabaseAccountRequiredFields } from "../types/loginTypes.ts";
|
||||
import { createShip } from "./shipService.ts";
|
||||
import type { Document, Types } from "mongoose";
|
||||
import { Loadout } from "../models/inventoryModels/loadoutModel.ts";
|
||||
import { Loadout, type TLoadoutDatabaseDocument } from "../models/inventoryModels/loadoutModel.ts";
|
||||
import { PersonalRooms } from "../models/personalRoomsModel.ts";
|
||||
import type { Request } from "express";
|
||||
import { config } from "./configService.ts";
|
||||
@@ -39,10 +39,10 @@ export const createAccount = async (accountData: IDatabaseAccountRequiredFields)
|
||||
const account = new Account(accountData);
|
||||
try {
|
||||
await account.save();
|
||||
const loadoutId = await createLoadout(account._id);
|
||||
const loadout = await createLoadout(account._id);
|
||||
const shipId = await createShip(account._id);
|
||||
await createPersonalRooms(account._id, shipId);
|
||||
await createInventory(account._id, { loadOutPresetId: loadoutId, ship: shipId });
|
||||
await createInventory(account._id, loadout, { loadOutPresetId: loadout._id, ship: shipId });
|
||||
await createStats(account._id.toString());
|
||||
return account.toJSON();
|
||||
} catch (error) {
|
||||
@@ -53,10 +53,10 @@ export const createAccount = async (accountData: IDatabaseAccountRequiredFields)
|
||||
}
|
||||
};
|
||||
|
||||
export const createLoadout = async (accountId: Types.ObjectId): Promise<Types.ObjectId> => {
|
||||
export const createLoadout = async (accountId: Types.ObjectId): Promise<TLoadoutDatabaseDocument> => {
|
||||
const loadout = new Loadout({ loadoutOwnerId: accountId });
|
||||
const savedLoadout = await loadout.save();
|
||||
return savedLoadout._id;
|
||||
return savedLoadout;
|
||||
};
|
||||
|
||||
export const createPersonalRooms = async (accountId: Types.ObjectId, shipId: Types.ObjectId): Promise<void> => {
|
||||
|
||||
Reference in New Issue
Block a user