Skip to content

Commit

Permalink
separate mode stats into their own pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobk999 committed Aug 19, 2024
1 parent 31ec6cf commit e12710f
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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 { Table } from "#components";
import type { LocalizeFunction } from "@statsify/discord";
import type { Warlords } from "@statsify/schemas";

export interface WarlordsCaptureTheFlagTableProps {
warlords: Warlords;
t: LocalizeFunction;
}

export const WarlordsCaptureTheFlagTable = ({ warlords, t }: WarlordsCaptureTheFlagTableProps) => (
<Table.table>
<Table.tr>
<Table.td title={t("stats.wins")} value={t(warlords.captureTheFlag.wins)} color="§a" />
<Table.td title={t("stats.kills")} value={t(warlords.captureTheFlag.kills)} color="§e" />
</Table.tr>
<Table.tr>
<Table.td title={t("stats.flagCaptures")} value={t(warlords.captureTheFlag.flagCaptures)} color="§c" />
<Table.td title={t("stats.flagReturns")} value={t(warlords.captureTheFlag.flagReturns)} color="§9" />
</Table.tr>
</Table.table>
);
25 changes: 25 additions & 0 deletions apps/discord-bot/src/commands/warlords/tables/deathmatch.table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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 { Table } from "#components";
import type { LocalizeFunction } from "@statsify/discord";
import type { Warlords } from "@statsify/schemas";

export interface WarlordsDeathmatchTableProps {
warlords: Warlords;
t: LocalizeFunction;
}

export const WarlordsDeathmatchTable = ({ warlords, t }: WarlordsDeathmatchTableProps) => (
<Table.table>
<Table.tr>
<Table.td title={t("stats.wins")} value={t(warlords.teamDeathmatch.wins)} color="§a" />
<Table.td title={t("stats.kills")} value={t(warlords.teamDeathmatch.kills)} color="§e" />
</Table.tr>
</Table.table>
);
30 changes: 30 additions & 0 deletions apps/discord-bot/src/commands/warlords/tables/domination.table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* 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 { Table } from "#components";
import type { LocalizeFunction } from "@statsify/discord";
import type { Warlords } from "@statsify/schemas";

export interface WarlordsDominationTableProps {
warlords: Warlords;
t: LocalizeFunction;
}

export const WarlordsDominationTable = ({ warlords, t }: WarlordsDominationTableProps) => (
<Table.table>
<Table.tr>
<Table.td title={t("stats.wins")} value={t(warlords.domination.wins)} color="§a" />
<Table.td title={t("stats.kills")} value={t(warlords.domination.kills)} color="§e" />
<Table.td title={t("stats.score")} value={t(warlords.domination.score)} color="§6" />
</Table.tr>
<Table.tr>
<Table.td title={t("stats.capturePoints")} value={t(warlords.domination.capturePoints)} color="§2" />
<Table.td title={t("stats.defendPoints")} value={t(warlords.domination.defendPoints)} color="§b" />
</Table.tr>
</Table.table>
);
4 changes: 4 additions & 0 deletions apps/discord-bot/src/commands/warlords/tables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
*/

export * from "./classes.table.js";
export * from "./capture-the-flag.table.js";
export * from "./domination.table.js";
export * from "./overall.table.js";
export * from "./deathmatch.table.js";
37 changes: 37 additions & 0 deletions apps/discord-bot/src/commands/warlords/tables/overall.table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* 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 { Table } from "#components";
import type { LocalizeFunction } from "@statsify/discord";
import type { Warlords } from "@statsify/schemas";

export interface WarlordsOverallTableProps {
warlords: Warlords;
t: LocalizeFunction;
}

export const WarlordsOverallTable = ({ warlords, t }: WarlordsOverallTableProps) => (
<Table.table>
<Table.tr>
<Table.td title={t("stats.wins")} value={t(warlords.wins)} color="§a" />
<Table.td title={t("stats.losses")} value={t(warlords.losses)} color="§c" />
<Table.td title={t("stats.wlr")} value={t(warlords.wlr)} color="§6" />
<Table.td
title={t("stats.gamesPlayed")}
value={t(warlords.gamesPlayed)}
color="§e"
/>
</Table.tr>
<Table.tr>
<Table.td title={t("stats.kills")} value={t(warlords.kills)} color="§a" />
<Table.td title={t("stats.deaths")} value={t(warlords.deaths)} color="§c" />
<Table.td title={t("stats.kdr")} value={t(warlords.kdr)} color="§6" />
<Table.td title={t("stats.assists")} value={t(warlords.assists)} color="§e" />
</Table.tr>
</Table.table>
);
76 changes: 22 additions & 54 deletions apps/discord-bot/src/commands/warlords/warlords.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

import { Container, Footer, Header, SidebarItem, Table } from "#components";
import { Container, Footer, Header, type SidebarItem } from "#components";
import { FormattedGame, type GameMode, WarlordsMage, WarlordsModes, WarlordsPaladin, WarlordsShaman, WarlordsWarrior } from "@statsify/schemas";
import { WarlordsClassTable } from "./tables/index.js";
import { WarlordsCaptureTheFlagTable, WarlordsClassTable, WarlordsDeathmatchTable, WarlordsDominationTable, WarlordsOverallTable } from "./tables/index.js";
import { prettify } from "@statsify/util";
import type { BaseProfileProps } from "#commands/base.hypixel-command";

Expand All @@ -33,68 +33,36 @@ export const WarlordsProfile = ({
[t("stats.coins"), t(warlords.coins), "§6"],
];

if (mode.api !== "overall")
if (mode.api !== "overall" && mode.api !== "captureTheFlag" && mode.api !== "domination" && mode.api !== "teamDeathmatch") {
sidebar.push(
[t("stats.spec"), prettify(warlords[mode.api].specification), "§a"],
[t("stats.level"), t(warlords[mode.api].level), "§a"]
);
} else {
sidebar.push([t("stats.class"), prettify(warlords.class), "§e"]);
const clazz = warlords.class as "mage" | "warrior" | "paladin" | "shaman";
// Verify that the cast is correct and the class is a valid class
if (clazz in warlords && typeof warlords[clazz] === "object") sidebar.push([t("stats.spec"), prettify(warlords[clazz].specification), "§a"]);
}

let table: JSX.Element;

switch (mode.api) {
case "overall": {
sidebar.push([t("stats.class"), prettify(warlords.class), "§e"]);
const clazz = warlords.class as "mage" | "warrior" | "paladin" | "shaman";
// Verify that the cast is correct and the class is a valid class
if (clazz in warlords && typeof warlords[clazz] === "object") sidebar.push([t("stats.spec"), prettify(warlords[clazz].specification), "§a"]);
case "overall":
table = <WarlordsOverallTable warlords={warlords} t={t} />;
break;

case "captureTheFlag":
table = <WarlordsCaptureTheFlagTable warlords={warlords} t={t} />;
break;

case "domination":
table = <WarlordsDominationTable warlords={warlords} t={t} />;
break;

table = (
<Table.table>
<Table.ts title="§6Overall">
<Table.tr>
<Table.td title={t("stats.wins")} value={t(warlords.wins)} color="§a" />
<Table.td title={t("stats.losses")} value={t(warlords.losses)} color="§c" />
<Table.td title={t("stats.wlr")} value={t(warlords.wlr)} color="§6" />
<Table.td
title={t("stats.gamesPlayed")}
value={t(warlords.gamesPlayed)}
color="§e"
/>
</Table.tr>
<Table.tr>
<Table.td title={t("stats.kills")} value={t(warlords.kills)} color="§a" />
<Table.td title={t("stats.deaths")} value={t(warlords.deaths)} color="§c" />
<Table.td title={t("stats.kdr")} value={t(warlords.kdr)} color="§6" />
<Table.td title={t("stats.assists")} value={t(warlords.assists)} color="§e" />
</Table.tr>
</Table.ts>
<Table.tr>
<Table.ts title="§6Capture the Flag">
<Table.tr>
<Table.td title={t("stats.wins")} value={t(warlords.captureTheFlag.wins)} color="§a" />
<Table.td title={t("stats.kills")} value={t(warlords.captureTheFlag.kills)} color="§e" />
</Table.tr>
</Table.ts>
<Table.ts title="§6Team Deathmatch">
<Table.tr>
<Table.td title={t("stats.wins")} value={t(warlords.teamDeathmatch.wins)} color="§a" />
<Table.td title={t("stats.kills")} value={t(warlords.teamDeathmatch.kills)} color="§e" />
</Table.tr>
</Table.ts>
</Table.tr>
<Table.ts title="§6Domination">
<Table.tr>
<Table.td title={t("stats.wins")} value={t(warlords.domination.wins)} color="§a" />
<Table.td title={t("stats.kills")} value={t(warlords.domination.kills)} color="§e" />
<Table.td title={t("stats.score")} value={t(warlords.domination.score)} color="§6" />
<Table.td title={t("stats.capturePoints")} value={t(warlords.domination.capturePoints)} color="§2" />
<Table.td title={t("stats.defendPoints")} value={t(warlords.domination.defendPoints)} color="§b" />
</Table.tr>
</Table.ts>
</Table.table>
);
case "teamDeathmatch":
table = <WarlordsDeathmatchTable warlords={warlords} t={t} />;
break;
}

case "mage":
table = <WarlordsClassTable stats={warlords.mage} constructor={WarlordsMage} color="§b" t={t} />;
Expand Down
2 changes: 1 addition & 1 deletion assets/private
6 changes: 4 additions & 2 deletions locales/en-US/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,9 @@
"defendPoints": "Defend Points",
"draws": "Draws",
"sheepThrown": "Sheep Thrown",
"magicWool": "Magic Wool"
"magicWool": "Magic Wool",
"flagCaptures": "Flag Captures",
"flagReturns": "Flag Returns"
},
"tips": {
"discord": "$t(emojis:socials.discord) Join our **$t(socials.discord)** and get **20% lower cooldowns** $t(emojis:heart)",
Expand Down Expand Up @@ -842,4 +844,4 @@
"successfulUnverification": "Successfully unverified your account!",
"successfulVerification": "You are now verified to **{{displayName}}**"
}
}
}
11 changes: 3 additions & 8 deletions packages/schemas/src/player/gamemodes/warlords/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,17 @@ import type { APIData } from "@statsify/util";

export const WARLORDS_MODES = new GameModes([
{ api: "overall" },

{ api: "captureTheFlag", hypixel: "ctf_mini", formatted: "Capture the Flag" },
{ api: "domination", hypixel: "domination", formatted: "Domination" },
{ api: "teamDeathmatch", hypixel: "team_deathmatch", formatted: "Team Deathmatch" },
{ api: "mage" },
{ api: "warrior" },
{ api: "paladin" },
{ api: "shaman" },

{ hypixel: "ctf_mini", formatted: "Capture the Flag" },
{ hypixel: "domination", formatted: "Domination" },
{ hypixel: "team_deathmatch", formatted: "Team Deathmatch" },
] as const);

export type WarlordsModes = ExtractGameModes<typeof WARLORDS_MODES>;

// [TODO]: flag_conquer_self
// [TODO]: flag_returns

export class Warlords {
@Field({ store: { default: "warrior" } })
public class: string;
Expand Down
9 changes: 9 additions & 0 deletions packages/schemas/src/player/gamemodes/warlords/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,18 @@ export class WarlordsCaptureTheFlag {
@Field()
public kills: number;

@Field()
public flagCaptures: number;

@Field()
public flagReturns: number;

public constructor(data: APIData) {
this.wins = data.wins_capturetheflag;
this.kills = data.kills_capturetheflag;

this.flagCaptures = data.flag_conquer_self;
this.flagReturns = data.flag_returns;
}
}

Expand Down

0 comments on commit e12710f

Please sign in to comment.