返回提交历史
Modified
src/models/inventoryModels/inventoryModel.ts
+27
-3
Modified
src/services/inventoryService.ts
+20
-1
Modified
src/types/inventoryTypes/inventoryTypes.ts
+11
-2
Modified
src/types/purchaseTypes.ts
+5
-5
XFEstudio/SpaceNinjaServer
feat: acquisition of resource extractor drones (#998)
Related to #793 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/998 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>
ebb28d56
代码差异
4 个文件
+63
-11
@@ -68,7 +68,9 @@ import {
68
68
ICalendarProgress,
69
69
IPendingCouponDatabase,
70
70
IPendingCouponClient,
71
ILibraryAvailableDailyTaskInfo
71
ILibraryAvailableDailyTaskInfo,
72
IDroneDatabase,
73
IDroneClient
72
74
} from "../../types/inventoryTypes/inventoryTypes";
73
75
import { IOid } from "../../types/commonTypes";
74
76
import {
@@ -349,6 +351,27 @@ const TypeXPItemSchema = new Schema<ITypeXPItem>(
349
351
{ _id: false }
350
352
);
351
353
354
const droneSchema = new Schema<IDroneDatabase>(
355
{
356
ItemType: String,
357
CurrentHP: Number,
358
RepairStart: { type: Date, default: undefined }
359
},
360
{ id: false }
361
);
362
droneSchema.set("toJSON", {
363
virtuals: true,
364
transform(_document, obj) {
365
const client = obj as IDroneClient;
366
const db = obj as IDroneDatabase;
367
368
client.ItemId = toOid(db._id);
369
370
delete obj._id;
371
delete obj.__v;
372
}
373
});
374
352
375
const challengeProgressSchema = new Schema<IChallengeProgress>(
353
376
{
354
377
Progress: Number,
@@ -1148,8 +1171,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1148
1171
CompletedSorties: [String],
1149
1172
LastSortieReward: [Schema.Types.Mixed],
1150
1173
1151
//Resource_Drone[Uselees stuff]
1152
Drones: [Schema.Types.Mixed],
1174
// Resource Extractor Drones
1175
Drones: [droneSchema],
1153
1176
1154
1177
//Active profile ico
1155
1178
ActiveAvatarImageType: String,
@@ -1299,6 +1322,7 @@ export type InventoryDocumentProps = {
1299
1322
PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>;
1300
1323
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
1301
1324
QuestKeys: Types.DocumentArray<IQuestKeyDatabase>;
1325
Drones: Types.DocumentArray<IDroneDatabase>;
1302
1326
} & { [K in TEquipmentKey]: Types.DocumentArray<IEquipmentDatabase> };
1303
1327
1304
1328
// eslint-disable-next-line @typescript-eslint/ban-types
@@ -24,7 +24,8 @@ import {
24
24
IKubrowPetEggDatabase,
25
25
IKubrowPetEggClient,
26
26
ILibraryAvailableDailyTaskInfo,
27
ICalendarProgress
27
ICalendarProgress,
28
IDroneClient
28
29
} from "@/src/types/inventoryTypes/inventoryTypes";
29
30
import { IGenericUpdate } from "../types/genericUpdate";
30
31
import {
@@ -38,6 +39,7 @@ import { IEquipmentClient, IEquipmentDatabase, IItemConfig } from "../types/inve
38
39
import {
39
40
ExportArcanes,
40
41
ExportCustoms,
42
ExportDrones,
41
43
ExportFlavour,
42
44
ExportFusionBundles,
43
45
ExportGear,
@@ -336,6 +338,12 @@ export const addItem = async (
336
338
}
337
339
};
338
340
}
341
if (typeName in ExportDrones) {
342
const inventoryChanges = addDrone(inventory, typeName);
343
return {
344
InventoryChanges: inventoryChanges
345
};
346
}
339
347
340
348
// Path-based duck typing
341
349
switch (typeName.substr(1).split("/")[1]) {
@@ -809,6 +817,17 @@ const addMotorcycle = (
809
817
return inventoryChanges;
810
818
};
811
819
820
const addDrone = (
821
inventory: TInventoryDatabaseDocument,
822
typeName: string,
823
inventoryChanges: IInventoryChanges = {}
824
): IInventoryChanges => {
825
const index = inventory.Drones.push({ ItemType: typeName, CurrentHP: ExportDrones[typeName].durability }) - 1;
826
inventoryChanges.Drones ??= [];
827
inventoryChanges.Drones.push(inventory.Drones[index].toJSON<IDroneClient>());
828
return inventoryChanges;
829
};
830
812
831
//TODO: wrong id is not erroring
813
832
export const addGearExpByCategory = (
814
833
inventory: TInventoryDatabaseDocument,
@@ -39,6 +39,7 @@ export interface IInventoryDatabase
39
39
| "DialogueHistory"
40
40
| "KubrowPetEggs"
41
41
| "PendingCoupon"
42
| "Drones"
42
43
| TEquipmentKey
43
44
>,
44
45
InventoryDatabaseEquipment {
@@ -63,6 +64,7 @@ export interface IInventoryDatabase
63
64
DialogueHistory?: IDialogueHistoryDatabase;
64
65
KubrowPetEggs?: IKubrowPetEggDatabase[];
65
66
PendingCoupon?: IPendingCouponDatabase;
67
Drones: IDroneDatabase[];
66
68
}
67
69
68
70
export interface IQuestKeyDatabase {
@@ -258,7 +260,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
258
260
Alignment: IAlignment;
259
261
CompletedSorties: string[];
260
262
LastSortieReward: ILastSortieReward[];
261
Drones: IDrone[];
263
Drones: IDroneClient[];
262
264
StepSequencers: IStepSequencer[];
263
265
ActiveAvatarImageType: string;
264
266
ShipDecorations: IConsumable[];
@@ -508,13 +510,20 @@ export interface IDiscoveredMarker {
508
510
discoveryState: number[];
509
511
}
510
512
511
export interface IDrone {
513
export interface IDroneClient {
512
514
ItemType: string;
513
515
CurrentHP: number;
514
516
ItemId: IOid;
515
517
RepairStart?: IMongoDate;
516
518
}
517
519
520
export interface IDroneDatabase {
521
ItemType: string;
522
CurrentHP: number;
523
_id: Types.ObjectId;
524
RepairStart?: Date;
525
}
526
518
527
export interface ITypeXPItem {
519
528
ItemType: string;
520
529
XP: number;
@@ -1,5 +1,5 @@
1
1
import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
2
import { IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
2
import { IDroneClient, IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
3
3
4
4
export interface IPurchaseRequest {
5
5
PurchaseParams: IPurchaseParams;
@@ -32,10 +32,10 @@ export type IInventoryChanges = {
32
32
[_ in SlotNames]?: IBinChanges;
33
33
} & {
34
34
[_ in TEquipmentKey]?: IEquipmentClient[];
35
} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundryClient } & Record<
36
string,
37
IBinChanges | number | object[] | IInfestedFoundryClient
38
>;
35
} & ICurrencyChanges & {
36
InfestedFoundry?: IInfestedFoundryClient;
37
Drones?: IDroneClient[];
38
} & Record<string, IBinChanges | number | object[] | IInfestedFoundryClient>;
39
39
40
40
export interface IAffiliationMods {
41
41
Tag: string;