Skip to content

Commit

Permalink
Fixed per-point achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
neketka committed May 3, 2024
1 parent f833c46 commit 678b681
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
24 changes: 15 additions & 9 deletions server/src/achievement/achievement.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export class AchievementService {
user: User,
evTracker: EventTracker,
pointsAdded: number,
journeyComplete: boolean,
) {
const ability = this.abilityFactory.createForUser(user);

Expand Down Expand Up @@ -326,15 +327,20 @@ export class AchievementService {
// must either be both challenge + journey achievement
// total points achievement
// or journey/challenge achievement depending on what was completed
OR: [
{ achievementType: AchievementType.TOTAL_CHALLENGES_OR_JOURNEYS },
{ achievementType: AchievementType.TOTAL_POINTS },
{
achievementType: isJourney
? AchievementType.TOTAL_JOURNEYS
: AchievementType.TOTAL_CHALLENGES,
},
],
OR: journeyComplete
? [
{
achievementType:
AchievementType.TOTAL_CHALLENGES_OR_JOURNEYS,
},
{ achievementType: AchievementType.TOTAL_POINTS },
{
achievementType: isJourney
? AchievementType.TOTAL_JOURNEYS
: AchievementType.TOTAL_CHALLENGES,
},
]
: [{ achievementType: AchievementType.TOTAL_POINTS }],
},
{
// Only find non-completed achievements
Expand Down
13 changes: 6 additions & 7 deletions server/src/challenge/challenge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,12 @@ export class ChallengeService {
},
})) === 0;

if (isJourneyCompleted) {
await this.achievementService.checkAchievementProgress(
user,
eventTracker,
deltaScore,
);
}
await this.achievementService.checkAchievementProgress(
user,
eventTracker,
deltaScore,
isJourneyCompleted,
);

await this.eventService.emitUpdateLeaderPosition({
playerId: newUser.id,
Expand Down

0 comments on commit 678b681

Please sign in to comment.