XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

fix: create NORMAL loadout with post-tutorial accounts (#3057)

There are some strange client bugs resulting from logging in to an account without a loadout in post-tutorial state. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3057 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

a3c1dcd1
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

2 个文件 +27 -6
Modified src/services/inventoryService.ts +22 -1
@@ -93,9 +93,11 @@ import type {
93 93 import { EquipmentFeatures, Status } from "../types/equipmentTypes.ts";
94 94 import type { ITypeCount } from "../types/commonTypes.ts";
95 95 import { skinLookupTable } from "../helpers/skinLookupTable.ts";
96 import type { TLoadoutDatabaseDocument } from "../models/inventoryModels/loadoutModel.ts";
96 97
97 98 export const createInventory = async (
98 99 accountOwnerId: Types.ObjectId,
100 loadout: TLoadoutDatabaseDocument,
99 101 defaultItemReferences: { loadOutPresetId: Types.ObjectId; ship: Types.ObjectId }
100 102 ): Promise<void> => {
101 103 try {
@@ -115,10 +117,29 @@ export const createInventory = async (
115 117
116 118 if (config.skipTutorial) {
117 119 inventory.PlayedParkourTutorial = true;
118 await addStartingGear(inventory);
120 const startingGear = await addStartingGear(inventory);
119 121 await completeQuest(inventory, "/Lotus/Types/Keys/VorsPrize/VorsPrizeQuestKeyChain", undefined);
120 122 await completeQuest(inventory, "/Lotus/Types/Keys/ModQuest/ModQuestKeyChain", undefined);
121 123
124 loadout.NORMAL.push({
125 s: {
126 ItemId: new Types.ObjectId(fromOid(startingGear.Suits![0].ItemId))
127 },
128 l: {
129 ItemId: new Types.ObjectId(fromOid(startingGear.LongGuns![0].ItemId))
130 },
131 p: {
132 ItemId: new Types.ObjectId(fromOid(startingGear.Pistols![0].ItemId))
133 },
134 m: {
135 ItemId: new Types.ObjectId(fromOid(startingGear.Melee![0].ItemId))
136 },
137 a: {
138 ItemId: new Types.ObjectId(fromOid(startingGear.SpecialItems![0].ItemId))
139 }
140 });
141 await loadout.save();
142
122 143 const completedMissions = ["SolNode27", "SolNode89", "SolNode63", "SolNode85", "SolNode15", "SolNode79"];
123 144
124 145 inventory.Missions.push(
Modified src/services/loginService.ts +5 -5
@@ -3,7 +3,7 @@ import { createInventory } from "./inventoryService.ts";
3 3 import type { IDatabaseAccountJson, IDatabaseAccountRequiredFields } from "../types/loginTypes.ts";
4 4 import { createShip } from "./shipService.ts";
5 5 import type { Document, Types } from "mongoose";
6 import { Loadout } from "../models/inventoryModels/loadoutModel.ts";
6 import { Loadout, type TLoadoutDatabaseDocument } from "../models/inventoryModels/loadoutModel.ts";
7 7 import { PersonalRooms } from "../models/personalRoomsModel.ts";
8 8 import type { Request } from "express";
9 9 import { config } from "./configService.ts";
@@ -39,10 +39,10 @@ export const createAccount = async (accountData: IDatabaseAccountRequiredFields)
39 39 const account = new Account(accountData);
40 40 try {
41 41 await account.save();
42 const loadoutId = await createLoadout(account._id);
42 const loadout = await createLoadout(account._id);
43 43 const shipId = await createShip(account._id);
44 44 await createPersonalRooms(account._id, shipId);
45 await createInventory(account._id, { loadOutPresetId: loadoutId, ship: shipId });
45 await createInventory(account._id, loadout, { loadOutPresetId: loadout._id, ship: shipId });
46 46 await createStats(account._id.toString());
47 47 return account.toJSON();
48 48 } catch (error) {
@@ -53,10 +53,10 @@ export const createAccount = async (accountData: IDatabaseAccountRequiredFields)
53 53 }
54 54 };
55 55
56 export const createLoadout = async (accountId: Types.ObjectId): Promise<Types.ObjectId> => {
56 export const createLoadout = async (accountId: Types.ObjectId): Promise<TLoadoutDatabaseDocument> => {
57 57 const loadout = new Loadout({ loadoutOwnerId: accountId });
58 58 const savedLoadout = await loadout.save();
59 return savedLoadout._id;
59 return savedLoadout;
60 60 };
61 61
62 62 export const createPersonalRooms = async (accountId: Types.ObjectId, shipId: Types.ObjectId): Promise<void> => {