Added best mode stats

This commit is contained in:
2025-09-14 21:05:12 +02:00
parent 3711b43b4e
commit 0d7c79a310
8 changed files with 113 additions and 10 deletions

View File

@@ -32,6 +32,24 @@ export function getMegaWallsClass(classId: typeof CLASSES[number]["id"]) {
return CLASSES.find(c => c.id === classId)!
}
export function getMegaWallsMostPlayedClass(stats: NonNullable<NonNullStats["MegaWalls"]>) {
let mostPlayedClass: typeof CLASSES[number] | null = null
let maxPlays = 0
for (const classObj of CLASSES) {
const wins = stats[`${classObj.id}_wins`] || 0
const losses = stats[`${classObj.id}_losses`] || 0
const totalPlays = wins + losses
if (totalPlays > maxPlays) {
maxPlays = totalPlays
mostPlayedClass = classObj
}
}
return mostPlayedClass
}
export function getAllMegawallsClassStats(stats: NonNullable<NonNullStats["MegaWalls"]>) {
const statsArr: { id: typeof CLASSES[number]["id"], val: number[] }[] = []
@@ -58,6 +76,27 @@ export function getMegaWallsClassStats(classId: typeof CLASSES[number]["id"], st
]
}
export function getMegaWallsMostPlayedMode(stats: NonNullable<NonNullStats["MegaWalls"]>) {
const modes = [
{
id: "standard" as const,
games: (stats.wins_standard || 0) + (stats.losses_standard || 0)
},
{
id: "face_off" as const,
games: (stats.wins_face_off || 0) + (stats.losses_face_off || 0)
},
{
id: "gvg" as const,
games: (stats.wins_gvg || 0) + (stats.losses_gvg || 0)
}
]
const mostPlayed = modes.reduce((max, current) => current.games > max.games ? current : max)
return mostPlayed.id
}
export function getMegaWallsModeStats(modeId: typeof MODES[number]["id"], stats: NonNullable<NonNullStats["MegaWalls"]>) {
return [
stats[`kills_${modeId}`],