From 239366186c0ae6b26fbbb232edce61f3bc31be9f Mon Sep 17 00:00:00 2001 From: jacobk999 Date: Sat, 17 Aug 2024 12:28:42 -0400 Subject: [PATCH 1/3] fix ctw stats --- .../commands/woolgames/sheepwars.table.tsx | 6 ++-- .../commands/woolgames/woolgames.profile.tsx | 4 +++ locales/en-US/default.json | 2 +- .../gamemodes/woolgames/capture-the-wool.ts | 34 +++++++++---------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/apps/discord-bot/src/commands/woolgames/sheepwars.table.tsx b/apps/discord-bot/src/commands/woolgames/sheepwars.table.tsx index 1f61e2a0e..d2171719a 100644 --- a/apps/discord-bot/src/commands/woolgames/sheepwars.table.tsx +++ b/apps/discord-bot/src/commands/woolgames/sheepwars.table.tsx @@ -25,7 +25,6 @@ export const SheepWarsTable = ({ sheepwars, t }: SheepWarsTableProps) => { - @@ -33,9 +32,8 @@ export const SheepWarsTable = ({ sheepwars, t }: SheepWarsTableProps) => { - - - + + ); diff --git a/apps/discord-bot/src/commands/woolgames/woolgames.profile.tsx b/apps/discord-bot/src/commands/woolgames/woolgames.profile.tsx index 9f610b29b..1cc74fd3e 100644 --- a/apps/discord-bot/src/commands/woolgames/woolgames.profile.tsx +++ b/apps/discord-bot/src/commands/woolgames/woolgames.profile.tsx @@ -71,6 +71,10 @@ export const WoolGamesProfile = ({ case "sheepwars": table = ; + sidebar.push( + [t("stats.magicWool"), t(woolgames.sheepwars.magicWool), "§5"], + [t("stats.sheepThrown"), t(woolgames.sheepwars.sheepThrown), "§c"] + ); break; } diff --git a/locales/en-US/default.json b/locales/en-US/default.json index 95c6edf87..8a3e90281 100644 --- a/locales/en-US/default.json +++ b/locales/en-US/default.json @@ -792,7 +792,7 @@ "arcadeWins": "Arcade Wins", "draws": "Draws", "sheepThrown": "Sheep Thrown", - "magicWoolHit": "Magic Wool" + "magicWool": "Magic Wool" }, "tips": { "discord": "$t(emojis:socials.discord) Join our **$t(socials.discord)** and get **20% lower cooldowns** $t(emojis:heart)", diff --git a/packages/schemas/src/player/gamemodes/woolgames/capture-the-wool.ts b/packages/schemas/src/player/gamemodes/woolgames/capture-the-wool.ts index 0ebd08941..477c45511 100644 --- a/packages/schemas/src/player/gamemodes/woolgames/capture-the-wool.ts +++ b/packages/schemas/src/player/gamemodes/woolgames/capture-the-wool.ts @@ -86,30 +86,30 @@ export class CaptureTheWool { public deathsAsWoolHolder: number; public constructor(data: APIData = {}) { - this.wins = data.woolhunt_participated_wins; - this.losses = data.woolhunt_participated_losses; + this.wins = data.participated_wins; + this.losses = data.participated_losses; this.wlr = ratio(this.wins, this.losses); - this.draws = data.woolhunt_participated_draws; + this.draws = data.participated_draws; - this.kills = data.woolhunt_kills; - this.deaths = data.woolhunt_deaths; + this.kills = data.kills; + this.deaths = data.deaths; this.kdr = ratio(this.kills, this.deaths); - this.assists = data.woolhunt_assists; + this.assists = data.assists; - this.woolCaptured = data.woolhunt_wools_captured; - this.woolPickedUp = data.woolhunt_wools_stolen; + this.woolCaptured = data.wools_captured; + this.woolPickedUp = data.wools_stolen; - this.longestGame = (data.woolhunt_longest_game ?? 0) * 1000; - this.fastestWin = (data.woolhunt_fastest_win ?? 0) * 1000; - this.fastestWoolCapture = (data.woolhunt_fastest_wool_capture ?? 0) * 1000; + this.longestGame = (data.longest_game ?? 0) * 1000; + this.fastestWin = (data.fastest_win ?? 0) * 1000; + this.fastestWoolCapture = (data.fastest_wool_capture ?? 0) * 1000; - this.goldEarned = data.woolhunt_gold_earned; - this.goldSpent = Math.abs(data.woolhunt_gold_spent ?? 0); + this.goldEarned = data.gold_earned; + this.goldSpent = Math.abs(data.gold_spent ?? 0); - this.killsOnWoolHolder = data.woolhunt_kills_on_woolholder; - this.deathsToWoolHolder = data.woolhunt_deaths_to_woolholder; + this.killsOnWoolHolder = data.kills_on_woolholder; + this.deathsToWoolHolder = data.deaths_to_woolholder; - this.killsAsWoolHolder = data.woolhunt_kills_with_wool; - this.deathsAsWoolHolder = data.woolhunt_deaths_with_wool; + this.killsAsWoolHolder = data.kills_with_wool; + this.deathsAsWoolHolder = data.deaths_with_wool; } } From f4d972bfefb3ef2ddd1b74eae4673bad2fc1bdec Mon Sep 17 00:00:00 2001 From: jacobk999 Date: Sat, 17 Aug 2024 12:53:39 -0400 Subject: [PATCH 2/3] fix challenge names --- .../challenges/challenges.profile.tsx | 60 +++++++++++++++++-- .../src/player/gamemodes/challenges/index.ts | 1 + 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/apps/discord-bot/src/commands/challenges/challenges.profile.tsx b/apps/discord-bot/src/commands/challenges/challenges.profile.tsx index 4e97e2f3e..c2b5e309c 100644 --- a/apps/discord-bot/src/commands/challenges/challenges.profile.tsx +++ b/apps/discord-bot/src/commands/challenges/challenges.profile.tsx @@ -7,15 +7,38 @@ */ import { + ArcadeChallenges, + ArenaBrawlChallenges, + BedWarsChallenges, + BlitzSGChallenges, + BuildBattleChallenges, ChallengeModes, Challenges, + CopsAndCrimsChallenges, + DuelsChallenges, FormattedGame, GameChallenges, type GameId, type GameMode, + MegaWallsChallenges, + MetadataEntry, MetadataScanner, + MurderMysteryChallenges, + PaintballChallenges, + QuakeChallenges, + SkyWarsChallenges, + SmashHeroesChallenges, + SpeedUHCChallenges, + TNTGamesChallenges, + TurboKartRacersChallenges, + UHCChallenges, + VampireZChallenges, + WallsChallenges, + WarlordsChallenges, + WoolGamesChallenges, } from "@statsify/schemas"; import { Container, Footer, GameList, Header, SidebarItem, Table } from "#components"; + import { arrayGroup, prettify } from "@statsify/util"; import type { BaseProfileProps } from "#commands/base.hypixel-command"; import type { Image } from "skia-canvas"; @@ -44,12 +67,36 @@ const NormalTable = ({ challenges, t, gameIcons }: NormalTableProps) => { interface GameTableProps { gameChallenges: GameChallenges; - constructor: any; + mode: Exclude["api"], "overall">; t: LocalizeFunction; } -const GameTable = ({ gameChallenges, constructor, t }: GameTableProps) => { - const metadata = MetadataScanner.scan(constructor); +const METADATA: Record["api"], "overall">, MetadataEntry[]> = { + ARCADE: MetadataScanner.scan(ArcadeChallenges), + ARENA_BRAWL: MetadataScanner.scan(ArenaBrawlChallenges), + BEDWARS: MetadataScanner.scan(BedWarsChallenges), + BLITZSG: MetadataScanner.scan(BlitzSGChallenges), + BUILD_BATTLE: MetadataScanner.scan(BuildBattleChallenges), + COPS_AND_CRIMS: MetadataScanner.scan(CopsAndCrimsChallenges), + DUELS: MetadataScanner.scan(DuelsChallenges), + MEGAWALLS: MetadataScanner.scan(MegaWallsChallenges), + MURDER_MYSTERY: MetadataScanner.scan(MurderMysteryChallenges), + PAINTBALL: MetadataScanner.scan(PaintballChallenges), + QUAKE: MetadataScanner.scan(QuakeChallenges), + SKYWARS: MetadataScanner.scan(SkyWarsChallenges), + SMASH_HEROES: MetadataScanner.scan(SmashHeroesChallenges), + SPEED_UHC: MetadataScanner.scan(SpeedUHCChallenges), + TNT_GAMES: MetadataScanner.scan(TNTGamesChallenges), + TURBO_KART_RACERS: MetadataScanner.scan(TurboKartRacersChallenges), + UHC: MetadataScanner.scan(UHCChallenges), + VAMPIREZ: MetadataScanner.scan(VampireZChallenges), + WALLS: MetadataScanner.scan(WallsChallenges), + WARLORDS: MetadataScanner.scan(WarlordsChallenges), + WOOLGAMES: MetadataScanner.scan(WoolGamesChallenges), +}; + +const GameTable = ({ gameChallenges, mode, t }: GameTableProps) => { + const metadata = METADATA[mode]; const entries = Object.entries(gameChallenges); const GROUP_SIZE = entries.length < 5 ? 4 : (entries.length - 1) ** 0.5; @@ -59,8 +106,9 @@ const GameTable = ({ gameChallenges, constructor, t }: GameTableProps) => { .filter(([k]) => k !== "total") .sort((a, b) => b[1] - a[1]) .map(([challenge, completions]) => { - const field = metadata.find(([k]) => k === challenge); - const realName = field?.[1]?.leaderboard?.name ?? prettify(challenge); + const [_, field] = metadata.find(([k]) => k === challenge)!; + + const realName = field.leaderboard?.name ?? prettify(challenge); return [realName, t(completions)]; }), GROUP_SIZE @@ -107,7 +155,7 @@ export const ChallengesProfile = ({ table = ( ); diff --git a/packages/schemas/src/player/gamemodes/challenges/index.ts b/packages/schemas/src/player/gamemodes/challenges/index.ts index 22b42096a..7c18a90d7 100644 --- a/packages/schemas/src/player/gamemodes/challenges/index.ts +++ b/packages/schemas/src/player/gamemodes/challenges/index.ts @@ -163,3 +163,4 @@ export class Challenges { } export * from "./game-challenges.js"; +export * from "./modes/index.js"; From 8af325df748b6de30afdbdef80465bf9decce174 Mon Sep 17 00:00:00 2001 From: jacobk999 Date: Sat, 17 Aug 2024 13:01:30 -0400 Subject: [PATCH 3/3] update arcade colors --- apps/discord-bot/src/commands/arcade/modes/overall-arcade.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/discord-bot/src/commands/arcade/modes/overall-arcade.tsx b/apps/discord-bot/src/commands/arcade/modes/overall-arcade.tsx index 1caa84333..f074cae81 100644 --- a/apps/discord-bot/src/commands/arcade/modes/overall-arcade.tsx +++ b/apps/discord-bot/src/commands/arcade/modes/overall-arcade.tsx @@ -44,7 +44,7 @@ export const OverallArcadeTable = ({ stats, t }: OverallArcadeTableProps) => { const rows = arrayGroup(games, rowSize); - const colors = ["§a", "§2", "§e", "§6", "§c", "§4"]; + const colors = ["§d", "§b", "§a", "§e", "§6", "§c"]; return (