2025-04-23 11:37:10 -07:00
|
|
|
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
|
2025-02-25 17:31:52 -08:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
|
|
import { RequestHandler } from "express";
|
|
|
|
|
|
|
|
export const claimLibraryDailyTaskRewardController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = await getAccountIdForRequest(req);
|
|
|
|
const inventory = await getInventory(accountId);
|
|
|
|
|
|
|
|
const rewardQuantity = inventory.LibraryActiveDailyTaskInfo!.RewardQuantity;
|
|
|
|
const rewardStanding = inventory.LibraryActiveDailyTaskInfo!.RewardStanding;
|
|
|
|
inventory.LibraryActiveDailyTaskInfo = undefined;
|
|
|
|
inventory.LibraryAvailableDailyTaskInfo = undefined;
|
|
|
|
|
|
|
|
let syndicate = inventory.Affiliations.find(x => x.Tag == "LibrarySyndicate");
|
|
|
|
if (!syndicate) {
|
|
|
|
syndicate = inventory.Affiliations[inventory.Affiliations.push({ Tag: "LibrarySyndicate", Standing: 0 }) - 1];
|
|
|
|
}
|
|
|
|
syndicate.Standing += rewardStanding;
|
|
|
|
|
2025-04-23 11:37:10 -07:00
|
|
|
addFusionPoints(inventory, 80 * rewardQuantity);
|
2025-02-25 17:31:52 -08:00
|
|
|
await inventory.save();
|
|
|
|
|
|
|
|
res.json({
|
|
|
|
RewardItem: "/Lotus/StoreItems/Upgrades/Mods/FusionBundles/RareFusionBundle",
|
|
|
|
RewardQuantity: rewardQuantity,
|
|
|
|
StandingAwarded: rewardStanding,
|
|
|
|
InventoryChanges: {
|
|
|
|
FusionPoints: 80 * rewardQuantity
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|