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

SpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/SpaceNinjaServer

fix: make crew member slots optional (#766)

53d5e7c3
Sainan <sainan@calamity.inc>
提交于

代码差异

2 个文件 +24 -18
Modified src/models/inventoryModels/inventoryModel.ts +13 -13
@@ -42,11 +42,12 @@ import {
42 42 ICrewShipPortGuns,
43 43 ICrewShipCustomization,
44 44 ICrewShipWeapon,
45 ICrewShipMembers,
45 ICrewShipMembersClient,
46 46 ICrewShip,
47 47 ICrewShipPilotWeapon,
48 48 IShipExterior,
49 IHelminthFoodRecord
49 IHelminthFoodRecord,
50 ICrewShipMembersDatabase
50 51 } from "../../types/inventoryTypes/inventoryTypes";
51 52 import { IOid } from "../../types/commonTypes";
52 53 import {
@@ -670,23 +671,22 @@ const crewShipCustomizationSchema = new Schema<ICrewShipCustomization>(
670 671 { _id: false }
671 672 );
672 673
673 const crewShipMembersSchema = new Schema<ICrewShipMembers>(
674 const crewShipMembersSchema = new Schema<ICrewShipMembersDatabase>(
674 675 {
675 SLOT_A: Schema.Types.ObjectId,
676 SLOT_B: Schema.Types.ObjectId,
677 SLOT_C: Schema.Types.ObjectId
676 SLOT_A: { type: Schema.Types.ObjectId, required: false },
677 SLOT_B: { type: Schema.Types.ObjectId, required: false },
678 SLOT_C: { type: Schema.Types.ObjectId, required: false }
678 679 },
679 680 { _id: false }
680 681 );
681 682 crewShipMembersSchema.set("toJSON", {
682 683 virtuals: true,
683 transform(_doc, ret) {
684 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
685 ret.SLOT_A = { ItemId: toOid(ret.SLOT_A) };
686 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
687 ret.SLOT_B = { ItemId: toOid(ret.SLOT_B) };
688 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
689 ret.SLOT_C = { ItemId: toOid(ret.SLOT_C) };
684 transform(_doc, obj) {
685 const db = obj as ICrewShipMembersDatabase;
686 const client = obj as ICrewShipMembersClient;
687 client.SLOT_A = db.SLOT_A ? { ItemId: toOid(db.SLOT_A) } : undefined;
688 client.SLOT_B = db.SLOT_B ? { ItemId: toOid(db.SLOT_B) } : undefined;
689 client.SLOT_C = db.SLOT_C ? { ItemId: toOid(db.SLOT_C) } : undefined;
690 690 }
691 691 });
692 692
Modified src/types/inventoryTypes/inventoryTypes.ts +11 -5
@@ -426,21 +426,27 @@ export interface ICrewShip {
426 426 Customization?: ICrewShipCustomization;
427 427 ItemName: string;
428 428 RailjackImage?: IFlavourItem;
429 CrewMembers?: ICrewShipMembers;
429 CrewMembers?: ICrewShipMembersClient;
430 430 ItemId: IOid;
431 431 _id: Types.ObjectId;
432 432 }
433 433
434 export interface ICrewShipMembers {
435 SLOT_A: ISlot;
436 SLOT_B: ISlot;
437 SLOT_C: ISlot;
434 export interface ICrewShipMembersClient {
435 SLOT_A?: ISlot;
436 SLOT_B?: ISlot;
437 SLOT_C?: ISlot;
438 438 }
439 439
440 440 export interface ISlot {
441 441 ItemId: IOid;
442 442 }
443 443
444 export interface ICrewShipMembersDatabase {
445 SLOT_A?: Types.ObjectId;
446 SLOT_B?: Types.ObjectId;
447 SLOT_C?: Types.ObjectId;
448 }
449
444 450 export interface ICrewShipCustomization {
445 451 CrewshipInterior: IShipExterior;
446 452 }