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: acquisition of railjack (#629)

45cb9c6d
Sainan <sainan@calamity.inc>
提交于

代码差异

4 个文件 +119 -25
Modified src/models/inventoryModels/inventoryModel.ts +91 -2
@@ -38,7 +38,14 @@ import {
38 38 IPeriodicMissionCompletionResponse,
39 39 ILoreFragmentScan,
40 40 IEvolutionProgress,
41 IEndlessXpProgress
41 IEndlessXpProgress,
42 ICrewShipPortGuns,
43 ICrewShipCustomization,
44 ICrewShipWeapon,
45 ICrewShipMembers,
46 ICrewShip,
47 ICrewShipPilotWeapon,
48 IShipExterior
42 49 } from "../../types/inventoryTypes/inventoryTypes";
43 50 import { IOid } from "../../types/commonTypes";
44 51 import {
@@ -52,6 +59,7 @@ import {
52 59 IArchonCrystalUpgrade
53 60 } from "@/src/types/inventoryTypes/commonInventoryTypes";
54 61 import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
62 import { EquipmentSelectionSchema } from "./loadoutModel";
55 63
56 64 const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
57 65
@@ -590,6 +598,85 @@ const endlessXpProgressSchema = new Schema<IEndlessXpProgress>(
590 598 { _id: false }
591 599 );
592 600
601 const crewShipPilotWeaponSchema = new Schema<ICrewShipPilotWeapon>(
602 {
603 PRIMARY_A: EquipmentSelectionSchema,
604 SECONDARY_A: EquipmentSelectionSchema
605 },
606 { _id: false }
607 );
608
609 const crewShipPortGunsSchema = new Schema<ICrewShipPortGuns>(
610 {
611 PRIMARY_A: EquipmentSelectionSchema
612 },
613 { _id: false }
614 );
615
616 const crewShipWeaponSchema = new Schema<ICrewShipWeapon>(
617 {
618 PILOT: crewShipPilotWeaponSchema,
619 PORT_GUNS: crewShipPortGunsSchema
620 },
621 { _id: false }
622 );
623
624 const shipExteriorSchema = new Schema<IShipExterior>(
625 {
626 SkinFlavourItem: String,
627 Colors: colorSchema,
628 ShipAttachments: { HOOD_ORNAMENT: String }
629 },
630 { _id: false }
631 );
632
633 const crewShipCustomizationSchema = new Schema<ICrewShipCustomization>(
634 {
635 CrewshipInterior: shipExteriorSchema
636 },
637 { _id: false }
638 );
639
640 const crewShipMembersSchema = new Schema<ICrewShipMembers>(
641 {
642 SLOT_A: Schema.Types.ObjectId,
643 SLOT_B: Schema.Types.ObjectId,
644 SLOT_C: Schema.Types.ObjectId
645 },
646 { _id: false }
647 );
648 crewShipMembersSchema.set("toJSON", {
649 virtuals: true,
650 transform(_doc, ret) {
651 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
652 ret.SLOT_A = { ItemId: toOid(ret.SLOT_A) };
653 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
654 ret.SLOT_B = { ItemId: toOid(ret.SLOT_B) };
655 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
656 ret.SLOT_C = { ItemId: toOid(ret.SLOT_C) };
657 }
658 });
659
660 const crewShipSchema = new Schema<ICrewShip>({
661 ItemType: { type: String, required: true },
662 Configs: { type: [ItemConfigSchema], default: [] },
663 Weapon: { type: crewShipWeaponSchema, default: undefined },
664 Customization: { type: crewShipCustomizationSchema, default: undefined },
665 ItemName: { type: String, default: "" },
666 RailjackImage: { type: FlavourItemSchema, default: undefined },
667 CrewMembers: { type: crewShipMembersSchema, default: undefined }
668 });
669 crewShipSchema.virtual("ItemId").get(function () {
670 return { $oid: this._id.toString() };
671 });
672 crewShipSchema.set("toJSON", {
673 virtuals: true,
674 transform(_doc, ret, _options) {
675 delete ret._id;
676 delete ret.__v;
677 }
678 });
679
593 680 const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
594 681 {
595 682 accountOwnerId: Schema.Types.ObjectId,
@@ -741,7 +828,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
741 828 CrewShipRawSalvage: [Schema.Types.Mixed],
742 829
743 830 //Default RailJack
744 CrewShips: [Schema.Types.Mixed],
831 CrewShips: [crewShipSchema],
745 832 CrewShipAmmo: [typeCountSchema],
746 833 CrewShipWeapons: [Schema.Types.Mixed],
747 834 CrewShipWeaponSkins: [Schema.Types.Mixed],
@@ -1005,6 +1092,8 @@ type InventoryDocumentProps = {
1005 1092 Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
1006 1093 MoaPets: Types.DocumentArray<IEquipmentDatabase>;
1007 1094 WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
1095 CrewShips: Types.DocumentArray<ICrewShip>;
1096 CrewShipHarnesses: Types.DocumentArray<IEquipmentDatabase>;
1008 1097 };
1009 1098
1010 1099 // eslint-disable-next-line @typescript-eslint/ban-types
Modified src/models/inventoryModels/loadoutModel.ts +1 -1
@@ -13,7 +13,7 @@ const oidSchema = new Schema<IOid>(
13 13 );
14 14
15 15 //create a mongoose schema based on interface M
16 const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
16 export const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
17 17 {
18 18 ItemId: oidSchema,
19 19 mod: Number,
Modified src/services/inventoryService.ts +13 -0
@@ -145,6 +145,12 @@ export const addItem = async (
145 145 ]
146 146 }
147 147 };
148 } else if (ExportResources[typeName].productCategory == "CrewShips") {
149 return {
150 InventoryChanges: {
151 CrewShips: [await addCrewShip(typeName, accountId)]
152 }
153 };
148 154 } else {
149 155 const miscItemChanges = [
150 156 {
@@ -597,6 +603,13 @@ export const addSkin = async (typeName: string, accountId: string): Promise<IWea
597 603 return changedInventory.WeaponSkins[index].toJSON() as object as IWeaponSkinClient;
598 604 };
599 605
606 const addCrewShip = async (typeName: string, accountId: string) => {
607 const inventory = await getInventory(accountId);
608 const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
609 const changedInventory = await inventory.save();
610 return changedInventory.CrewShips[index].toJSON();
611 };
612
600 613 const addGearExpByCategory = (
601 614 inventory: IInventoryDatabaseDocument,
602 615 gearArray: IEquipmentClient[] | undefined,
Modified src/types/inventoryTypes/inventoryTypes.ts +14 -22
@@ -420,28 +420,19 @@ export interface ICrewShipSalvagedWeaponSkin {
420 420 _id?: Types.ObjectId;
421 421 }
422 422
423 export interface ICrewShipWeapon {
424 ItemType: string;
425 UpgradeType?: string;
426 UpgradeFingerprint?: string;
427 Configs?: IItemConfig[];
428 UpgradeVer?: number;
429 ItemId: IOid;
430 }
431
432 423 export interface ICrewShip {
433 424 ItemType: string;
434 425 Configs: IItemConfig[];
435 Weapon: ICrewshipWeapon;
436 Customization: ICustomization;
426 Weapon?: ICrewShipWeapon;
427 Customization?: ICrewShipCustomization;
437 428 ItemName: string;
438 RailjackImage: IFlavourItem;
439 CrewMembers: ICrewMembers;
429 RailjackImage?: IFlavourItem;
430 CrewMembers?: ICrewShipMembers;
440 431 ItemId: IOid;
441 432 _id: Types.ObjectId;
442 433 }
443 434
444 export interface ICrewMembers {
435 export interface ICrewShipMembers {
445 436 SLOT_A: ISlot;
446 437 SLOT_B: ISlot;
447 438 SLOT_C: ISlot;
@@ -451,7 +442,7 @@ export interface ISlot {
451 442 ItemId: IOid;
452 443 }
453 444
454 export interface ICustomization {
445 export interface ICrewShipCustomization {
455 446 CrewshipInterior: IShipExterior;
456 447 }
457 448
@@ -462,7 +453,7 @@ export interface IShipExterior {
462 453 }
463 454
464 455 export interface IShipAttachments {
465 HOOD_ORNAMENT: string; //TODO: Others are probably possible
456 HOOD_ORNAMENT: string;
466 457 }
467 458
468 459 export interface IFlavourItem {
@@ -474,17 +465,18 @@ export interface IMiscItem {
474 465 ItemType: string;
475 466 }
476 467
477 export interface ICrewshipWeapon {
478 PILOT: IPilot;
479 PORT_GUNS: IPortGuns;
468 export interface ICrewShipWeapon {
469 PILOT: ICrewShipPilotWeapon;
470 PORT_GUNS: ICrewShipPortGuns;
480 471 }
481 472
482 export interface IPortGuns {
473 export interface ICrewShipPilotWeapon {
483 474 PRIMARY_A: IEquipmentSelection;
475 SECONDARY_A: IEquipmentSelection;
484 476 }
485 477
486 export interface IPilot extends IPortGuns {
487 SECONDARY_A: IEquipmentSelection;
478 export interface ICrewShipPortGuns {
479 PRIMARY_A: IEquipmentSelection;
488 480 }
489 481
490 482 export interface IDiscoveredMarker {