Skip to content

Commit

Permalink
asdasd
Browse files Browse the repository at this point in the history
Merge branch 'feat/woolgames' into feat/pit-ratios
  • Loading branch information
jacobk999 committed Aug 17, 2024
2 parents 902e895 + 8af325d commit 96ffa1b
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 29 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: 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: 1 addition & 1 deletion locales/en-US/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,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
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";
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 96ffa1b

Please sign in to comment.