Added new column for pit stats
This commit is contained in:
@@ -32,8 +32,8 @@ export default function PitStats({ stats }: { stats: NonNullStats["Pit"] }) {
|
|||||||
stat: (
|
stat: (
|
||||||
<p className="font-bold">
|
<p className="font-bold">
|
||||||
<span className={`text-mc-${prestigeColor}`}>[</span>
|
<span className={`text-mc-${prestigeColor}`}>[</span>
|
||||||
<span className="text-mc-yellow">{romanize(prestige)}</span>
|
{prestige > 0 && <span className="text-mc-yellow">{romanize(prestige)}</span>}
|
||||||
<span className={`text-mc-${levelColor}`}>{`-${level}`}</span>
|
<span className={`text-mc-${levelColor}`}>{`${prestige === 0 ? "" : "-"}${level}`}</span>
|
||||||
<span className={`text-mc-${prestigeColor}`}>]</span>
|
<span className={`text-mc-${prestigeColor}`}>]</span>
|
||||||
</p>
|
</p>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { formatNumber } from "@/lib/formatters"
|
import { formatNumber, formatSecondsToTime } from "@/lib/formatters"
|
||||||
import { romanize } from "@/lib/hypixel/general"
|
import { devide, romanize } from "@/lib/hypixel/general"
|
||||||
import { getLevelColor, getPrestige, getPrestigeColor } from "@/lib/hypixel/pit/general"
|
import { getLevelColor, getPrestige, getPrestigeColor } from "@/lib/hypixel/pit/general"
|
||||||
import { getPitLevel } from "@/lib/hypixel/pit/level"
|
import { getPitLevel } from "@/lib/hypixel/pit/level"
|
||||||
import { NonNullStats } from "@/lib/schema/player"
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
@@ -10,11 +10,19 @@ export default function PitGeneralStats({ stats }: { stats: NonNullable<NonNullS
|
|||||||
const level = getPitLevel(stats.profile.xp, prestige)
|
const level = getPitLevel(stats.profile.xp, prestige)
|
||||||
const pretigeColor = getPrestigeColor(prestige)
|
const pretigeColor = getPrestigeColor(prestige)
|
||||||
const levelColor = getLevelColor(level)
|
const levelColor = getLevelColor(level)
|
||||||
|
const kah = formatNumber(devide(stats.kills + stats.assists, stats.playtime_minutes / 60))
|
||||||
|
const gh = formatNumber(devide(stats.cash_earned, stats.playtime_minutes / 60))
|
||||||
|
const xph = formatNumber(devide(stats.profile.xp, stats.playtime_minutes / 60))
|
||||||
|
const kd = formatNumber(devide(stats.kills, stats.deaths))
|
||||||
|
const kad = formatNumber(devide((stats.kills, stats.assists), stats.deaths))
|
||||||
|
const ddr = formatNumber(devide(stats.damage_dealt, stats.damage_received))
|
||||||
|
const sa = formatNumber(devide(stats.sword_hits, stats.left_clicks) * 100)
|
||||||
|
const aa = formatNumber(devide(stats.arrow_hits, stats.arrows_fired) * 100)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<BasicStat title="Pretige: " value={romanize(prestige)} className={`font-bold text-mc-${pretigeColor}`} />
|
<BasicStat title="Pretige: " value={prestige === 0 ? "None" : romanize(prestige)} className={`font-bold text-mc-${pretigeColor}`} />
|
||||||
<BasicStat title="Level: " value={level} className={`font-bold text-mc-${levelColor}`} />
|
<BasicStat title="Level: " value={level} className={`font-bold text-mc-${levelColor}`} />
|
||||||
<BasicStat title="Gold: " value={formatNumber(Math.floor(stats.profile.cash))} className="text-mc-gold" />
|
<BasicStat title="Gold: " value={formatNumber(Math.floor(stats.profile.cash))} className="text-mc-gold" />
|
||||||
<BasicStat title="Lifetime Gold: " value={formatNumber(Math.floor(stats.cash_earned))} className="text-mc-gold" />
|
<BasicStat title="Lifetime Gold: " value={formatNumber(Math.floor(stats.cash_earned))} className="text-mc-gold" />
|
||||||
@@ -23,8 +31,46 @@ export default function PitGeneralStats({ stats }: { stats: NonNullable<NonNullS
|
|||||||
<p>
|
<p>
|
||||||
<br />
|
<br />
|
||||||
</p>
|
</p>
|
||||||
|
<BasicStat title="Playtime: " value={formatSecondsToTime(stats.playtime_minutes * 60)} />
|
||||||
|
<BasicStat title="Kill+Assists/Hour: " value={kah} />
|
||||||
|
<BasicStat title="Gold/Hour: " value={gh} className="text-mc-gold" />
|
||||||
|
<BasicStat title="XP/Hour: " value={xph} className="text-mc-aqua" />
|
||||||
|
<p>
|
||||||
|
<br />
|
||||||
|
</p>
|
||||||
|
<BasicStat title="Kills: " value={formatNumber(stats.kills)} />
|
||||||
|
<BasicStat title="Assists: " value={formatNumber(stats.assists)} />
|
||||||
|
<BasicStat title="Deaths: " value={formatNumber(stats.deaths)} />
|
||||||
|
<BasicStat title="Kill/Death Ratio: " value={kd} />
|
||||||
|
<BasicStat title="Kill+Assist/Death Ratio: " value={kad} />
|
||||||
|
<BasicStat title="Highest Killstreak: " value={formatNumber(stats.max_streak)} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
|
<BasicStat title="Damage Dealt: " value={formatNumber(stats.damage_dealt)} />
|
||||||
|
<BasicStat title="Damage Received: " value={formatNumber(stats.damage_received)} />
|
||||||
|
<BasicStat title="Melee Damage Dealt: " value={formatNumber(stats.melee_damage_dealt)} />
|
||||||
|
<BasicStat title="Melee Damage Received: " value={formatNumber(stats.melee_damage_received)} />
|
||||||
|
<BasicStat title="Bow Damage Dealt: " value={formatNumber(stats.bow_damage_dealt)} />
|
||||||
|
<BasicStat title="Bow Damage Received: " value={formatNumber(stats.bow_damage_received)} />
|
||||||
|
<BasicStat title="Damage Dealt/Received Ratio: " value={ddr} />
|
||||||
|
<p>
|
||||||
|
<br />
|
||||||
|
</p>
|
||||||
|
<BasicStat title="Sword Hits: " value={formatNumber(stats.sword_hits)} />
|
||||||
|
<BasicStat title="Sword Swings: " value={formatNumber(stats.left_clicks)} />
|
||||||
|
<BasicStat title="Sword Hit Accuracy: " value={`${sa}%`} />
|
||||||
|
<p>
|
||||||
|
<br />
|
||||||
|
</p>
|
||||||
|
<BasicStat title="Arrow Hits: " value={formatNumber(stats.arrow_hits)} />
|
||||||
|
<BasicStat title="Arrow Shot: " value={formatNumber(stats.arrows_fired)} />
|
||||||
|
<BasicStat title="Arrow Hit Accuracy: " value={`${aa}%`} />
|
||||||
|
<p>
|
||||||
|
<br />
|
||||||
|
</p>
|
||||||
|
<BasicStat title="Contracts Completed: " value={formatNumber(stats.contracts_completed)} />
|
||||||
|
<BasicStat title="Jumps into the Pit: " value={formatNumber(stats.jumped_into_pit)} />
|
||||||
|
<BasicStat title="Launcher Launches: " value={formatNumber(stats.launched_by_launchers)} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -33,10 +33,7 @@ export function formatSecondsToTime(seconds: number) {
|
|||||||
if (minutes) parts.push(minutes + "m")
|
if (minutes) parts.push(minutes + "m")
|
||||||
if (secs || parts.length === 0) parts.push(secs + "s")
|
if (secs || parts.length === 0) parts.push(secs + "s")
|
||||||
|
|
||||||
if (parts.length === 1) return parts[0]
|
return parts.join(" ")
|
||||||
if (parts.length === 2) return parts[0] + " and " + parts[1]
|
|
||||||
// For 3+ parts: separate first n-1 by comma+space, last preceded by 'and'
|
|
||||||
return parts.slice(0, -1).join(", ") + " and " + parts[parts.length - 1]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatRelativeTime(timestamp: number, type: "past" | "future") {
|
export function formatRelativeTime(timestamp: number, type: "past" | "future") {
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ export function getPrestigeColor(prestige: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getPrestige(stats: NonNullable<NonNullStats["Pit"]>) {
|
export function getPrestige(stats: NonNullable<NonNullStats["Pit"]>) {
|
||||||
return stats.profile.prestiges.length
|
return stats.profile.prestiges === undefined ? 0 : stats.profile.prestiges.length
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -450,14 +450,30 @@ export const pitStats = z.looseObject({
|
|||||||
pit_stats_ptl: z.looseObject({
|
pit_stats_ptl: z.looseObject({
|
||||||
kills: z.number().default(0),
|
kills: z.number().default(0),
|
||||||
deaths: z.number().default(0),
|
deaths: z.number().default(0),
|
||||||
cash_earned: z.number().default(0)
|
cash_earned: z.number().default(0),
|
||||||
|
playtime_minutes: z.number().default(0),
|
||||||
|
assists: z.number().default(0),
|
||||||
|
max_streak: z.number().default(0),
|
||||||
|
damage_dealt: z.number().default(0),
|
||||||
|
damage_received: z.number().default(0),
|
||||||
|
melee_damage_dealt: z.number().default(0),
|
||||||
|
melee_damage_received: z.number().default(0),
|
||||||
|
bow_damage_dealt: z.number().default(0),
|
||||||
|
bow_damage_received: z.number().default(0),
|
||||||
|
sword_hits: z.number().default(0),
|
||||||
|
left_clicks: z.number().default(0),
|
||||||
|
arrow_hits: z.number().default(0),
|
||||||
|
arrows_fired: z.number().default(0),
|
||||||
|
contracts_completed: z.number().default(0),
|
||||||
|
jumped_into_pit: z.number().default(0),
|
||||||
|
launched_by_launchers: z.number().default(0)
|
||||||
}),
|
}),
|
||||||
profile: z.looseObject({
|
profile: z.looseObject({
|
||||||
prestiges: z.array(z.looseObject({
|
prestiges: z.array(z.looseObject({
|
||||||
index: z.number(),
|
index: z.number(),
|
||||||
xp_on_prestige: z.number(),
|
xp_on_prestige: z.number(),
|
||||||
timestamp: z.number()
|
timestamp: z.number()
|
||||||
})),
|
})).optional(),
|
||||||
xp: z.number().default(0),
|
xp: z.number().default(0),
|
||||||
cash: z.number().default(0),
|
cash: z.number().default(0),
|
||||||
renown: z.number().default(0)
|
renown: z.number().default(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user