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

feat: handle railjack armaments, crew, & customizations in saveLoadout (#1706)

Closes #467 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1706 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

5 个文件 +74 -39
Modified src/models/inventoryModels/inventoryModel.ts +11 -14
@@ -39,10 +39,9 @@ import {
39 39 ILoreFragmentScan,
40 40 IEvolutionProgress,
41 41 IEndlessXpProgress,
42 ICrewShipPortGuns,
43 42 ICrewShipCustomization,
44 43 ICrewShipWeapon,
45 ICrewShipPilotWeapon,
44 ICrewShipWeaponEmplacements,
46 45 IShipExterior,
47 46 IHelminthFoodRecord,
48 47 ICrewShipMembersDatabase,
@@ -772,25 +771,23 @@ const endlessXpProgressSchema = new Schema<IEndlessXpProgress>(
772 771 { _id: false }
773 772 );
774 773
775 const crewShipPilotWeaponSchema = new Schema<ICrewShipPilotWeapon>(
774 const crewShipWeaponEmplacementsSchema = new Schema<ICrewShipWeaponEmplacements>(
776 775 {
777 776 PRIMARY_A: EquipmentSelectionSchema,
778 SECONDARY_A: EquipmentSelectionSchema
779 },
780 { _id: false }
781 );
782
783 const crewShipPortGunsSchema = new Schema<ICrewShipPortGuns>(
784 {
785 PRIMARY_A: EquipmentSelectionSchema
777 PRIMARY_B: EquipmentSelectionSchema,
778 SECONDARY_A: EquipmentSelectionSchema,
779 SECONDARY_B: EquipmentSelectionSchema
786 780 },
787 781 { _id: false }
788 782 );
789 783
790 784 const crewShipWeaponSchema = new Schema<ICrewShipWeapon>(
791 785 {
792 PILOT: crewShipPilotWeaponSchema,
793 PORT_GUNS: crewShipPortGunsSchema
786 PILOT: crewShipWeaponEmplacementsSchema,
787 PORT_GUNS: crewShipWeaponEmplacementsSchema,
788 STARBOARD_GUNS: crewShipWeaponEmplacementsSchema,
789 ARTILLERY: crewShipWeaponEmplacementsSchema,
790 SCANNER: crewShipWeaponEmplacementsSchema
794 791 },
795 792 { _id: false }
796 793 );
@@ -814,7 +811,7 @@ const crewShipCustomizationSchema = new Schema<ICrewShipCustomization>(
814 811 const crewShipMemberSchema = new Schema<ICrewShipMemberDatabase>(
815 812 {
816 813 ItemId: { type: Schema.Types.ObjectId, required: false },
817 NemesisFingerprint: { type: Number, required: false }
814 NemesisFingerprint: { type: BigInt, required: false }
818 815 },
819 816 { _id: false }
820 817 );
Modified src/services/importService.ts +8 -8
@@ -104,18 +104,18 @@ const replaceSlots = (db: ISlots, client: ISlots): void => {
104 104 db.Slots = client.Slots;
105 105 };
106 106
107 const convertCrewShipMember = (client: ICrewShipMemberClient): ICrewShipMemberDatabase => {
108 return {
109 ...client,
110 ItemId: client.ItemId ? new Types.ObjectId(client.ItemId.$oid) : undefined
111 };
107 export const importCrewMemberId = (crewMemberId: ICrewShipMemberClient): ICrewShipMemberDatabase => {
108 if (crewMemberId.ItemId) {
109 return { ItemId: new Types.ObjectId(crewMemberId.ItemId.$oid) };
110 }
111 return { NemesisFingerprint: BigInt(crewMemberId.NemesisFingerprint ?? 0) };
112 112 };
113 113
114 114 const convertCrewShipMembers = (client: ICrewShipMembersClient): ICrewShipMembersDatabase => {
115 115 return {
116 SLOT_A: client.SLOT_A ? convertCrewShipMember(client.SLOT_A) : undefined,
117 SLOT_B: client.SLOT_B ? convertCrewShipMember(client.SLOT_B) : undefined,
118 SLOT_C: client.SLOT_C ? convertCrewShipMember(client.SLOT_C) : undefined
116 SLOT_A: client.SLOT_A ? importCrewMemberId(client.SLOT_A) : undefined,
117 SLOT_B: client.SLOT_B ? importCrewMemberId(client.SLOT_B) : undefined,
118 SLOT_C: client.SLOT_C ? importCrewMemberId(client.SLOT_C) : undefined
119 119 };
120 120 };
121 121
Modified src/services/saveLoadoutService.ts +24 -2
@@ -13,6 +13,8 @@ import { Types } from "mongoose";
13 13 import { isEmptyObject } from "@/src/helpers/general";
14 14 import { logger } from "@/src/utils/logger";
15 15 import { equipmentKeys, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
16 import { IItemConfig } from "../types/inventoryTypes/commonInventoryTypes";
17 import { importCrewMemberId } from "./importService";
16 18
17 19 //TODO: setup default items on account creation or like originally in giveStartingItems.php
18 20
@@ -174,8 +176,8 @@ export const handleInventoryItemConfigChange = async (
174 176 }
175 177
176 178 for (const [configId, config] of Object.entries(itemConfigEntries)) {
177 if (typeof config !== "boolean") {
178 inventoryItem.Configs[parseInt(configId)] = config;
179 if (/^[0-9]+$/.test(configId)) {
180 inventoryItem.Configs[parseInt(configId)] = config as IItemConfig;
179 181 }
180 182 }
181 183 if ("Favorite" in itemConfigEntries) {
@@ -184,6 +186,26 @@ export const handleInventoryItemConfigChange = async (
184 186 if ("IsNew" in itemConfigEntries) {
185 187 inventoryItem.IsNew = itemConfigEntries.IsNew;
186 188 }
189
190 if ("ItemName" in itemConfigEntries) {
191 inventoryItem.ItemName = itemConfigEntries.ItemName;
192 }
193 if ("RailjackImage" in itemConfigEntries) {
194 inventoryItem.RailjackImage = itemConfigEntries.RailjackImage;
195 }
196 if ("Customization" in itemConfigEntries) {
197 inventoryItem.Customization = itemConfigEntries.Customization;
198 }
199 if ("Weapon" in itemConfigEntries) {
200 inventoryItem.Weapon = itemConfigEntries.Weapon;
201 }
202 if (itemConfigEntries.CrewMembers) {
203 inventoryItem.CrewMembers = {
204 SLOT_A: importCrewMemberId(itemConfigEntries.CrewMembers.SLOT_A ?? {}),
205 SLOT_B: importCrewMemberId(itemConfigEntries.CrewMembers.SLOT_B ?? {}),
206 SLOT_C: importCrewMemberId(itemConfigEntries.CrewMembers.SLOT_C ?? {})
207 };
208 }
187 209 }
188 210 break;
189 211 } else {
Modified src/types/inventoryTypes/inventoryTypes.ts +14 -13
@@ -538,12 +538,12 @@ export interface ICrewShipMembersDatabase {
538 538
539 539 export interface ICrewShipMemberClient {
540 540 ItemId?: IOid;
541 NemesisFingerprint?: number;
541 NemesisFingerprint?: number | bigint;
542 542 }
543 543
544 544 export interface ICrewShipMemberDatabase {
545 545 ItemId?: Types.ObjectId;
546 NemesisFingerprint?: number;
546 NemesisFingerprint?: bigint;
547 547 }
548 548
549 549 export interface ICrewShipCustomization {
@@ -568,17 +568,18 @@ export type IMiscItem = ITypeCount;
568 568
569 569 // inventory.CrewShips[0].Weapon
570 570 export interface ICrewShipWeapon {
571 PILOT: ICrewShipPilotWeapon;
572 PORT_GUNS: ICrewShipPortGuns;
573 }
574
575 export interface ICrewShipPilotWeapon {
576 PRIMARY_A: IEquipmentSelection;
577 SECONDARY_A: IEquipmentSelection;
578 }
579
580 export interface ICrewShipPortGuns {
581 PRIMARY_A: IEquipmentSelection;
571 PILOT?: ICrewShipWeaponEmplacements;
572 PORT_GUNS?: ICrewShipWeaponEmplacements;
573 STARBOARD_GUNS?: ICrewShipWeaponEmplacements;
574 ARTILLERY?: ICrewShipWeaponEmplacements;
575 SCANNER?: ICrewShipWeaponEmplacements;
576 }
577
578 export interface ICrewShipWeaponEmplacements {
579 PRIMARY_A?: IEquipmentSelection;
580 PRIMARY_B?: IEquipmentSelection;
581 SECONDARY_A?: IEquipmentSelection;
582 SECONDARY_B?: IEquipmentSelection;
582 583 }
583 584
584 585 export interface IDiscoveredMarker {
Modified src/types/saveLoadoutTypes.ts +17 -2
@@ -1,7 +1,13 @@
1 1 import { IOid } from "@/src/types/commonTypes";
2 2 import { IItemConfig, IOperatorConfigClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
3 3 import { Types } from "mongoose";
4 import { ILoadoutConfigClient } from "./inventoryTypes/inventoryTypes";
4 import {
5 ICrewShipCustomization,
6 ICrewShipMembersClient,
7 ICrewShipWeapon,
8 IFlavourItem,
9 ILoadoutConfigClient
10 } from "./inventoryTypes/inventoryTypes";
5 11
6 12 export interface ISaveLoadoutRequest {
7 13 LoadOuts: ILoadoutClient;
@@ -51,7 +57,16 @@ export interface IItemEntry {
51 57
52 58 export type IConfigEntry = {
53 59 [configId in "0" | "1" | "2" | "3" | "4" | "5"]: IItemConfig;
54 } & { Favorite?: boolean; IsNew?: boolean };
60 } & {
61 Favorite?: boolean;
62 IsNew?: boolean;
63 // Railjack
64 ItemName?: string;
65 RailjackImage?: IFlavourItem;
66 Customization?: ICrewShipCustomization;
67 Weapon?: ICrewShipWeapon;
68 CrewMembers?: ICrewShipMembersClient;
69 };
55 70
56 71 export type ILoadoutClient = Omit<ILoadoutDatabase, "_id" | "loadoutOwnerId">;
57 72