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: correctly add kubrow eggs to inventory (#875)

3a7cb5d9
Sainan <sainan@calamity.inc>
提交于

代码差异

3 个文件 +68 -20
Modified src/models/inventoryModels/inventoryModel.ts +24 -2
@@ -58,7 +58,9 @@ import {
58 58 equipmentKeys,
59 59 IKubrowPetDetailsDatabase,
60 60 ITraits,
61 IKubrowPetDetailsClient
61 IKubrowPetDetailsClient,
62 IKubrowPetEggDatabase,
63 IKubrowPetEggClient
62 64 } from "../../types/inventoryTypes/inventoryTypes";
63 65 import { IOid } from "../../types/commonTypes";
64 66 import {
@@ -378,6 +380,26 @@ StepSequencersSchema.set("toJSON", {
378 380 }
379 381 });
380 382
383 const kubrowPetEggSchema = new Schema<IKubrowPetEggDatabase>(
384 {
385 ItemType: String
386 },
387 { id: false }
388 );
389 kubrowPetEggSchema.set("toJSON", {
390 virtuals: true,
391 transform(_document, obj) {
392 const client = obj as IKubrowPetEggClient;
393 const db = obj as IKubrowPetEggDatabase;
394
395 client.ExpirationDate = { $date: { $numberLong: "2000000000000" } };
396 client.ItemId = toOid(db._id);
397
398 delete obj._id;
399 delete obj.__v;
400 }
401 });
402
381 403 const affiliationsSchema = new Schema<IAffiliation>(
382 404 {
383 405 Initiated: Boolean,
@@ -910,7 +932,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
910 932 //The Mandachord(Octavia) is a step sequencer
911 933 StepSequencers: [StepSequencersSchema],
912 934
913 KubrowPetEggs: [Schema.Types.Mixed],
935 KubrowPetEggs: [kubrowPetEggSchema],
914 936 //Prints Cat(3 Prints)\Kubrow(2 Prints) Pets
915 937 KubrowPetPrints: [Schema.Types.Mixed],
916 938
Modified src/services/inventoryService.ts +34 -11
@@ -20,7 +20,9 @@ import {
20 20 TEquipmentKey,
21 21 IFusionTreasure,
22 22 IDailyAffiliations,
23 IInventoryDatabase
23 IInventoryDatabase,
24 IKubrowPetEggDatabase,
25 IKubrowPetEggClient
24 26 } from "@/src/types/inventoryTypes/inventoryTypes";
25 27 import { IGenericUpdate } from "../types/genericUpdate";
26 28 import {
@@ -46,6 +48,7 @@ import {
46 48 import { createShip } from "./shipService";
47 49 import { creditBundles, fusionBundles } from "@/src/services/missionInventoryUpdateService";
48 50 import { IGiveKeyChainTriggeredItemsRequest } from "@/src/controllers/api/giveKeyChainTriggeredItemsController";
51 import { toOid } from "../helpers/inventoryHelpers";
49 52
50 53 export const createInventory = async (
51 54 accountOwnerId: Types.ObjectId,
@@ -209,7 +212,20 @@ export const addItem = async (
209 212 };
210 213 }
211 214 if (typeName in ExportResources) {
212 if (ExportResources[typeName].productCategory == "Ships") {
215 if (ExportResources[typeName].productCategory == "MiscItems") {
216 const miscItemChanges = [
217 {
218 ItemType: typeName,
219 ItemCount: quantity
220 } satisfies IMiscItem
221 ];
222 addMiscItems(inventory, miscItemChanges);
223 return {
224 InventoryChanges: {
225 MiscItems: miscItemChanges
226 }
227 };
228 } else if (ExportResources[typeName].productCategory == "Ships") {
213 229 const oid = await createShip(inventory.accountOwnerId, typeName);
214 230 inventory.Ships.push(oid);
215 231 return {
@@ -238,17 +254,24 @@ export const addItem = async (
238 254 ShipDecorations: changes
239 255 }
240 256 };
241 } else {
242 const miscItemChanges = [
243 {
244 ItemType: typeName,
245 ItemCount: quantity
246 } satisfies IMiscItem
247 ];
248 addMiscItems(inventory, miscItemChanges);
257 } else if (ExportResources[typeName].productCategory == "KubrowPetEggs") {
258 const changes: IKubrowPetEggClient[] = [];
259 for (let i = 0; i != quantity; ++i) {
260 const egg: IKubrowPetEggDatabase = {
261 ItemType: "/Lotus/Types/Game/KubrowPet/Eggs/KubrowEgg",
262 _id: new Types.ObjectId()
263 };
264 inventory.KubrowPetEggs ??= [];
265 inventory.KubrowPetEggs.push(egg);
266 changes.push({
267 ItemType: egg.ItemType,
268 ExpirationDate: { $date: { $numberLong: "2000000000000" } },
269 ItemId: toOid(egg._id)
270 });
271 }
249 272 return {
250 273 InventoryChanges: {
251 MiscItems: miscItemChanges
274 KubrowPetEggs: changes
252 275 }
253 276 };
254 277 }
Modified src/types/inventoryTypes/inventoryTypes.ts +10 -7
@@ -33,6 +33,7 @@ export interface IInventoryDatabase
33 33 | "KahlLoadOuts"
34 34 | "InfestedFoundry"
35 35 | "DialogueHistory"
36 | "KubrowPetEggs"
36 37 | TEquipmentKey
37 38 > {
38 39 accountOwnerId: Types.ObjectId;
@@ -54,6 +55,7 @@ export interface IInventoryDatabase
54 55 KahlLoadOuts: IOperatorConfigDatabase[];
55 56 InfestedFoundry?: IInfestedFoundryDatabase;
56 57 DialogueHistory?: IDialogueHistoryDatabase;
58 KubrowPetEggs?: IKubrowPetEggDatabase[];
57 59
58 60 Suits: IEquipmentDatabase[];
59 61 LongGuns: IEquipmentDatabase[];
@@ -271,7 +273,7 @@ export interface IInventoryClient extends IDailyAffiliations {
271 273 TauntHistory?: ITaunt[];
272 274 StoryModeChoice: string;
273 275 PeriodicMissionCompletions: IPeriodicMissionCompletionDatabase[];
274 KubrowPetEggs: IKubrowPetEgg[];
276 KubrowPetEggs?: IKubrowPetEggClient[];
275 277 LoreFragmentScans: ILoreFragmentScan[];
276 278 EquippedEmotes: string[];
277 279 PendingTrades: IPendingTrade[];
@@ -613,21 +615,22 @@ export interface IInvasionChainProgress {
613 615 count: number;
614 616 }
615 617
616 export interface IKubrowPetEgg {
617 ItemType: KubrowPetEggItemType;
618 ExpirationDate: IMongoDate;
618 export interface IKubrowPetEggClient {
619 ItemType: string;
620 ExpirationDate: IMongoDate; // seems to be set to 7 days ahead @ 0 UTC
619 621 ItemId: IOid;
620 622 }
621 623
622 export enum KubrowPetEggItemType {
623 LotusTypesGameKubrowPetEggsKubrowEgg = "/Lotus/Types/Game/KubrowPet/Eggs/KubrowEgg"
624 export interface IKubrowPetEggDatabase {
625 ItemType: string;
626 _id: Types.ObjectId;
624 627 }
625 628
626 629 export interface IKubrowPetPrint {
627 630 ItemType: KubrowPetPrintItemType;
628 631 Name: string;
629 632 IsMale: boolean;
630 Size: number;
633 Size: number; // seems to be 0.7 to 1.0
631 634 DominantTraits: ITraits;
632 635 RecessiveTraits: ITraits;
633 636 ItemId: IOid;