fix: use ELO change instead of win rate for best partner calculation
This commit is contained in:
@@ -86,12 +86,14 @@ export default async function PlayerProfilePage({ params }: PageProps) {
|
|||||||
const totalWins = player.wins
|
const totalWins = player.wins
|
||||||
const winRate = totalGames > 0 ? ((totalWins / totalGames) * 100).toFixed(1) : "0.0"
|
const winRate = totalGames > 0 ? ((totalWins / totalGames) * 100).toFixed(1) : "0.0"
|
||||||
|
|
||||||
// Get best partnership
|
// Get best partnership based on ELO contribution
|
||||||
|
// Best partner is the one who contributed most to your rating (highest totalEloChange)
|
||||||
|
// Must have played at least 2 games together to be considered
|
||||||
const bestPartnership = partnershipStats.reduce((best, stat) => {
|
const bestPartnership = partnershipStats.reduce((best, stat) => {
|
||||||
if (stat.gamesPlayed < 3) return best // Need at least 3 games for partnership to be meaningful
|
if (stat.gamesPlayed < 2) return best // Need at least 2 games for partnership to be meaningful
|
||||||
const currentRate = stat.wins / stat.gamesPlayed
|
const currentEloChange = stat.totalEloChange
|
||||||
const bestRate = best ? best.wins / best.gamesPlayed : 0
|
const bestEloChange = best ? best.totalEloChange : -Infinity
|
||||||
return currentRate > bestRate ? stat : best
|
return currentEloChange > bestEloChange ? stat : best
|
||||||
}, null as (typeof partnershipStats[0] | null))
|
}, null as (typeof partnershipStats[0] | null))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user