Added stats for general modes
This commit is contained in:
@@ -18,4 +18,3 @@ export async function getPlayer(uuid: string) {
|
||||
|
||||
return data.player
|
||||
}
|
||||
|
||||
|
||||
@@ -60,3 +60,36 @@ export function getLatestRoom(rooms?: Record<string, boolean>) {
|
||||
|
||||
return latestRoom
|
||||
}
|
||||
|
||||
export type _BedwarsStats = Record<string, number> & { [key: `${string}_winstreak`]: number | undefined }
|
||||
|
||||
export function getBedwarsModeStats(mode: "solo" | "doubles" | "3s" | "4s", stats: _BedwarsStats) {
|
||||
switch (mode) {
|
||||
case "solo":
|
||||
return bedwarsModeStats("eight_one", stats)
|
||||
case "doubles":
|
||||
return bedwarsModeStats("eight_two", stats)
|
||||
case "3s":
|
||||
return bedwarsModeStats("four_three", stats)
|
||||
case "4s":
|
||||
return bedwarsModeStats("four_four", stats)
|
||||
}
|
||||
}
|
||||
|
||||
function bedwarsModeStats(prefix: string, stats: _BedwarsStats) {
|
||||
return [
|
||||
stats[`${prefix}_kills_bedwars`],
|
||||
stats[`${prefix}_deaths_bedwars`],
|
||||
(stats[`${prefix}_kills_bedwars`] / stats[`${prefix}_deaths_bedwars`]).toFixed(2),
|
||||
stats[`${prefix}_final_kills_bedwars`],
|
||||
stats[`${prefix}_final_deaths_bedwars`],
|
||||
(stats[`${prefix}_final_kills_bedwars`] / stats[`${prefix}_final_deaths_bedwars`]).toFixed(2),
|
||||
stats[`${prefix}_wins_bedwars`],
|
||||
stats[`${prefix}_losses_bedwars`],
|
||||
(stats[`${prefix}_wins_bedwars`] / stats[`${prefix}_losses_bedwars`]).toFixed(2),
|
||||
stats[`${prefix}_winstreak`] ?? "?",
|
||||
stats[`${prefix}_beds_broken_bedwars`],
|
||||
stats[`${prefix}_beds_lost_bedwars`],
|
||||
(stats[`${prefix}_beds_broken_bedwars`] / stats[`${prefix}_beds_lost_bedwars`]).toFixed(2)
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function validatePlayer(ign: string) {
|
||||
if (!uuid) {
|
||||
return {
|
||||
error: true,
|
||||
message: "Player not found",
|
||||
message: "Player not found"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,13 @@ export async function validatePlayer(ign: string) {
|
||||
if (!player) {
|
||||
return {
|
||||
error: true,
|
||||
message: "Player never logged on to Hypixel",
|
||||
message: "Player never logged on to Hypixel"
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
error: false,
|
||||
message: "Player found",
|
||||
message: "Player found"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user