Skip to content

Commit

Permalink
Properly check benefit eligibility
Browse files Browse the repository at this point in the history
Fixes #697
  • Loading branch information
RussellLVP committed Jun 9, 2020
1 parent c4f9f40 commit 9f9bc01
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions javascript/features/collectables/collectables.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,14 @@ export default class Collectables extends Feature {
// tied to a particular achievement that can be awarded to the |player|. This method is the
// canonical place for such associations to live, used by both JavaScript and Pawn code.
isPlayerEligibleForBenefit(player, benefit) {
const requiredAchievements = kBenefitMapping.get(benefit) || [];
const requiredAchievement = kBenefitMapping.get(benefit);
const achievements = this.manager_.getDelegate(CollectableDatabase.kAchievement);

// Allow the |benefit| if the requirements are not known, otherwise it's unachievable.
if (!requiredAchievements.length || !achievements)
if (!requiredAchievement)
return true;

for (const achievement of requiredAchievements) {
if (!achievements.hasAchievement(player, achievement, /* round= */ false))
return false;
}

return true;
return achievements.hasAchievement(player, requiredAchievement, /* round= */ false);
}

// ---------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 9f9bc01

Please sign in to comment.