SpaceNinjaServer/src/controllers/api/getVoidProjectionRewardsController.ts
Sainan 39f0f7de9a
Some checks failed
Build / build (20) (push) Successful in 37s
Build / build (18) (push) Successful in 1m6s
Build / build (22) (push) Successful in 1m12s
Build Docker image / docker (push) Has been cancelled
feat: cracking relics in non-endless missions (#1010)
Closes #415

Reviewed-on: #1010
Co-authored-by: Sainan <sainan@calamity.inc>
Co-committed-by: Sainan <sainan@calamity.inc>
2025-02-25 04:38:47 -08:00

39 lines
1.4 KiB
TypeScript

import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { crackRelic } from "@/src/helpers/relicHelper";
import { getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IVoidTearParticipantInfo } from "@/src/types/requestTypes";
import { RequestHandler } from "express";
export const getVoidProjectionRewardsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const data = getJSONfromString<IVoidProjectionRewardRequest>(String(req.body));
if (data.ParticipantInfo.QualifiesForReward && !data.ParticipantInfo.HaveRewardResponse) {
const inventory = await getInventory(accountId);
await crackRelic(inventory, data.ParticipantInfo);
await inventory.save();
}
const response: IVoidProjectionRewardResponse = {
CurrentWave: data.CurrentWave,
ParticipantInfo: data.ParticipantInfo,
DifficultyTier: data.DifficultyTier
};
res.json(response);
};
interface IVoidProjectionRewardRequest {
CurrentWave: number;
ParticipantInfo: IVoidTearParticipantInfo;
VoidTier: string;
DifficultyTier: number;
VoidProjectionRemovalHash: string;
}
interface IVoidProjectionRewardResponse {
CurrentWave: number;
ParticipantInfo: IVoidTearParticipantInfo;
DifficultyTier: number;
}