Updated mw stats
This commit is contained in:
@@ -28,6 +28,36 @@ export function getMegaWallsModeName(modeId: typeof MODES[number]["id"]) {
|
||||
return MODES.find(m => m.id === modeId)!.name
|
||||
}
|
||||
|
||||
export function getMegaWallsClass(classId: typeof CLASSES[number]["id"]) {
|
||||
return CLASSES.find(c => c.id === classId)!
|
||||
}
|
||||
|
||||
export function getAllClassStats(stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
||||
const statsArr: { id: typeof CLASSES[number]["id"], val: number[] }[] = []
|
||||
|
||||
for (const klass of CLASSES) {
|
||||
statsArr.push({ id: klass.id, val: megaWalsClassStats(klass.id, stats) })
|
||||
}
|
||||
|
||||
return statsArr
|
||||
}
|
||||
|
||||
export function megaWalsClassStats(classId: typeof CLASSES[number]["id"], stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
||||
return [
|
||||
stats[`${classId}_kills`],
|
||||
stats[`${classId}_deaths`],
|
||||
devide(stats[`${classId}_kills`], stats[`${classId}_deaths`]),
|
||||
stats[`${classId}_final_kills`],
|
||||
stats[`${classId}_final_deaths`],
|
||||
devide(stats[`${classId}_final_kills`], stats[`${classId}_final_deaths`]),
|
||||
stats[`${classId}_wins`],
|
||||
stats[`${classId}_losses`],
|
||||
devide(stats[`${classId}_wins`], stats[`${classId}_deaths`]),
|
||||
stats.classes === undefined ? 0 : stats.classes[classId].prestige,
|
||||
stats.classes === undefined ? 0 : stats.classes[classId].enderchest_rows
|
||||
]
|
||||
}
|
||||
|
||||
export function getMegaWallsModeStats(modeId: typeof MODES[number]["id"], stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
||||
return [
|
||||
stats[`kills_${modeId}`],
|
||||
|
||||
@@ -586,19 +586,38 @@ function megawallsClassStats() {
|
||||
] as const
|
||||
|
||||
const stats = [
|
||||
"kills",
|
||||
"deaths",
|
||||
"final_kills",
|
||||
"final_deaths",
|
||||
"wins",
|
||||
"losses"
|
||||
] as const
|
||||
|
||||
const classesOther = [
|
||||
"prestige",
|
||||
"enderchest_rows"
|
||||
] as const
|
||||
|
||||
const entries = new Map<string, z.ZodDefault<z.ZodNumber>>()
|
||||
const classes = new Map<string, z.ZodObject<{ prestige: z.ZodDefault<z.ZodNumber>, enderchest_rows: z.ZodDefault<z.ZodNumber> }, z.core.$loose>>()
|
||||
|
||||
for (const id of ids) {
|
||||
for (const stat of stats) {
|
||||
entries.set(`${id}_${stat}`, z.number().default(0))
|
||||
}
|
||||
for (const klass of classesOther) {
|
||||
classes.set(id, z.looseObject({ prestige: z.number().default(0), enderchest_rows: z.number().default(0) }))
|
||||
}
|
||||
}
|
||||
|
||||
return Object.fromEntries(entries) as Record<`${typeof ids[number]}_${typeof stats[number]}`, z.ZodDefault<z.ZodNumber>>
|
||||
return {
|
||||
classStats: Object.fromEntries(entries) as Record<`${typeof ids[number]}_${typeof stats[number]}`, z.ZodDefault<z.ZodNumber>>,
|
||||
classOther: Object.fromEntries(classes) as Record<
|
||||
`${typeof ids[number]}`,
|
||||
z.ZodObject<{ prestige: z.ZodDefault<z.ZodNumber>, enderchest_rows: z.ZodDefault<z.ZodNumber> }, z.core.$loose>
|
||||
>
|
||||
}
|
||||
}
|
||||
|
||||
function megawallsModeStats() {
|
||||
@@ -640,6 +659,7 @@ export const megawallsStats = z.looseObject({
|
||||
coins: z.number().default(0),
|
||||
wither_damage: z.number().default(0),
|
||||
witherDamage: z.number().default(0),
|
||||
...megawallsClassStats(),
|
||||
classes: z.looseObject(megawallsClassStats().classOther).optional(),
|
||||
...megawallsClassStats().classStats,
|
||||
...megawallsModeStats()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user