feat: acquisition of resource extractor drones
All checks were successful
Build / build (20) (push) Successful in 1m7s
Build / build (22) (push) Successful in 38s
Build / build (18) (pull_request) Successful in 39s
Build / build (18) (push) Successful in 1m2s
Build / build (20) (pull_request) Successful in 1m5s
Build / build (22) (pull_request) Successful in 1m0s

This commit is contained in:
Sainan 2025-02-24 06:05:00 +01:00
parent 50d687e59a
commit f58f8cefd6
4 changed files with 63 additions and 11 deletions

View File

@ -68,7 +68,9 @@ import {
ICalendarProgress, ICalendarProgress,
IPendingCouponDatabase, IPendingCouponDatabase,
IPendingCouponClient, IPendingCouponClient,
ILibraryAvailableDailyTaskInfo ILibraryAvailableDailyTaskInfo,
IDroneDatabase,
IDroneClient
} from "../../types/inventoryTypes/inventoryTypes"; } from "../../types/inventoryTypes/inventoryTypes";
import { IOid } from "../../types/commonTypes"; import { IOid } from "../../types/commonTypes";
import { import {
@ -349,6 +351,27 @@ const TypeXPItemSchema = new Schema<ITypeXPItem>(
{ _id: false } { _id: false }
); );
const droneSchema = new Schema<IDroneDatabase>(
{
ItemType: String,
CurrentHP: Number,
RepairStart: { type: Date, default: undefined }
},
{ id: false }
);
droneSchema.set("toJSON", {
virtuals: true,
transform(_document, obj) {
const client = obj as IDroneClient;
const db = obj as IDroneDatabase;
client.ItemId = toOid(db._id);
delete obj._id;
delete obj.__v;
}
});
const challengeProgressSchema = new Schema<IChallengeProgress>( const challengeProgressSchema = new Schema<IChallengeProgress>(
{ {
Progress: Number, Progress: Number,
@ -1148,8 +1171,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
CompletedSorties: [String], CompletedSorties: [String],
LastSortieReward: [Schema.Types.Mixed], LastSortieReward: [Schema.Types.Mixed],
//Resource_Drone[Uselees stuff] // Resource Extractor Drones
Drones: [Schema.Types.Mixed], Drones: [droneSchema],
//Active profile ico //Active profile ico
ActiveAvatarImageType: String, ActiveAvatarImageType: String,
@ -1299,6 +1322,7 @@ export type InventoryDocumentProps = {
PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>; PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>;
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>; WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
QuestKeys: Types.DocumentArray<IQuestKeyDatabase>; QuestKeys: Types.DocumentArray<IQuestKeyDatabase>;
Drones: Types.DocumentArray<IDroneDatabase>;
} & { [K in TEquipmentKey]: Types.DocumentArray<IEquipmentDatabase> }; } & { [K in TEquipmentKey]: Types.DocumentArray<IEquipmentDatabase> };
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types

View File

@ -24,7 +24,8 @@ import {
IKubrowPetEggDatabase, IKubrowPetEggDatabase,
IKubrowPetEggClient, IKubrowPetEggClient,
ILibraryAvailableDailyTaskInfo, ILibraryAvailableDailyTaskInfo,
ICalendarProgress ICalendarProgress,
IDroneClient
} from "@/src/types/inventoryTypes/inventoryTypes"; } from "@/src/types/inventoryTypes/inventoryTypes";
import { IGenericUpdate } from "../types/genericUpdate"; import { IGenericUpdate } from "../types/genericUpdate";
import { import {
@ -38,6 +39,7 @@ import { IEquipmentClient, IEquipmentDatabase, IItemConfig } from "../types/inve
import { import {
ExportArcanes, ExportArcanes,
ExportCustoms, ExportCustoms,
ExportDrones,
ExportFlavour, ExportFlavour,
ExportFusionBundles, ExportFusionBundles,
ExportGear, ExportGear,
@ -336,6 +338,12 @@ export const addItem = async (
} }
}; };
} }
if (typeName in ExportDrones) {
const inventoryChanges = addDrone(inventory, typeName);
return {
InventoryChanges: inventoryChanges
};
}
// Path-based duck typing // Path-based duck typing
switch (typeName.substr(1).split("/")[1]) { switch (typeName.substr(1).split("/")[1]) {
@ -823,6 +831,17 @@ const addMotorcycle = (
return inventoryChanges; return inventoryChanges;
}; };
const addDrone = (
inventory: TInventoryDatabaseDocument,
typeName: string,
inventoryChanges: IInventoryChanges = {}
): IInventoryChanges => {
const index = inventory.Drones.push({ ItemType: typeName, CurrentHP: ExportDrones[typeName].durability }) - 1;
inventoryChanges.Drones ??= [];
inventoryChanges.Drones.push(inventory.Drones[index].toJSON<IDroneClient>());
return inventoryChanges;
};
//TODO: wrong id is not erroring //TODO: wrong id is not erroring
export const addGearExpByCategory = ( export const addGearExpByCategory = (
inventory: TInventoryDatabaseDocument, inventory: TInventoryDatabaseDocument,

View File

@ -39,6 +39,7 @@ export interface IInventoryDatabase
| "DialogueHistory" | "DialogueHistory"
| "KubrowPetEggs" | "KubrowPetEggs"
| "PendingCoupon" | "PendingCoupon"
| "Drones"
| TEquipmentKey | TEquipmentKey
>, >,
InventoryDatabaseEquipment { InventoryDatabaseEquipment {
@ -63,6 +64,7 @@ export interface IInventoryDatabase
DialogueHistory?: IDialogueHistoryDatabase; DialogueHistory?: IDialogueHistoryDatabase;
KubrowPetEggs?: IKubrowPetEggDatabase[]; KubrowPetEggs?: IKubrowPetEggDatabase[];
PendingCoupon?: IPendingCouponDatabase; PendingCoupon?: IPendingCouponDatabase;
Drones: IDroneDatabase[];
} }
export interface IQuestKeyDatabase { export interface IQuestKeyDatabase {
@ -258,7 +260,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
Alignment: IAlignment; Alignment: IAlignment;
CompletedSorties: string[]; CompletedSorties: string[];
LastSortieReward: ILastSortieReward[]; LastSortieReward: ILastSortieReward[];
Drones: IDrone[]; Drones: IDroneClient[];
StepSequencers: IStepSequencer[]; StepSequencers: IStepSequencer[];
ActiveAvatarImageType: string; ActiveAvatarImageType: string;
ShipDecorations: IConsumable[]; ShipDecorations: IConsumable[];
@ -508,13 +510,20 @@ export interface IDiscoveredMarker {
discoveryState: number[]; discoveryState: number[];
} }
export interface IDrone { export interface IDroneClient {
ItemType: string; ItemType: string;
CurrentHP: number; CurrentHP: number;
ItemId: IOid; ItemId: IOid;
RepairStart?: IMongoDate; RepairStart?: IMongoDate;
} }
export interface IDroneDatabase {
ItemType: string;
CurrentHP: number;
_id: Types.ObjectId;
RepairStart?: Date;
}
export interface ITypeXPItem { export interface ITypeXPItem {
ItemType: string; ItemType: string;
XP: number; XP: number;

View File

@ -1,5 +1,5 @@
import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes"; import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
import { IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes"; import { IDroneClient, IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
export interface IPurchaseRequest { export interface IPurchaseRequest {
PurchaseParams: IPurchaseParams; PurchaseParams: IPurchaseParams;
@ -32,10 +32,10 @@ export type IInventoryChanges = {
[_ in SlotNames]?: IBinChanges; [_ in SlotNames]?: IBinChanges;
} & { } & {
[_ in TEquipmentKey]?: IEquipmentClient[]; [_ in TEquipmentKey]?: IEquipmentClient[];
} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundryClient } & Record< } & ICurrencyChanges & {
string, InfestedFoundry?: IInfestedFoundryClient;
IBinChanges | number | object[] | IInfestedFoundryClient Drones?: IDroneClient[];
>; } & Record<string, IBinChanges | number | object[] | IInfestedFoundryClient>;
export interface IAffiliationMods { export interface IAffiliationMods {
Tag: string; Tag: string;