Skip to content

Commit

Permalink
Merge pull request #218 from Kathund/commas
Browse files Browse the repository at this point in the history
Big Number formatting in commands
  • Loading branch information
DuckySoLucky authored Nov 10, 2023
2 parents 7305b87 + 8312a32 commit e6626ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/minecraft/commands/bedwarsStatsCommand.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { capitalize, formatNumber } = require("../../contracts/helperFunctions.js");
const minecraftCommand = require("../../contracts/minecraftCommand.js");
const hypixel = require("../../contracts/API/HypixelRebornAPI.js");
const { capitalize } = require("../../contracts/helperFunctions.js");

class BedwarsCommand extends minecraftCommand {
constructor(minecraft) {
Expand Down Expand Up @@ -33,19 +33,21 @@ class BedwarsCommand extends minecraftCommand {
const { broken, BLRatio } = player.stats.bedwars.beds;

this.send(
`/gc [${level}✫] ${
player.nickname
} FK: ${finalKills.toLocaleString()} FKDR: ${finalKDRatio} W: ${wins} WLR: ${WLRatio} BB: ${broken} BLR: ${BLRatio} WS: ${winstreak}`
`/gc [${level}✫] ${player.nickname} FK: ${formatNumber(finalKills)} FKDR: ${finalKDRatio} W: ${formatNumber(
wins
)} WLR: ${WLRatio} BB: ${formatNumber(broken)} BLR: ${BLRatio} WS: ${winstreak}`
);
} else if (mode !== undefined) {
const { level } = player.stats.bedwars;
const { finalKills, finalKDRatio, wins, WLRatio, winstreak } = player.stats.bedwars[mode];
const { broken, BLRatio } = player.stats.bedwars[mode].beds;

this.send(
`/gc [${level}✫] ${player.nickname} ${capitalize(
mode
)} FK: ${finalKills.toLocaleString()} FKDR: ${finalKDRatio} Wins: ${wins} WLR: ${WLRatio} BB: ${broken} BLR: ${BLRatio} WS: ${winstreak}`
`/gc [${level}✫] ${player.nickname} ${capitalize(mode)} FK: ${formatNumber(
finalKills
)} FKDR: ${finalKDRatio} Wins: ${formatNumber(wins)} WLR: ${WLRatio} BB: ${formatNumber(
broken
)} BLR: ${BLRatio} WS: ${winstreak}`
);
} else {
this.send("/gc Invalid mode. Valid modes: overall, solo, doubles, threes, fours, 4v4");
Expand Down
2 changes: 1 addition & 1 deletion src/minecraft/commands/duelsStatsCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DuelsStatsCommand extends minecraftCommand {
} else {
const duelData = player.stats.duels?.[duel]?.[Object.keys(player.stats.duels[duel])[0]];
const division = duelData?.division ?? player.stats.duels?.[duel]?.division ?? "Unknown";
const wins = duelData?.wins ?? 0;
const wins = formatNumber(duelData?.wins ?? 0);
const winstreak = duelData?.winstreak ?? 0;
const bestWinstreak = duelData?.bestWinstreak ?? 0;
const WLRatio = duelData?.WLRatio ?? 0;
Expand Down
9 changes: 5 additions & 4 deletions src/minecraft/commands/woolwarsCommand.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const minecraftCommand = require("../../contracts/minecraftCommand.js");
const { formatNumber } = require("../../contracts/helperFunctions.js");
const hypixel = require("../../contracts/API/HypixelRebornAPI.js");

class WoolwarsCommand extends minecraftCommand {
Expand Down Expand Up @@ -40,11 +41,11 @@ class WoolwarsCommand extends minecraftCommand {
const level = getWoolWarsStar(experience);

this.send(
`/gc [${Math.floor(level)}✫] ${username}: W: ${wins ?? 0} | WLR: ${(wins / games_played).toFixed(2)} | KDR: ${(
kills / deaths
).toFixed(2)} | BB: ${blocks_broken} | WP: ${wool_placed} | WPP: ${(wool_placed / games_played).toFixed(
`/gc [${Math.floor(level)}✫] ${username}: W: ${formatNumber(wins ?? 0)} | WLR: ${(wins / games_played).toFixed(
2
)} | WPG: ${(wool_placed / blocks_broken).toFixed(2)}`
)} | KDR: ${(kills / deaths).toFixed(2)} | BB: ${formatNumber(blocks_broken)} | WP: ${formatNumber(
wool_placed
)} | WPP: ${(wool_placed / games_played).toFixed(2)} | WPG: ${(wool_placed / blocks_broken).toFixed(2)}`
);
} catch (error) {
this.send(`/gc [ERROR] ${error}`);
Expand Down

0 comments on commit e6626ea

Please sign in to comment.