2023-06-01 17:08:05 -07:00
|
|
|
import { RequestHandler } from "express";
|
2023-08-31 14:29:09 +04:00
|
|
|
import { missionInventoryUpdate } from "@/src/services/inventoryService";
|
2024-06-17 16:38:43 +02:00
|
|
|
import { combineRewardAndLootInventory, getRewards } from "@/src/services/missionInventoryUpdateService";
|
2023-09-10 00:10:21 +04:00
|
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
2024-05-28 13:45:06 +02:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
2023-09-10 00:10:21 +04:00
|
|
|
import { IMissionInventoryUpdateRequest } from "@/src/types/requestTypes";
|
2023-08-31 14:29:09 +04:00
|
|
|
/*
|
2023-09-06 14:02:54 +04:00
|
|
|
**** INPUT ****
|
2023-08-31 14:29:09 +04:00
|
|
|
- [ ] crossPlaySetting
|
|
|
|
- [ ] rewardsMultiplier
|
|
|
|
- [ ] ActiveBoosters
|
|
|
|
- [x] LongGuns
|
|
|
|
- [x] Pistols
|
|
|
|
- [x] Suits
|
|
|
|
- [x] Melee
|
|
|
|
- [x] RawUpgrades
|
|
|
|
- [x] MiscItems
|
|
|
|
- [x] RegularCredits
|
|
|
|
- [ ] RandomUpgradesIdentified
|
|
|
|
- [ ] MissionFailed
|
|
|
|
- [ ] MissionStatus
|
|
|
|
- [ ] CurrentLoadOutIds
|
|
|
|
- [ ] AliveTime
|
|
|
|
- [ ] MissionTime
|
2023-09-10 00:10:21 +04:00
|
|
|
- [x] Missions
|
2023-08-31 14:29:09 +04:00
|
|
|
- [ ] CompletedAlerts
|
|
|
|
- [ ] LastRegionPlayed
|
|
|
|
- [ ] GameModeId
|
|
|
|
- [ ] hosts
|
|
|
|
- [x] ChallengeProgress
|
|
|
|
- [ ] SeasonChallengeHistory
|
2023-09-05 07:37:30 -05:00
|
|
|
- [ ] PS (Passive anti-cheat data which includes your username, module list, process list, and system name.)
|
2023-08-31 14:29:09 +04:00
|
|
|
- [ ] ActiveDojoColorResearch
|
2023-09-06 14:02:54 +04:00
|
|
|
- [x] RewardInfo
|
2023-08-31 14:29:09 +04:00
|
|
|
- [ ] ReceivedCeremonyMsg
|
|
|
|
- [ ] LastCeremonyResetDate
|
2023-09-05 07:37:30 -05:00
|
|
|
- [ ] MissionPTS (Used to validate the mission/alive time above.)
|
|
|
|
- [ ] RepHash (A hash from the replication manager/RepMgr Unknown what it does.)
|
2023-08-31 14:29:09 +04:00
|
|
|
- [ ] EndOfMatchUpload
|
|
|
|
- [ ] ObjectiveReached
|
|
|
|
- [ ] FpsAvg
|
|
|
|
- [ ] FpsMin
|
|
|
|
- [ ] FpsMax
|
|
|
|
- [ ] FpsSamples
|
|
|
|
*/
|
2023-06-01 17:08:05 -07:00
|
|
|
|
2023-08-31 14:29:09 +04:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
2023-09-10 00:10:21 +04:00
|
|
|
const missionInventoryUpdateController: RequestHandler = async (req, res): Promise<void> => {
|
2024-05-28 13:45:06 +02:00
|
|
|
const accountId = await getAccountIdForRequest(req);
|
2023-08-31 14:29:09 +04:00
|
|
|
|
|
|
|
try {
|
2023-09-10 00:10:21 +04:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
|
|
|
const lootInventory = getJSONfromString(req.body.toString()) as IMissionInventoryUpdateRequest;
|
2023-09-06 14:02:54 +04:00
|
|
|
|
2023-09-10 00:10:21 +04:00
|
|
|
const { InventoryChanges, MissionRewards } = getRewards(lootInventory);
|
2023-09-06 14:02:54 +04:00
|
|
|
|
|
|
|
const { combinedInventoryChanges, TotalCredits, CreditsBonus, MissionCredits, FusionPoints } =
|
|
|
|
combineRewardAndLootInventory(InventoryChanges, lootInventory);
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-09-10 00:10:21 +04:00
|
|
|
const InventoryJson = JSON.stringify(await missionInventoryUpdate(combinedInventoryChanges, accountId));
|
2023-09-06 14:02:54 +04:00
|
|
|
res.json({
|
|
|
|
// InventoryJson, // this part will reset game data and missions will be locked
|
|
|
|
MissionRewards,
|
|
|
|
InventoryChanges,
|
|
|
|
TotalCredits,
|
|
|
|
CreditsBonus,
|
|
|
|
MissionCredits,
|
|
|
|
...(FusionPoints !== undefined && { FusionPoints })
|
|
|
|
});
|
2023-08-31 14:29:09 +04:00
|
|
|
} catch (err) {
|
|
|
|
console.error("Error parsing JSON data:", err);
|
|
|
|
}
|
2023-06-01 17:08:05 -07:00
|
|
|
};
|
|
|
|
|
2023-09-06 14:02:54 +04:00
|
|
|
/*
|
|
|
|
**** OUTPUT ****
|
|
|
|
- [x] InventoryJson
|
|
|
|
- [x] MissionRewards
|
|
|
|
- [x] TotalCredits
|
|
|
|
- [x] CreditsBonus
|
|
|
|
- [x] MissionCredits
|
|
|
|
- [x] InventoryChanges
|
|
|
|
- [x] FusionPoints
|
|
|
|
*/
|
|
|
|
|
2023-06-01 17:08:05 -07:00
|
|
|
export { missionInventoryUpdateController };
|