diff --git a/src/app/(stats)/player/[ign]/_stats/woolgames/modes.tsx b/src/app/(stats)/player/[ign]/_stats/woolgames/modes.tsx new file mode 100644 index 0000000..3ad56d1 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/woolgames/modes.tsx @@ -0,0 +1,130 @@ +import { formatNumber, formatSecondsToTime } from "@/lib/formatters" +import { devide } from "@/lib/hypixel/general" +import { getWoolGamesWoolWarsClass, getWoolGamesWoolWarsClassColor } from "@/lib/hypixel/woolgames/general" +import { NonNullStats } from "@/lib/schema/player" +import { cn } from "@/lib/utils" +import { BasicStat } from "../../_components/Stats" + +export function WoolGamesCaptureTheWool({ ctw }: { ctw: NonNullable["capture_the_wool"] }) { + if (!ctw) { + return ( + <> +

Capture The Wool

+

This person has no Capture The Wool stats.

+ + ) + } + + const kd = formatNumber(devide(ctw.stats?.kills || 0, ctw.stats?.deaths || 0)) + const wl = formatNumber(devide(ctw.stats?.participated_wins || 0, ctw.stats?.participated_losses || 0)) + + return ( + <> +

Capture The Wool

+
+
+ + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + ) +} + +export function WoolGamesSheepWars({ sw }: { sw: NonNullable["sheep_wars"] }) { + if (!sw) { + return ( + <> +

Sheep Wars

+

This person has no Sheep Wars stats.

+ + ) + } + + const kd = formatNumber(devide(sw.stats?.kills || 0, sw.stats?.deaths || 0)) + const wl = formatNumber(devide(sw.stats?.wins || 0, sw.stats?.losses || 0)) + + return ( + <> +

Sheep Wars

+
+
+ + + +
+
+ + + +
+
+ + +
+
+ + ) +} + +export function WoolGamesWoolWars({ ww }: { ww: NonNullable["wool_wars"] }) { + if (!ww) { + return ( + <> +

Wool Wars

+

This person has no Wool Wars stats.

+ + ) + } + + const klass = getWoolGamesWoolWarsClass(ww.selected_class) + const klassName = klass?.name || "Unknown" + const klassColor = getWoolGamesWoolWarsClassColor(klass?.difficulty) + const kd = formatNumber(devide(ww.stats?.kills || 0, ww.stats?.deaths || 0)) + const wl = formatNumber(devide(ww.stats?.wins || 0, ww.stats?.losses || 0)) + + return ( + <> +

Wool Wars

+
+
+ + + + + +
+
+ + + +
+
+ + + +
+
+ + ) +} diff --git a/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx b/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx index c892398..15845cb 100644 --- a/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx +++ b/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx @@ -4,6 +4,7 @@ import { getWoolGamesLevel, getWoolGamesPrestige, getWoolGamesPretigeIcon } from import { NonNullStats } from "@/lib/schema/player" import Multicolored from "../../_components/Multicolored" import GeneralStats from "../GeneralStats" +import { WoolGamesCaptureTheWool, WoolGamesSheepWars, WoolGamesWoolWars } from "./modes" import WoolGamesProgress from "./progress" import WoolGamesGeneralStats from "./stats" @@ -40,6 +41,12 @@ export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGam + + + + + + ) } diff --git a/src/data/hypixel/woolgames.ts b/src/data/hypixel/woolgames.ts index 8924b03..a84f37f 100644 --- a/src/data/hypixel/woolgames.ts +++ b/src/data/hypixel/woolgames.ts @@ -26,12 +26,12 @@ export const ICONS = { YIN_YANG: "\u262f" // ☯ } as const export const CLASSES = [ - { id: "tank", name: "Tank", difficulty: 1 }, - { id: "archer", name: "Archer", difficulty: 2 }, - { id: "swordsman", name: "Swordsman", difficulty: 1 }, - { id: "engineer", name: "Engineer", difficulty: 1 }, - { id: "golem", name: "Golem", difficulty: 2 }, - { id: "assault", name: "Assault", difficulty: 3 } + { id: "TANK", name: "Tank", difficulty: 1 }, + { id: "ARCHER", name: "Archer", difficulty: 2 }, + { id: "SWORDSMAN", name: "Swordsman", difficulty: 1 }, + { id: "ENGINEER", name: "Engineer", difficulty: 1 }, + { id: "GOLEM", name: "Golem", difficulty: 2 }, + { id: "ASSAULT", name: "Assault", difficulty: 3 } ] as const export const DIFFICULTIES = { "1": "green", diff --git a/src/lib/hypixel/woolgames/general.ts b/src/lib/hypixel/woolgames/general.ts index db6c0f1..f0643c1 100644 --- a/src/lib/hypixel/woolgames/general.ts +++ b/src/lib/hypixel/woolgames/general.ts @@ -1,7 +1,19 @@ -import { EASY_XP, ICONS, NORMAL_XP, PRESTIGES } from "@/data/hypixel/woolgames" +import { CLASSES, DIFFICULTIES, EASY_XP, ICONS, NORMAL_XP, PRESTIGES } from "@/data/hypixel/woolgames" import { getColorFromCode } from "@/lib/colors" import { floorLevel } from "../general" +export function getWoolGamesWoolWarsClass(val?: string) { + const klass = CLASSES.find(c => c.id === val) + return klass || null +} + +export function getWoolGamesWoolWarsClassColor(id?: 1 | 2 | 3 | 4) { + if (!id) { + return null + } + return DIFFICULTIES[id] +} + export function getWoolGamesPrestige(level: number) { const floored = floorLevel(Math.floor(level), 100) diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index 8e94135..954cec5 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -735,19 +735,40 @@ export const woolGamesStatsSchema = z.looseObject({ capture_the_wool: z.looseObject({ stats: z.looseObject({ kills: z.number().default(0), - participated_wins: z.number().default(0) + assits: z.number().default(0), + deaths: z.number().default(0), + participated_wins: z.number().default(0), + participated_losses: z.number().default(0), + fastest_win: z.number().default(0), + longest_game: z.number().default(0), + wools_stolen: z.number().default(0), + wools_captured: z.number().default(0), + fastest_wool_capture: z.number().default(0), + gold_earned: z.number().default(0), + gold_spent: z.number().default(0) }).optional() }).optional(), sheep_wars: z.looseObject({ stats: z.looseObject({ kills: z.number().default(0), - wins: z.number().default(0) + deaths: z.number().default(0), + wins: z.number().default(0), + losses: z.number().default(0), + sheep_thrown: z.number().default(0), + damage_dealt: z.number().default(0) }).optional() }).optional(), wool_wars: z.looseObject({ + selected_class: z.string().optional(), stats: z.looseObject({ kills: z.number().default(0), - wins: z.number().default(0) + assits: z.number().default(0), + deaths: z.number().default(0), + wins: z.number().default(0), + losses: z.number().default(0), + wool_placed: z.number().default(0), + blocks_broken: z.number().default(0), + powerups_gotten: z.number().default(0) }).optional() }).optional() })