From b13d6023ffdc65bb5dc245df97d7e4234240ede7 Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 20 Sep 2025 00:33:15 +0200 Subject: [PATCH] Finished warlords stats --- .../player/[ign]/_stats/warlords/warlords.tsx | 3 ++ .../player/[ign]/_stats/warlords/weapons.tsx | 41 +++++++++++++++++++ src/data/hypixel/warlords.ts | 12 +++--- src/lib/hypixel/warlords/general.ts | 38 ++++++++++++++++- src/lib/schema/stats/warlords.ts | 17 ++++++++ 5 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 src/app/(stats)/player/[ign]/_stats/warlords/weapons.tsx diff --git a/src/app/(stats)/player/[ign]/_stats/warlords/warlords.tsx b/src/app/(stats)/player/[ign]/_stats/warlords/warlords.tsx index 3da0f81..9ea0617 100644 --- a/src/app/(stats)/player/[ign]/_stats/warlords/warlords.tsx +++ b/src/app/(stats)/player/[ign]/_stats/warlords/warlords.tsx @@ -7,6 +7,7 @@ import GeneralStats from "../GeneralStats" import { WarlordsWeaponsBar } from "./client" import WarlordsGeneralStats from "./stats" import { WarlordsClassStatsTable, WarlordsModeStatsTable } from "./table" +import WarlordsWeaponsList from "./weapons" export default function WarlordsStats({ stats }: { stats: NonNullStats["Warlords"] }) { if (!stats) return null @@ -44,6 +45,8 @@ export default function WarlordsStats({ stats }: { stats: NonNullStats["Warlords + + diff --git a/src/app/(stats)/player/[ign]/_stats/warlords/weapons.tsx b/src/app/(stats)/player/[ign]/_stats/warlords/weapons.tsx new file mode 100644 index 0000000..25c5d98 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/warlords/weapons.tsx @@ -0,0 +1,41 @@ +import { + getWarlordsPlayerClass, + getWarlordsWeaponMaterial, + getWarlordsWeaponPrefix, + getWarlordsWeaponRarityColor +} from "@/lib/hypixel/warlords/general" +import { NonNullStats } from "@/lib/schema/player" + +export default function WarlordsWeaponsList({ weapons }: { weapons: NonNullable["weapon_inventory"] }) { + return ( +
+

Weapon Inventory

+ {weapons !== undefined ? + ( +
+ {weapons.map((w, i) => { + return + })} +
+ ) : +

This person has no weapons.

} +
+ ) +} + +function Weapon({ data }: { data: NonNullable["weapon_inventory"]>[number] }) { + const score = data.damage * (1 + data.upgradeTimes * 0.075) + + data.chance + + data.multiplier + + data.abilityBoost * (1 + data.upgradeTimes * 0.075) + + data.health * (1 + data.upgradeTimes * 0.25) + + data.energy * (1 + data.upgradeTimes * 0.1) + + data.cooldown * (1 + data.upgradeTimes * 0.075) + + data.movement * (1 + data.upgradeTimes * 0.075) + + const prefix = getWarlordsWeaponPrefix(score, data.category) ?? "Unknown" + const material = getWarlordsWeaponMaterial(data.material) ?? "Unknown" + const playerClass = getWarlordsPlayerClass(0, 0) ?? "Unknown" + const rarityColor = getWarlordsWeaponRarityColor(data.category) + return

{`${prefix} ${material} of the ${playerClass}`}

+} diff --git a/src/data/hypixel/warlords.ts b/src/data/hypixel/warlords.ts index 65772e2..18eabca 100644 --- a/src/data/hypixel/warlords.ts +++ b/src/data/hypixel/warlords.ts @@ -79,12 +79,12 @@ export const MATERIALS = { "COOKED_PORKCHOP": "Gemini", "GOLDEN_CARROT": "Void Edge" } as const -export const PLAYERCLASSES = { - mage: ["Pyromancer", "Cryomancer", "Aquamancer"], - warrior: ["Berserker", "Defender", "Revenant"], - paladin: ["Avenger", "Crusader", "Protector"], - shaman: ["Thunderlord", "Earthwarden", "Spiritguard"] -} as const +export const PLAYERCLASSES = [ + ["Pyromancer", "Cryomancer", "Aquamancer"], + ["Berserker", "Defender", "Revenant"], + ["Avenger", "Crusader", "Protector"], + ["Thunderlord", "Earthwarden", "Spiritguard"] +] as const export const SCORES = { COMMON: [ { score: 276, prefix: "Crumbly" }, diff --git a/src/lib/hypixel/warlords/general.ts b/src/lib/hypixel/warlords/general.ts index 6b73b47..2703bd4 100644 --- a/src/lib/hypixel/warlords/general.ts +++ b/src/lib/hypixel/warlords/general.ts @@ -1,7 +1,43 @@ -import { CLASSES, MODES, RARITIES, UPGRADES } from "@/data/hypixel/warlords" +import { CLASSES, MATERIALS, MODES, PLAYERCLASSES, RARITIES, SCORES, UPGRADES } from "@/data/hypixel/warlords" import { NonNullStats } from "@/lib/schema/player" import { devide } from "../general" +export function getWarlordsWeaponRarityColor(category?: string) { + const rarity = RARITIES.find(r => r.id === category?.toLowerCase()) + + return rarity?.color || RARITIES.find(r => r.id === "common")!.color +} + +export function getWarlordsPlayerClass(playerClass: number | undefined, spec: number | undefined) { + if (playerClass === undefined || spec === undefined) return null + const klass = PLAYERCLASSES[playerClass][spec] + return klass || null +} + +export function getWarlordsWeaponMaterial(material?: string) { + const mats = Object.entries(MATERIALS) + const mat = mats.find(m => m[0] === material)?.[1] + return mat || null +} + +export function getWarlordsWeaponPrefix(score: number, category?: string) { + let prefix = "" + + const scores = Object.entries(SCORES) + const indexed = scores.find(s => s[0] === category)?.[1] + + if (!indexed) return null + + for (const s of indexed.slice().reverse()) { + if (score > s.score) { + prefix = s.prefix + break + } + } + + return prefix +} + export function getWarlordsClassLevel(classId: Exclude, stats: NonNullable) { let level = 0 diff --git a/src/lib/schema/stats/warlords.ts b/src/lib/schema/stats/warlords.ts index 79c3c36..068cea4 100644 --- a/src/lib/schema/stats/warlords.ts +++ b/src/lib/schema/stats/warlords.ts @@ -71,6 +71,23 @@ export const warlordsStatsSchema = z.object({ kills_capturetheflag: z.number().default(0), kills_domination: z.number().default(0), kills_teamdeathmatch: z.number().default(0), + weapon_inventory: z.array(z.object({ + damage: z.number().default(0), + chance: z.number().default(0), + multiplier: z.number().default(0), + abilityBoost: z.number().default(0), + health: z.number().default(0), + energy: z.number().default(0), + cooldown: z.number().default(0), + movement: z.number().default(0), + upgradeTimes: z.number().default(0), + category: z.string().optional(), + material: z.string().optional(), + spec: z.object({ + spec: z.number(), + playerClass: z.number() + }) + })).optional(), ...warlordsClassStats().left_right, ...warlordsClassStats().right_left })