fix: acquisition of railjack

This commit is contained in:
Sainan 2024-12-23 20:37:30 +01:00
parent d50c6b8c76
commit 7fb5729eff
4 changed files with 119 additions and 25 deletions

View File

@ -38,7 +38,14 @@ import {
IPeriodicMissionCompletionResponse,
ILoreFragmentScan,
IEvolutionProgress,
IEndlessXpProgress
IEndlessXpProgress,
ICrewShipPortGuns,
ICrewShipCustomization,
ICrewShipWeapon,
ICrewShipMembers,
ICrewShip,
ICrewShipPilotWeapon,
IShipExterior
} from "../../types/inventoryTypes/inventoryTypes";
import { IOid } from "../../types/commonTypes";
import {
@ -52,6 +59,7 @@ import {
IArchonCrystalUpgrade
} from "@/src/types/inventoryTypes/commonInventoryTypes";
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
import { EquipmentSelectionSchema } from "./loadoutModel";
const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
@ -590,6 +598,85 @@ const endlessXpProgressSchema = new Schema<IEndlessXpProgress>(
{ _id: false }
);
const crewShipPilotWeaponSchema = new Schema<ICrewShipPilotWeapon>(
{
PRIMARY_A: EquipmentSelectionSchema,
SECONDARY_A: EquipmentSelectionSchema
},
{ _id: false }
);
const crewShipPortGunsSchema = new Schema<ICrewShipPortGuns>(
{
PRIMARY_A: EquipmentSelectionSchema
},
{ _id: false }
);
const crewShipWeaponSchema = new Schema<ICrewShipWeapon>(
{
PILOT: crewShipPilotWeaponSchema,
PORT_GUNS: crewShipPortGunsSchema
},
{ _id: false }
);
const shipExteriorSchema = new Schema<IShipExterior>(
{
SkinFlavourItem: String,
Colors: colorSchema,
ShipAttachments: { HOOD_ORNAMENT: String }
},
{ _id: false }
);
const crewShipCustomizationSchema = new Schema<ICrewShipCustomization>(
{
CrewshipInterior: shipExteriorSchema
},
{ _id: false }
);
const crewShipMembersSchema = new Schema<ICrewShipMembers>(
{
SLOT_A: Schema.Types.ObjectId,
SLOT_B: Schema.Types.ObjectId,
SLOT_C: Schema.Types.ObjectId
},
{ _id: false }
);
crewShipMembersSchema.set("toJSON", {
virtuals: true,
transform(_doc, ret) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
ret.SLOT_A = { ItemId: toOid(ret.SLOT_A) };
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
ret.SLOT_B = { ItemId: toOid(ret.SLOT_B) };
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
ret.SLOT_C = { ItemId: toOid(ret.SLOT_C) };
}
});
const crewShipSchema = new Schema<ICrewShip>({
ItemType: { type: String, required: true },
Configs: { type: [ItemConfigSchema], default: [] },
Weapon: { type: crewShipWeaponSchema, default: undefined },
Customization: { type: crewShipCustomizationSchema, default: undefined },
ItemName: { type: String, default: "" },
RailjackImage: { type: FlavourItemSchema, default: undefined },
CrewMembers: { type: crewShipMembersSchema, default: undefined }
});
crewShipSchema.virtual("ItemId").get(function () {
return { $oid: this._id.toString() };
});
crewShipSchema.set("toJSON", {
virtuals: true,
transform(_doc, ret, _options) {
delete ret._id;
delete ret.__v;
}
});
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
{
accountOwnerId: Schema.Types.ObjectId,
@ -741,7 +828,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
CrewShipRawSalvage: [Schema.Types.Mixed],
//Default RailJack
CrewShips: [Schema.Types.Mixed],
CrewShips: [crewShipSchema],
CrewShipAmmo: [typeCountSchema],
CrewShipWeapons: [Schema.Types.Mixed],
CrewShipWeaponSkins: [Schema.Types.Mixed],
@ -1005,6 +1092,8 @@ type InventoryDocumentProps = {
Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
MoaPets: Types.DocumentArray<IEquipmentDatabase>;
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
CrewShips: Types.DocumentArray<ICrewShip>;
CrewShipHarnesses: Types.DocumentArray<IEquipmentDatabase>;
};
// eslint-disable-next-line @typescript-eslint/ban-types

View File

@ -13,7 +13,7 @@ const oidSchema = new Schema<IOid>(
);
//create a mongoose schema based on interface M
const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
export const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
{
ItemId: oidSchema,
mod: Number,

View File

@ -144,6 +144,12 @@ export const addItem = async (
]
}
};
} else if (ExportResources[typeName].productCategory == "CrewShips") {
return {
InventoryChanges: {
CrewShips: [await addCrewShip(typeName, accountId)]
}
};
} else {
const miscItemChanges = [
{
@ -563,6 +569,13 @@ export const addSkin = async (typeName: string, accountId: string): Promise<IWea
return changedInventory.WeaponSkins[index].toJSON() as object as IWeaponSkinClient;
};
const addCrewShip = async (typeName: string, accountId: string) => {
const inventory = await getInventory(accountId);
const index = inventory.CrewShips.push({ ItemType: typeName }) - 1;
const changedInventory = await inventory.save();
return changedInventory.CrewShips[index].toJSON();
};
const addGearExpByCategory = (
inventory: IInventoryDatabaseDocument,
gearArray: IEquipmentClient[] | undefined,

View File

@ -420,28 +420,19 @@ export interface ICrewShipSalvagedWeaponSkin {
_id?: Types.ObjectId;
}
export interface ICrewShipWeapon {
ItemType: string;
UpgradeType?: string;
UpgradeFingerprint?: string;
Configs?: IItemConfig[];
UpgradeVer?: number;
ItemId: IOid;
}
export interface ICrewShip {
ItemType: string;
Configs: IItemConfig[];
Weapon: ICrewshipWeapon;
Customization: ICustomization;
Weapon?: ICrewShipWeapon;
Customization?: ICrewShipCustomization;
ItemName: string;
RailjackImage: IFlavourItem;
CrewMembers: ICrewMembers;
RailjackImage?: IFlavourItem;
CrewMembers?: ICrewShipMembers;
ItemId: IOid;
_id: Types.ObjectId;
}
export interface ICrewMembers {
export interface ICrewShipMembers {
SLOT_A: ISlot;
SLOT_B: ISlot;
SLOT_C: ISlot;
@ -451,7 +442,7 @@ export interface ISlot {
ItemId: IOid;
}
export interface ICustomization {
export interface ICrewShipCustomization {
CrewshipInterior: IShipExterior;
}
@ -462,7 +453,7 @@ export interface IShipExterior {
}
export interface IShipAttachments {
HOOD_ORNAMENT: string; //TODO: Others are probably possible
HOOD_ORNAMENT: string;
}
export interface IFlavourItem {
@ -474,17 +465,18 @@ export interface IMiscItem {
ItemType: string;
}
export interface ICrewshipWeapon {
PILOT: IPilot;
PORT_GUNS: IPortGuns;
export interface ICrewShipWeapon {
PILOT: ICrewShipPilotWeapon;
PORT_GUNS: ICrewShipPortGuns;
}
export interface IPortGuns {
export interface ICrewShipPilotWeapon {
PRIMARY_A: IEquipmentSelection;
SECONDARY_A: IEquipmentSelection;
}
export interface IPilot extends IPortGuns {
SECONDARY_A: IEquipmentSelection;
export interface ICrewShipPortGuns {
PRIMARY_A: IEquipmentSelection;
}
export interface IDiscoveredMarker {