Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
45 changes: 31 additions & 14 deletions apps/discord-bot/src/commands/warlords/tables/classes.table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
* https://github.com/Statsify/statsify/blob/main/LICENSE
*/

import { ClassMetadata, METADATA_KEY, WarlordsClass, WarlordsSpecification } from "@statsify/schemas";
import { LocalizeFunction } from "@statsify/discord";
import { Table } from "#components";
import { Warlords, WarlordsClass } from "@statsify/schemas";
import type { Constructor } from "@statsify/util";

interface WarlordsClassColumnProps {
title: string;
stats: WarlordsClass;
stats: WarlordsSpecification;
t: LocalizeFunction;
}

const WarlordsClassColumn = ({ title, stats, t }: WarlordsClassColumnProps) => (
const WarlordsSpecificationColumn = ({ title, stats, t }: WarlordsClassColumnProps) => (
<Table.ts title={title}>
<Table.td title={t("stats.wins")} value={t(stats.wins)} color="§e" />
<Table.td title={t("stats.damage")} value={t(stats.damage)} color="§c" />
Expand All @@ -27,17 +28,33 @@ const WarlordsClassColumn = ({ title, stats, t }: WarlordsClassColumnProps) => (
);

export interface WarlordsClassTableProps {
warlords: Warlords;
stats: WarlordsClass;
constructor: Constructor<WarlordsClass>;
color: string;
t: LocalizeFunction;
}

export const WarlordsClassTable = ({ warlords, t }: WarlordsClassTableProps) => (
<Table.table>
<Table.tr>
<WarlordsClassColumn title="§bMage" stats={warlords.mage} t={t} />
<WarlordsClassColumn title="§7Warrior" stats={warlords.warrior} t={t} />
<WarlordsClassColumn title="§ePaladin" stats={warlords.paladin} t={t} />
<WarlordsClassColumn title="§2Shaman" stats={warlords.shaman} t={t} />
</Table.tr>
</Table.table>
);
export const WarlordsClassTable = ({ stats, t, constructor, color }: WarlordsClassTableProps) => {
const { attack, defense, healer } = getSpecificationNames(constructor);

return (
<Table.table>
<Table.tr>
<WarlordsSpecificationColumn title={`${color}Overall`} stats={stats} t={t} />
<WarlordsSpecificationColumn title={`§4${attack}`} stats={stats.attack} t={t} />
<WarlordsSpecificationColumn title={`§7${defense}`} stats={stats.defense} t={t} />
<WarlordsSpecificationColumn title={`§3${healer}`} stats={stats.healer} t={t} />
</Table.tr>
</Table.table>
);
};

function getSpecificationNames(constructor: Constructor<WarlordsClass>) {
const metadata = Reflect.getMetadata(METADATA_KEY, constructor.prototype) as ClassMetadata;

return {
attack: metadata.attack.leaderboard.name,
defense: metadata.defense.leaderboard.name,
healer: metadata.healer.leaderboard.name,
};
}
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>
);
68 changes: 42 additions & 26 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 { FormattedGame, type GameMode, WarlordsModes } from "@statsify/schemas";
import { WarlordsClassTable } from "./tables/index.js";
import { Container, Footer, Header, type SidebarItem } from "#components";
import { FormattedGame, type GameMode, WarlordsMage, WarlordsModes, WarlordsPaladin, WarlordsShaman, WarlordsWarrior } from "@statsify/schemas";
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 @@ -31,37 +31,53 @@ export const WarlordsProfile = ({

const sidebar: SidebarItem[] = [
[t("stats.coins"), t(warlords.coins), "§6"],
[t("stats.class"), prettify(warlords.class), "§e"],
];

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":
table = (
<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>
);
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;

case "teamDeathmatch":
table = <WarlordsDeathmatchTable warlords={warlords} t={t} />;
break;

case "mage":
table = <WarlordsClassTable stats={warlords.mage} constructor={WarlordsMage} color="§b" t={t} />;
break;

case "warrior":
table = <WarlordsClassTable stats={warlords.warrior} constructor={WarlordsWarrior} color="§7" t={t} />;
break;

case "paladin":
table = <WarlordsClassTable stats={warlords.paladin} constructor={WarlordsPaladin} color="§e" t={t} />;
break;

case "classes":
table = <WarlordsClassTable warlords={warlords} t={t} />;
case "shaman":
table = <WarlordsClassTable stats={warlords.shaman} constructor={WarlordsShaman} color="§2" t={t} />;
break;
}

Expand Down
7 changes: 6 additions & 1 deletion locales/en-US/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -790,10 +790,15 @@
"fails": "Fails",
"mapsCompleted": "Maps Completed",
"arcadeWins": "Arcade Wins",
"spec": "Spec",
"capturePoints": "Capture Points",
"defendPoints": "Defend Points",
"draws": "Draws",
"sheepThrown": "Sheep Thrown",
"sheepKilled": "Sheep Killed",
"magicWool": "Magic Wool",
"flagCaptures": "Flag Captures",
"flagReturns": "Flag Returns",
"airTime": "Air Time",
"potionsSplashed": "Potions Splashed",
"powerOrbs": "Power Orbs"
Expand Down Expand Up @@ -842,4 +847,4 @@
"successfulUnverification": "Successfully unverified your account!",
"successfulVerification": "You are now verified to **{{displayName}}**"
}
}
}
Loading