返回提交历史
Modified
src/controllers/api/dronesController.ts
+13
-12
Modified
src/controllers/api/inventoryController.ts
+3
-0
Modified
src/types/inventoryTypes/inventoryTypes.ts
+1
-1
XFEstudio/XFESpaceNinjaServer
chore: legacy drones support (#3587)
Closes #3586 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3587 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
3a716981
代码差异
3 个文件
+17
-13
@@ -1,34 +1,35 @@
1
import { toMongoDate, toOid } from "../../helpers/inventoryHelpers.ts";
1
import { toMongoDate2, toOid2 } from "../../helpers/inventoryHelpers.ts";
2
2
import { addMiscItems, getInventory } from "../../services/inventoryService.ts";
3
3
import { fromStoreItem } from "../../services/itemDataService.ts";
4
import { getAccountIdForRequest } from "../../services/loginService.ts";
4
import { getAccountForRequest } from "../../services/loginService.ts";
5
5
import { getRandomInt, getRandomWeightedRewardUc } from "../../services/rngService.ts";
6
import type { IMongoDate, IOid } from "../../types/commonTypes.ts";
6
import type { IMongoDateWithLegacySupport, IOidWithLegacySupport } from "../../types/commonTypes.ts";
7
7
import type { IDroneClient } from "../../types/inventoryTypes/inventoryTypes.ts";
8
8
import type { IInventoryChanges } from "../../types/purchaseTypes.ts";
9
9
import type { RequestHandler } from "express";
10
10
import { ExportDrones, ExportResources, ExportSystems } from "warframe-public-export-plus";
11
11
12
12
export const dronesController: RequestHandler = async (req, res) => {
13
const accountId = await getAccountIdForRequest(req);
13
const account = await getAccountForRequest(req);
14
const accountId = account._id.toString();
14
15
if ("GetActive" in req.query) {
15
16
const inventory = await getInventory(accountId, "Drones");
16
17
const activeDrones: IActiveDrone[] = [];
17
18
for (const drone of inventory.Drones) {
18
19
if (drone.DeployTime) {
19
20
activeDrones.push({
20
DeployTime: toMongoDate(drone.DeployTime),
21
DeployTime: toMongoDate2(drone.DeployTime, account.BuildLabel),
21
22
System: drone.System!,
22
ItemId: toOid(drone._id),
23
ItemId: toOid2(drone._id, account.BuildLabel),
23
24
ItemType: drone.ItemType,
24
25
CurrentHP: drone.CurrentHP,
25
DamageTime: toMongoDate(drone.DamageTime!),
26
DamageTime: toMongoDate2(drone.DamageTime!, account.BuildLabel),
26
27
PendingDamage: drone.PendingDamage!,
27
28
Resources: [
28
29
{
29
30
ItemType: drone.ResourceType!,
30
31
BinTotal: drone.ResourceCount!,
31
StartTime: toMongoDate(drone.DeployTime)
32
StartTime: toMongoDate2(drone.DeployTime, account.BuildLabel)
32
33
}
33
34
]
34
35
});
@@ -130,16 +131,16 @@ export const dronesController: RequestHandler = async (req, res) => {
130
131
};
131
132
132
133
interface IActiveDrone {
133
DeployTime: IMongoDate;
134
DeployTime: IMongoDateWithLegacySupport;
134
135
System: number;
135
ItemId: IOid;
136
ItemId: IOidWithLegacySupport;
136
137
ItemType: string;
137
138
CurrentHP: number;
138
DamageTime: IMongoDate;
139
DamageTime: IMongoDateWithLegacySupport;
139
140
PendingDamage: number;
140
141
Resources: {
141
142
ItemType: string;
142
143
BinTotal: number;
143
StartTime: IMongoDate;
144
StartTime: IMongoDateWithLegacySupport;
144
145
}[];
145
146
}
@@ -737,6 +737,9 @@ export const getInventoryResponse = async (
737
737
}
738
738
}
739
739
}
740
for (const item of inventoryResponse.Drones) {
741
toLegacyOid(item.ItemId);
742
}
740
743
}
741
744
}
742
745
}
@@ -697,7 +697,7 @@ export interface IDiscoveredMarker {
697
697
export interface IDroneClient {
698
698
ItemType: string;
699
699
CurrentHP: number;
700
ItemId: IOid;
700
ItemId: IOidWithLegacySupport;
701
701
RepairStart?: IMongoDate;
702
702
}
703
703