diff --git a/src/app/players/[id]/_components/games-table.tsx b/src/app/players/[id]/_components/games-table.tsx index 9180afd..c3ab562 100644 --- a/src/app/players/[id]/_components/games-table.tsx +++ b/src/app/players/[id]/_components/games-table.tsx @@ -20,7 +20,12 @@ import { getSortedRowModel, useReactTable, } from '@tanstack/react-table' -import { ArrowDownCircle, ArrowUp, ArrowUpCircle } from 'lucide-react' +import { + ArrowDownCircle, + ArrowUp, + ArrowUpCircle, + MinusCircle, +} from 'lucide-react' import { useFormatter } from 'next-intl' import Link from 'next/link' import { useMemo, useState } from 'react' @@ -95,11 +100,17 @@ const useColumns = () => { 0 ? 'text-emerald-500' : 'text-rose-500' + mmrChange === 0 + ? 'text-zink-800 dark:text-zink-200' + : mmrChange > 0 + ? 'text-emerald-500' + : 'text-rose-500' )} > {numberFormatter.format(Math.trunc(mmrChange))} - {mmrChange > 0 ? ( + {mmrChange === 0 ? ( + + ) : mmrChange > 0 ? ( ) : ( diff --git a/src/app/players/[id]/user.tsx b/src/app/players/[id]/user.tsx index 8a2c34e..4add093 100644 --- a/src/app/players/[id]/user.tsx +++ b/src/app/players/[id]/user.tsx @@ -108,6 +108,8 @@ export function UserInfo() { losses++ } else if (game.result === 'tie') { ties++ + } else { + ties++ } } @@ -115,14 +117,19 @@ export function UserInfo() { const lastGame = games.at(0) const currentName = lastGame?.playerName ?? discord_user.username + const meaningful_games = games_played - ties const profileData = { username: currentName, avatar: discord_user.avatar_url, games: games_played, + meaningful_games, wins, losses, ties, - winRate: games_played > 0 ? Math.round((wins / games_played) * 100) : 0, + winRate: + meaningful_games > 0 ? Math.ceil((wins / meaningful_games) * 100) : 0, + lossRate: + meaningful_games > 0 ? Math.floor((losses / meaningful_games) * 100) : 0, } const firstGame = games.at(-1) @@ -218,11 +225,11 @@ export function UserInfo() {
} - description={`${profileData.games > 0 ? Math.round((profileData.losses / profileData.games) * 100) : 0}% loss rate`} + description={`${profileData.lossRate}% loss rate`} accentColor='text-rose-500' /> - } - description={`${profileData.games > 0 ? Math.round((profileData.ties / profileData.games) * 100) : 0}% tie rate`} - accentColor='text-amber-500' - /> {isNonNullish(rankedUserRank?.mmr) && ( 0 - ? 'text-emerald-500' - : 'text-rose-500' + lastRankedGame.mmrChange === 0 + ? 'text-zink-800 dark:text-zink-200' + : lastRankedGame.mmrChange > 0 + ? 'text-emerald-500' + : 'text-rose-500' )} > - {lastRankedGame.mmrChange > 0 ? ( + {lastRankedGame.mmrChange === 0 ? ( + 'Tied' + ) : lastRankedGame.mmrChange > 0 ? ( ) : ( )} - {numberFormatter.format( - Math.trunc(lastRankedGame.mmrChange) - )}{' '} + {lastRankedGame.mmrChange !== 0 + ? numberFormatter.format( + Math.trunc(lastRankedGame.mmrChange) + ) + : null}{' '} last match ) : null @@ -297,19 +303,25 @@ export function UserInfo() { 0 - ? 'text-emerald-500' - : 'text-rose-500' + lastVanillaGame.mmrChange === 0 + ? 'text-zink-800 dark:text-zink-200' + : lastVanillaGame.mmrChange > 0 + ? 'text-emerald-500' + : 'text-rose-500' )} > - {lastVanillaGame.mmrChange > 0 ? ( + {lastVanillaGame.mmrChange === 0 ? ( + 'Tied' + ) : lastVanillaGame.mmrChange > 0 ? ( ) : ( )} - {numberFormatter.format( - Math.trunc(lastVanillaGame.mmrChange) - )}{' '} + {lastVanillaGame.mmrChange !== 0 + ? numberFormatter.format( + Math.trunc(lastVanillaGame.mmrChange) + ) + : null}{' '} last match ) : null @@ -365,7 +377,7 @@ export function UserInfo() {
- +