Fix the issue with incorrect unlock status. (#169)

The issue was that it never decrease challengesToDo with completed challenges from previous level, so only first level was unlocked. My mistake.
This commit is contained in:
BONNe 2019-09-02 09:05:18 +03:00 committed by BuildTools
parent 0026cb7404
commit 707625a9da

View File

@ -989,7 +989,8 @@ public class ChallengesManager
ChallengeLevel previousLevel = levelIndex < 1 ? null : challengeLevelList.get(levelIndex - 1);
int challengesToDo = previousLevel == null ? 0 :
(previousLevel.getChallenges().size() - level.getWaiverAmount());
(previousLevel.getChallenges().size() - level.getWaiverAmount()) -
(int) previousLevel.getChallenges().stream().filter(playerData::isChallengeDone).count();
// As level already contains unique ids of challenges, just iterate through them.
int doneChallengeCount = (int) level.getChallenges().stream().filter(playerData::isChallengeDone).count();