Skip to content

Commit

Permalink
fix(front): use correct xp calculations on profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
tsa96 committed Oct 23, 2024
1 parent 75ee2ad commit f24be95
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class PlayerCardComponent implements OnInit {
if (!user) return;
this.user = user;
this.level = user.userStats.level;
this.xp = user.userStats.cosXP as number;
this.xp = user.userStats.cosXP;
this.currLevelXp = this.xpService.getCosmeticXpForLevel(this.level);
this.nextLevelXp = this.xpService.getCosmeticXpForLevel(this.level + 1);
});
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/app/pages/profile/profile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
@if (!hasRole(Role.DELETED)) {
<div class="flex w-full gap-2 font-display text-2xl">
<div class="flex-grow">
<p class="pb-1 leading-none">{{ currXp }} / {{ nextXp }} xp</p>
<p-progressBar class="h-2 w-full" [showValue]="false" [value]="(100 * currXp) / nextXp" />
<p class="pb-1 leading-none">{{ xp - currLevelXp }} / {{ nextLevelXp - currLevelXp }} xp</p>
<p-progressBar class="h-2 w-full" [showValue]="false" [value]="(100 * (xp - currLevelXp)) / (nextLevelXp - currLevelXp)" />
</div>
<m-level-indicator class="mt-auto" [totalLevel]="user.userStats.level" />
</div>
Expand Down
19 changes: 11 additions & 8 deletions apps/frontend/src/app/pages/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ export class ProfileComponent implements OnInit {
followingUsers: Follow[] = [];
followedByUsers: Follow[] = [];
localFollowStatus = new BehaviorSubject<Follow>(null);
currXp: number;
nextXp: number;
level: number;
xp: number;
currLevelXp: number;
nextLevelXp: number;
protected credits: MapCredit[];
protected creditMap: Partial<Record<MapCreditType, MapCredit[]>>;

Expand Down Expand Up @@ -132,12 +134,13 @@ export class ProfileComponent implements OnInit {

this.avatarLoaded = true;
this.countryDisplayName = ISOCountryCode[this.user.country];
this.currXp =
(user.userStats.cosXP as number) -
this.xpService.getCosmeticXpForLevel(user.userStats.level);
this.nextXp =
this.xpService.getCosmeticXpForLevel(user.userStats.level + 1) -
this.xpService.getCosmeticXpForLevel(user.userStats.level);

this.level = user.userStats.level;
this.xp = user.userStats.cosXP;
this.currLevelXp = this.xpService.getCosmeticXpForLevel(this.level);
this.nextLevelXp = this.xpService.getCosmeticXpForLevel(
this.level + 1
);

this.usersService.getUserFollows(this.user).subscribe({
next: (response) => (this.followingUsers = response.data),
Expand Down

0 comments on commit f24be95

Please sign in to comment.