From f0054f89044aa9f65f81cf49f00f9656470a57c9 Mon Sep 17 00:00:00 2001 From: jacobk999 Date: Wed, 12 Feb 2025 15:17:36 -0500 Subject: [PATCH 1/3] feat(skywars): add perks page --- apps/discord-bot/package.json | 5 +- .../bedwars/bedwars-challenges.command.tsx | 30 --- .../src/commands/bedwars/bedwars.command.tsx | 2 + .../deprecated/bedwars-challenges.command.tsx | 23 +++ .../deprecated/skywars-challenges.command.tsx | 23 +++ ...les.table.tsx => duels-titles.profile.tsx} | 103 +++++++---- .../src/commands/duels/duels.command.tsx | 4 +- .../src/commands/duels/duels.profile.tsx | 46 ++--- .../src/commands/duels/tables/index.ts | 1 - .../commands/historical/session.command.tsx | 56 +++--- .../skywars/skywars-challenges.command.tsx | 30 --- .../skywars/skywars-challenges.profile.tsx | 5 +- .../skywars/skywars-perks.profile.tsx | 174 ++++++++++++++++++ .../src/commands/skywars/skywars.command.tsx | 31 +++- apps/discord-bot/src/components/WordWrap.tsx | 48 +++++ apps/discord-bot/src/components/index.ts | 1 + package.json | 2 +- .../src/player/gamemodes/bedwars/index.ts | 8 +- .../src/player/gamemodes/skywars/index.ts | 39 +++- .../src/player/gamemodes/skywars/perks.ts | 43 +++++ pnpm-lock.yaml | 62 +++---- turbo.json | 41 ++++- 22 files changed, 565 insertions(+), 212 deletions(-) delete mode 100644 apps/discord-bot/src/commands/bedwars/bedwars-challenges.command.tsx create mode 100644 apps/discord-bot/src/commands/deprecated/bedwars-challenges.command.tsx create mode 100644 apps/discord-bot/src/commands/deprecated/skywars-challenges.command.tsx rename apps/discord-bot/src/commands/duels/{tables/titles.table.tsx => duels-titles.profile.tsx} (58%) delete mode 100644 apps/discord-bot/src/commands/skywars/skywars-challenges.command.tsx create mode 100644 apps/discord-bot/src/commands/skywars/skywars-perks.profile.tsx create mode 100644 apps/discord-bot/src/components/WordWrap.tsx create mode 100644 packages/schemas/src/player/gamemodes/skywars/perks.ts diff --git a/apps/discord-bot/package.json b/apps/discord-bot/package.json index d364e4a0d..9b5f35e7c 100644 --- a/apps/discord-bot/package.json +++ b/apps/discord-bot/package.json @@ -41,7 +41,10 @@ "default": "./dist/components/index.js" }, "#commands/*": { - "types": "./src/commands/*.ts", + "types": [ + "./src/commands/*.ts", + "./src/commands/*.tsx" + ], "default": "./dist/commands/*.js" }, "#services": { diff --git a/apps/discord-bot/src/commands/bedwars/bedwars-challenges.command.tsx b/apps/discord-bot/src/commands/bedwars/bedwars-challenges.command.tsx deleted file mode 100644 index b7323b175..000000000 --- a/apps/discord-bot/src/commands/bedwars/bedwars-challenges.command.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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 { BEDWARS_MODES, BedWarsModes, GameModeWithSubModes, Player } from "@statsify/schemas"; -import { BaseHypixelCommand, BaseProfileProps } from "#commands/base.hypixel-command"; -import { BedWarsChallengesProfile } from "./bedwars-challenges.profile.js"; -import { Command } from "@statsify/discord"; - -@Command({ description: (t) => t("commands.bedwars-challenges") }) -export class BedWarsChallengesCommand extends BaseHypixelCommand { - public constructor() { - super(BEDWARS_MODES); - } - - public filterModes( - player: Player, - modes: GameModeWithSubModes[] - ): GameModeWithSubModes[] { - return [modes[0]]; - } - - public getProfile(base: BaseProfileProps): JSX.Element { - return ; - } -} diff --git a/apps/discord-bot/src/commands/bedwars/bedwars.command.tsx b/apps/discord-bot/src/commands/bedwars/bedwars.command.tsx index e404439ae..a19fa57e1 100644 --- a/apps/discord-bot/src/commands/bedwars/bedwars.command.tsx +++ b/apps/discord-bot/src/commands/bedwars/bedwars.command.tsx @@ -12,6 +12,7 @@ import { BaseProfileProps, ProfileData, } from "#commands/base.hypixel-command"; +import { BedWarsChallengesProfile } from "./bedwars-challenges.profile.js"; import { BedWarsProfile } from "./bedwars.profile.js"; import { Command } from "@statsify/discord"; @@ -25,6 +26,7 @@ export class BedWarsCommand extends BaseHypixelCommand { base: BaseProfileProps, { mode }: ProfileData ): JSX.Element { + if (mode.api === "overall" && mode.submode.api === "challenges") return ; return ; } } diff --git a/apps/discord-bot/src/commands/deprecated/bedwars-challenges.command.tsx b/apps/discord-bot/src/commands/deprecated/bedwars-challenges.command.tsx new file mode 100644 index 000000000..7067d2617 --- /dev/null +++ b/apps/discord-bot/src/commands/deprecated/bedwars-challenges.command.tsx @@ -0,0 +1,23 @@ +/** + * 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 { Command, type IMessage } from "@statsify/discord"; + +@Command({ description: (t) => t("deprecated.command-description", { newCommandName: "/bedwars" }) }) +export class BedWarsChallengesCommand { + public run(): IMessage { + return { + content: (t) => t("deprecated.merged-dropdown", { + oldCommandName: "`/bedwarschallenges`", + newCommand: "", + newCommandName: `${t("emojis:games.BEDWARS")} **BedWars**`, + mode: "**Challenges**", + }), + }; + } +} diff --git a/apps/discord-bot/src/commands/deprecated/skywars-challenges.command.tsx b/apps/discord-bot/src/commands/deprecated/skywars-challenges.command.tsx new file mode 100644 index 000000000..d2a73f0fc --- /dev/null +++ b/apps/discord-bot/src/commands/deprecated/skywars-challenges.command.tsx @@ -0,0 +1,23 @@ +/** + * 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 { Command, type IMessage } from "@statsify/discord"; + +@Command({ description: (t) => t("deprecated.command-description", { newCommandName: "/skywars" }) }) +export class SkyWarsChallengesCommand { + public run(): IMessage { + return { + content: (t) => t("deprecated.merged-dropdown", { + oldCommandName: "`/skywarschallenges`", + newCommand: "", + newCommandName: `${t("emojis:games.SKYWARS")} **SkyWars**`, + mode: "**Challenges**", + }), + }; + } +} diff --git a/apps/discord-bot/src/commands/duels/tables/titles.table.tsx b/apps/discord-bot/src/commands/duels/duels-titles.profile.tsx similarity index 58% rename from apps/discord-bot/src/commands/duels/tables/titles.table.tsx rename to apps/discord-bot/src/commands/duels/duels-titles.profile.tsx index fa0bbc314..5d248a5c7 100644 --- a/apps/discord-bot/src/commands/duels/tables/titles.table.tsx +++ b/apps/discord-bot/src/commands/duels/duels-titles.profile.tsx @@ -6,32 +6,31 @@ * https://github.com/Statsify/statsify/blob/main/LICENSE */ +import { Container, Footer, Header } from "#components"; +import { FormattedGame } from "@statsify/schemas"; + +import { Image } from "skia-canvas"; +import { LocalizeFunction } from "@statsify/discord"; import { arrayGroup } from "@statsify/util"; -import type { Duels } from "@statsify/schemas"; -import type { DuelsModeIcons } from "../duels.command.js"; -import type { Image } from "skia-canvas"; -import type { LocalizeFunction } from "@statsify/discord"; +import type { BaseProfileProps } from "#commands/base.hypixel-command"; +import type { DuelsModeIcons } from "./duels.command.js"; -interface TitlesTableProps { - duels: Duels; - t: LocalizeFunction; +export interface DuelsTitlesProfileProps extends Omit { modeIcons: DuelsModeIcons; } -function ModeTitle({ icon, title, wins, t }: { icon: Image; title: string;wins: number;t: LocalizeFunction }) { - return ( - - - - {title} - -
- {t(wins)} - - ); -} +export const DuelsTitlesProfile = ({ + skin, + player, + background, + logo, + user, + badge, + t, + modeIcons, +}: DuelsTitlesProfileProps) => { + const { duels } = player.stats; -export const TitlesTable = ({ duels, t, modeIcons }: TitlesTableProps) => { const games = [ { icon: modeIcons.blitzsg, title: duels.blitzsg.titleFormatted, wins: duels.blitzsg.wins }, { icon: modeIcons.bow, title: duels.bow.titleFormatted, wins: duels.bow.wins }, @@ -53,27 +52,51 @@ export const TitlesTable = ({ duels, t, modeIcons }: TitlesTableProps) => { const groups = arrayGroup(games, games.length / 2); return ( -
- +
-
- {groups.map((group) => ( -
- {group.map(({ icon, title, wins }) => ( - - ))} -
- ))} +
+ +
+ {groups.map((group) => ( +
+ {group.map(({ icon, title, wins }) => ( + + ))} +
+ ))} +
-
+