feat: acquisition of resource extractor drones #998
@ -68,7 +68,9 @@ import {
 | 
			
		||||
    ICalendarProgress,
 | 
			
		||||
    IPendingCouponDatabase,
 | 
			
		||||
    IPendingCouponClient,
 | 
			
		||||
    ILibraryAvailableDailyTaskInfo
 | 
			
		||||
    ILibraryAvailableDailyTaskInfo,
 | 
			
		||||
    IDroneDatabase,
 | 
			
		||||
    IDroneClient
 | 
			
		||||
} from "../../types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IOid } from "../../types/commonTypes";
 | 
			
		||||
import {
 | 
			
		||||
@ -349,6 +351,27 @@ const TypeXPItemSchema = new Schema<ITypeXPItem>(
 | 
			
		||||
    { _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>(
 | 
			
		||||
    {
 | 
			
		||||
        Progress: Number,
 | 
			
		||||
@ -1148,8 +1171,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
			
		||||
        CompletedSorties: [String],
 | 
			
		||||
        LastSortieReward: [Schema.Types.Mixed],
 | 
			
		||||
 | 
			
		||||
        //Resource_Drone[Uselees stuff]
 | 
			
		||||
        Drones: [Schema.Types.Mixed],
 | 
			
		||||
        // Resource Extractor Drones
 | 
			
		||||
        Drones: [droneSchema],
 | 
			
		||||
 | 
			
		||||
        //Active profile ico
 | 
			
		||||
        ActiveAvatarImageType: String,
 | 
			
		||||
@ -1299,6 +1322,7 @@ export type InventoryDocumentProps = {
 | 
			
		||||
    PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>;
 | 
			
		||||
    WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
 | 
			
		||||
    QuestKeys: Types.DocumentArray<IQuestKeyDatabase>;
 | 
			
		||||
    Drones: Types.DocumentArray<IDroneDatabase>;
 | 
			
		||||
} & { [K in TEquipmentKey]: Types.DocumentArray<IEquipmentDatabase> };
 | 
			
		||||
 | 
			
		||||
// eslint-disable-next-line @typescript-eslint/ban-types
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,8 @@ import {
 | 
			
		||||
    IKubrowPetEggDatabase,
 | 
			
		||||
    IKubrowPetEggClient,
 | 
			
		||||
    ILibraryAvailableDailyTaskInfo,
 | 
			
		||||
    ICalendarProgress
 | 
			
		||||
    ICalendarProgress,
 | 
			
		||||
    IDroneClient
 | 
			
		||||
} from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IGenericUpdate } from "../types/genericUpdate";
 | 
			
		||||
import {
 | 
			
		||||
@ -38,6 +39,7 @@ import { IEquipmentClient, IEquipmentDatabase, IItemConfig } from "../types/inve
 | 
			
		||||
import {
 | 
			
		||||
    ExportArcanes,
 | 
			
		||||
    ExportCustoms,
 | 
			
		||||
    ExportDrones,
 | 
			
		||||
    ExportFlavour,
 | 
			
		||||
    ExportFusionBundles,
 | 
			
		||||
    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
 | 
			
		||||
    switch (typeName.substr(1).split("/")[1]) {
 | 
			
		||||
@ -823,6 +831,17 @@ const addMotorcycle = (
 | 
			
		||||
    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
 | 
			
		||||
export const addGearExpByCategory = (
 | 
			
		||||
    inventory: TInventoryDatabaseDocument,
 | 
			
		||||
 | 
			
		||||
@ -39,6 +39,7 @@ export interface IInventoryDatabase
 | 
			
		||||
            | "DialogueHistory"
 | 
			
		||||
            | "KubrowPetEggs"
 | 
			
		||||
            | "PendingCoupon"
 | 
			
		||||
            | "Drones"
 | 
			
		||||
            | TEquipmentKey
 | 
			
		||||
        >,
 | 
			
		||||
        InventoryDatabaseEquipment {
 | 
			
		||||
@ -63,6 +64,7 @@ export interface IInventoryDatabase
 | 
			
		||||
    DialogueHistory?: IDialogueHistoryDatabase;
 | 
			
		||||
    KubrowPetEggs?: IKubrowPetEggDatabase[];
 | 
			
		||||
    PendingCoupon?: IPendingCouponDatabase;
 | 
			
		||||
    Drones: IDroneDatabase[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IQuestKeyDatabase {
 | 
			
		||||
@ -258,7 +260,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
 | 
			
		||||
    Alignment: IAlignment;
 | 
			
		||||
    CompletedSorties: string[];
 | 
			
		||||
    LastSortieReward: ILastSortieReward[];
 | 
			
		||||
    Drones: IDrone[];
 | 
			
		||||
    Drones: IDroneClient[];
 | 
			
		||||
    StepSequencers: IStepSequencer[];
 | 
			
		||||
    ActiveAvatarImageType: string;
 | 
			
		||||
    ShipDecorations: IConsumable[];
 | 
			
		||||
@ -508,13 +510,20 @@ export interface IDiscoveredMarker {
 | 
			
		||||
    discoveryState: number[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IDrone {
 | 
			
		||||
export interface IDroneClient {
 | 
			
		||||
    ItemType: string;
 | 
			
		||||
    CurrentHP: number;
 | 
			
		||||
    ItemId: IOid;
 | 
			
		||||
    RepairStart?: IMongoDate;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IDroneDatabase {
 | 
			
		||||
    ItemType: string;
 | 
			
		||||
    CurrentHP: number;
 | 
			
		||||
    _id: Types.ObjectId;
 | 
			
		||||
    RepairStart?: Date;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ITypeXPItem {
 | 
			
		||||
    ItemType: string;
 | 
			
		||||
    XP: number;
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
 | 
			
		||||
import { IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IDroneClient, IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
 | 
			
		||||
 | 
			
		||||
export interface IPurchaseRequest {
 | 
			
		||||
    PurchaseParams: IPurchaseParams;
 | 
			
		||||
@ -32,10 +32,10 @@ export type IInventoryChanges = {
 | 
			
		||||
    [_ in SlotNames]?: IBinChanges;
 | 
			
		||||
} & {
 | 
			
		||||
    [_ in TEquipmentKey]?: IEquipmentClient[];
 | 
			
		||||
} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundryClient } & Record<
 | 
			
		||||
        string,
 | 
			
		||||
        IBinChanges | number | object[] | IInfestedFoundryClient
 | 
			
		||||
    >;
 | 
			
		||||
} & ICurrencyChanges & {
 | 
			
		||||
        InfestedFoundry?: IInfestedFoundryClient;
 | 
			
		||||
        Drones?: IDroneClient[];
 | 
			
		||||
    } & Record<string, IBinChanges | number | object[] | IInfestedFoundryClient>;
 | 
			
		||||
 | 
			
		||||
export interface IAffiliationMods {
 | 
			
		||||
    Tag: string;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user