Finished progress

This commit is contained in:
2025-09-03 23:21:29 +02:00
parent 0cd3628e3d
commit 1b13abdc32
3 changed files with 36 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import { formatNumber } from "@/lib/formatters"
import { getBuildBattleRank } from "@/lib/hypixel/build-battle/general"
import { NonNullStats } from "@/lib/schema/player"
import CollapsedStats from "../../_components/CollapsedStats"
import BuildBattleTitleProgress from "./progress"
import BuildBattleGeneralStats from "./stats"
export default function BuildBattleStats({ stats }: { stats: NonNullStats["BuildBattle"] }) {
@@ -34,6 +35,8 @@ export default function BuildBattleStats({ stats }: { stats: NonNullStats["Build
</div>
</AccordionTrigger>
<AccordionContent>
<Separator className="my-4" />
<BuildBattleTitleProgress score={stats.score} />
<Separator className="my-4" />
<BuildBattleGeneralStats stats={stats} />
<Separator className="my-4" />

View File

@@ -0,0 +1,25 @@
import { getBuildBattleRank, getNextBuildBattleRank } from "@/lib/hypixel/build-battle/general"
import { getProgress } from "@/lib/hypixel/general"
import { cn } from "@/lib/utils"
import GenericProgress from "../../_components/GenericProgress"
export default function BuildBattleTitleProgress({ score }: { score: number }) {
const current = getBuildBattleRank(score)
const next = getNextBuildBattleRank(score)
const percent = getProgress(0, score, next !== null ? next.value : 0)
return (
<div className="flex gap-2 items-center">
<GenericProgress
percent={percent}
tooltipId="build-battle-progress"
tooltipContent={`${score}/${next !== null ? next.value : 0} Score`}
className={`bg-mc-${current.color}`}
/>
<p className={cn("font-bold", next !== null ? `text-mc-${next.color}` : "text-mc-gold")}>
{next !== null ? next.name : "Already max rank"}
</p>
</div>
)
}

View File

@@ -6,3 +6,11 @@ export function getBuildBattleRank(score: number) {
}
return STARS[0]
}
export function getNextBuildBattleRank(score: number) {
const current = getBuildBattleRank(score)
const next = STARS.indexOf(current) + 1
return next > STARS.length - 1 ? null : STARS[next]
}