2023-08-31 14:29:09 +04:00
|
|
|
import { RequestHandler } from "express";
|
2024-05-28 13:45:06 +02:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
2024-05-15 21:55:59 +02:00
|
|
|
import { config } from "@/src/services/configService";
|
2024-05-03 21:04:01 +02:00
|
|
|
import allScans from "@/static/fixed_responses/allScans.json";
|
2024-12-28 18:31:10 +01:00
|
|
|
import { ExportEnemies } from "warframe-public-export-plus";
|
2025-01-19 01:58:59 +01:00
|
|
|
import { getInventory } from "@/src/services/inventoryService";
|
2025-02-06 04:42:59 -08:00
|
|
|
import { getStats } from "@/src/services/statsService";
|
2025-02-11 21:27:05 -08:00
|
|
|
import { IStatsClient } from "@/src/types/statTypes";
|
2023-08-31 14:29:09 +04:00
|
|
|
|
2024-05-08 22:53:06 +02:00
|
|
|
const viewController: RequestHandler = async (req, res) => {
|
2024-05-28 13:45:06 +02:00
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2025-01-19 01:58:59 +01:00
|
|
|
const inventory = await getInventory(accountId, "XPInfo");
|
2025-02-06 04:42:59 -08:00
|
|
|
const playerStats = await getStats(accountId);
|
2024-05-08 22:53:06 +02:00
|
|
|
|
2025-02-11 21:27:05 -08:00
|
|
|
const responseJson = playerStats.toJSON() as IStatsClient;
|
2025-02-06 04:42:59 -08:00
|
|
|
responseJson.Weapons ??= [];
|
2024-05-08 22:53:06 +02:00
|
|
|
for (const item of inventory.XPInfo) {
|
2025-02-06 04:42:59 -08:00
|
|
|
const weaponIndex = responseJson.Weapons.findIndex(element => element.type == item.ItemType);
|
|
|
|
if (weaponIndex !== -1) {
|
2025-03-29 15:20:54 -07:00
|
|
|
responseJson.Weapons[weaponIndex].xp = item.XP;
|
2025-02-06 04:42:59 -08:00
|
|
|
} else {
|
|
|
|
responseJson.Weapons.push({ type: item.ItemType, xp: item.XP });
|
|
|
|
}
|
2024-05-08 22:53:06 +02:00
|
|
|
}
|
2024-05-03 21:04:01 +02:00
|
|
|
if (config.unlockAllScans) {
|
2025-01-19 01:58:59 +01:00
|
|
|
const scans = new Set(allScans);
|
2024-12-28 18:31:10 +01:00
|
|
|
for (const type of Object.keys(ExportEnemies.avatars)) {
|
2025-02-06 04:42:59 -08:00
|
|
|
if (!scans.has(type)) scans.add(type);
|
2024-12-28 18:31:10 +01:00
|
|
|
}
|
2025-02-06 04:42:59 -08:00
|
|
|
responseJson.Scans ??= [];
|
2025-01-19 01:58:59 +01:00
|
|
|
for (const type of scans) {
|
|
|
|
responseJson.Scans.push({ type: type, scans: 9999 });
|
|
|
|
}
|
2024-05-03 21:04:01 +02:00
|
|
|
}
|
|
|
|
res.json(responseJson);
|
2023-08-31 14:29:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
export { viewController };
|