99 lines
4.3 KiB
TypeScript
99 lines
4.3 KiB
TypeScript
import z from "zod"
|
|
import { arcadeStatsSchema } from "./stats/arcade"
|
|
import { bedwarsStatsSchema } from "./stats/bedwars"
|
|
import { blitzStatsSchema } from "./stats/blitz"
|
|
import { buildBattleStatsSchema } from "./stats/build-battle"
|
|
import { copsAndCrimsStatsSchema } from "./stats/copsandcrims"
|
|
import { duelsStatsSchema } from "./stats/duels"
|
|
import { megawallsStats } from "./stats/megawalls"
|
|
import { murderMysteryStatsSchema } from "./stats/murder-mystery"
|
|
import { pitStats } from "./stats/pit"
|
|
import { skywarsStatsSchema } from "./stats/skywars"
|
|
import { smashHerosStats } from "./stats/smashheros"
|
|
import { speedUhcStatsSchema } from "./stats/speeduhc"
|
|
import { tntGamesStatsSchema } from "./stats/tnt-games"
|
|
import { uhcSchema } from "./stats/uhc"
|
|
import { warlordsStatsSchema } from "./stats/warlords"
|
|
import { woolGamesStatsSchema } from "./stats/woolgames"
|
|
|
|
export const playerSchema = z.looseObject({
|
|
player: z.looseObject({
|
|
displayname: z.string(),
|
|
uuid: z.string(),
|
|
newPackageRank: z.string().optional(),
|
|
monthlyPackageRank: z.string().optional(),
|
|
rankPlusColor: z.string().optional(),
|
|
monthlyRankColor: z.string().optional(),
|
|
networkExp: z.number().default(0),
|
|
karma: z.number().default(0),
|
|
achievementPoints: z.number().default(0),
|
|
achievements: z.record(z.string(), z.number()).optional(),
|
|
stats: z.looseObject({
|
|
Bedwars: bedwarsStatsSchema.optional(),
|
|
SkyWars: skywarsStatsSchema.optional(),
|
|
Duels: duelsStatsSchema.optional(),
|
|
MurderMystery: murderMysteryStatsSchema.optional(),
|
|
BuildBattle: buildBattleStatsSchema.optional(),
|
|
UHC: uhcSchema.optional(),
|
|
Pit: pitStats.optional(),
|
|
TNTGames: tntGamesStatsSchema.optional(),
|
|
Walls3: megawallsStats.optional(),
|
|
MCGO: copsAndCrimsStatsSchema.optional(),
|
|
WoolGames: woolGamesStatsSchema.optional(),
|
|
HungerGames: blitzStatsSchema.optional(),
|
|
Arcade: arcadeStatsSchema.optional(),
|
|
SpeedUHC: speedUhcStatsSchema.optional(),
|
|
SuperSmash: smashHerosStats.optional(),
|
|
Battleground: warlordsStatsSchema.optional()
|
|
}).transform(({ Walls3, MCGO, HungerGames, SuperSmash, Battleground, ...rest }) => {
|
|
return {
|
|
MegaWalls: Walls3,
|
|
CopsAndCrims: MCGO,
|
|
Blitz: HungerGames,
|
|
SmashHeros: SuperSmash,
|
|
Warlords: Battleground,
|
|
...rest
|
|
}
|
|
}).optional(),
|
|
quests: z.record(
|
|
z.string(),
|
|
z.looseObject({
|
|
completions: z.array(
|
|
z.looseObject({
|
|
time: z.number()
|
|
})
|
|
).optional()
|
|
})
|
|
).optional(),
|
|
challenges: z.looseObject({
|
|
all_time: z.record(z.string(), z.number())
|
|
}).optional(),
|
|
lastClaimedReward: z.number().optional(),
|
|
rewardHighScore: z.number().optional(),
|
|
rewardStreak: z.number().optional(),
|
|
totalRewards: z.number().optional(),
|
|
giftingMeta: z.looseObject({
|
|
giftsGiven: z.number().optional(),
|
|
ranksGiven: z.number().optional()
|
|
}).optional(),
|
|
firstLogin: z.number().optional(),
|
|
lastLogin: z.number().optional(),
|
|
lastLogout: z.number().optional(),
|
|
socialMedia: z.looseObject({
|
|
links: z.looseObject({
|
|
DISCORD: z.string().optional(),
|
|
TWITCH: z.string().transform(v => v.match(/https?:\/\//)?.length === 1 ? v : `https://${v}`).optional(),
|
|
HYPIXEL: z.string().transform(v => v.match(/https?:\/\//)?.length === 1 ? v : `https://${v}`).optional(),
|
|
TWITTER: z.string().transform(v => v.match(/https?:\/\//)?.length === 1 ? v : `https://${v}`).optional(),
|
|
YOUTUBE: z.string().transform(v => v.match(/https?:\/\//)?.length === 1 ? v : `https://${v}`).optional()
|
|
}).optional()
|
|
}).optional(),
|
|
rank: z.string().optional(),
|
|
eulaCoins: z.boolean().optional(),
|
|
prefix: z.string().transform(v => v.replaceAll(/§[a-z]/g, "")).optional()
|
|
})
|
|
})
|
|
|
|
export type Player = z.infer<typeof playerSchema>
|
|
export type NonNullStats = NonNullable<Player["player"]["stats"]>
|