From 62beebaf452510a372f87ade808c92f14093300b Mon Sep 17 00:00:00 2001 From: eatmyvenom Date: Sat, 1 Oct 2022 01:23:02 -0700 Subject: [PATCH] style(schemas): rework game modes to be done with decorators --- .../commands/tntgames/tntgames.command.tsx | 11 +- packages/schemas/src/game/game-modes.ts | 6 +- packages/schemas/src/index.ts | 2 +- .../schemas/src/metadata/GameType/index.ts | 75 ++++++++++++ packages/schemas/src/metadata/constants.ts | 2 +- packages/schemas/src/metadata/field/index.ts | 7 +- packages/schemas/src/metadata/index.ts | 1 + .../schemas/src/metadata/metadata-scanner.ts | 4 +- .../src/player/gamemodes/arcade/index.ts | 56 +++++---- .../src/player/gamemodes/arenabrawl/index.ts | 27 ++-- .../src/player/gamemodes/bedwars/index.ts | 86 +++++++------ .../src/player/gamemodes/blitzsg/index.ts | 115 ++++++++++-------- .../src/player/gamemodes/buildbattle/index.ts | 33 +++-- .../src/player/gamemodes/challenges/index.ts | 65 +++++----- .../player/gamemodes/copsandcrims/index.ts | 29 +++-- .../src/player/gamemodes/duels/index.ts | 101 ++++++++------- .../src/player/gamemodes/duels/mode.ts | 19 +++ .../src/player/gamemodes/general/index.ts | 11 +- .../src/player/gamemodes/megawalls/index.ts | 67 +++++----- .../player/gamemodes/murdermystery/index.ts | 34 +++--- .../src/player/gamemodes/paintball/index.ts | 12 +- .../src/player/gamemodes/parkour/index.ts | 11 +- .../schemas/src/player/gamemodes/pit/index.ts | 13 +- .../src/player/gamemodes/quake/index.ts | 23 ++-- .../src/player/gamemodes/skywars/index.ts | 55 +++++---- .../src/player/gamemodes/smashheroes/index.ts | 65 +++++----- .../src/player/gamemodes/speeduhc/index.ts | 49 +++++--- .../src/player/gamemodes/tntgames/index.ts | 28 +++-- .../player/gamemodes/turbokartracers/index.ts | 13 +- .../schemas/src/player/gamemodes/uhc/index.ts | 23 ++-- .../src/player/gamemodes/vampirez/index.ts | 17 ++- .../src/player/gamemodes/walls/index.ts | 11 +- .../src/player/gamemodes/warlords/index.ts | 6 + .../src/player/gamemodes/woolwars/index.ts | 33 ++--- 34 files changed, 664 insertions(+), 446 deletions(-) create mode 100644 packages/schemas/src/metadata/GameType/index.ts diff --git a/apps/discord-bot/src/commands/tntgames/tntgames.command.tsx b/apps/discord-bot/src/commands/tntgames/tntgames.command.tsx index fdb6aaff7..7fd8a8bd3 100644 --- a/apps/discord-bot/src/commands/tntgames/tntgames.command.tsx +++ b/apps/discord-bot/src/commands/tntgames/tntgames.command.tsx @@ -8,7 +8,7 @@ import { BaseHypixelCommand, BaseProfileProps } from "../base.hypixel-command"; import { Command } from "@statsify/discord"; -import { TNTGamesModes, TNT_GAMES_MODES } from "@statsify/schemas"; +import { GameMode, Player, TNTGamesModes, TNT_GAMES_MODES } from "@statsify/schemas"; import { TNTGamesProfile } from "./tntgames.profile"; @Command({ description: (t) => t("commands.tntgames") }) @@ -17,6 +17,15 @@ export class TNTGamesCommand extends BaseHypixelCommand { super(TNT_GAMES_MODES); } + public filterModes( + player: Player, + modes: GameMode[] + ): GameMode[] { + const [overall] = modes; + + return [overall]; + } + public getProfile(base: BaseProfileProps): JSX.Element { return ; } diff --git a/packages/schemas/src/game/game-modes.ts b/packages/schemas/src/game/game-modes.ts index 3bc8952f7..68bf6405a 100644 --- a/packages/schemas/src/game/game-modes.ts +++ b/packages/schemas/src/game/game-modes.ts @@ -8,13 +8,13 @@ import { prettify } from "@statsify/util"; -interface StatsifyGameMode { +export interface StatsifyGameMode { hypixel?: string; api: T; formatted?: string; } -interface HypixelGameMode { +export interface HypixelGameMode { hypixel: string; formatted: string; } @@ -37,7 +37,7 @@ export class GameModes { this.hypixelModes = Object.fromEntries( modes - .filter((m) => "hypixel" in m) + .filter((m) => m.hypixel) .map((m) => [m.hypixel, m.formatted ?? prettify((m as GameMode).api)]) ); } diff --git a/packages/schemas/src/index.ts b/packages/schemas/src/index.ts index 512134c98..3bbb29475 100644 --- a/packages/schemas/src/index.ts +++ b/packages/schemas/src/index.ts @@ -6,7 +6,7 @@ * https://github.com/Statsify/statsify/blob/main/LICENSE */ -export { METADATA_KEY } from "./metadata/constants"; +export { FIELD_METADATA_KEY as METADATA_KEY } from "./metadata/constants"; export * from "./color"; export * from "./commands"; export * from "./friends"; diff --git a/packages/schemas/src/metadata/GameType/index.ts b/packages/schemas/src/metadata/GameType/index.ts new file mode 100644 index 000000000..a0738f239 --- /dev/null +++ b/packages/schemas/src/metadata/GameType/index.ts @@ -0,0 +1,75 @@ +/** + * Copyright (c) Statsify + * + * This source code is licensed under the GNU GPL v3 license found in the + * LICENSE file in the root directory of this source tree. + * https://github.com/Statsify/statsify/blob/main/LICENSE + */ + +import { ChallengesBedWars } from "../../player"; +import { Constructor } from "@statsify/util"; +import { HypixelGameMode, StatsifyGameMode } from "../../game"; +import { Progression } from "../../progression"; + +const GAMETYPE_METADATA_KEY = "statsify:gametype"; + +export interface HypixelGameMetadata { + gameModes?: StatsifyGameMode[]; +} + +type ignoredTypes = string | boolean | number | Progression | ChallengesBedWars; +type OptionalString = K extends string ? K : never; + +export type StatsifyApiModes = + | OptionalString + | keyof Pick< + T, + { + [Key in keyof T]: T[Key] extends ignoredTypes ? never : Key; + }[keyof T] + >; + +export function Mode(hypixel?: string, formatted?: string): PropertyDecorator { + return (target, propertyKey) => { + const { gameModes = [] } = (Reflect.getMetadata(GAMETYPE_METADATA_KEY, target) ?? + {}) as HypixelGameMetadata; + + hypixel = hypixel === "" ? undefined : hypixel; + formatted = formatted === "" ? undefined : formatted; + + Reflect.defineMetadata( + GAMETYPE_METADATA_KEY, + { + gameModes: [...gameModes, { hypixel, api: propertyKey, formatted }], + }, + target + ); + }; +} + +export function GameType( + baseName?: string, + hypixel?: string, + formatted?: string +): ClassDecorator { + return (target: any) => { + if (!baseName) return; + const { gameModes = [] } = (Reflect.getMetadata(GAMETYPE_METADATA_KEY, target) ?? + {}) as HypixelGameMetadata; + + Reflect.defineMetadata( + GAMETYPE_METADATA_KEY, + { + gameModes: [{ api: baseName, hypixel, formatted }, ...gameModes], + }, + target + ); + }; +} + +export function GetMetadataModes(target: Constructor) { + const { gameModes = [] } = (Reflect.getMetadata(GAMETYPE_METADATA_KEY, target) ?? + {}) as HypixelGameMetadata; + + return gameModes as HypixelGameMode[]; +} diff --git a/packages/schemas/src/metadata/constants.ts b/packages/schemas/src/metadata/constants.ts index 6f4740c66..0f7975af5 100644 --- a/packages/schemas/src/metadata/constants.ts +++ b/packages/schemas/src/metadata/constants.ts @@ -8,7 +8,7 @@ import { Constructor } from "@statsify/util"; -export const METADATA_KEY = "statsify"; +export const FIELD_METADATA_KEY = "statsify:field"; export const primitiveConstructors = [ String, diff --git a/packages/schemas/src/metadata/field/index.ts b/packages/schemas/src/metadata/field/index.ts index 620a2da32..3c89bb4cc 100644 --- a/packages/schemas/src/metadata/field/index.ts +++ b/packages/schemas/src/metadata/field/index.ts @@ -8,8 +8,8 @@ import { ApiHideProperty, ApiProperty } from "@nestjs/swagger"; import { ClassMetadata } from "../metadata.interface"; +import { FIELD_METADATA_KEY } from "../constants"; import { FieldOptions } from "../field.options"; -import { METADATA_KEY } from "../constants"; import { getLeaderboardMetadata } from "./get-leaderboard-metadata"; import { getStoreMetadata } from "./get-store-metadata"; import { getTypeMetadata } from "./get-type-metadata"; @@ -23,7 +23,8 @@ export function Field({ mongo: mongoOptions, }: FieldOptions = {}): PropertyDecorator { return (target, propertyKey) => { - const metadata = (Reflect.getMetadata(METADATA_KEY, target) ?? {}) as ClassMetadata; + const metadata = (Reflect.getMetadata(FIELD_METADATA_KEY, target) ?? + {}) as ClassMetadata; const type = getTypeMetadata(typeOptions, target, propertyKey); const leaderboard = getLeaderboardMetadata( @@ -34,7 +35,7 @@ export function Field({ const store = getStoreMetadata(type, leaderboard, storeOptions); Reflect.defineMetadata( - METADATA_KEY, + FIELD_METADATA_KEY, { ...metadata, [propertyKey as string]: { diff --git a/packages/schemas/src/metadata/index.ts b/packages/schemas/src/metadata/index.ts index 47f5da75c..2239b79bd 100644 --- a/packages/schemas/src/metadata/index.ts +++ b/packages/schemas/src/metadata/index.ts @@ -7,6 +7,7 @@ */ export * from "./field"; +export * from "./GameType"; export * from "./metadata-scanner"; export * from "./serialize"; export * from "./field.options"; diff --git a/packages/schemas/src/metadata/metadata-scanner.ts b/packages/schemas/src/metadata/metadata-scanner.ts index 55f16d05a..1a7695750 100644 --- a/packages/schemas/src/metadata/metadata-scanner.ts +++ b/packages/schemas/src/metadata/metadata-scanner.ts @@ -8,8 +8,8 @@ import { ClassMetadata, FieldMetadata } from "./metadata.interface"; import { Constructor } from "@statsify/util"; +import { FIELD_METADATA_KEY } from "./constants"; import { LEADERBOARD_RATIO_KEYS } from "../ratios"; -import { METADATA_KEY } from "./constants"; export type MetadataEntry = [string, FieldMetadata]; @@ -32,7 +32,7 @@ export class MetadataScanner { baseName = "" ): MetadataEntry[] { const classMetadata = Reflect.getMetadata( - METADATA_KEY, + FIELD_METADATA_KEY, constructor.prototype ) as ClassMetadata; diff --git a/packages/schemas/src/player/gamemodes/arcade/index.ts b/packages/schemas/src/player/gamemodes/arcade/index.ts index 11e6d8fba..34a4d592d 100644 --- a/packages/schemas/src/player/gamemodes/arcade/index.ts +++ b/packages/schemas/src/player/gamemodes/arcade/index.ts @@ -29,33 +29,15 @@ import { Zombies, } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; - -export const ARCADE_MODES = new GameModes([ - { api: "overall" }, - { api: "blockingDead", hypixel: "DAYONE" }, - { api: "bountyHunters", hypixel: "ONEINTHEQUIVER" }, - { api: "captureTheWool", hypixel: "PVP_CTW" }, - { api: "creeperAttack", hypixel: "DEFENDER" }, - { api: "dragonWars", hypixel: "DRAGONWARS2" }, - { api: "enderSpleef", hypixel: "ENDER" }, - { api: "farmHunt", hypixel: "FARM_HUNT" }, - { api: "football", hypixel: "SOCCER" }, - { api: "galaxyWars", hypixel: "STARWARS" }, - { api: "hideAndSeek" }, - { api: "holeInTheWall", hypixel: "HOLE_IN_THE_WALL" }, - { api: "hypixelSays", hypixel: "SIMON_SAYS" }, - { api: "miniWalls", hypixel: "MINI_WALLS" }, - { api: "partyGames", hypixel: "PARTY" }, - { api: "pixelPainters", hypixel: "DRAW_THEIR_THING" }, - { api: "pixelParty", hypixel: "PIXEL_PARTY" }, - { api: "seasonal" }, - { api: "throwOut", hypixel: "THROW_OUT" }, - { api: "zombies" }, -]); - -export type ArcadeModes = IGameModes; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; +@GameType("overall") export class Arcade { @Field() public coins: number; @@ -63,60 +45,79 @@ export class Arcade { @Field() public wins: number; + @Mode("DAYONE") @Field() public blockingDead: BlockingDead; + @Mode("ONEINTHEQUIVER") @Field() public bountyHunters: BountyHunters; + @Mode("PVP_CTW") @Field() public captureTheWool: CaptureTheWool; + @Mode("DEFENDER") @Field() public creeperAttack: CreeperAttack; + @Mode("DRAGONWARS2") @Field() public dragonWars: DragonWars; + @Mode("ENDER") @Field() public enderSpleef: EnderSpleef; + @Mode("FARM_HUNT") @Field() public farmHunt: FarmHunt; + @Mode("SOCCER") @Field() public football: Football; + @Mode("STARWARS") @Field() public galaxyWars: GalaxyWars; + @Mode() @Field() public hideAndSeek: HideAndSeek; + @Mode("HOLE_IN_THE_WALL") @Field() public holeInTheWall: HoleInTheWall; + @Mode("SIMON_SAYS") @Field() public hypixelSays: HypixelSays; + @Mode("MINI_WALLS") @Field() public miniWalls: MiniWalls; + @Mode("PARTY") @Field() public partyGames: PartyGames; + @Mode("DRAW_THEIR_THING") @Field() public pixelPainters: PixelPainters; + @Mode("PIXEL_PARTY") @Field() public pixelParty: PixelParty; + @Mode() @Field() public seasonal: Seasonal; + @Mode("THROW_OUT") @Field() public throwOut: ThrowOut; + @Mode() @Field() public zombies: Zombies; @@ -145,5 +146,8 @@ export class Arcade { } } +export type ArcadeModes = StatsifyApiModes; +export const ARCADE_MODES = new GameModes(GetMetadataModes(Arcade)); + export * from "./mode"; export * from "./seasonal-mode"; diff --git a/packages/schemas/src/player/gamemodes/arenabrawl/index.ts b/packages/schemas/src/player/gamemodes/arenabrawl/index.ts index 85aaaad7e..ef1e007b9 100644 --- a/packages/schemas/src/player/gamemodes/arenabrawl/index.ts +++ b/packages/schemas/src/player/gamemodes/arenabrawl/index.ts @@ -9,7 +9,7 @@ import { APIData } from "@statsify/util"; import { ArenaBrawlMode } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression, @@ -17,16 +17,15 @@ import { getFormattedPrefix, rainbow, } from "../prefixes"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { deepAdd } from "@statsify/math"; -export const ARENA_BRAWL_MODES = new GameModes([ - { api: "overall" }, - { api: "solo" }, - { api: "doubles" }, - { api: "fours" }, -]); - const prefixes: GamePrefix[] = [ { fmt: (n) => `§8[${n}]`, req: 0 }, { fmt: (n) => `§7[${n}]`, req: 500 }, @@ -40,8 +39,7 @@ const prefixes: GamePrefix[] = [ { fmt: (n) => rainbow(`[${n}]`), req: 15_000 }, ]; -export type ArenaBrawlModes = IGameModes; - +@GameType() export class ArenaBrawl { @Field() public progression: Progression; @@ -55,15 +53,19 @@ export class ArenaBrawl { @Field() public nextPrefix: string; + @Mode() @Field() public overall: ArenaBrawlMode; + @Mode() @Field() public solo: ArenaBrawlMode; + @Mode() @Field() public doubles: ArenaBrawlMode; + @Mode() @Field() public fours: ArenaBrawlMode; @@ -132,4 +134,9 @@ export class ArenaBrawl { } } +export type ArenaBrawlModes = StatsifyApiModes; +export const ARENA_BRAWL_MODES = new GameModes( + GetMetadataModes(ArenaBrawl) +); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/bedwars/index.ts b/packages/schemas/src/player/gamemodes/bedwars/index.ts index 34b89972f..37b4788e2 100644 --- a/packages/schemas/src/player/gamemodes/bedwars/index.ts +++ b/packages/schemas/src/player/gamemodes/bedwars/index.ts @@ -9,47 +9,18 @@ import { APIData } from "@statsify/util"; import { BedWarsMode, ChallengesBedWars, DreamsBedWarsMode } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { add, deepSub } from "@statsify/math"; import { getExpReq, getFormattedLevel, getLevel } from "./util"; -export const BEDWARS_MODES = new GameModes([ - { api: "overall" }, - { api: "core" }, - { api: "solo", hypixel: "BEDWARS_EIGHT_ONE" }, - { api: "doubles", hypixel: "BEDWARS_EIGHT_TWO" }, - { api: "threes", hypixel: "BEDWARS_FOUR_THREE" }, - { api: "fours", hypixel: "BEDWARS_FOUR_FOUR" }, - { api: "4v4", hypixel: "BEDWARS_TWO_FOUR" }, - { api: "armed" }, - { api: "castle", hypixel: "BEDWARS_CASTLE" }, - { api: "lucky" }, - { api: "rush" }, - { api: "swap" }, - { api: "ultimate" }, - { api: "underworld" }, - { api: "voidless" }, - - { hypixel: "BEDWARS_EIGHT_TWO_ARMED", formatted: "Armed Doubles" }, - { hypixel: "BEDWARS_FOUR_FOUR_ARMED", formatted: "Armed Fours" }, - { hypixel: "BEDWARS_EIGHT_TWO_LUCKY", formatted: "Lucky Doubles" }, - { hypixel: "BEDWARS_FOUR_FOUR_LUCKY", formatted: "Lucky Fours" }, - { hypixel: "BEDWARS_EIGHT_TWO_RUSH", formatted: "Rush Doubles" }, - { hypixel: "BEDWARS_FOUR_FOUR_RUSH", formatted: "Rush Fours" }, - { hypixel: "BEDWARS_EIGHT_TWO_SWAP", formatted: "Swap Doubles" }, - { hypixel: "BEDWARS_FOUR_FOUR_SWAP", formatted: "Swap Fours" }, - { hypixel: "BEDWARS_EIGHT_TWO_ULTIMATE", formatted: "Ultimate Doubles" }, - { hypixel: "BEDWARS_FOUR_FOUR_ULTIMATE", formatted: "Ultimate Fours" }, - { hypixel: "BEDWARS_EIGHT_TWO_UNDERWORLD", formatted: "Underworld Doubles" }, - { hypixel: "BEDWARS_FOUR_FOUR_UNDERWORLD", formatted: "Underworld Fours" }, - { hypixel: "BEDWARS_EIGHT_TWO_VOIDLESS", formatted: "Voidless Doubles" }, - { hypixel: "BEDWARS_FOUR_FOUR_VOIDLESS", formatted: "Voidless Fours" }, - { hypixel: "BEDWARS_PRACTICE", formatted: "Practice" }, -]); - -export type BedWarsModes = IGameModes; - +@GameType() export class BedWars { @Field() public coins: number; @@ -83,48 +54,63 @@ export class BedWars { @Field() public nextLevelFormatted: string; + @Mode() @Field() public overall: BedWarsMode; + @Mode() + @Field() + public core: BedWarsMode; + + @Mode("BEDWARS_EIGHT_ONE") @Field() public solo: BedWarsMode; + @Mode("BEDWARS_EIGHT_TWO") @Field() public doubles: BedWarsMode; + @Mode("BEDWARS_FOUR_THREE") @Field() public threes: BedWarsMode; + @Mode("BEDWARS_FOUR_FOUR") @Field() public fours: BedWarsMode; - @Field() - public core: BedWarsMode; - + @Mode("BEDWARS_TWO_FOUR") @Field() public "4v4": BedWarsMode; + @Mode() @Field() public armed: BedWarsMode; + @Mode("BEDWARS_CASTLE") @Field() public castle: BedWarsMode; + @Mode() @Field() public lucky: BedWarsMode; + @Mode() @Field() public rush: BedWarsMode; + @Mode() @Field() public swap: BedWarsMode; + @Mode() @Field() public ultimate: BedWarsMode; + @Mode() @Field() public underworld: BedWarsMode; + @Mode() @Field() public voidless: BedWarsMode; @@ -181,4 +167,24 @@ export class BedWars { } } +export type BedWarsModes = StatsifyApiModes; +export const BEDWARS_MODES = new GameModes([ + ...GetMetadataModes(BedWars), + { hypixel: "BEDWARS_EIGHT_TWO_ARMED", formatted: "Armed Doubles" }, + { hypixel: "BEDWARS_FOUR_FOUR_ARMED", formatted: "Armed Fours" }, + { hypixel: "BEDWARS_EIGHT_TWO_LUCKY", formatted: "Lucky Doubles" }, + { hypixel: "BEDWARS_FOUR_FOUR_LUCKY", formatted: "Lucky Fours" }, + { hypixel: "BEDWARS_EIGHT_TWO_RUSH", formatted: "Rush Doubles" }, + { hypixel: "BEDWARS_FOUR_FOUR_RUSH", formatted: "Rush Fours" }, + { hypixel: "BEDWARS_EIGHT_TWO_SWAP", formatted: "Swap Doubles" }, + { hypixel: "BEDWARS_FOUR_FOUR_SWAP", formatted: "Swap Fours" }, + { hypixel: "BEDWARS_EIGHT_TWO_ULTIMATE", formatted: "Ultimate Doubles" }, + { hypixel: "BEDWARS_FOUR_FOUR_ULTIMATE", formatted: "Ultimate Fours" }, + { hypixel: "BEDWARS_EIGHT_TWO_UNDERWORLD", formatted: "Underworld Doubles" }, + { hypixel: "BEDWARS_FOUR_FOUR_UNDERWORLD", formatted: "Underworld Fours" }, + { hypixel: "BEDWARS_EIGHT_TWO_VOIDLESS", formatted: "Voidless Doubles" }, + { hypixel: "BEDWARS_FOUR_FOUR_VOIDLESS", formatted: "Voidless Fours" }, + { hypixel: "BEDWARS_PRACTICE", formatted: "Practice" }, +]); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/blitzsg/index.ts b/packages/schemas/src/player/gamemodes/blitzsg/index.ts index 24266dd9d..1f48d03db 100644 --- a/packages/schemas/src/player/gamemodes/blitzsg/index.ts +++ b/packages/schemas/src/player/gamemodes/blitzsg/index.ts @@ -10,67 +10,22 @@ import { APIData } from "@statsify/util"; import { BlitzSGKit } from "./kit"; import { BlitzSGMode, BlitzSGOverall } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression, defaultPrefix, getFormattedPrefix, } from "../prefixes"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { sub } from "@statsify/math"; -export const BLITZSG_MODES = new GameModes([ - { api: "overall" }, - { api: "arachnologist" }, - { api: "archer" }, - { api: "armorer" }, - { api: "astronaut" }, - { api: "baker" }, - { api: "blaze" }, - { api: "creepertamer" }, - { api: "diver" }, - { api: "donkeytamer" }, - { api: "farmer" }, - { api: "fisherman" }, - { api: "florist" }, - { api: "golem" }, - { api: "guardian" }, - { api: "horsetamer" }, - { api: "hunter" }, - { api: "hypetrain" }, - { api: "jockey" }, - { api: "knight" }, - { api: "meatmaster" }, - { api: "milkman" }, - { api: "necromancer" }, - { api: "paladin" }, - { api: "phoenix" }, - { api: "pigman" }, - { api: "rambo" }, - { api: "random" }, - { api: "ranger" }, - { api: "reaper" }, - { api: "reddragon" }, - { api: "rogue" }, - { api: "scout" }, - { api: "shadowknight" }, - { api: "shark" }, - { api: "slimeyslime" }, - { api: "snowman" }, - { api: "speleologist" }, - { api: "tim" }, - { api: "toxicologist" }, - { api: "troll" }, - { api: "viking" }, - { api: "warlock" }, - { api: "warrior" }, - { api: "wolftamer" }, - - { hypixel: "solo_normal", formatted: "Solo" }, - { hypixel: "teams_normal", formatted: "Doubles" }, -]); - const prefixes: GamePrefix[] = [ { fmt: (n) => `§f[§7${n}§f]`, req: 0 }, { fmt: (n) => `§e[${n}]`, req: 1000 }, @@ -84,8 +39,7 @@ const prefixes: GamePrefix[] = [ { fmt: (n) => `§2§l[${n}]`, req: 300_000 }, ]; -export type BlitzSGModes = IGameModes; - +@GameType() export class BlitzSG { @Field() public coins: number; @@ -93,6 +47,7 @@ export class BlitzSG { @Field({ store: { default: "none" } }) public kit: string; + @Mode() @Field() public overall: BlitzSGOverall; @@ -114,135 +69,179 @@ export class BlitzSG { @Field() public doubles: BlitzSGMode; + @Mode() @Field({ store: { required: false } }) public arachnologist: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public archer: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public armorer: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public astronaut: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public baker: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public blaze: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public creepertamer: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public diver: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public donkeytamer: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public farmer: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public fisherman: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public florist: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public golem: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public guardian: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public horsetamer: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public hunter: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public hypetrain: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public jockey: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public knight: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public meatmaster: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public milkman: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public necromancer: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public paladin: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public phoenix: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public pigman: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public rambo: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public random: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public ranger: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public reaper: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public reddragon: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public rogue: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public scout: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public shadowknight: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public shark: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public slimeyslime: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public snowman: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public speleologist: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public tim: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public toxicologist: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public troll: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public viking: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public warlock: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public warrior: BlitzSGKit; + @Mode() @Field({ store: { required: false } }) public wolftamer: BlitzSGKit; @@ -322,5 +321,13 @@ export class BlitzSG { } } +type ExcludeKeys = "solo" | "doubles"; +export type BlitzSGModes = StatsifyApiModes>; +export const BLITZSG_MODES = new GameModes([ + ...GetMetadataModes(BlitzSG), + { hypixel: "solo_normal", formatted: "Solo" }, + { hypixel: "teams_normal", formatted: "Doubles" }, +]); + export * from "./kit"; export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/buildbattle/index.ts b/packages/schemas/src/player/gamemodes/buildbattle/index.ts index 9311cf34d..a93e661f3 100644 --- a/packages/schemas/src/player/gamemodes/buildbattle/index.ts +++ b/packages/schemas/src/player/gamemodes/buildbattle/index.ts @@ -14,25 +14,21 @@ import { BuildBattlePro, } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GameTitle, createPrefixProgression, defaultPrefix, getFormattedPrefix, } from "../prefixes"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; -export const BUILD_BATTLE_MODES = new GameModes([ - { api: "overall" }, - - { hypixel: "BUILD_BATTLE_SOLO_NORMAL_LATEST", formatted: "1.14" }, - { hypixel: "BUILD_BATTLE_GUESS_THE_BUILD", formatted: "GTB" }, - { hypixel: "BUILD_BATTLE_TEAMS_NORMAL", formatted: "Teams" }, - { hypixel: "BUILD_BATTLE_SOLO_NORMAL", formatted: "Solo" }, - { hypixel: "BUILD_BATTLE_SOLO_PRO", formatted: "Pro" }, -]); - const titles: GameTitle[] = [ { req: 0, fmt: (n) => `§f${n}`, title: "Rookie" }, { req: 100, fmt: (n) => `§8${n}`, title: "Untrained" }, @@ -48,9 +44,9 @@ const titles: GameTitle[] = [ { req: 20_000, fmt: (n) => `§4${n}`, title: "Master" }, ]; -export type BuildBattleModes = IGameModes; - +@GameType() export class BuildBattle { + @Mode() @Field() public overall: BuildBattleOverall; @@ -122,4 +118,15 @@ export class BuildBattle { } } +export type BuildBattleModes = StatsifyApiModes; +export const BUILD_BATTLE_MODES = new GameModes([ + ...GetMetadataModes(BuildBattle), + + { hypixel: "BUILD_BATTLE_SOLO_NORMAL_LATEST", formatted: "1.14" }, + { hypixel: "BUILD_BATTLE_GUESS_THE_BUILD", formatted: "GTB" }, + { hypixel: "BUILD_BATTLE_TEAMS_NORMAL", formatted: "Teams" }, + { hypixel: "BUILD_BATTLE_SOLO_NORMAL", formatted: "Solo" }, + { hypixel: "BUILD_BATTLE_SOLO_PRO", formatted: "Pro" }, +]); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/challenges/index.ts b/packages/schemas/src/player/gamemodes/challenges/index.ts index 8465ccd1c..44fde939e 100644 --- a/packages/schemas/src/player/gamemodes/challenges/index.ts +++ b/packages/schemas/src/player/gamemodes/challenges/index.ts @@ -31,101 +31,99 @@ import { WoolWarsChallenges, } from "./modes"; import { Field } from "../../../metadata"; -import { FormattedGame, GameModes, IGameModes } from "../../../game"; - -export const CHALLENGE_MODES = new GameModes([ - { api: "overall" }, - { api: "ARCADE", formatted: removeFormatting(FormattedGame.ARCADE) }, - { api: "ARENA_BRAWL", formatted: removeFormatting(FormattedGame.ARENA_BRAWL) }, - { api: "BEDWARS", formatted: removeFormatting(FormattedGame.BEDWARS) }, - { api: "BLITZSG", formatted: removeFormatting(FormattedGame.BLITZSG) }, - { api: "BUILD_BATTLE", formatted: removeFormatting(FormattedGame.BUILD_BATTLE) }, - { api: "DUELS", formatted: removeFormatting(FormattedGame.DUELS) }, - { api: "COPS_AND_CRIMS", formatted: removeFormatting(FormattedGame.COPS_AND_CRIMS) }, - { api: "MEGAWALLS", formatted: removeFormatting(FormattedGame.MEGAWALLS) }, - { api: "MURDER_MYSTERY", formatted: removeFormatting(FormattedGame.MURDER_MYSTERY) }, - { api: "PAINTBALL", formatted: removeFormatting(FormattedGame.PAINTBALL) }, - { api: "QUAKE", formatted: removeFormatting(FormattedGame.QUAKE) }, - { api: "SKYWARS", formatted: removeFormatting(FormattedGame.SKYWARS) }, - { api: "SMASH_HEROES", formatted: removeFormatting(FormattedGame.SMASH_HEROES) }, - { api: "SPEED_UHC", formatted: removeFormatting(FormattedGame.SPEED_UHC) }, - { api: "TNT_GAMES", formatted: removeFormatting(FormattedGame.TNT_GAMES) }, - { - api: "TURBO_KART_RACERS", - formatted: removeFormatting(FormattedGame.TURBO_KART_RACERS), - }, - { api: "UHC", formatted: removeFormatting(FormattedGame.UHC) }, - { api: "VAMPIREZ", formatted: removeFormatting(FormattedGame.VAMPIREZ) }, - { api: "WALLS", formatted: removeFormatting(FormattedGame.WALLS) }, - { api: "WARLORDS", formatted: removeFormatting(FormattedGame.WARLORDS) }, - { api: "WOOLWARS", formatted: removeFormatting(FormattedGame.WOOLWARS) }, -]); - -export type ChallengeModes = IGameModes; +import { FormattedGame, GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; +@GameType("overall") export class Challenges { + @Mode("", removeFormatting(FormattedGame.ARCADE)) @Field({ leaderboard: { fieldName: `${FormattedGame.ARCADE} Challenges -` } }) public ARCADE: ArcadeChallenges; + @Mode("", removeFormatting(FormattedGame.ARENA_BRAWL)) @Field({ leaderboard: { fieldName: `${FormattedGame.ARENA_BRAWL} Challenges -` } }) public ARENA_BRAWL: ArenaBrawlChallenges; + @Mode("", removeFormatting(FormattedGame.BEDWARS)) @Field({ leaderboard: { fieldName: `${FormattedGame.BEDWARS} Challenges -` } }) public BEDWARS: BedWarsChallenges; + @Mode("", removeFormatting(FormattedGame.BLITZSG)) @Field({ leaderboard: { fieldName: `${FormattedGame.BLITZSG} Challenges -` } }) public BLITZSG: BlitzSGChallenges; + @Mode("", removeFormatting(FormattedGame.BUILD_BATTLE)) @Field({ leaderboard: { fieldName: `${FormattedGame.BUILD_BATTLE} Challenges -` } }) public BUILD_BATTLE: BuildBattleChallenges; + @Mode("", removeFormatting(FormattedGame.COPS_AND_CRIMS)) @Field({ leaderboard: { fieldName: `${FormattedGame.COPS_AND_CRIMS} Challenges -` } }) public COPS_AND_CRIMS: CopsAndCrimsChallenges; + @Mode("", removeFormatting(FormattedGame.DUELS)) @Field({ leaderboard: { fieldName: `${FormattedGame.DUELS} Challenges -` } }) public DUELS: DuelsChallenges; + @Mode("", removeFormatting(FormattedGame.MEGAWALLS)) @Field({ leaderboard: { fieldName: `${FormattedGame.MEGAWALLS} Challenges -` } }) public MEGAWALLS: MegaWallsChallenges; + @Mode("", removeFormatting(FormattedGame.MURDER_MYSTERY)) @Field({ leaderboard: { fieldName: `${FormattedGame.MURDER_MYSTERY} Challenges -` } }) public MURDER_MYSTERY: MurderMysteryChallenges; + @Mode("", removeFormatting(FormattedGame.PAINTBALL)) @Field({ leaderboard: { fieldName: `${FormattedGame.PAINTBALL} Challenges -` } }) public PAINTBALL: PaintballChallenges; + @Mode("", removeFormatting(FormattedGame.QUAKE)) @Field({ leaderboard: { fieldName: `${FormattedGame.QUAKE} Challenges -` } }) public QUAKE: QuakeChallenges; + @Mode("", removeFormatting(FormattedGame.SKYWARS)) @Field({ leaderboard: { fieldName: `${FormattedGame.SKYWARS} Challenges -` } }) public SKYWARS: SkyWarsChallenges; + @Mode("", removeFormatting(FormattedGame.SMASH_HEROES)) @Field({ leaderboard: { fieldName: `${FormattedGame.SMASH_HEROES} Challenges -` } }) public SMASH_HEROES: SmashHeroesChallenges; + @Mode("", removeFormatting(FormattedGame.SPEED_UHC)) @Field({ leaderboard: { fieldName: `${FormattedGame.SPEED_UHC} Challenges -` } }) public SPEED_UHC: SpeedUHCChallenges; + @Mode("", removeFormatting(FormattedGame.TNT_GAMES)) @Field({ leaderboard: { fieldName: `${FormattedGame.TNT_GAMES} Challenges -` } }) public TNT_GAMES: TNTGamesChallenges; + @Mode("", removeFormatting(FormattedGame.TURBO_KART_RACERS)) @Field({ leaderboard: { fieldName: `${FormattedGame.TURBO_KART_RACERS} Challenges -` }, }) public TURBO_KART_RACERS: TurboKartRacersChallenges; + @Mode("", removeFormatting(FormattedGame.UHC)) @Field({ leaderboard: { fieldName: `${FormattedGame.UHC} Challenges -` } }) public UHC: UHCChallenges; + @Mode("", removeFormatting(FormattedGame.VAMPIREZ)) @Field({ leaderboard: { fieldName: `${FormattedGame.VAMPIREZ} Challenges -` } }) public VAMPIREZ: VampireZChallenges; + @Mode("", removeFormatting(FormattedGame.WALLS)) @Field({ leaderboard: { fieldName: `${FormattedGame.WALLS} Challenges -` } }) public WALLS: WallsChallenges; + @Mode("", removeFormatting(FormattedGame.WARLORDS)) @Field({ leaderboard: { fieldName: `${FormattedGame.WARLORDS} Challenges -` } }) public WARLORDS: WarlordsChallenges; + @Mode("", removeFormatting(FormattedGame.WOOLWARS)) @Field({ leaderboard: { fieldName: `${FormattedGame.WOOLWARS} Challenges -` } }) public WOOLWARS: WoolWarsChallenges; @@ -162,4 +160,9 @@ export class Challenges { } } +export type ChallengeModes = StatsifyApiModes; +export const CHALLENGE_MODES = new GameModes( + GetMetadataModes(Challenges) +); + export * from "./game-challenges"; diff --git a/packages/schemas/src/player/gamemodes/copsandcrims/index.ts b/packages/schemas/src/player/gamemodes/copsandcrims/index.ts index 89101d394..000c16101 100644 --- a/packages/schemas/src/player/gamemodes/copsandcrims/index.ts +++ b/packages/schemas/src/player/gamemodes/copsandcrims/index.ts @@ -9,20 +9,16 @@ import { APIData } from "@statsify/util"; import { CopsAndCrimsOverall, Deathmatch, Defusal, GunGame } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, defaultPrefix, getFormattedPrefix } from "../prefixes"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { add } from "@statsify/math"; -export const COPS_AND_CRIMS_MODES = new GameModes([ - { api: "overall" }, - { api: "defusal", hypixel: "normal" }, - { api: "deathmatch", hypixel: "deathmatch" }, - { api: "gunGame", hypixel: "gungame" }, - { hypixel: "normal_party", formatted: "Challenge" }, -]); - -export type CopsAndCrimsModes = IGameModes; - type PrefixParams = [kills: number, prefix: string]; const prefixes: GamePrefix[] = [ @@ -67,6 +63,7 @@ const PREFIX_MAP: Record = { carbine: "ᨦᨧ", }; +@GameType() export class CopsAndCrims { @Field() public coins: number; @@ -76,15 +73,19 @@ export class CopsAndCrims { }) public naturalPrefix: string; + @Mode() @Field() public overall: CopsAndCrimsOverall; + @Mode("normal") @Field() public defusal: Defusal; + @Mode("deathmatch") @Field() public deathmatch: Deathmatch; + @Mode("gungame") @Field() public gunGame: GunGame; @@ -114,4 +115,10 @@ export class CopsAndCrims { } } +export type CopsAndCrimsModes = StatsifyApiModes; +export const COPS_AND_CRIMS_MODES = new GameModes([ + ...GetMetadataModes(CopsAndCrims), + { hypixel: "normal_party", formatted: "Challenge" }, +]); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/duels/index.ts b/packages/schemas/src/player/gamemodes/duels/index.ts index ec1c5d327..3ba83117f 100644 --- a/packages/schemas/src/player/gamemodes/duels/index.ts +++ b/packages/schemas/src/player/gamemodes/duels/index.ts @@ -15,60 +15,15 @@ import { UHCDuels, } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; - -export const DUELS_MODES = new GameModes([ - { api: "overall" }, - { api: "arena", hypixel: "DUELS_DUEL_ARENA" }, - { api: "blitzsg", hypixel: "DUELS_BLITZ_DUEL", formatted: "BlitzSG" }, - { api: "bow", hypixel: "DUELS_BOW_DUEL" }, - { api: "bowSpleef", hypixel: "DUELS_BOWSPLEEF_DUEL" }, - { api: "boxing", hypixel: "DUELS_BOXING_DUEL" }, - { api: "bridge" }, - { api: "classic", hypixel: "DUELS_CLASSIC_DUEL" }, - { api: "combo", hypixel: "DUELS_COMBO_DUEL" }, - { api: "megawalls", formatted: "MegaWalls" }, - { api: "nodebuff", hypixel: "DUELS_POTION_DUEL", formatted: "NoDebuff" }, - { api: "op", formatted: "OP" }, - { api: "parkour", hypixel: "DUELS_PARKOUR_EIGHT" }, - { api: "skywars", formatted: "SkyWars" }, - { api: "sumo", hypixel: "DUELS_SUMO_DUEL" }, - { api: "uhc", formatted: "UHC" }, - - { hypixel: "DUELS_MW_DUEL", formatted: "MegaWalls Solo" }, - { hypixel: "DUELS_MW_DOUBLES", formatted: "MegaWalls Doubles" }, - { hypixel: "DUELS_UHC_DUEL", formatted: "UHC Solo" }, - { hypixel: "DUELS_UHC_DOUBLES", formatted: "UHC Doubles" }, - { hypixel: "DUELS_UHC_FOUR", formatted: "UHC Fours" }, - { hypixel: "DUELS_UHC_MEETUP", formatted: "UHC Deathmatch" }, - { hypixel: "DUELS_SW_DUEL", formatted: "SkyWars Solo" }, - { hypixel: "DUELS_SW_DOUBLES", formatted: "SkyWars Doubles" }, - { hypixel: "DUELS_OP_DUEL", formatted: "OP Solo" }, - { hypixel: "DUELS_OP_DOUBLES", formatted: "OP Doubles" }, - { hypixel: "DUELS_BRIDGE_DUEL", formatted: "Bridge Solo" }, - { hypixel: "DUELS_BRIDGE_DOUBLES", formatted: "Bridge Doubles" }, - { hypixel: "DUELS_BRIDGE_THREES", formatted: "Bridge Threes" }, - { hypixel: "DUELS_BRIDGE_FOUR", formatted: "Bridge Fours" }, - { hypixel: "DUELS_BRIDGE_2V2V2V2", formatted: "Bridge 2v2v2v2" }, - { hypixel: "DUELS_BRIDGE_3V3V3V3", formatted: "Bridge 3v3v3v3" }, - { hypixel: "DUELS_CAPTURE_THREES", formatted: "Bridge CTF" }, -]); - -export type DuelsModes = IGameModes; - -export const BRIDGE_MODES = new GameModes([ - { api: "overall" }, - { api: "solo" }, - { api: "doubles" }, - { api: "threes" }, - { api: "fours" }, - { api: "2v2v2v2" }, - { api: "3v3v3v3" }, - { api: "ctf", formatted: "CTF" }, -]); - -export type BridgeModes = IGameModes; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; +@GameType() export class Duels { @Field({ store: { default: 300 }, leaderboard: { enabled: false } }) public pingRange: number; @@ -79,12 +34,15 @@ export class Duels { @Field({ leaderboard: { extraDisplay: "this.overall.titleFormatted" } }) public lootChests: number; + @Mode() @Field({ leaderboard: { extraDisplay: "this.overall.titleFormatted" } }) public overall: SinglePVPDuelsGameMode; + @Mode("DUELS_DUEL_ARENA") @Field({ leaderboard: { extraDisplay: "this.arena.titleFormatted" } }) public arena: SingleDuelsGameMode; + @Mode("DUELS_BLITZ_DUEL", "BlitzSG") @Field({ leaderboard: { fieldName: "BlitzSG", @@ -93,24 +51,31 @@ export class Duels { }) public blitzsg: SinglePVPDuelsGameMode; + @Mode("DUELS_BOW_DUEL") @Field({ leaderboard: { extraDisplay: "this.bow.titleFormatted" } }) public bow: SinglePVPDuelsGameMode; + @Mode("DUELS_BOWSPLEEF_DUEL") @Field({ leaderboard: { extraDisplay: "this.bowSpleef.titleFormatted" } }) public bowSpleef: SingleDuelsGameMode; + @Mode("DUELS_BOXING_DUEL") @Field({ leaderboard: { extraDisplay: "this.boxing.titleFormatted" } }) public boxing: SinglePVPDuelsGameMode; + @Mode() @Field({ leaderboard: { extraDisplay: "this.bridge.titleFormatted" } }) public bridge: BridgeDuels; + @Mode("DUELS_CLASSIC_DUEL") @Field({ leaderboard: { extraDisplay: "this.classic.titleFormatted" } }) public classic: SinglePVPDuelsGameMode; + @Mode("DUELS_COMBO_DUEL") @Field({ leaderboard: { extraDisplay: "this.combo.titleFormatted" } }) public combo: SinglePVPDuelsGameMode; + @Mode("", "MegaWalls") @Field({ leaderboard: { fieldName: "MegaWalls", @@ -119,6 +84,7 @@ export class Duels { }) public megawalls: MultiPVPDuelsGameMode; + @Mode("DUELS_POTION_DUEL", "NoDebuff") @Field({ leaderboard: { fieldName: "NoDebuff", @@ -127,14 +93,17 @@ export class Duels { }) public nodebuff: SinglePVPDuelsGameMode; + @Mode("", "OP") @Field({ leaderboard: { fieldName: "OP", extraDisplay: "this.op.titleFormatted" }, }) public op: MultiPVPDuelsGameMode; + @Mode("DUELS_PARKOUR_EIGHT") @Field({ leaderboard: { extraDisplay: "this.parkour.titleFormatted" } }) public parkour: SingleDuelsGameMode; + @Mode("", "SkyWars") @Field({ leaderboard: { fieldName: "SkyWars", @@ -143,9 +112,11 @@ export class Duels { }) public skywars: MultiPVPDuelsGameMode; + @Mode("DUELS_SUMO_DUEL") @Field({ leaderboard: { extraDisplay: "this.sumo.titleFormatted" } }) public sumo: SinglePVPDuelsGameMode; + @Mode("", "UHC") @Field({ leaderboard: { fieldName: "UHC", extraDisplay: "this.uhc.titleFormatted" }, }) @@ -178,4 +149,28 @@ export class Duels { } } +export type DuelsModes = StatsifyApiModes; + +export const DUELS_MODES = new GameModes([ + ...GetMetadataModes(Duels), + + { hypixel: "DUELS_MW_DUEL", formatted: "MegaWalls Solo" }, + { hypixel: "DUELS_MW_DOUBLES", formatted: "MegaWalls Doubles" }, + { hypixel: "DUELS_UHC_DUEL", formatted: "UHC Solo" }, + { hypixel: "DUELS_UHC_DOUBLES", formatted: "UHC Doubles" }, + { hypixel: "DUELS_UHC_FOUR", formatted: "UHC Fours" }, + { hypixel: "DUELS_UHC_MEETUP", formatted: "UHC Deathmatch" }, + { hypixel: "DUELS_SW_DUEL", formatted: "SkyWars Solo" }, + { hypixel: "DUELS_SW_DOUBLES", formatted: "SkyWars Doubles" }, + { hypixel: "DUELS_OP_DUEL", formatted: "OP Solo" }, + { hypixel: "DUELS_OP_DOUBLES", formatted: "OP Doubles" }, + { hypixel: "DUELS_BRIDGE_DUEL", formatted: "Bridge Solo" }, + { hypixel: "DUELS_BRIDGE_DOUBLES", formatted: "Bridge Doubles" }, + { hypixel: "DUELS_BRIDGE_THREES", formatted: "Bridge Threes" }, + { hypixel: "DUELS_BRIDGE_FOUR", formatted: "Bridge Fours" }, + { hypixel: "DUELS_BRIDGE_2V2V2V2", formatted: "Bridge 2v2v2v2" }, + { hypixel: "DUELS_BRIDGE_3V3V3V3", formatted: "Bridge 3v3v3v3" }, + { hypixel: "DUELS_CAPTURE_THREES", formatted: "Bridge CTF" }, +]); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/duels/mode.ts b/packages/schemas/src/player/gamemodes/duels/mode.ts index 1376af868..bb98b219b 100644 --- a/packages/schemas/src/player/gamemodes/duels/mode.ts +++ b/packages/schemas/src/player/gamemodes/duels/mode.ts @@ -8,7 +8,14 @@ import { APIData, romanNumeral } from "@statsify/util"; import { Field } from "../../../metadata"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression } from "../prefixes"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { Title, getTitle, titleScores } from "./util"; import { deepAdd, ratio } from "@statsify/math"; @@ -113,6 +120,7 @@ export class BridgeDuelsMode extends PVPBaseDuelsGameMode { } } +@GameType() export class BridgeDuels { @Field() public titleFormatted: string; @@ -126,27 +134,35 @@ export class BridgeDuels { @Field() public progression: Progression; + @Mode() @Field() public overall: BridgeDuelsMode; + @Mode() @Field() public solo: BridgeDuelsMode; + @Mode() @Field() public doubles: BridgeDuelsMode; + @Mode() @Field() public threes: BridgeDuelsMode; + @Mode() @Field() public fours: BridgeDuelsMode; + @Mode() @Field() public "2v2v2v2": BridgeDuelsMode; + @Mode() @Field() public "3v3v3v3": BridgeDuelsMode; + @Mode("", "CTF") @Field({ leaderboard: { fieldName: "CTF" } }) public ctf: BridgeDuelsMode; @@ -195,6 +211,9 @@ export class BridgeDuels { } } +export type BridgeModes = StatsifyApiModes; +export const BRIDGE_MODES = new GameModes(GetMetadataModes(BridgeDuels)); + export class MultiPVPDuelsGameMode { @Field() public titleFormatted: string; diff --git a/packages/schemas/src/player/gamemodes/general/index.ts b/packages/schemas/src/player/gamemodes/general/index.ts index 48e36b7ca..b06b477f7 100644 --- a/packages/schemas/src/player/gamemodes/general/index.ts +++ b/packages/schemas/src/player/gamemodes/general/index.ts @@ -9,12 +9,11 @@ import { APIData } from "@statsify/util"; import { Events } from "./events"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { GameType, GetMetadataModes, StatsifyApiModes } from "../../../metadata/GameType"; import { getNetworkLevel } from "./util"; -export const GENERAL_MODES = new GameModes([{ api: "overall" }]); -export type GeneralModes = IGameModes; - +@GameType("overall") export class General { @Field() public achievementPoints: number; @@ -78,4 +77,8 @@ export class General { } } +type ExcludeKeys = "events"; +export type GeneralModes = StatsifyApiModes, "overall">; +export const GENERAL_MODES = new GameModes(GetMetadataModes(General)); + export * from "./events"; diff --git a/packages/schemas/src/player/gamemodes/megawalls/index.ts b/packages/schemas/src/player/gamemodes/megawalls/index.ts index f16b7f7cb..4c013fa7e 100644 --- a/packages/schemas/src/player/gamemodes/megawalls/index.ts +++ b/packages/schemas/src/player/gamemodes/megawalls/index.ts @@ -8,39 +8,16 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { MegaWallsKit, MegaWallsOverall } from "./kit"; -export const MEGAWALLS_MODES = new GameModes([ - { api: "overall" }, - { api: "arcanist" }, - { api: "assassin" }, - { api: "automaton" }, - { api: "blaze" }, - { api: "cow" }, - { api: "creeper" }, - { api: "dreadlord" }, - { api: "enderman" }, - { api: "golem" }, - { api: "herobrine" }, - { api: "hunter" }, - { api: "moleman" }, - { api: "phoenix" }, - { api: "pigman" }, - { api: "pirate" }, - { api: "renegade" }, - { api: "shaman" }, - { api: "shark" }, - { api: "skeleton" }, - { api: "snowman" }, - { api: "spider" }, - { api: "squid" }, - { api: "werewolf" }, - { api: "zombie" }, -]); - -export type MegaWallsModes = IGameModes; - +@GameType() export class MegaWalls { @Field() public coins: number; @@ -51,78 +28,103 @@ export class MegaWalls { @Field({ store: { default: "none" } }) public class: string; + @Mode() @Field() public overall: MegaWallsOverall; + @Mode() @Field({ store: { required: false } }) public arcanist: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public assassin: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public automaton: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public blaze: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public cow: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public creeper: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public dreadlord: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public enderman: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public golem: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public herobrine: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public hunter: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public moleman: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public phoenix: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public pigman: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public pirate: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public renegade: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public shaman: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public shark: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public skeleton: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public snowman: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public spider: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public squid: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public werewolf: MegaWallsKit; + @Mode() @Field({ store: { required: false } }) public zombie: MegaWallsKit; @@ -159,4 +161,7 @@ export class MegaWalls { } } +export type MegaWallsModes = StatsifyApiModes; +export const MEGAWALLS_MODES = new GameModes(GetMetadataModes(MegaWalls)); + export * from "./kit"; diff --git a/packages/schemas/src/player/gamemodes/murdermystery/index.ts b/packages/schemas/src/player/gamemodes/murdermystery/index.ts index efc619740..99b53e330 100644 --- a/packages/schemas/src/player/gamemodes/murdermystery/index.ts +++ b/packages/schemas/src/player/gamemodes/murdermystery/index.ts @@ -14,24 +14,16 @@ import { StandardMurderMysteryMode, } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { add } from "@statsify/math"; -export const MURDER_MYSTERY_MODES = new GameModes([ - { api: "overall" }, - { api: "classic" }, - { api: "doubleUp" }, - { api: "assassins" }, - { api: "infection" }, - - { hypixel: "MURDER_DOUBLE_UP", formatted: "Double Up" }, - { hypixel: "MURDER_INFECTION", formatted: "Infection" }, - { hypixel: "MURDER_ASSASSINS", formatted: "Assassins" }, - { hypixel: "MURDER_CLASSIC", formatted: "Classic" }, -]); - -export type MurderMysteryModes = IGameModes; - +@GameType() export class MurderMystery { @Field() public coins: number; @@ -39,18 +31,23 @@ export class MurderMystery { @Field() public lootChests: number; + @Mode() @Field() public overall: StandardMurderMysteryMode; + @Mode("MURDER_CLASSIC", "Classic") @Field() public classic: ClassicMurderMysteryMode; + @Mode("MURDER_ASSASSINS", "Assassins") @Field() public assassins: AssassinsMurderMysteryMode; + @Mode("MURDER_DOUBLE_UP", "Double Up") @Field() public doubleUp: ClassicMurderMysteryMode; + @Mode("MURDER_INFECTION", "Infection") @Field() public infection: InfectionMurderMysteryMode; @@ -76,4 +73,9 @@ export class MurderMystery { } } +export type MurderMysteryModes = StatsifyApiModes; +export const MURDER_MYSTERY_MODES = new GameModes( + GetMetadataModes(MurderMystery) +); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/paintball/index.ts b/packages/schemas/src/player/gamemodes/paintball/index.ts index 099804afb..70470e47e 100644 --- a/packages/schemas/src/player/gamemodes/paintball/index.ts +++ b/packages/schemas/src/player/gamemodes/paintball/index.ts @@ -8,21 +8,18 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression, defaultPrefix, getFormattedPrefix, } from "../prefixes"; +import { GameType, GetMetadataModes, StatsifyApiModes } from "../../../metadata/GameType"; import { PaintballPerks } from "./perks"; import { Progression } from "../../../progression"; import { ratio } from "@statsify/math"; -export const PAINTBALL_MODES = new GameModes([{ api: "overall" }]); - -export type PaintballModes = IGameModes; - const prefixes: GamePrefix[] = [ { fmt: (n) => `§8[${n}]`, req: 0 }, { fmt: (n) => `§7[${n}]`, req: 1000 }, @@ -38,6 +35,7 @@ const prefixes: GamePrefix[] = [ { fmt: (n) => `§6[${n}]`, req: 1_000_000 }, ]; +@GameType("overall") export class Paintball { @Field() public coins: number; @@ -121,4 +119,8 @@ export class Paintball { } } +type ExcludeKeys = "perks"; +export type PaintballModes = StatsifyApiModes, "overall">; +export const PAINTBALL_MODES = new GameModes(GetMetadataModes(Paintball)); + export * from "./perks"; diff --git a/packages/schemas/src/player/gamemodes/parkour/index.ts b/packages/schemas/src/player/gamemodes/parkour/index.ts index dc05594de..50ee0af6b 100644 --- a/packages/schemas/src/player/gamemodes/parkour/index.ts +++ b/packages/schemas/src/player/gamemodes/parkour/index.ts @@ -8,14 +8,12 @@ import { APIData, formatTime } from "@statsify/util"; import { Field } from "../../../metadata"; -import { FormattedGame, GameModes, IGameModes } from "../../../game"; - -export const PARKOUR_MODES = new GameModes([{ api: "overall" }]); - -export type ParkourModes = IGameModes; +import { FormattedGame, GameModes } from "../../../game"; +import { GameType, GetMetadataModes, StatsifyApiModes } from "../../../metadata/GameType"; const fieldOptions = { sort: "ASC", formatter: formatTime, fieldName: "Time" }; +@GameType("overall") export class Parkour { @Field({ leaderboard: { ...fieldOptions, name: `${FormattedGame.ARCADE} Lobby` } }) public ARCADE: number; @@ -107,3 +105,6 @@ export class Parkour { this.WOOLWARS = getTime("WoolGames"); } } + +export type ParkourModes = StatsifyApiModes; +export const PARKOUR_MODES = new GameModes(GetMetadataModes(Parkour)); diff --git a/packages/schemas/src/player/gamemodes/pit/index.ts b/packages/schemas/src/player/gamemodes/pit/index.ts index ab701b78a..696d9b627 100644 --- a/packages/schemas/src/player/gamemodes/pit/index.ts +++ b/packages/schemas/src/player/gamemodes/pit/index.ts @@ -8,17 +8,13 @@ import { APIData, formatTime } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { GameType, GetMetadataModes, StatsifyApiModes } from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { add, ratio } from "@statsify/math"; import { getBounty, getLevel, getLevelFormatted, getPres, getPresReq } from "./util"; -export const PIT_MODES = new GameModes([ - { api: "overall", hypixel: "PIT", formatted: "Pit" }, -]); - -export type PitModes = IGameModes; - +@GameType("overall", "PIT", "Pit") export class Pit { @Field({ leaderboard: { @@ -148,3 +144,6 @@ export class Pit { this.joins = data.joins; } } + +export type PitModes = StatsifyApiModes; +export const PIT_MODES = new GameModes(GetMetadataModes(Pit)); diff --git a/packages/schemas/src/player/gamemodes/quake/index.ts b/packages/schemas/src/player/gamemodes/quake/index.ts index 3aa829142..da7fa7fbc 100644 --- a/packages/schemas/src/player/gamemodes/quake/index.ts +++ b/packages/schemas/src/player/gamemodes/quake/index.ts @@ -8,25 +8,23 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression, defaultPrefix, getFormattedPrefix, } from "../prefixes"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { QuakeMode } from "./mode"; import { deepAdd } from "@statsify/math"; -export const QUAKE_MODES = new GameModes([ - { api: "overall" }, - { api: "solo", hypixel: "solo" }, - { api: "teams", hypixel: "teams" }, -]); - -export type QuakeModes = IGameModes; - const indexes = [ "zero", "one", @@ -56,6 +54,7 @@ const prefixes: GamePrefix[] = [ { fmt: (n) => `§0[${n}]`, req: 2_000_000 }, ]; +@GameType() export class Quake { @Field() public progression: Progression; @@ -69,12 +68,15 @@ export class Quake { @Field() public nextPrefix: string; + @Mode() @Field() public overall: QuakeMode; + @Mode("solo", "solo") @Field() public solo: QuakeMode; + @Mode("teams", "teams") @Field() public teams: QuakeMode; @@ -138,4 +140,7 @@ export class Quake { } } +export type QuakeModes = StatsifyApiModes; +export const QUAKE_MODES = new GameModes(GetMetadataModes(Quake)); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/skywars/index.ts b/packages/schemas/src/player/gamemodes/skywars/index.ts index d57260e29..db94b6b9d 100644 --- a/packages/schemas/src/player/gamemodes/skywars/index.ts +++ b/packages/schemas/src/player/gamemodes/skywars/index.ts @@ -8,35 +8,19 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { SkyWarsMode } from "./mode"; import { add } from "@statsify/math"; import { getFormattedLevel, getLevel, getLevelProgress, parseKit } from "./util"; -export const SKYWARS_MODES = new GameModes([ - { api: "overall" }, - { api: "solo" }, - { api: "doubles" }, - - { hypixel: "solo_insane_lucky", formatted: "Lucky Solo" }, - { hypixel: "teams_insane_lucky", formatted: "Lucky Doubles" }, - { hypixel: "solo_insane_slime", formatted: "Slime Solo" }, - { hypixel: "teams_insane_slime", formatted: "Slime Doubles" }, - { hypixel: "solo_insane_rush", formatted: "Rush Solo" }, - { hypixel: "teams_insane_rush", formatted: "Rush Doubles" }, - { hypixel: "solo_normal", formatted: "Solo Normal" }, - { hypixel: "solo_insane", formatted: "Solo Insane" }, - { hypixel: "teams_normal", formatted: "Doubles Normal" }, - { hypixel: "teams_insane", formatted: "Doubles Insane" }, - { hypixel: "solo_insane_tnt_madness", formatted: "TNT Madness Solo" }, - { hypixel: "teams_insane_tnt_madness", formatted: "TNT Madness Doubles" }, - { hypixel: "mega_normal", formatted: "Mega" }, - { hypixel: "mega_doubles", formatted: "Mega Doubles" }, -]); - -export type SkyWarsModes = IGameModes; - +@GameType() export class SkyWars { @Field({ leaderboard: { @@ -84,12 +68,15 @@ export class SkyWars { @Field() public progression: Progression; + @Mode() @Field() public overall: SkyWarsMode; + @Mode() @Field() public solo: SkyWarsMode; + @Mode() @Field() public doubles: SkyWarsMode; @@ -150,4 +137,24 @@ export class SkyWars { } } +export type SkyWarsModes = StatsifyApiModes; +export const SKYWARS_MODES = new GameModes([ + ...GetMetadataModes(SkyWars), + + { hypixel: "solo_insane_lucky", formatted: "Lucky Solo" }, + { hypixel: "teams_insane_lucky", formatted: "Lucky Doubles" }, + { hypixel: "solo_insane_slime", formatted: "Slime Solo" }, + { hypixel: "teams_insane_slime", formatted: "Slime Doubles" }, + { hypixel: "solo_insane_rush", formatted: "Rush Solo" }, + { hypixel: "teams_insane_rush", formatted: "Rush Doubles" }, + { hypixel: "solo_normal", formatted: "Solo Normal" }, + { hypixel: "solo_insane", formatted: "Solo Insane" }, + { hypixel: "teams_normal", formatted: "Doubles Normal" }, + { hypixel: "teams_insane", formatted: "Doubles Insane" }, + { hypixel: "solo_insane_tnt_madness", formatted: "TNT Madness Solo" }, + { hypixel: "teams_insane_tnt_madness", formatted: "TNT Madness Doubles" }, + { hypixel: "mega_normal", formatted: "Mega" }, + { hypixel: "mega_doubles", formatted: "Mega Doubles" }, +]); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/smashheroes/index.ts b/packages/schemas/src/player/gamemodes/smashheroes/index.ts index 7aca50ace..622191963 100644 --- a/packages/schemas/src/player/gamemodes/smashheroes/index.ts +++ b/packages/schemas/src/player/gamemodes/smashheroes/index.ts @@ -8,39 +8,17 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { SmashHeroesKit, SmashHeroesMode } from "./mode"; const formatLevel = (level: number) => `§b${level}§6✶`; -export const SMASH_HEROES_MODES = new GameModes([ - { api: "overall" }, - { api: "solo", hypixel: "solo_normal" }, - { api: "doubles", hypixel: "2v2_normal" }, - { api: "teams", hypixel: "teams_normal" }, - { api: "botman" }, - { api: "bulk" }, - { api: "cakeMonster" }, - { api: "cryomancer" }, - { api: "generalCluck" }, - { api: "greenHood" }, - { api: "karakot" }, - { api: "marauder" }, - { api: "pug" }, - { api: "sanic" }, - { api: "sergeantShield" }, - { api: "shoop" }, - { api: "skullfire" }, - { api: "spoderman" }, - { api: "tinman" }, - { api: "voidCrawler" }, - - { hypixel: "1v1_normal", formatted: "1v1" }, - { hypixel: "friends_normal", formatted: "Friends" }, -]); - -export type SmashHeroesModes = IGameModes; - enum SmashHeroesClass { BOTMUN = "Botmon", CAKE_MONSTER = "Cake Monster", @@ -60,16 +38,21 @@ enum SmashHeroesClass { TINMAN = "Tinman", } +@GameType() export class SmashHeroes { + @Mode() @Field() public overall: SmashHeroesMode; + @Mode("solo_normal") @Field() public solo: SmashHeroesMode; + @Mode("2v2_normal") @Field() public doubles: SmashHeroesMode; + @Mode("teams_normal") @Field() public teams: SmashHeroesMode; @@ -85,51 +68,67 @@ export class SmashHeroes { @Field({ store: { default: "none" } }) public kit: string; + @Mode() @Field() public cakeMonster: SmashHeroesKit; + @Mode() @Field() public generalCluck: SmashHeroesKit; + @Mode() @Field() public tinman: SmashHeroesKit; + @Mode() @Field() public spoderman: SmashHeroesKit; + @Mode() @Field() public skullfire: SmashHeroesKit; + @Mode() @Field() public karakot: SmashHeroesKit; + @Mode() @Field() public bulk: SmashHeroesKit; + @Mode() @Field() public botman: SmashHeroesKit; + @Mode() @Field() public sanic: SmashHeroesKit; + @Mode() @Field() public marauder: SmashHeroesKit; + @Mode() @Field() public voidCrawler: SmashHeroesKit; + @Mode() @Field() public pug: SmashHeroesKit; + @Mode() @Field() public sergeantShield: SmashHeroesKit; + @Mode() @Field() public cryomancer: SmashHeroesKit; + @Mode() @Field() public shoop: SmashHeroesKit; + @Mode() @Field() public greenHood: SmashHeroesKit; @@ -164,4 +163,12 @@ export class SmashHeroes { } } +export type SmashHeroesModes = StatsifyApiModes; +export const SMASH_HEROES_MODES = new GameModes([ + ...GetMetadataModes(SmashHeroes), + + { hypixel: "1v1_normal", formatted: "1v1" }, + { hypixel: "friends_normal", formatted: "Friends" }, +]); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/speeduhc/index.ts b/packages/schemas/src/player/gamemodes/speeduhc/index.ts index d33f5c394..a778da36c 100644 --- a/packages/schemas/src/player/gamemodes/speeduhc/index.ts +++ b/packages/schemas/src/player/gamemodes/speeduhc/index.ts @@ -8,8 +8,9 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression } from "../prefixes"; +import { GameType, Mode, StatsifyApiModes } from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { SpeedUHCMastery } from "./mastery"; import { SpeedUHCMode } from "./mode"; @@ -17,35 +18,22 @@ import { getLevelIndex, titleScores } from "./util"; const formatLevel = (level: number | string) => `§d[${level}❋]`; -export const SPEED_UHC_MODES = new GameModes([ - { api: "overall" }, - { api: "solo", hypixel: "solo_normal" }, - { api: "teams", hypixel: "team_normal" }, - { api: "wildSpecialist" }, - { api: "guardian" }, - { api: "sniper" }, - { api: "berserk" }, - { api: "masterBaker" }, - { api: "invigorate" }, - { api: "huntsman" }, - { api: "fortune" }, - { api: "vampirism" }, -]); - const prefixes: GamePrefix[] = titleScores.map((level) => ({ fmt: formatLevel, req: level.req, })); -export type SpeedUHCModes = IGameModes; - +@GameType() export class SpeedUHC { + @Mode() @Field() public overall: SpeedUHCMode; + @Mode("solo_normal") @Field() public solo: SpeedUHCMode; + @Mode("team_normal") @Field() public teams: SpeedUHCMode; @@ -73,30 +61,39 @@ export class SpeedUHC { @Field({ store: { default: titleScores[0].title } }) public title: string; + @Mode() @Field() public wildSpecialist: SpeedUHCMastery; + @Mode() @Field() public guardian: SpeedUHCMastery; + @Mode() @Field() public sniper: SpeedUHCMastery; + @Mode() @Field() public berserk: SpeedUHCMastery; + @Mode() @Field() public masterBaker: SpeedUHCMastery; + @Mode() @Field() public invigorate: SpeedUHCMastery; + @Mode() @Field() public huntsman: SpeedUHCMastery; + @Mode() @Field() public fortune: SpeedUHCMastery; + @Mode() @Field() public vampirism: SpeedUHCMastery; @@ -131,5 +128,21 @@ export class SpeedUHC { } } +export type SpeedUHCModes = StatsifyApiModes; +export const SPEED_UHC_MODES = new GameModes([ + { api: "overall" }, + { api: "solo", hypixel: "solo_normal" }, + { api: "teams", hypixel: "team_normal" }, + { api: "wildSpecialist" }, + { api: "guardian" }, + { api: "sniper" }, + { api: "berserk" }, + { api: "masterBaker" }, + { api: "invigorate" }, + { api: "huntsman" }, + { api: "fortune" }, + { api: "vampirism" }, +]); + export * from "./mastery"; export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/tntgames/index.ts b/packages/schemas/src/player/gamemodes/tntgames/index.ts index 16bcb7f47..7dc6af453 100644 --- a/packages/schemas/src/player/gamemodes/tntgames/index.ts +++ b/packages/schemas/src/player/gamemodes/tntgames/index.ts @@ -9,19 +9,15 @@ import { APIData } from "@statsify/util"; import { BowSpleef, PVPRun, TNTRun, TNTTag, Wizards } from "./mode"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; - -export const TNT_GAMES_MODES = new GameModes([ - { api: "overall" }, - { hypixel: "PVPRUN", formatted: "PVP Run" }, - { hypixel: "TNTAG", formatted: "TNT Tag" }, - { hypixel: "TNTRUN", formatted: "TNT Run" }, - { hypixel: "BOWSPLEEF", formatted: "Bow Spleef" }, - { hypixel: "CAPTURE", formatted: "Wizards" }, -]); - -export type TNTGamesModes = IGameModes; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; +@GameType("overall") export class TNTGames { @Field() public coins: number; @@ -32,18 +28,23 @@ export class TNTGames { @Field() public blocksRan: number; + @Mode("TNTRUN", "TNT Run") @Field({ leaderboard: { fieldName: "TNT Run" } }) public tntRun: TNTRun; + @Mode("PVPRUN", "PVP Run") @Field({ leaderboard: { fieldName: "PVP Run" } }) public pvpRun: PVPRun; + @Mode("BOWSPLEEF", "Bow Spleef") @Field() public bowSpleef: BowSpleef; + @Mode("CAPTURE", "Wizards") @Field() public wizards: Wizards; + @Mode("TNTAG", "TNT Tag") @Field({ leaderboard: { fieldName: "TNT Tag" } }) public tntTag: TNTTag; @@ -60,4 +61,7 @@ export class TNTGames { } } +export type TNTGamesModes = StatsifyApiModes; +export const TNT_GAMES_MODES = new GameModes(GetMetadataModes(TNTGames)); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/turbokartracers/index.ts b/packages/schemas/src/player/gamemodes/turbokartracers/index.ts index 58c5bef56..417b81d12 100644 --- a/packages/schemas/src/player/gamemodes/turbokartracers/index.ts +++ b/packages/schemas/src/player/gamemodes/turbokartracers/index.ts @@ -8,20 +8,17 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression, defaultPrefix, getFormattedPrefix, } from "../prefixes"; +import { GameType, GetMetadataModes, StatsifyApiModes } from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { add, ratio } from "@statsify/math"; -export const TURBO_KART_RACERS_MODES = new GameModes([{ api: "overall" }]); - -export type TurboKartRacersModes = IGameModes; - const prefixes: GamePrefix[] = [ { fmt: (n) => `§8[${n}✪]`, req: 0 }, { fmt: (n) => `§7[${n}✪]`, req: 5 }, @@ -39,6 +36,7 @@ const prefixes: GamePrefix[] = [ { fmt: (n) => `§0[${n}✪]`, req: 10_000 }, ]; +@GameType("overall") export class TurboKartRacers { @Field() public coins: number; @@ -137,3 +135,8 @@ export class TurboKartRacers { this.trophyRate = ratio(this.total, this.gamesPlayed, 100); } } + +export type TurboKartRacersModes = StatsifyApiModes; +export const TURBO_KART_RACERS_MODES = new GameModes( + GetMetadataModes(TurboKartRacers) +); diff --git a/packages/schemas/src/player/gamemodes/uhc/index.ts b/packages/schemas/src/player/gamemodes/uhc/index.ts index 8991245d8..460c82be4 100644 --- a/packages/schemas/src/player/gamemodes/uhc/index.ts +++ b/packages/schemas/src/player/gamemodes/uhc/index.ts @@ -8,8 +8,14 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression } from "../prefixes"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { UHCMode } from "./mode"; import { deepAdd } from "@statsify/math"; @@ -17,26 +23,22 @@ import { getLevelIndex, titleScores } from "./util"; const formatLevel = (level: number | string) => `§6[${level}✫]`; -export const UHC_MODES = new GameModes([ - { api: "overall" }, - { api: "solo", hypixel: "SOLO" }, - { api: "teams", hypixel: "TEAMS" }, -]); - const prefixes: GamePrefix[] = titleScores.map((level) => ({ fmt: formatLevel, req: level.req, })); -export type UHCModes = IGameModes; - +@GameType() export class UHC { + @Mode() @Field() public overall: UHCMode; + @Mode("SOLO") @Field() public solo: UHCMode; + @Mode("TEAMS") @Field() public teams: UHCMode; @@ -96,4 +98,7 @@ export class UHC { } } +export type UHCModes = StatsifyApiModes; +export const UHC_MODES = new GameModes(GetMetadataModes(UHC)); + export * from "./mode"; diff --git a/packages/schemas/src/player/gamemodes/vampirez/index.ts b/packages/schemas/src/player/gamemodes/vampirez/index.ts index b1926a1eb..16b6888b6 100644 --- a/packages/schemas/src/player/gamemodes/vampirez/index.ts +++ b/packages/schemas/src/player/gamemodes/vampirez/index.ts @@ -8,13 +8,17 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { VampireZHuman, VampireZVampire } from "./life"; import { add } from "@statsify/math"; -export const VAMPIREZ_MODES = new GameModes([{ api: "human" }, { api: "vampire" }]); -export type VampireZModes = IGameModes; - +@GameType() export class VampireZ { @Field() public coins: number; @@ -31,6 +35,7 @@ export class VampireZ { @Field() public zombieKills: number; + @Mode() @Field({ leaderboard: { extraDisplay: "stats.vampirez.human.naturalPrefix", @@ -39,6 +44,7 @@ export class VampireZ { }) public human: VampireZHuman; + @Mode() @Field({ leaderboard: { extraDisplay: "stats.vampirez.vampire.naturalPrefix", @@ -61,4 +67,7 @@ export class VampireZ { } } +export type VampireZModes = StatsifyApiModes; +export const VAMPIREZ_MODES = new GameModes(GetMetadataModes(VampireZ)); + export * from "./life"; diff --git a/packages/schemas/src/player/gamemodes/walls/index.ts b/packages/schemas/src/player/gamemodes/walls/index.ts index 2bcd24693..58fbab09f 100644 --- a/packages/schemas/src/player/gamemodes/walls/index.ts +++ b/packages/schemas/src/player/gamemodes/walls/index.ts @@ -8,7 +8,7 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; import { GamePrefix, createPrefixProgression, @@ -16,13 +16,10 @@ import { getFormattedPrefix, rainbow, } from "../prefixes"; +import { GameType, GetMetadataModes, StatsifyApiModes } from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { ratio } from "@statsify/math"; -export const WALLS_MODES = new GameModes([{ api: "overall" }]); - -export type WallsModes = IGameModes; - const prefixes: GamePrefix[] = [ { fmt: (n) => `§8[${n}]`, req: 0 }, { fmt: (n) => `§7[${n}]`, req: 25 }, @@ -38,6 +35,7 @@ const prefixes: GamePrefix[] = [ { fmt: (n) => rainbow(`[${n}]`), req: 2001 }, ]; +@GameType("overall") export class Walls { @Field() public coins: number; @@ -110,3 +108,6 @@ export class Walls { this.progression = createPrefixProgression(prefixes, score); } } + +export type WallsModes = StatsifyApiModes; +export const WALLS_MODES = new GameModes(GetMetadataModes(Walls)); diff --git a/packages/schemas/src/player/gamemodes/warlords/index.ts b/packages/schemas/src/player/gamemodes/warlords/index.ts index 32cb6b34e..1404b5aac 100644 --- a/packages/schemas/src/player/gamemodes/warlords/index.ts +++ b/packages/schemas/src/player/gamemodes/warlords/index.ts @@ -9,6 +9,7 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; import { GameModes, IGameModes } from "../../../game"; +import { GameType, Mode } from "../../../metadata/GameType"; import { WarlordsClass } from "./class"; import { add, ratio, sub } from "@statsify/math"; @@ -23,16 +24,21 @@ export const WARLORDS_MODES = new GameModes([ export type WarlordsModes = IGameModes; +@GameType() export class Warlords { + @Mode() @Field() public mage: WarlordsClass; + @Mode() @Field() public warrior: WarlordsClass; + @Mode() @Field() public paladin: WarlordsClass; + @Mode() @Field() public shaman: WarlordsClass; diff --git a/packages/schemas/src/player/gamemodes/woolwars/index.ts b/packages/schemas/src/player/gamemodes/woolwars/index.ts index 837510230..a11f6d775 100644 --- a/packages/schemas/src/player/gamemodes/woolwars/index.ts +++ b/packages/schemas/src/player/gamemodes/woolwars/index.ts @@ -8,24 +8,18 @@ import { APIData } from "@statsify/util"; import { Field } from "../../../metadata"; -import { GameModes, IGameModes } from "../../../game"; +import { GameModes } from "../../../game"; +import { + GameType, + GetMetadataModes, + Mode, + StatsifyApiModes, +} from "../../../metadata/GameType"; import { Progression } from "../../../progression"; import { WoolWarsClass, WoolWarsOverall } from "./class"; import { getExpReq, getFormattedLevel, getLevel } from "./util"; -export const WOOLWARS_MODES = new GameModes([ - { api: "overall" }, - { api: "tank" }, - { api: "archer" }, - { api: "builder" }, - { api: "swordsman" }, - { api: "engineer" }, - { api: "golem" }, - { api: "assault" }, -]); - -export type WoolWarsModes = IGameModes; - +@GameType() export class WoolWars { @Field() public coins: number; @@ -55,27 +49,35 @@ export class WoolWars { @Field() public nextLevelFormatted: string; + @Mode() @Field() public overall: WoolWarsOverall; + @Mode() @Field() public tank: WoolWarsClass; + @Mode() @Field() public archer: WoolWarsClass; + @Mode() @Field() public builder: WoolWarsClass; + @Mode() @Field() public swordsman: WoolWarsClass; + @Mode() @Field() public engineer: WoolWarsClass; + @Mode() @Field() public golem: WoolWarsClass; + @Mode() @Field() public assault: WoolWarsClass; @@ -108,4 +110,7 @@ export class WoolWars { } } +export type WoolWarsModes = StatsifyApiModes; +export const WOOLWARS_MODES = new GameModes(GetMetadataModes(WoolWars)); + export * from "./class";