import { formatNumber } from "@/lib/formatters"
import { getBuildBattleRank } from "@/lib/hypixel/build-battle/general"
import { devide } from "@/lib/hypixel/general"
import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
import { BasicStat } from "../../_components/Stats"

export default function BuildBattleGeneralStats({ stats }: { stats: NonNullable<NonNullStats["BuildBattle"]> }) {
    const rank = getBuildBattleRank(stats.score)
    return (
        <div className="flex">
            <div className="flex-1">
                <BasicStat title="Score: " value={formatNumber(stats.score)} />
                <BasicStat title="Title: " value={rank.name} className={cn(rank.bold && "font-bold", `text-mc-${rank.color}`)} />
                <BasicStat title="Tokens: " value={formatNumber(stats.coins)} className="text-mc-dark-green" />
            </div>
            <div className="flex-1">
                <BasicStat title="Wins: " value={formatNumber(stats.wins)} />
                <BasicStat title="Losses: " value={formatNumber(stats.games_played - stats.wins)} />
                <BasicStat title="Win/Loss Ratio: " value={formatNumber(devide(stats.wins, stats.games_played - stats.wins))} />
            </div>
            <div className="flex-1">
                <BasicStat title="Correct Guesses: " value={formatNumber(stats.correct_guesses)} />
                <BasicStat title="Super Votes: " value={formatNumber(stats.super_votes)} />
            </div>
        </div>
    )
}
