Weapon Inventory
+ {weapons !== undefined ? + ( +This person has no weapons.
} +{`${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