Skip to content

Commit

Permalink
feat: add sheep wars stats, and introduce /woolgames (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobk999 authored Aug 17, 2024
1 parent aee3ac6 commit 66fd297
Show file tree
Hide file tree
Showing 118 changed files with 1,484 additions and 1,213 deletions.
11 changes: 2 additions & 9 deletions apps/discord-bot/src/commands/arcade/arcade.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

import { ArcadeModes, FormattedGame, GameMode } from "@statsify/schemas";
import { ArcadeModes, FormattedGame, type GameMode } from "@statsify/schemas";
import {
BlockingDeadTable,
BountyHuntersTable,
CaptureTheWoolTable,
CreeperAttackTable,
DragonWarsTable,
DropperTable,
Expand All @@ -29,7 +28,6 @@ import {
SeasonalTable,
ThrowOutTable,
ZombiesTable,
captureTheWoolSiderbar,
} from "./modes/index.js";
import { Container, Footer, Header, SidebarItem } from "#components";
import type { BaseProfileProps } from "#commands/base.hypixel-command";
Expand All @@ -51,7 +49,7 @@ export const ArcadeProfile = ({
}: ArcadeProfileProps) => {
const { arcade } = player.stats;

let sidebar: SidebarItem[] = [
const sidebar: SidebarItem[] = [
[t("stats.coins"), t(arcade.coins), "§6"],
[t("stats.coinConversions"), t(arcade.coinConversions), "§e"],
[t("stats.arcadeWins"), t(arcade.wins), "§b"],
Expand All @@ -69,11 +67,6 @@ export const ArcadeProfile = ({
table = <BountyHuntersTable stats={arcade[api]} t={t} />;
break;

case "captureTheWool":
table = <CaptureTheWoolTable stats={arcade[api]} t={t} time={time} />;
sidebar = captureTheWoolSiderbar(arcade, t);
break;

case "creeperAttack":
table = <CreeperAttackTable stats={arcade[api]} t={t} />;
break;
Expand Down
2 changes: 1 addition & 1 deletion apps/discord-bot/src/commands/arcade/dropper.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { Container, Footer, Header } from "#components";
import { DropperMapsTable, DropperTable } from "./modes/index.js";
import { DropperModes, FormattedGame, GameMode } from "@statsify/schemas";
import { DropperModes, FormattedGame, type GameMode } from "@statsify/schemas";
import type { BaseProfileProps } from "#commands/base.hypixel-command";

export interface DropperProfileProps extends BaseProfileProps {
Expand Down
103 changes: 0 additions & 103 deletions apps/discord-bot/src/commands/arcade/modes/capture-the-wool.tsx

This file was deleted.

1 change: 0 additions & 1 deletion apps/discord-bot/src/commands/arcade/modes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

export * from "./blocking-dead.js";
export * from "./bounty-hunters.js";
export * from "./capture-the-wool.js";
export * from "./creeper-attack.js";
export * from "./dragon-wars.js";
export * from "./dropper.js";
Expand Down
5 changes: 2 additions & 3 deletions apps/discord-bot/src/commands/arcade/modes/overall-arcade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ interface OverallArcadeTableProps {
}

export const OverallArcadeTable = ({ stats, t }: OverallArcadeTableProps) => {
const rowSize = 5;
const rowSize = 3;

const games: [string, number][] = [
["Blocking Dead", stats.blockingDead.wins],
["Bounty Hunters", stats.bountyHunters.wins],
["Capture The Wool", stats.captureTheWool.wins],
["Dragon Wars", stats.dragonWars.wins],
["Dropper", stats.dropper.wins],
["Ender Spleef", stats.enderSpleef.wins],
Expand All @@ -45,7 +44,7 @@ export const OverallArcadeTable = ({ stats, t }: OverallArcadeTableProps) => {

const rows = arrayGroup(games, rowSize);

const colors = [a", e", 6", c", 4"];
const colors = [d", b", a", e", 6", "§c"];

return (
<Table.table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

import { ArenaBrawlModes, FormattedGame, GameMode } from "@statsify/schemas";
import { ArenaBrawlModes, FormattedGame, type GameMode } from "@statsify/schemas";
import {
Container,
Footer,
Expand Down
93 changes: 68 additions & 25 deletions apps/discord-bot/src/commands/base.hypixel-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Page,
PaginateService,
PlayerArgument,
SubPage,
} from "@statsify/discord";
import { Container } from "typedi";
import { GamesWithBackgrounds, mapBackground } from "#constants";
Expand All @@ -23,7 +24,7 @@ import { getBackground, getLogo } from "@statsify/assets";
import { getTheme } from "#themes";
import { noop } from "@statsify/util";
import { render } from "@statsify/rendering";
import type { GameMode, GameModes, Player, User } from "@statsify/schemas";
import type { GameMode, GameModeWithSubModes, GameModes, Player, User } from "@statsify/schemas";
import type { Image } from "skia-canvas";

export type ProfileTime = "LIVE" | HistoricalTimeData;
Expand All @@ -48,8 +49,8 @@ export type ModeEmoji = LocalizationString | false | undefined;

export interface BaseHypixelCommand<T extends GamesWithBackgrounds, K = never> {
getPreProfileData?(player: Player): K | Promise<K>;
filterModes?(player: Player, modes: GameMode<T>[]): GameMode<T>[];
getModeEmojis?(modes: GameMode<T>[]): ModeEmoji[];
filterModes?(player: Player, modes: GameModeWithSubModes<T>[]): GameModeWithSubModes<T>[];
getModeEmojis?(modes: GameModeWithSubModes<T>[]): ModeEmoji[];
}

@Command({
Expand Down Expand Up @@ -83,29 +84,71 @@ export abstract class BaseHypixelCommand<T extends GamesWithBackgrounds, K = nev
const filteredModes = this.filterModes?.(player, allModes) ?? allModes;
const emojis = this.getModeEmojis?.(filteredModes) ?? [];

const pages: Page[] = filteredModes.map((mode, index) => ({
label: mode.formatted,
emoji: emojis[index],
generator: async (t) => {
const background = await getBackground(...mapBackground(this.modes, mode.api));

const profile = this.getProfile(
{
player,
skin,
background,
logo,
t,
user,
badge,
time: "LIVE",
const pages: Page[] = filteredModes.map((mode, index) => {
const pageInput = {
label: mode.formatted,
emoji: emojis[index],
};

if (mode.submodes.length === 0) {
const gameMode = { ...mode, submode: undefined } as unknown as GameMode<T>;

return {
...pageInput,
generator: async (t) => {
const background = await getBackground(...mapBackground(this.modes, mode.api));

const profile = this.getProfile(
{
player,
skin,
background,
logo,
t,
user,
badge,
time: "LIVE",
},
{ mode: gameMode, data }
);

return render(profile, getTheme(user));
},
{ mode, data }
);

return render(profile, getTheme(user));
},
}));
};
}

const subPages = mode.submodes.map((submode): SubPage => ({
label: submode.formatted,
generator: async (t) => {
const background = await getBackground(...mapBackground(this.modes, mode.api));

const gameMode = {
api: mode.api,
formatted: mode.formatted,
hypixel: mode.hypixel,
submode,
} as GameMode<T>;

const profile = this.getProfile(
{
player,
skin,
background,
logo,
t,
user,
badge,
time: "LIVE",
},
{ mode: gameMode, data }
);

return render(profile, getTheme(user));
},
}));

return { ...pageInput, subPages };
});

return this.paginateService.paginate(context, pages);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

import { BEDWARS_MODES, BedWarsModes, GameMode, Player } from "@statsify/schemas";
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";
Expand All @@ -19,8 +19,8 @@ export class BedWarsChallengesCommand extends BaseHypixelCommand<BedWarsModes> {

public filterModes(
player: Player,
modes: GameMode<BedWarsModes>[]
): GameMode<BedWarsModes>[] {
modes: GameModeWithSubModes<BedWarsModes>[]
): GameModeWithSubModes<BedWarsModes>[] {
return [modes[0]];
}

Expand Down
2 changes: 1 addition & 1 deletion apps/discord-bot/src/commands/bedwars/bedwars.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

import { BedWarsModes, FormattedGame, GameMode } from "@statsify/schemas";
import { BedWarsModes, FormattedGame, type GameMode } from "@statsify/schemas";
import {
Container,
Footer,
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/src/commands/blitzsg/blitzsg.command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

import { BLITZSG_MODES, BlitzSGModes, GameMode, Player } from "@statsify/schemas";
import { BLITZSG_MODES, BlitzSGModes, GameModeWithSubModes, Player } from "@statsify/schemas";
import {
BaseHypixelCommand,
BaseProfileProps,
Expand All @@ -23,8 +23,8 @@ export class BlitzSGCommand extends BaseHypixelCommand<BlitzSGModes> {

public filterModes(
player: Player,
modes: GameMode<BlitzSGModes>[]
): GameMode<BlitzSGModes>[] {
modes: GameModeWithSubModes<BlitzSGModes>[]
): GameModeWithSubModes<BlitzSGModes>[] {
return filterBlitzKits(player, modes);
}

Expand Down
7 changes: 4 additions & 3 deletions apps/discord-bot/src/commands/blitzsg/blitzsg.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
BlitzSGKit,
BlitzSGModes,
FormattedGame,
GameMode,
type GameMode,
type GameModeWithSubModes,
Player,
} from "@statsify/schemas";
import {
Expand Down Expand Up @@ -193,8 +194,8 @@ export const BlitzSGProfile = ({

export function filterBlitzKits(
player: Player,
modes: GameMode<BlitzSGModes>[]
): GameMode<BlitzSGModes>[] {
modes: GameModeWithSubModes<BlitzSGModes>[]
): GameModeWithSubModes<BlitzSGModes>[] {
const { blitzsg } = player.stats;
const [overall, ...kits] = modes;

Expand Down
Loading

0 comments on commit 66fd297

Please sign in to comment.