mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-12-01 15:03:31 +01:00
Fixes #243
Challenges level status for unlocking should look on previous level waiver amount, not on its value. Also, if second level is marked as locked, then all next levels should also be marked as locked.
This commit is contained in:
parent
679fe48871
commit
dd8834f1df
@ -1107,6 +1107,7 @@ public class ChallengesManager
|
|||||||
// The first level is always unlocked and previous for it is null.
|
// The first level is always unlocked and previous for it is null.
|
||||||
ChallengeLevel previousLevel = null;
|
ChallengeLevel previousLevel = null;
|
||||||
int doneChallengeCount = 0;
|
int doneChallengeCount = 0;
|
||||||
|
boolean previousUnlocked = true;
|
||||||
|
|
||||||
// For each challenge level, check how many the storageDataID has done
|
// For each challenge level, check how many the storageDataID has done
|
||||||
for (ChallengeLevel level : challengeLevelList)
|
for (ChallengeLevel level : challengeLevelList)
|
||||||
@ -1116,20 +1117,25 @@ public class ChallengesManager
|
|||||||
// remove waiver amount to get count of challenges that still necessary to do.
|
// remove waiver amount to get count of challenges that still necessary to do.
|
||||||
|
|
||||||
int challengesToDo = previousLevel == null ? 0 :
|
int challengesToDo = previousLevel == null ? 0 :
|
||||||
(previousLevel.getChallenges().size() - doneChallengeCount - level.getWaiverAmount());
|
(previousLevel.getChallenges().size() - doneChallengeCount - previousLevel.getWaiverAmount());
|
||||||
|
|
||||||
// As level already contains unique ids of challenges, just iterate through them.
|
// As level already contains unique ids of challenges, just iterate through them.
|
||||||
doneChallengeCount = (int) level.getChallenges().stream().filter(playerData::isChallengeDone).count();
|
doneChallengeCount = (int) level.getChallenges().stream().filter(playerData::isChallengeDone).count();
|
||||||
|
|
||||||
|
// Mark if level is unlocked
|
||||||
|
boolean unlocked = previousUnlocked && challengesToDo <= 0;
|
||||||
|
|
||||||
result.add(new LevelStatus(
|
result.add(new LevelStatus(
|
||||||
level,
|
level,
|
||||||
previousLevel,
|
previousLevel,
|
||||||
challengesToDo,
|
challengesToDo,
|
||||||
level.getChallenges().size() == doneChallengeCount,
|
level.getChallenges().size() == doneChallengeCount,
|
||||||
challengesToDo <= 0));
|
unlocked));
|
||||||
|
|
||||||
previousLevel = level;
|
previousLevel = level;
|
||||||
|
previousUnlocked = unlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1160,7 +1166,7 @@ public class ChallengesManager
|
|||||||
ChallengeLevel previousLevel = levelIndex < 1 ? null : challengeLevelList.get(levelIndex - 1);
|
ChallengeLevel previousLevel = levelIndex < 1 ? null : challengeLevelList.get(levelIndex - 1);
|
||||||
|
|
||||||
int challengesToDo = previousLevel == null ? 0 :
|
int challengesToDo = previousLevel == null ? 0 :
|
||||||
(previousLevel.getChallenges().size() - level.getWaiverAmount()) -
|
(previousLevel.getChallenges().size() - previousLevel.getWaiverAmount()) -
|
||||||
(int) previousLevel.getChallenges().stream().filter(playerData::isChallengeDone).count();
|
(int) previousLevel.getChallenges().stream().filter(playerData::isChallengeDone).count();
|
||||||
|
|
||||||
// As level already contains unique ids of challenges, just iterate through them.
|
// As level already contains unique ids of challenges, just iterate through them.
|
||||||
|
Loading…
Reference in New Issue
Block a user