forked from OpenWF/SpaceNinjaServer
fix: acquisition of railjack (#629)
This commit is contained in:
parent
7dcb1f4fa4
commit
45cb9c6da0
@ -38,7 +38,14 @@ import {
|
|||||||
IPeriodicMissionCompletionResponse,
|
IPeriodicMissionCompletionResponse,
|
||||||
ILoreFragmentScan,
|
ILoreFragmentScan,
|
||||||
IEvolutionProgress,
|
IEvolutionProgress,
|
||||||
IEndlessXpProgress
|
IEndlessXpProgress,
|
||||||
|
ICrewShipPortGuns,
|
||||||
|
ICrewShipCustomization,
|
||||||
|
ICrewShipWeapon,
|
||||||
|
ICrewShipMembers,
|
||||||
|
ICrewShip,
|
||||||
|
ICrewShipPilotWeapon,
|
||||||
|
IShipExterior
|
||||||
} from "../../types/inventoryTypes/inventoryTypes";
|
} from "../../types/inventoryTypes/inventoryTypes";
|
||||||
import { IOid } from "../../types/commonTypes";
|
import { IOid } from "../../types/commonTypes";
|
||||||
import {
|
import {
|
||||||
@ -52,6 +59,7 @@ import {
|
|||||||
IArchonCrystalUpgrade
|
IArchonCrystalUpgrade
|
||||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
|
} from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
||||||
|
import { EquipmentSelectionSchema } from "./loadoutModel";
|
||||||
|
|
||||||
const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
|
const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
|
||||||
|
|
||||||
@ -590,6 +598,85 @@ const endlessXpProgressSchema = new Schema<IEndlessXpProgress>(
|
|||||||
{ _id: false }
|
{ _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>(
|
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||||
{
|
{
|
||||||
accountOwnerId: Schema.Types.ObjectId,
|
accountOwnerId: Schema.Types.ObjectId,
|
||||||
@ -741,7 +828,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
|||||||
CrewShipRawSalvage: [Schema.Types.Mixed],
|
CrewShipRawSalvage: [Schema.Types.Mixed],
|
||||||
|
|
||||||
//Default RailJack
|
//Default RailJack
|
||||||
CrewShips: [Schema.Types.Mixed],
|
CrewShips: [crewShipSchema],
|
||||||
CrewShipAmmo: [typeCountSchema],
|
CrewShipAmmo: [typeCountSchema],
|
||||||
CrewShipWeapons: [Schema.Types.Mixed],
|
CrewShipWeapons: [Schema.Types.Mixed],
|
||||||
CrewShipWeaponSkins: [Schema.Types.Mixed],
|
CrewShipWeaponSkins: [Schema.Types.Mixed],
|
||||||
@ -1005,6 +1092,8 @@ type InventoryDocumentProps = {
|
|||||||
Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
|
Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
|
||||||
MoaPets: Types.DocumentArray<IEquipmentDatabase>;
|
MoaPets: Types.DocumentArray<IEquipmentDatabase>;
|
||||||
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
|
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
|
||||||
|
CrewShips: Types.DocumentArray<ICrewShip>;
|
||||||
|
CrewShipHarnesses: Types.DocumentArray<IEquipmentDatabase>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
@ -13,7 +13,7 @@ const oidSchema = new Schema<IOid>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
//create a mongoose schema based on interface M
|
//create a mongoose schema based on interface M
|
||||||
const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
|
export const EquipmentSelectionSchema = new Schema<IEquipmentSelection>(
|
||||||
{
|
{
|
||||||
ItemId: oidSchema,
|
ItemId: oidSchema,
|
||||||
mod: Number,
|
mod: Number,
|
||||||
|
@ -145,6 +145,12 @@ export const addItem = async (
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
} else if (ExportResources[typeName].productCategory == "CrewShips") {
|
||||||
|
return {
|
||||||
|
InventoryChanges: {
|
||||||
|
CrewShips: [await addCrewShip(typeName, accountId)]
|
||||||
|
}
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
const miscItemChanges = [
|
const miscItemChanges = [
|
||||||
{
|
{
|
||||||
@ -597,6 +603,13 @@ export const addSkin = async (typeName: string, accountId: string): Promise<IWea
|
|||||||
return changedInventory.WeaponSkins[index].toJSON() as object as IWeaponSkinClient;
|
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 = (
|
const addGearExpByCategory = (
|
||||||
inventory: IInventoryDatabaseDocument,
|
inventory: IInventoryDatabaseDocument,
|
||||||
gearArray: IEquipmentClient[] | undefined,
|
gearArray: IEquipmentClient[] | undefined,
|
||||||
|
@ -420,28 +420,19 @@ export interface ICrewShipSalvagedWeaponSkin {
|
|||||||
_id?: Types.ObjectId;
|
_id?: Types.ObjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICrewShipWeapon {
|
|
||||||
ItemType: string;
|
|
||||||
UpgradeType?: string;
|
|
||||||
UpgradeFingerprint?: string;
|
|
||||||
Configs?: IItemConfig[];
|
|
||||||
UpgradeVer?: number;
|
|
||||||
ItemId: IOid;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ICrewShip {
|
export interface ICrewShip {
|
||||||
ItemType: string;
|
ItemType: string;
|
||||||
Configs: IItemConfig[];
|
Configs: IItemConfig[];
|
||||||
Weapon: ICrewshipWeapon;
|
Weapon?: ICrewShipWeapon;
|
||||||
Customization: ICustomization;
|
Customization?: ICrewShipCustomization;
|
||||||
ItemName: string;
|
ItemName: string;
|
||||||
RailjackImage: IFlavourItem;
|
RailjackImage?: IFlavourItem;
|
||||||
CrewMembers: ICrewMembers;
|
CrewMembers?: ICrewShipMembers;
|
||||||
ItemId: IOid;
|
ItemId: IOid;
|
||||||
_id: Types.ObjectId;
|
_id: Types.ObjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICrewMembers {
|
export interface ICrewShipMembers {
|
||||||
SLOT_A: ISlot;
|
SLOT_A: ISlot;
|
||||||
SLOT_B: ISlot;
|
SLOT_B: ISlot;
|
||||||
SLOT_C: ISlot;
|
SLOT_C: ISlot;
|
||||||
@ -451,7 +442,7 @@ export interface ISlot {
|
|||||||
ItemId: IOid;
|
ItemId: IOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICustomization {
|
export interface ICrewShipCustomization {
|
||||||
CrewshipInterior: IShipExterior;
|
CrewshipInterior: IShipExterior;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,7 +453,7 @@ export interface IShipExterior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IShipAttachments {
|
export interface IShipAttachments {
|
||||||
HOOD_ORNAMENT: string; //TODO: Others are probably possible
|
HOOD_ORNAMENT: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IFlavourItem {
|
export interface IFlavourItem {
|
||||||
@ -474,17 +465,18 @@ export interface IMiscItem {
|
|||||||
ItemType: string;
|
ItemType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICrewshipWeapon {
|
export interface ICrewShipWeapon {
|
||||||
PILOT: IPilot;
|
PILOT: ICrewShipPilotWeapon;
|
||||||
PORT_GUNS: IPortGuns;
|
PORT_GUNS: ICrewShipPortGuns;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPortGuns {
|
export interface ICrewShipPilotWeapon {
|
||||||
PRIMARY_A: IEquipmentSelection;
|
PRIMARY_A: IEquipmentSelection;
|
||||||
|
SECONDARY_A: IEquipmentSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPilot extends IPortGuns {
|
export interface ICrewShipPortGuns {
|
||||||
SECONDARY_A: IEquipmentSelection;
|
PRIMARY_A: IEquipmentSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDiscoveredMarker {
|
export interface IDiscoveredMarker {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user