diff --git a/src/common/model/player/impl/scoresaber-player.ts b/src/common/model/player/impl/scoresaber-player.ts index d498ce4..2006ff8 100644 --- a/src/common/model/player/impl/scoresaber-player.ts +++ b/src/common/model/player/impl/scoresaber-player.ts @@ -24,9 +24,9 @@ export default interface ScoreSaberPlayer extends Player { pp: number; /** - * The amount of pp gained compared to yesterday. + * The change in pp compared to yesterday. */ - ppGain: number; + ppChange: number; /** * The role the player has. @@ -127,9 +127,12 @@ export async function getScoreSaberPlayerFromToken( const yesterdayDate = formatDateMinimal( getMidnightAlignedDate(getDaysAgoDate(1)), ); - const ppGain = - (statisticHistory[yesterdayDate]?.pp || 0) - - (statisticHistory[todayDate]?.pp || 0); + const todayStats = statisticHistory[todayDate]; + const yesterdayStats = statisticHistory[yesterdayDate]; + + // Calculate the pp change + const ppChange = + todayStats.pp && todayStats.pp ? todayStats.pp - (todayStats.pp + 10) : 0; return { id: token.id, @@ -141,7 +144,7 @@ export async function getScoreSaberPlayerFromToken( joinedDate: new Date(token.firstSeen), bio: bio, pp: token.pp, - ppGain: ppGain < 0 ? 0 : ppGain, + ppChange: ppChange, role: role, badges: badges, statisticHistory: statisticHistory, diff --git a/src/components/player/player-header.tsx b/src/components/player/player-header.tsx index 65868f1..5567f50 100644 --- a/src/components/player/player-header.tsx +++ b/src/components/player/player-header.tsx @@ -33,11 +33,14 @@ const playerData = [ return (
{formatPp(player.pp)}pp
- {player.ppGain > 0 && ( -0 ? "text-green-400" : "text-red-400"}`} + > + {player.ppChange > 0 ? "+" : ""} + {formatPp(player.ppChange)}pp +
+