Added pit progress
This commit is contained in:
@@ -7,6 +7,7 @@ import { getLevelColor, getPrestige, getPrestigeColor } from "@/lib/hypixel/pit/
|
||||
import { getPitLevel } from "@/lib/hypixel/pit/level"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
import CollapsedStats from "../../_components/CollapsedStats"
|
||||
import PitProgress from "./progress"
|
||||
import PitGeneralStats from "./stats"
|
||||
|
||||
export default function PitStats({ stats }: { stats: NonNullStats["Pit"] }) {
|
||||
@@ -52,6 +53,8 @@ export default function PitStats({ stats }: { stats: NonNullStats["Pit"] }) {
|
||||
</div>
|
||||
</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
<Separator className="my-4" />
|
||||
<PitProgress prestige={prestige} xp={stats.profile.xp} />
|
||||
<Separator className="my-4" />
|
||||
<PitGeneralStats stats={stats} />
|
||||
<Separator className="my-4" />
|
||||
|
||||
19
src/app/(stats)/player/[ign]/_stats/pit/progress.tsx
Normal file
19
src/app/(stats)/player/[ign]/_stats/pit/progress.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { formatNumber } from "@/lib/formatters"
|
||||
import { getProgress } from "@/lib/hypixel/general"
|
||||
import { getPrestigeColor, getXpForPrestige } from "@/lib/hypixel/pit/general"
|
||||
import GenericProgress from "../../_components/GenericProgress"
|
||||
export default function PitProgress({ prestige, xp }: { prestige: number, xp: number }) {
|
||||
const presColor = getPrestigeColor(prestige)
|
||||
const currentXp = getXpForPrestige(prestige)
|
||||
const nextXp = getXpForPrestige(prestige + 1)
|
||||
const percent = getProgress(currentXp, xp, nextXp)
|
||||
|
||||
return (
|
||||
<GenericProgress
|
||||
tooltipId="pit-progress"
|
||||
tooltipContent={`${formatNumber(currentXp)}/${formatNumber(nextXp)} XP`}
|
||||
percent={percent}
|
||||
className={`bg-mc-${presColor}`}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LEVELCOLORS, PRESTIGECOLORS } from "@/data/hypixel/pit"
|
||||
import { LEVELCOLORS, PRESTIGE_MULTIPLIERS, PRESTIGECOLORS } from "@/data/hypixel/pit"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
|
||||
export function getLevelColor(level: number) {
|
||||
@@ -17,6 +17,11 @@ export function getPrestigeColor(prestige: number) {
|
||||
return PRESTIGECOLORS.at(0)!.color
|
||||
}
|
||||
|
||||
export function getXpForPrestige(prestige: number): number {
|
||||
if (prestige <= 0 || prestige > PRESTIGE_MULTIPLIERS.length) return 0
|
||||
return PRESTIGE_MULTIPLIERS[prestige - 1].SumXp
|
||||
}
|
||||
|
||||
export function getPrestige(stats: NonNullable<NonNullStats["Pit"]>) {
|
||||
return stats.profile.prestiges === undefined ? 0 : stats.profile.prestiges.length
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user