Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobk999 committed Aug 17, 2024
2 parents 57d56c8 + ee6e426 commit bc2d193
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Table.table>
Expand Down
60 changes: 54 additions & 6 deletions apps/discord-bot/src/commands/challenges/challenges.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -44,12 +67,36 @@ const NormalTable = ({ challenges, t, gameIcons }: NormalTableProps) => {

interface GameTableProps {
gameChallenges: GameChallenges;
constructor: any;
mode: Exclude<GameMode<ChallengeModes>["api"], "overall">;
t: LocalizeFunction;
}

const GameTable = ({ gameChallenges, constructor, t }: GameTableProps) => {
const metadata = MetadataScanner.scan(constructor);
const METADATA: Record<Exclude<GameMode<ChallengeModes>["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;
Expand All @@ -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
Expand Down Expand Up @@ -107,7 +155,7 @@ export const ChallengesProfile = ({
table = (
<GameTable
gameChallenges={challenges[api]}
constructor={challenges[api].constructor}
mode={api}
t={t}
/>
);
Expand Down
6 changes: 6 additions & 0 deletions apps/discord-bot/src/commands/ratios/ratios.command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
MEGAWALLS_MODES,
MURDER_MYSTERY_MODES,
PAINTBALL_MODES,
PIT_MODES,
Player,
PlayerStats,
QUAKE_MODES,
Expand Down Expand Up @@ -128,6 +129,11 @@ export class RatiosCommand {
return this.run(context, PAINTBALL_MODES);
}

@SubCommand({ description: (t) => t("commands.ratios-pit"), args })
public pit(context: CommandContext) {
return this.run(context, PIT_MODES);
}

@SubCommand({ description: (t) => t("commands.ratios-quake"), args, group: "classic" })
public quake(context: CommandContext) {
return this.run(context, QUAKE_MODES);
Expand Down
2 changes: 0 additions & 2 deletions apps/discord-bot/src/commands/ratios/ratios.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export type RatioWithStats = [

export interface RatiosProfileProps extends Omit<BaseProfileProps, "time"> {
mode: GameMode<any>;

ratios: RatioWithStats[];

gameName: FormattedGame;
}

Expand Down
6 changes: 2 additions & 4 deletions apps/discord-bot/src/commands/woolgames/sheepwars.table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ export const SheepWarsTable = ({ sheepwars, t }: SheepWarsTableProps) => {
<Table.td title={t("stats.wins")} value={t(stats.wins)} color="§a" />
<Table.td title={t("stats.losses")} value={t(stats.losses)} color="§c" />
<Table.td title={t("stats.wlr")} value={t(stats.wlr)} color="§6" />
<Table.td title={t("stats.gamesPlayed")} value={t(stats.gamesPlayed)} color="§e" />
</Table.tr>
<Table.tr>
<Table.td title={t("stats.kills")} value={t(stats.kills)} color="§a" />
<Table.td title={t("stats.deaths")} value={t(stats.deaths)} color="§c" />
<Table.td title={t("stats.kdr")} value={t(stats.kdr)} color="§6" />
</Table.tr>
<Table.tr>
<Table.td title={t("stats.sheepThrown")} value={t(stats.sheepThrown)} color="§a" />
<Table.td title={t("stats.magicWoolHit")} value={t(stats.magicWool)} color="§c" />
<Table.td title={t("stats.kit")} value={prettify(stats.kit)} color="§6" />
<Table.td title={t("stats.gamesPlayed")} value={t(stats.gamesPlayed)} color="§e" />
<Table.td title={t("stats.kit")} value={prettify(stats.kit)} color="§b" />
</Table.tr>
</>
);
Expand Down
4 changes: 4 additions & 0 deletions apps/discord-bot/src/commands/woolgames/woolgames.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export const WoolGamesProfile = ({

case "sheepwars":
table = <SheepWarsTable sheepwars={woolgames[mode.api]} t={t} />;
sidebar.push(
[t("stats.magicWool"), t(woolgames.sheepwars.magicWool), "§5"],
[t("stats.sheepThrown"), t(woolgames.sheepwars.sheepThrown), "§c"]
);
break;
}

Expand Down
2 changes: 2 additions & 0 deletions apps/discord-bot/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ export const MODES_TO_API = new Map<GameModes<GamesWithBackgrounds>, keyof Playe
[MEGAWALLS_MODES, "megawalls"],
[MURDER_MYSTERY_MODES, "murdermystery"],
[PAINTBALL_MODES, "paintball"],
[PIT_MODES, "pit"],
[PARKOUR_MODES, "parkour"],
[QUAKE_MODES, "quake"],
[SKYWARS_MODES, "skywars"],
Expand Down Expand Up @@ -429,6 +430,7 @@ export const MODES_TO_FORMATTED = new Map<GameModes<GamesWithBackgrounds>, Forma
[MEGAWALLS_MODES, FormattedGame.MEGAWALLS],
[MURDER_MYSTERY_MODES, FormattedGame.MURDER_MYSTERY],
[PAINTBALL_MODES, FormattedGame.PAINTBALL],
[PIT_MODES, FormattedGame.PIT],
[PARKOUR_MODES, FormattedGame.PARKOUR],
[QUAKE_MODES, FormattedGame.QUAKE],
[SKYWARS_MODES, FormattedGame.SKYWARS],
Expand Down
3 changes: 2 additions & 1 deletion locales/en-US/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"ratios-megawalls": "$t(commands.ratios-command, { \"name\": \"MegaWalls\" })",
"ratios-murdermystery": "$t(commands.ratios-command, { \"name\": \"Murder Mystery\" })",
"ratios-paintball": "$t(commands.ratios-command, { \"name\": \"Paintball\" })",
"ratios-pit": "$t(commands.ratios-command, { \"name\": \"Pit\" })",
"ratios-quake": "$t(commands.ratios-command, { \"name\": \"Quake\" })",
"ratios-skywars": "$t(commands.ratios-command, { \"name\": \"SkyWars\" })",
"ratios-smashheroes": "$t(commands.ratios-command, { \"name\": \"Smash Heroes\" })",
Expand Down Expand Up @@ -786,7 +787,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)",
Expand Down
26 changes: 26 additions & 0 deletions packages/discord/src/services/paginate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class PaginateService {
currentIndex = index;
currentSubIndex = 0;

<<<<<<< HEAD
if ("subPages" in pages[index] && pages[index].subPages.length > 1) {
subController = new PageController(pages[index].subPages, currentSubIndex);
subController.register(listener, (interaction, subIndex) => handler(interaction, currentIndex, subIndex));
Expand All @@ -128,6 +129,31 @@ export class PaginateService {
function onTimeout() {
mainController.unregister(listener);
subController?.unregister(listener);
||||||| aee3ac6
=======
if ("subPages" in pages[index]) {
subController = new PageController(pages[index].subPages, currentSubIndex);
subController.register(listener, (interaction, subIndex) => handler(interaction, currentIndex, subIndex));
} else {
subController = undefined;
}
} else if (subIndex !== currentSubIndex) {
subController?.switchPage(subIndex);
currentSubIndex = subIndex;
}
const message = await getMessage(index, subIndex);
message.components = [mainController.getActionRow(), subController?.getActionRow()]
.filter((row) => row !== undefined);
return context.reply(message);
}
function onTimeout() {
mainController.unregister(listener);
subController?.unregister(listener);
>>>>>>> main
cache.clear();
return context.reply({ components: [] });
}
Expand Down
1 change: 1 addition & 0 deletions packages/schemas/src/player/gamemodes/challenges/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@ export class Challenges {
}

export * from "./game-challenges.js";
export * from "./modes/index.js";
5 changes: 4 additions & 1 deletion packages/schemas/src/player/gamemodes/pit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
getPrestigeReq,
} from "./util.js";

export const PIT_MODES = new GameModes([{ api: "overall", hypixel: "PIT", formatted: "Pit" }] as const);
export const PIT_MODES = new GameModes([
{ api: "overall" },
{ hypixel: "PIT", formatted: "Pit" },
] as const);

export type PitModes = ExtractGameModes<typeof PIT_MODES>;

Expand Down
34 changes: 17 additions & 17 deletions packages/schemas/src/player/gamemodes/woolgames/capture-the-wool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit bc2d193

Please sign in to comment.