forked from OpenWF/SpaceNinjaServer
Same idea as with typeCountSchema. The game needs to be able to store these safely in an i32 on the C++ side. Reviewed-on: OpenWF/SpaceNinjaServer#1797 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
|
|
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;
|
|
|
|
addFusionPoints(inventory, 80 * rewardQuantity);
|
|
await inventory.save();
|
|
|
|
res.json({
|
|
RewardItem: "/Lotus/StoreItems/Upgrades/Mods/FusionBundles/RareFusionBundle",
|
|
RewardQuantity: rewardQuantity,
|
|
StandingAwarded: rewardStanding,
|
|
InventoryChanges: {
|
|
FusionPoints: 80 * rewardQuantity
|
|
}
|
|
});
|
|
};
|