feat: opening relics in endless missions #713

Merged
Sainan merged 3 commits from open-relic into main 2025-01-05 20:35:36 -08:00
Showing only changes of commit 38d8fc448e - Show all commits

View File

@ -22,7 +22,7 @@ export const getVoidProjectionRewardsController: RequestHandler = async (req, re
logger.debug(`opening a relic of quality ${relic.quality}; rarity weights are`, weights); logger.debug(`opening a relic of quality ${relic.quality}; rarity weights are`, weights);
const reward = getRandomWeightedReward2( const reward = getRandomWeightedReward2(
ExportRewards[relic.rewardManifest][0] as { type: string; itemCount: number; rarity: TRarity }[], // rarity is nullable in PE+ typings, but always present for relics ExportRewards[relic.rewardManifest][0] as { type: string; itemCount: number; rarity: TRarity }[], // rarity is nullable in PE+ typings, but always present for relics
refinementToWeights[relic.quality] weights
)!; )!;
logger.debug(`relic rolled`, reward); logger.debug(`relic rolled`, reward);
response.ParticipantInfo.Reward = reward.type; response.ParticipantInfo.Reward = reward.type;
coderabbitai[bot] commented 2025-01-04 19:05:07 -08:00 (Migrated from github.com)
Review

⚠️ Potential issue

Confirm relic existence

When retrieving relic from ExportRelics[data.ParticipantInfo.VoidProjection], handle the case where the key might not exist. An undefined relic lookup could cause runtime errors.

-        const relic = ExportRelics[data.ParticipantInfo.VoidProjection];
+        const relicKey = data.ParticipantInfo.VoidProjection;
+        if (!ExportRelics[relicKey]) {
+            logger.warn(`Relic with key '${relicKey}' not found`);
+            return res.status(400).json({ error: "Invalid relic" });
+        }
+        const relic = ExportRelics[relicKey];

Committable suggestion skipped: line range outside the PR's diff.

_:warning: Potential issue_ **Confirm relic existence** When retrieving `relic` from `ExportRelics[data.ParticipantInfo.VoidProjection]`, handle the case where the key might not exist. An undefined relic lookup could cause runtime errors. ```diff - const relic = ExportRelics[data.ParticipantInfo.VoidProjection]; + const relicKey = data.ParticipantInfo.VoidProjection; + if (!ExportRelics[relicKey]) { + logger.warn(`Relic with key '${relicKey}' not found`); + return res.status(400).json({ error: "Invalid relic" }); + } + const relic = ExportRelics[relicKey]; ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->