Fixed things and added tokens finally
This commit is contained in:
@@ -65,7 +65,7 @@ export default function Sidebar({ level, ign, player, guild }: SidebarProps) {
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="font-bold">{"Challenges Completed: "}</span>
|
<span className="font-bold">{"Challenges Completed: "}</span>
|
||||||
<span>{formatNumber(getTotalChallenges(player.challenges.all_time))}</span>
|
<span>{formatNumber(getTotalChallenges(player.challenges))}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Separator className="my-4" />
|
<Separator className="my-4" />
|
||||||
@@ -155,11 +155,11 @@ export default function Sidebar({ level, ign, player, guild }: SidebarProps) {
|
|||||||
<h1 className="text-xl font-bold underline">Social Links</h1>
|
<h1 className="text-xl font-bold underline">Social Links</h1>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<SocialIcons
|
<SocialIcons
|
||||||
discord={player.socialMedia.links.DISCORD}
|
discord={player?.socialMedia?.links?.DISCORD}
|
||||||
twitch={player.socialMedia.links.TWITCH}
|
twitch={player?.socialMedia?.links?.TWITCH}
|
||||||
youtube={player.socialMedia.links.YOUTUBE}
|
youtube={player?.socialMedia?.links?.YOUTUBE}
|
||||||
twitter={player.socialMedia.links.TWITCH}
|
twitter={player?.socialMedia?.links?.TWITCH}
|
||||||
hypixel={player.socialMedia.links.HYPIXEL}
|
hypixel={player?.socialMedia?.links?.HYPIXEL}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ import { FiTwitter } from "react-icons/fi"
|
|||||||
import { toast } from "sonner"
|
import { toast } from "sonner"
|
||||||
|
|
||||||
export default function SocialIcons(
|
export default function SocialIcons(
|
||||||
{ discord, twitch, youtube, twitter, hypixel }: { discord?: string, twitch?: string, youtube?: string, twitter?: string, hypixel?: string }
|
{ discord, twitch, youtube, twitter, hypixel }: {
|
||||||
|
discord?: string
|
||||||
|
twitch?: string
|
||||||
|
youtube?: string
|
||||||
|
twitter?: string
|
||||||
|
hypixel?: string
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { getBedwarsStar, getTextColor } from "@/lib/hypixel/bedwars"
|
import { getBedwarsStar, getPrestigeName, getTextColor } from "@/lib/hypixel/bedwars"
|
||||||
import { getBWLevelForExp } from "@/lib/hypixel/bedwarsLevel"
|
import { getBWLevelForExp } from "@/lib/hypixel/bedwarsLevel"
|
||||||
import { bedwarsLevelColors } from "@/lib/hypixelFormatters"
|
import { bedwarsLevelColors } from "@/lib/hypixelFormatters"
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
import Multicolored from "../../_components/Multicolored"
|
import Multicolored from "../../_components/Multicolored"
|
||||||
|
|
||||||
export function BedwarsLevel({ xp }: { xp: number }) {
|
export function BedwarsLevel({ xp }: { xp: number }) {
|
||||||
@@ -15,10 +16,68 @@ export function BedwarsLevel({ xp }: { xp: number }) {
|
|||||||
export function BedwarsProgress({ level, percent }: { level: number, percent: number }) {
|
export function BedwarsProgress({ level, percent }: { level: number, percent: number }) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center mb-10">
|
<div className="flex items-center mb-10">
|
||||||
<div className={`mr-2 text-mc-${getTextColor(level)}`}>{level}</div>
|
<LevelNumber level={level} className="mr-2" />
|
||||||
<div className={`h-5 bg-mc-${getTextColor(level)} rounded-l-md`} style={{ width: `${percent}%` }}></div>
|
<Progress level={level} percent={percent} />
|
||||||
<div className="flex-1 h-5 rounded-r-md bg-background"></div>
|
<div className="flex-1 h-5 rounded-r-md bg-background"></div>
|
||||||
<div className={`ml-2 text-mc-${getTextColor(level)}`}>{level + 1}</div>
|
<LevelNumber level={level + 1} className="ml-2" />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function BedWarsPrestige({ level }: { level: number }) {
|
||||||
|
if (level >= 1000 && level < 2000) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
backgroundImage: "linear-gradient(to left,#a0a,#f5f,#5ff,#5f5,#ff5,#fa0,#f55)",
|
||||||
|
WebkitBackgroundClip: "text",
|
||||||
|
color: "transparent"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{`${getPrestigeName(level)} ${getBedwarsStar(level)}`}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className={`text-mc-${getTextColor(level)}`}>
|
||||||
|
{`${getPrestigeName(level)} ${getBedwarsStar(level)}`}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function LevelNumber({ level, className }: { level: number, className?: string }) {
|
||||||
|
if (level >= 1000 && level < 2000) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={className}
|
||||||
|
style={{
|
||||||
|
backgroundImage: "linear-gradient(to left,#a0a,#f5f,#5ff,#5f5,#ff5,#fa0,#f55)",
|
||||||
|
WebkitBackgroundClip: "text",
|
||||||
|
color: "transparent"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{level}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div className={cn(`text-mc-${getTextColor(level)}`, className)}>{level}</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
function Progress({ level, percent }: { level: number, percent: number }) {
|
||||||
|
if (level >= 1000 && level < 2000) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="h-5 rounded-l-md"
|
||||||
|
style={{
|
||||||
|
width: `${percent}%`,
|
||||||
|
background: "repeating-linear-gradient(to right,#f55,#fa0,#ff5,#5f5,#5ff,#f5f,#a0a,#f55 16rem)"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div className={`h-5 bg-mc-${getTextColor(level)} rounded-l-md`} style={{ width: `${percent}%` }}></div>
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Card, CardContent } from "@/components/ui/card"
|
import { Card, CardContent } from "@/components/ui/card"
|
||||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
|
||||||
import { getBedwarsStar, getPrestigeName, getTextColor } from "@/lib/hypixel/bedwars"
|
import { formatNumber } from "@/lib/formatters"
|
||||||
import { getBWLevelForExp, getTotalExpForLevel } from "@/lib/hypixel/bedwarsLevel"
|
import { getBWLevelForExp, getTotalExpForLevel } from "@/lib/hypixel/bedwarsLevel"
|
||||||
import { getProgress } from "@/lib/hypixel/general"
|
import { getProgress } from "@/lib/hypixel/general"
|
||||||
import { Player } from "@/lib/schema/player"
|
import { Player } from "@/lib/schema/player"
|
||||||
@@ -10,7 +10,7 @@ import { Separator } from "@radix-ui/react-separator"
|
|||||||
import { ChevronDown, ChevronUp, Menu } from "lucide-react"
|
import { ChevronDown, ChevronUp, Menu } from "lucide-react"
|
||||||
import { useEffect, useRef, useState } from "react"
|
import { useEffect, useRef, useState } from "react"
|
||||||
import CollapsedStats from "../../_components/CollapsedStats"
|
import CollapsedStats from "../../_components/CollapsedStats"
|
||||||
import { BedwarsLevel, BedwarsProgress } from "./bedwars-components"
|
import { BedwarsLevel, BedWarsPrestige, BedwarsProgress } from "./bedwars-components"
|
||||||
|
|
||||||
export default function BedwarsStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
|
export default function BedwarsStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
|
||||||
const ref = useRef<HTMLDivElement>(null)
|
const ref = useRef<HTMLDivElement>(null)
|
||||||
@@ -105,13 +105,11 @@ export default function BedwarsStats({ stats }: { stats: Player["player"]["stats
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="font-bold">{"Prestige: "}</span>
|
<span className="font-bold">{"Prestige: "}</span>
|
||||||
<span className={`text-mc-${getTextColor(level)}`}>
|
<BedWarsPrestige level={level} />
|
||||||
{`${getPrestigeName(level)} ${getBedwarsStar(level)}`}
|
|
||||||
</span>
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="font-bold">{"Tokens: "}</span>
|
<span className="font-bold">{"Tokens: "}</span>
|
||||||
<span className="text-mc-dark-green">{}</span>
|
<span className="text-mc-dark-green">{formatNumber(stats.coins)}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { object } from "zod"
|
|
||||||
import { Guild } from "../schema/guild"
|
import { Guild } from "../schema/guild"
|
||||||
|
|
||||||
export function getGuildMember(guild: Guild["guild"], uuid: string) {
|
export function getGuildMember(guild: Guild["guild"], uuid: string) {
|
||||||
|
|||||||
@@ -20,11 +20,15 @@ export function getTotalCoins(stats: Record<string, Record<"coins", number | und
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getTotalQuests(quests: Player["player"]["quests"]) {
|
export function getTotalQuests(quests: Player["player"]["quests"]) {
|
||||||
|
if (!quests) return 0
|
||||||
|
|
||||||
return Object.values(quests).reduce((total, quest) => total + (quest.completions?.length || 0), 0)
|
return Object.values(quests).reduce((total, quest) => total + (quest.completions?.length || 0), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTotalChallenges(challenges: Player["player"]["challenges"]["all_time"]) {
|
export function getTotalChallenges(challenges: Player["player"]["challenges"]) {
|
||||||
return Object.values(challenges).reduce((total, challenge) => total + challenge, 0)
|
if (!challenges?.all_time) return 0
|
||||||
|
|
||||||
|
return Object.values(challenges.all_time).reduce((total, challenge) => total + challenge, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rewardClaimed(claimedAt?: number) {
|
export function rewardClaimed(claimedAt?: number) {
|
||||||
@@ -39,4 +43,3 @@ export function rewardClaimed(claimedAt?: number) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import z from "zod"
|
|||||||
|
|
||||||
export const playerSchema = z.looseObject({
|
export const playerSchema = z.looseObject({
|
||||||
player: z.looseObject({
|
player: z.looseObject({
|
||||||
displayname: z.string().optional(),
|
displayname: z.string(),
|
||||||
uuid: z.string().optional(),
|
uuid: z.string(),
|
||||||
newPackageRank: z.string().optional(),
|
newPackageRank: z.string().optional(),
|
||||||
monthlyPackageRank: z.string().optional(),
|
monthlyPackageRank: z.string().optional(),
|
||||||
rankPlusColor: z.string().optional(),
|
rankPlusColor: z.string().optional(),
|
||||||
@@ -14,6 +14,7 @@ export const playerSchema = z.looseObject({
|
|||||||
stats: z.looseObject({
|
stats: z.looseObject({
|
||||||
Bedwars: z.looseObject({
|
Bedwars: z.looseObject({
|
||||||
Experience: z.number().default(0),
|
Experience: z.number().default(0),
|
||||||
|
coins: z.number().default(0),
|
||||||
winstreak: z.number().optional(),
|
winstreak: z.number().optional(),
|
||||||
kills_bedwars: z.number().default(0),
|
kills_bedwars: z.number().default(0),
|
||||||
deaths_bedwars: z.number().default(0),
|
deaths_bedwars: z.number().default(0),
|
||||||
@@ -31,9 +32,9 @@ export const playerSchema = z.looseObject({
|
|||||||
completions: z.array(
|
completions: z.array(
|
||||||
z.looseObject({
|
z.looseObject({
|
||||||
time: z.number()
|
time: z.number()
|
||||||
}).optional()
|
})
|
||||||
).optional()
|
).optional()
|
||||||
}).optional()
|
})
|
||||||
).optional(),
|
).optional(),
|
||||||
challenges: z.looseObject({
|
challenges: z.looseObject({
|
||||||
all_time: z.record(z.string(), z.number())
|
all_time: z.record(z.string(), z.number())
|
||||||
|
|||||||
Reference in New Issue
Block a user