feat: rewards for enemy caches & rathuum #384

Merged
Sainan merged 2 commits from more-rewards into main 2024-06-23 06:12:32 -07:00
Showing only changes of commit ba32ff6c4b - Show all commits

View File

@ -23,7 +23,10 @@ const getRewards = ({
return { InventoryChanges: {}, MissionRewards: [] }; return { InventoryChanges: {}, MissionRewards: [] };
} }
const rewardManifests = ExportRegions[RewardInfo.node]?.rewardManifests ?? []; const drops: IReward[] = [];
if (RewardInfo.node in ExportRegions) {
const region = ExportRegions[RewardInfo.node];
const rewardManifests = region.rewardManifests ?? [];
if (rewardManifests.length == 0) { if (rewardManifests.length == 0) {
return { InventoryChanges: {}, MissionRewards: [] }; return { InventoryChanges: {}, MissionRewards: [] };
} }
@ -38,7 +41,6 @@ const getRewards = ({
const rotationCount = RewardInfo.rewardQualifications?.length || 0; const rotationCount = RewardInfo.rewardQualifications?.length || 0;
rotations = getRotations(rotationCount); rotations = getRotations(rotationCount);
} }
const drops: IReward[] = [];
rewardManifests rewardManifests
.map(name => ExportRewards[name]) .map(name => ExportRewards[name])
.forEach(table => { .forEach(table => {
@ -51,6 +53,17 @@ const getRewards = ({
} }
}); });
if (region.cacheRewardManifest && RewardInfo.EnemyCachesFound) {
const deck = ExportRewards[region.cacheRewardManifest];
for (let rotation = 0; rotation != RewardInfo.EnemyCachesFound; ++rotation) {
const drop = getRandomRewardByChance(deck[rotation]);
if (drop) {
drops.push(drop);
}
}
}
}
logger.debug("Mission rewards:", drops); logger.debug("Mission rewards:", drops);
return formatRewardsToInventoryType(drops); return formatRewardsToInventoryType(drops);
}; };