import { formatNumber, formatSecondsToTime } from "@/lib/formatters"
import { devide } from "@/lib/hypixel/general"
import { NonNullStats } from "@/lib/schema/player"
import { BasicStat } from "../../_components/Stats"

export function ArenaBrawlGeneralStats({ coins, keys, ws }: { coins: number, keys: number, ws: number }) {
    return (
        <div>
            <BasicStat title="Coins: " value={formatNumber(coins)} className="text-mc-gold" />
            <BasicStat title="Keys: " value={formatNumber(keys)} className="text-mc-aqua" />
            <BasicStat title="Win Streaks: " value={formatNumber(ws)} className="text-mc-yellow" />
        </div>
    )
}

export function PaintballGeneralStats({ stats }: { stats: NonNullable<NonNullStats["Paintball"]> }) {
    return (
        <div className="flex">
            <div className="flex-1">
                <BasicStat title="Coins: " value={formatNumber(stats.coins)} className="text-mc-gold" />
                <BasicStat title="Wins: " value={formatNumber(stats.wins)} />
                <BasicStat title="Force Field Time: " value={`${formatSecondsToTime(stats.forcefieldTime)}s`} />
            </div>
            <div className="flex-1">
                <BasicStat title="Kills: " value={formatNumber(stats.kills)} />
                <BasicStat title="Deaths: " value={formatNumber(stats.deaths)} />
                <BasicStat title="Kill/Death Ratio: " value={formatNumber(devide(stats.kills, stats.deaths))} />
            </div>
            <div className="flex-1">
                <BasicStat title="Killstreaks: " value={formatNumber(stats.killstreaks)} />
                <BasicStat title="Shots Fired: " value={formatNumber(stats.shots_fired)} />
                <BasicStat title="Shot/Kill Ratio: " value={formatNumber(devide(stats.shots_fired, stats.kills))} />
            </div>
        </div>
    )
}

export function WallsGeneralStats({ stats }: { stats: NonNullable<NonNullStats["Walls"]> }) {
    return (
        <div>
            <BasicStat title="Coins: " value={formatNumber(stats.coins)} className="text-mc-gold" />
            <p>
                <br />
            </p>
            <BasicStat title="Kills: " value={formatNumber(stats.kills)} />
            <BasicStat title="Deaths: " value={formatNumber(stats.deaths)} />
            <BasicStat title="Kill/Death Ratio: " value={formatNumber(devide(stats.kills, stats.deaths))} />
            <p>
                <br />
            </p>
            <BasicStat title="Wins: " value={formatNumber(stats.wins)} />
            <BasicStat title="Losses: " value={formatNumber(stats.losses)} />
            <BasicStat title="Win/Loss Ratio: " value={formatNumber(devide(stats.wins, stats.losses))} />
        </div>
    )
}

export function VampireZGeneralStats({ stats }: { stats: NonNullable<NonNullStats["VampireZ"]> }) {
    return (
        <>
            <div>
                <BasicStat title="Coins: " value={formatNumber(stats.coins)} className="text-mc-gold" />
            </div>
            <div className="flex mt-4">
                <div className="flex-1">
                    <BasicStat title="Wins as Vampire: " value={formatNumber(stats.vampire_wins)} />
                    <p>
                        <br />
                    </p>
                    <BasicStat title="Vampire Kills: " value={formatNumber(stats.vampire_kills)} />
                    <BasicStat title="Vampire Deaths: " value={formatNumber(stats.vampire_deaths)} />
                    <BasicStat title="Vampire Kill/Death Ratio: " value={formatNumber(devide(stats.human_kills, stats.vampire_deaths))} />
                </div>
                <div className="flex-1">
                    <BasicStat title="Human Wins: " value={formatNumber(stats.human_wins)} />
                    <p>
                        <br />
                    </p>
                    <BasicStat title="Human Kills: " value={formatNumber(stats.human_kills)} />
                    <BasicStat title="Human Deaths: " value={formatNumber(stats.human_deaths)} />
                    <BasicStat title="Human Kill/Death Ratio: " value={formatNumber(devide(stats.vampire_kills, stats.human_deaths))} />
                </div>
                <div className="flex-1">
                    <BasicStat title="Zombie Kills: " value={formatNumber(stats.zombie_kills)} />
                </div>
            </div>
        </>
    )
}

export function QuakeCraftGeneralStats({ stats, godlikes }: { stats: NonNullable<NonNullStats["Quakecraft"]>, godlikes: number }) {
    return (
        <div className="flex">
            <div className="flex-1">
                <BasicStat title="Coins: " value={formatNumber(stats.coins)} className="text-mc-gold" />
                <p>
                    <br />
                </p>
                <BasicStat title="Kills: " value={formatNumber(stats.kills + stats.kills_teams)} />
                <BasicStat title="Deaths: " value={formatNumber(stats.deaths + stats.deaths_teams)} />
                <BasicStat
                    title="Kill/Death Ratio: "
                    value={formatNumber(devide(stats.kills + stats.kills_teams, stats.deaths + stats.deaths_teams))}
                />
            </div>
            <div className="flex-1">
                <BasicStat title="Wins: " value={formatNumber(stats.wins + stats.wins_teams)} />
                <p>
                    <br />
                </p>
                <BasicStat title="Godlikes: " value={formatNumber(godlikes)} />
                <BasicStat title="Highest Killstreak: " value={formatNumber(stats.highest_killstreak)} />
                <BasicStat title="Dash Cooldown: " value={stats.dash_cooldown + 1} />
                <BasicStat title="Dash Power: " value={stats.dash_power + 1} />
            </div>
        </div>
    )
}

export function TkrGeneralStats({ stats }: { stats: NonNullable<NonNullStats["TurboKartRacers"]> }) {
    const bsr = formatNumber(devide(stats.banana_hits_sent, stats.banana_hits_received))
    return (
        <div className="flex">
            <div className="flex-1">
                <BasicStat title="Coins: " value={formatNumber(stats.coins)} className="text-mc-gold" />
                <BasicStat title="Grand Prix Tokens: " value={formatNumber(stats.grand_prix_tokens)} className="text-mc-aqua" />
                <p>
                    <br />
                </p>
                <BasicStat title="Wins: " value={formatNumber(stats.wins)} />
                <BasicStat title="Gold Trophies: " value={`${formatNumber(stats.gold_trophy)}🏆\uFE0E`} className="text-mc-gold" />
                <BasicStat title="Silver Trophies: " value={`${formatNumber(stats.silver_trophy)}🏆\uFE0E`} className="text-mc-white" />
                <BasicStat title="Bronze Trophies: " value={`${formatNumber(stats.bronze_trophy)}🏆\uFE0E`} className="text-mc-brown" />
            </div>
            <div className="flex-1">
                <BasicStat title="Coins Picked Up: " value={formatNumber(stats.coins_picked_up)} />
                <BasicStat title="Powerups Picked Up: " value={formatNumber(stats.box_pickups)} />
                <BasicStat title="Laps Completed: " value={formatNumber(stats.laps_completed)} />
                <BasicStat title="Blue Torpedos Hit: " value={formatNumber(stats.blue_torpedo_hit)} />
                <p>
                    <br />
                </p>
                <BasicStat title="Banana Hits Sent: " value={formatNumber(stats.banana_hits_sent)} />
                <BasicStat title="Banana Hits Received: " value={formatNumber(stats.banana_hits_received)} />
                <BasicStat title="Banana Sent/Received Ratio: " value={bsr} />
            </div>
        </div>
    )
}
