From 44c3d5ff0dea3cd2d7182c340d76654ffa7eab98 Mon Sep 17 00:00:00 2001 From: Jacob Date: Thu, 15 Aug 2024 10:07:59 +0800 Subject: [PATCH] Case Changing --- .vscode/extensions.json | 3 +- src/Client.ts | 21 ++++--- src/Errors.ts | 3 + src/structures/MiniGames/Arcade.ts | 22 +++---- src/structures/MiniGames/ArenaBrawl.ts | 6 +- src/structures/MiniGames/BedWars.ts | 30 ++++----- .../MiniGames/BlitzSurvivalGames.ts | 14 ++--- src/structures/MiniGames/BuildBattle.ts | 4 +- src/structures/MiniGames/CopsAndCrims.ts | 18 +++--- src/structures/MiniGames/Duels.ts | 62 +++++++++---------- src/structures/MiniGames/MegaWalls.ts | 20 +++--- src/structures/MiniGames/MurderMystery.ts | 6 +- src/structures/MiniGames/Paintball.ts | 4 +- src/structures/MiniGames/Pit.ts | 14 ++--- src/structures/MiniGames/Quakecraft.ts | 6 +- src/structures/MiniGames/SkyWars.ts | 18 +++--- src/structures/MiniGames/SmashHeroes.ts | 14 ++--- src/structures/MiniGames/SpeedUHC.ts | 6 +- src/structures/MiniGames/TNTGames.ts | 8 +-- src/structures/MiniGames/UHC.ts | 4 +- src/structures/MiniGames/VampireZ.ts | 6 +- src/structures/MiniGames/Walls.ts | 6 +- src/structures/MiniGames/Warlords.ts | 8 +-- src/structures/MiniGames/WoolWars.ts | 10 +-- src/typings/Client.d.ts | 2 +- src/utils/arrayTools.ts | 2 - src/utils/divide.ts | 2 +- src/utils/romanize.ts | 2 +- 28 files changed, 165 insertions(+), 156 deletions(-) delete mode 100644 src/utils/arrayTools.ts diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 714920c..1fe48d5 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "eamodio.gitlens", - "aaron-bond.better-comments" + "aaron-bond.better-comments", + "vitest.explorer" ] } \ No newline at end of file diff --git a/src/Client.ts b/src/Client.ts index f630910..eac6810 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -8,24 +8,26 @@ import API from './API'; const clients: Client[] = []; class Client { - readonly key: string; - + declare options: ClientOptions; declare requests: Requests; declare cacheHandler: CacheHandler; declare updater: Updater; declare errors: Errors; - declare options: ClientOptions; + readonly key: string; - constructor(key: string, options?: ClientOptions) { - this.key = key; + declare interval: NodeJS.Timeout; + constructor(key: string, options?: ClientOptions) { this.options = this.parasOptions(options); this.requests = new Requests(this); this.cacheHandler = new CacheHandler(this); this.updater = new Updater(this); this.errors = new Errors(); + this.key = key; + if (!this.key.length) throw new Error(this.errors.NO_API_KEY); + for (const func in API) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error @@ -43,10 +45,9 @@ class Client { } if (this.options.checkForUpdates) { - setInterval( + this.interval = setInterval( () => { this.updater.checkForUpdates(); - // 3600000 ms = 1 hour }, 1000 * 60 * (this.options.checkForUpdatesInterval ?? 60) ); @@ -55,6 +56,12 @@ class Client { clients.push(this); } + destroy() { + const clientIndex = clients.findIndex((client) => client.key === this.key); + if (-1 !== clientIndex) clients.splice(clientIndex, 1); + if (this.interval) clearInterval(this.interval); + } + private parasOptions(options?: ClientOptions): ClientOptions { return { cache: options?.cache ?? true, diff --git a/src/Errors.ts b/src/Errors.ts index b5e786f..897a1ee 100644 --- a/src/Errors.ts +++ b/src/Errors.ts @@ -3,6 +3,8 @@ class Errors { INVALID_API_KEY: string = '[Hypixel-API-Reborn] Invalid API Key! For help join our Discord Server https://discord.gg/NSEBNMM'; + NO_API_KEY: string = + '[Hypixel-API-Reborn] No API Key specified! For help join our Discord Server https://discord.gg/NSEBNMM'; ERROR_CODE_CAUSE: string = '[Hypixel-API-Reborn] Code: {code} - {cause}! For help join our Discord Server https://discord.gg/NSEBNMM'; ERROR_STATUSTEXT: string = @@ -11,6 +13,7 @@ class Errors { NO_UUID: string = '[Hypixel-API-Reborn] No uuid specified.'; UUID_NICKNAME_MUST_BE_A_STRING: string = '[Hypixel-API-Reborn] Nickname or uuid must be a string.'; MALFORMED_UUID: string = '[Hypixel-API-Reborn] Malformed UUID!'; + PLAYER_HAS_NEVER_LOGGED: string = '[Hypixel-API-Reborn] Player has never logged into Hypixel.'; NO_GUILD_QUERY: string = '[Hypixel-API-Reborn] No guild search query specified.'; INVALID_GUILD_ID: string = '[Hypixel-API-Reborn] Specified Guild ID is invalid.'; INVALID_GUILD_SEARCH_PARAMETER: string = diff --git a/src/structures/MiniGames/Arcade.ts b/src/structures/MiniGames/Arcade.ts index 30a9774..9673062 100644 --- a/src/structures/MiniGames/Arcade.ts +++ b/src/structures/MiniGames/Arcade.ts @@ -2,7 +2,7 @@ import { removeSnakeCaseString } from '../../utils/removeSnakeCase'; import { weekAB, monthAB } from '../../utils/oscillation'; -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; function parseZombiesKills(data: Record): Record { const matches = Array.from(Object.keys(data)) @@ -68,9 +68,9 @@ class Zombies { this.killsByZombie = parseZombiesKills(data); this.bulletsHit = data.bullets_hit_zombies || 0; this.bulletsShot = data.bullets_shot_zombies || 0; - this.gunAccuracy = divide(this.bulletsHit, this.bulletsShot); + this.gunAccuracy = Divide(this.bulletsHit, this.bulletsShot); this.headshots = data.headshots_zombies || 0; - this.headshotAccuracy = divide(this.headshots, this.bulletsShot); + this.headshotAccuracy = Divide(this.headshots, this.bulletsShot); } } @@ -114,7 +114,7 @@ class BountyHunters { this.wins = data.wins_oneinthequiver || 0; this.kills = data.kills_oneinthequiver || 0; this.deaths = data.deaths_oneinthequiver || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.bountyKills = data.bounty_kills_oneinthequiver || 0; this.bowKills = data.bow_kills_oneinthequiver || 0; this.swordKills = data.sword_kills_oneinthequiver || 0; @@ -139,11 +139,11 @@ class CaptureTheWool { constructor(data: Record) { this.wins = data.woolhunt_participated_wins || 0; this.losses = data.woolhunt_participated_losses || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.draws = data.woolhunt_participated_draws || 0; this.kills = data.woolhunt_kills || 0; this.deaths = data.woolhunt_deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.assists = data.woolhunt_assists || 0; this.woolPickedUp = data.woolhunt_wools_stolen || 0; this.woolCaptured = data.woolhunt_wools_captured || 0; @@ -371,13 +371,13 @@ class MiniWalls { this.wins = data.wins_mini_walls || 0; this.kills = data.kills_mini_walls || 0; this.deaths = data.deaths_mini_walls || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.finalKills = data.final_kills_mini_walls || 0; this.witherKills = data.wither_kills_mini_walls || 0; this.witherDamage = data.wither_damage_mini_walls || 0; this.arrowsShot = data.arrows_shot_mini_walls || 0; this.arrowsHit = data.arrows_hit_mini_walls || 0; - this.bowAccuracy = divide(this.arrowsHit, this.arrowsShot); + this.bowAccuracy = Divide(this.arrowsHit, this.arrowsShot); } } /** @@ -407,7 +407,7 @@ class PixelPartyGameMode { this.wins = data?.[`wins_${modeName}`] || 0; this.gamesPlayed = data?.[`games_played_${modeName}`] || 0; this.losses = this.gamesPlayed - this.wins; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.roundsPlayed = data?.[`rounds_completed_${modeName}`] || 0; this.powerUpsCollected = data?.[`power_ups_collected_${modeName}`] || 0; } @@ -431,7 +431,7 @@ class PixelParty { this.wins = data?.pixel_party?.wins || 0; this.gamesPlayed = data?.pixel_party?.games_played || 0; this.losses = this.gamesPlayed - this.wins; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.roundsPlayed = data?.pixel_party?.rounds_completed || 0; this.powerUpsCollected = data?.pixel_party?.power_ups_collected || 0; this.normal = new PixelPartyGameMode(data.pixel_party, 'normal'); @@ -453,7 +453,7 @@ class ThrowOut { this.wins = data.wins_throw_out || 0; this.kills = data.kills_throw_out || 0; this.deaths = data.deaths_throw_out || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); } } /** diff --git a/src/structures/MiniGames/ArenaBrawl.ts b/src/structures/MiniGames/ArenaBrawl.ts index 6032be3..b71a420 100644 --- a/src/structures/MiniGames/ArenaBrawl.ts +++ b/src/structures/MiniGames/ArenaBrawl.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class ArenaBrawlMode { damage: number; @@ -15,11 +15,11 @@ class ArenaBrawlMode { this.damage = data[`damage_${mode}`]; this.kills = data[`kills_${mode}`]; this.deaths = data[`deaths_${mode}`]; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.healed = data[`healed_${mode}`]; this.wins = data[`wins_${mode}`]; this.losses = data[`losses_${mode}`]; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.games = data[`games_${mode}`]; this.winstreak = data[`win_streaks_${mode}`]; } diff --git a/src/structures/MiniGames/BedWars.ts b/src/structures/MiniGames/BedWars.ts index 39b7214..54db9b8 100644 --- a/src/structures/MiniGames/BedWars.ts +++ b/src/structures/MiniGames/BedWars.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; export type BedWarsPrestige = | 'Stone' @@ -167,18 +167,18 @@ function generateStatsForMode(data: Record, mode: string): BedWarsM beds: { broken: data[`${mode}_beds_broken_bedwars`] || 0, lost: data[`${mode}_beds_lost_bedwars`] || 0, - BLRatio: divide(data[`${mode}_beds_broken_bedwars`], data[`${mode}_beds_lost_bedwars`]) + BLRatio: Divide(data[`${mode}_beds_broken_bedwars`], data[`${mode}_beds_lost_bedwars`]) }, avg: { - kills: divide(data[`${mode}_kills_bedwars`], data[`${mode}_games_played_bedwars`]), - finalKills: divide(data[`${mode}_final_kills_bedwars`], data[`${mode}_games_played_bedwars`]), - bedsBroken: divide(data[`${mode}_beds_broken_bedwars`], data[`${mode}_games_played_bedwars`]) + kills: Divide(data[`${mode}_kills_bedwars`], data[`${mode}_games_played_bedwars`]), + finalKills: Divide(data[`${mode}_final_kills_bedwars`], data[`${mode}_games_played_bedwars`]), + bedsBroken: Divide(data[`${mode}_beds_broken_bedwars`], data[`${mode}_games_played_bedwars`]) }, - KDRatio: divide(data[`${mode}_kills_bedwars`], data[`${mode}_deaths_bedwars`]), - WLRatio: divide(data[`${mode}_wins_bedwars`], data[`${mode}_losses_bedwars`]), - finalKDRatio: divide(data[`${mode}_final_kills_bedwars`], data[`${mode}_final_deaths_bedwars`]) + KDRatio: Divide(data[`${mode}_kills_bedwars`], data[`${mode}_deaths_bedwars`]), + WLRatio: Divide(data[`${mode}_wins_bedwars`], data[`${mode}_losses_bedwars`]), + finalKDRatio: Divide(data[`${mode}_final_kills_bedwars`], data[`${mode}_final_deaths_bedwars`]) }; } @@ -428,16 +428,16 @@ class BedWars { this.beds = { lost: data.beds_lost_bedwars || 0, broken: data.beds_broken_bedwars || 0, - BLRatio: divide(data.beds_broken_bedwars, data.beds_lost_bedwars) + BLRatio: Divide(data.beds_broken_bedwars, data.beds_lost_bedwars) }; this.avg = { - kills: divide(this.kills, this.playedGames), - finalKills: divide(this.finalKills, this.playedGames), - bedsBroken: divide(this.beds.broken, this.playedGames) + kills: Divide(this.kills, this.playedGames), + finalKills: Divide(this.finalKills, this.playedGames), + bedsBroken: Divide(this.beds.broken, this.playedGames) }; - this.KDRatio = divide(this.kills, this.deaths); - this.finalKDRatio = divide(this.finalKills, this.finalDeaths); - this.WLRatio = divide(this.wins, this.losses); + this.KDRatio = Divide(this.kills, this.deaths); + this.finalKDRatio = Divide(this.finalKills, this.finalDeaths); + this.WLRatio = Divide(this.wins, this.losses); this.solo = generateStatsForMode(data, 'eight_one'); this.doubles = generateStatsForMode(data, 'eight_two'); this.threes = generateStatsForMode(data, 'four_three'); diff --git a/src/structures/MiniGames/BlitzSurvivalGames.ts b/src/structures/MiniGames/BlitzSurvivalGames.ts index 96da098..20f3ae4 100644 --- a/src/structures/MiniGames/BlitzSurvivalGames.ts +++ b/src/structures/MiniGames/BlitzSurvivalGames.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class BlitzSGKit { level: number; @@ -25,14 +25,14 @@ class BlitzSGKit { this.exp = data[`exp_${kitName}`] || 0; this.kills = data[`kills_${kitName}`] || 0; this.deaths = data[`deaths_${kitName}`] || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data[`wins_${kitName}`] || 0; this.gamesPlayed = data[`games_played_${kitName}`] || 0; this.losses = this.gamesPlayed - this.wins; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.arrowsShot = data[`arrows_fired_${kitName}`] || 0; this.arrowsHit = data[`arrows_hit_${kitName}`] || 0; - this.bowAccuracy = divide(this.arrowsHit, this.arrowsShot); + this.bowAccuracy = Divide(this.arrowsHit, this.arrowsShot); this.damage = data[`damage_${kitName}`] || 0; this.damageTaken = data[`damage_taken_${kitName}`] || 0; this.potionsDrunk = data[`potions_drunk_${kitName}`] || 0; @@ -115,16 +115,16 @@ class BlitzSurvivalGames { this.killsSolo = data.kills_solo_normal || 0; this.killsTeams = data.kills_teams_normal || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.wins || 0; this.winsSolo = data.wins_solo_normal || 0; this.winsTeam = data.wins_teams || 0; this.gamesPlayed = data.games_played || 0; this.losses = this.gamesPlayed - this.wins; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.arrowsShot = data.arrows_fired || 0; this.arrowsHit = data.arrows_hit || 0; - this.bowAccuracy = divide(this.arrowsHit, this.arrowsShot); + this.bowAccuracy = Divide(this.arrowsHit, this.arrowsShot); this.damage = data.damage || 0; this.damageTaken = data.damage_taken || 0; this.potionsDrunk = data.potions_drunk || 0; diff --git a/src/structures/MiniGames/BuildBattle.ts b/src/structures/MiniGames/BuildBattle.ts index 474193b..b1c8d52 100644 --- a/src/structures/MiniGames/BuildBattle.ts +++ b/src/structures/MiniGames/BuildBattle.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; export interface BuildBattleWins { solo: number; @@ -23,7 +23,7 @@ class BuildBattle { this.score = data.score || 0; this.totalWins = data.wins || 0; this.games = data.games_played || 0; - this.WLRatio = divide(this.totalWins, this.games); + this.WLRatio = Divide(this.totalWins, this.games); this.superVotes = data.super_votes || 0; this.coins = data.coins || 0; this.totalVotes = data.total_votes || 0; diff --git a/src/structures/MiniGames/CopsAndCrims.ts b/src/structures/MiniGames/CopsAndCrims.ts index 106199e..b5fe046 100644 --- a/src/structures/MiniGames/CopsAndCrims.ts +++ b/src/structures/MiniGames/CopsAndCrims.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; /** * Cops and crims Defusal class */ @@ -23,11 +23,11 @@ class CopsAndCrimsDefusal { this.headshotKills = data.headshot_kills || 0; this.assists = data.assists || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.game_wins || 0; this.gamesPlayed = data.game_plays || 0; this.losses = this.gamesPlayed - this.wins; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.roundWins = data.round_wins || 0; this.shotsFired = data.shots_fired || 0; this.bombsDefused = data.bombs_defused || 0; @@ -54,11 +54,11 @@ class CopsAndCrimsDeathmatch { this.kills = data.kills_deathmatch || 0; this.assists = data.assists_deathmatch || 0; this.deaths = data.deaths_deathmatch || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.game_wins_deathmatch || 0; this.gamesPlayed = data.game_plays_deathmatch || 0; this.losses = this.gamesPlayed - this.wins; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.killsAsCrim = data.criminal_kills_deathmatch || 0; this.killsAsCop = data.cop_kills_deathmatch || 0; } @@ -82,11 +82,11 @@ class CopsAndCrimsGunGame { this.kills = data.kills_gungame || 0; this.assists = data.assists_gungame || 0; this.deaths = data.deaths_gungame || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.game_wins_gungame || 0; this.gamesPlayed = data.game_plays_gungame || 0; this.losses = this.gamesPlayed - this.wins; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.killsAsCrim = data.criminal_kills_gungame || 0; this.killsAsCop = data.cop_kills_gungame || 0; this.fastestWin = data.fastest_win_gungame || 0; @@ -122,11 +122,11 @@ class CopsAndCrims { this.kills = this.defusal.kills + this.deathmath.kills + this.gunGame.kills; this.assists = this.defusal.assists + this.deathmath.assists + this.gunGame.assists; this.deaths = this.defusal.deaths + this.deathmath.deaths + this.gunGame.deaths; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = this.defusal.wins + this.deathmath.wins + this.gunGame.wins; this.gamesPlayed = this.defusal.gamesPlayed + this.deathmath.gamesPlayed + this.gunGame.gamesPlayed; this.losses = this.gamesPlayed - this.wins; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.killsAsCrim = this.defusal.killsAsCrim + this.deathmath.killsAsCrim + this.gunGame.killsAsCrim; this.killsAsCop = this.defusal.killsAsCop + this.deathmath.killsAsCop + this.gunGame.killsAsCop; this.prefixColor = data.lobbyPrefixColor || ''; diff --git a/src/structures/MiniGames/Duels.ts b/src/structures/MiniGames/Duels.ts index 17f01a2..b4ca859 100644 --- a/src/structures/MiniGames/Duels.ts +++ b/src/structures/MiniGames/Duels.ts @@ -1,12 +1,12 @@ import Constants from '../../utils/Constants'; -import romanize from '../../utils/romanize'; -import divide from '../../utils/divide'; +import Romanize from '../../utils/Romanize'; +import Divide from '../../utils/Divide'; function getTitle(data: Record, mode: string | null = null): string { for (const div of Constants.duelsDivisions.slice().reverse()) { const prestige = data[`${mode ? mode : 'all_modes'}_${div.key}_title_prestige`]; if (prestige) { - return `${div.name} ${romanize(prestige)}`; + return `${div.name} ${Romanize(prestige)}`; } } return ''; @@ -38,17 +38,17 @@ class DuelsGamemode { this.bestWinstreak = data[`best_winstreak_mode_${mode}`] || 0; this.kills = data[`${mode}_kills`] || 0; this.deaths = data[`${mode}_deaths`] || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data[`${mode}_wins`] || 0; this.losses = data[`${mode}_losses`] || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.playedGames = data[`${mode}_rounds_played`] || 0; this.swings = data[`${mode}_melee_swings`] || 0; this.hits = data[`${mode}_melee_hits`] || 0; - this.meleeAccuracy = divide(this.swings, this.hits); + this.meleeAccuracy = Divide(this.swings, this.hits); this.bowShots = data[`${mode}_bow_shots`] || 0; this.bowHits = data[`${mode}_bow_hits`] || 0; - this.bowAccuracy = divide(this.bowShots, this.bowHits); + this.bowAccuracy = Divide(this.bowShots, this.bowHits); this.blocksPlaced = data[`${mode}_blocks_placed`] || 0; this.healthRegenerated = data[`${mode}_health_regenerated`] || 0; this.goldenApplesEatan = data[`${mode}_golden_apples_eaten`] || 0; @@ -89,18 +89,18 @@ class DuelsUHC { this.deathmatch = new DuelsGamemode(data, 'uhc_meetup', this.title); this.kills = this.solo.kills + this.doubles.kills + this.fours.kills + this.deathmatch.kills; this.deaths = this.solo.deaths + this.doubles.deaths + this.fours.deaths + this.deathmatch.deaths; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = this.solo.wins + this.doubles.wins + this.fours.wins + this.deathmatch.wins; this.losses = this.solo.losses + this.doubles.losses + this.fours.losses + this.deathmatch.losses; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.playedGames = this.solo.playedGames + this.doubles.playedGames + this.fours.playedGames + this.deathmatch.playedGames; this.swings = this.solo.swings + this.doubles.swings + this.fours.swings + this.deathmatch.swings; this.hits = this.solo.hits + this.doubles.hits + this.fours.hits + this.deathmatch.hits; - this.meleeAccuracy = divide(this.hits, this.swings); + this.meleeAccuracy = Divide(this.hits, this.swings); this.bowShots = this.solo.bowShots + this.doubles.bowShots + this.fours.bowShots + this.deathmatch.bowShots; this.bowHits = this.solo.bowHits + this.doubles.bowHits + this.fours.bowHits + this.deathmatch.bowHits; - this.bowAccuracy = divide(this.bowHits, this.bowShots); + this.bowAccuracy = Divide(this.bowHits, this.bowShots); this.blocksPlaced = this.solo.blocksPlaced + this.doubles.blocksPlaced + this.fours.blocksPlaced + this.deathmatch.blocksPlaced; this.healthRegenerated = @@ -145,17 +145,17 @@ class DuelsSkyWars { this.doubles = new DuelsGamemode(data, 'sw_doubles', this.title); this.kills = this.solo.kills + this.doubles.kills; this.deaths = this.solo.deaths + this.doubles.deaths; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = this.solo.wins + this.doubles.wins; this.losses = this.solo.losses + this.doubles.losses; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.playedGames = this.solo.playedGames + this.doubles.playedGames; this.swings = this.solo.swings + this.doubles.swings; this.hits = this.solo.hits + this.doubles.hits; - this.meleeAccuracy = divide(this.hits, this.swings); + this.meleeAccuracy = Divide(this.hits, this.swings); this.bowShots = this.solo.bowShots + this.doubles.bowShots; this.bowHits = this.solo.bowHits + this.doubles.bowHits; - this.bowAccuracy = divide(this.bowHits, this.bowShots); + this.bowAccuracy = Divide(this.bowHits, this.bowShots); this.blocksPlaced = this.solo.blocksPlaced + this.doubles.blocksPlaced; this.healthRegenerated = this.solo.healthRegenerated + this.doubles.healthRegenerated; this.goldenApplesEatan = this.solo.goldenApplesEatan + this.doubles.goldenApplesEatan; @@ -191,17 +191,17 @@ class DuelsMegaWalls { this.doubles = new DuelsGamemode(data, 'mw_doubles', this.title); this.kills = this.solo.kills + this.doubles.kills; this.deaths = this.solo.deaths + this.doubles.deaths; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = this.solo.wins + this.doubles.wins; this.losses = this.solo.losses + this.doubles.losses; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.playedGames = this.solo.playedGames + this.doubles.playedGames; this.swings = this.solo.swings + this.doubles.swings; this.hits = this.solo.hits + this.doubles.hits; - this.meleeAccuracy = divide(this.hits, this.swings); + this.meleeAccuracy = Divide(this.hits, this.swings); this.bowShots = this.solo.bowShots + this.doubles.bowShots; this.bowHits = this.solo.bowHits + this.doubles.bowHits; - this.bowAccuracy = divide(this.bowHits, this.bowShots); + this.bowAccuracy = Divide(this.bowHits, this.bowShots); this.blocksPlaced = this.solo.blocksPlaced + this.doubles.blocksPlaced; this.healthRegenerated = this.solo.healthRegenerated + this.doubles.healthRegenerated; this.goldenApplesEatan = this.solo.goldenApplesEatan + this.doubles.goldenApplesEatan; @@ -237,17 +237,17 @@ class DuelsOP { this.doubles = new DuelsGamemode(data, 'op_doubles', this.title); this.kills = this.solo.kills + this.doubles.kills; this.deaths = this.solo.deaths + this.doubles.deaths; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = this.solo.wins + this.doubles.wins; this.losses = this.solo.losses + this.doubles.losses; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.playedGames = this.solo.playedGames + this.doubles.playedGames; this.swings = this.solo.swings + this.doubles.swings; this.hits = this.solo.hits + this.doubles.hits; - this.meleeAccuracy = divide(this.hits, this.swings); + this.meleeAccuracy = Divide(this.hits, this.swings); this.bowShots = this.solo.bowShots + this.doubles.bowShots; this.bowHits = this.solo.bowHits + this.doubles.bowHits; - this.bowAccuracy = divide(this.bowHits, this.bowShots); + this.bowAccuracy = Divide(this.bowHits, this.bowShots); this.blocksPlaced = this.solo.blocksPlaced + this.doubles.blocksPlaced; this.healthRegenerated = this.solo.healthRegenerated + this.doubles.healthRegenerated; this.goldenApplesEatan = this.solo.goldenApplesEatan + this.doubles.goldenApplesEatan; @@ -307,7 +307,7 @@ class DuelsBridge { this['2v2v2v2'].deaths + this['3v3v3v3'].deaths + this.ctf.deaths; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = this.solo.wins + this.doubles.wins + @@ -324,7 +324,7 @@ class DuelsBridge { this['2v2v2v2'].losses + this['3v3v3v3'].losses + this.ctf.losses; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.playedGames = this.solo.playedGames + this.doubles.playedGames + @@ -349,7 +349,7 @@ class DuelsBridge { this['2v2v2v2'].hits + this['3v3v3v3'].hits + this.ctf.hits; - this.meleeAccuracy = divide(this.hits, this.swings); + this.meleeAccuracy = Divide(this.hits, this.swings); this.bowShots = this.solo.bowShots + this.doubles.bowShots + @@ -366,7 +366,7 @@ class DuelsBridge { this['2v2v2v2'].bowHits + this['3v3v3v3'].bowHits + this.ctf.bowHits; - this.bowAccuracy = divide(this.bowHits, this.bowShots); + this.bowAccuracy = Divide(this.bowHits, this.bowShots); this.blocksPlaced = this.solo.blocksPlaced + this.doubles.blocksPlaced + @@ -438,10 +438,10 @@ class Duels { this.title = getTitle(data); this.kills = data.kills || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.wins || 0; this.losses = data.losses || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.playedGames = data.games_played_duels || 0; this.winstreak = data.current_winstreak || 0; this.bestWinstreak = data.best_overall_winstreak || 0; @@ -449,10 +449,10 @@ class Duels { this.blocksPlaced = data.blocks_placed || 0; this.swings = data.melee_swings || 0; this.hits = data.melee_hits || 0; - this.meleeAccuracy = divide(this.hits, this.swings); + this.meleeAccuracy = Divide(this.hits, this.swings); this.bowShots = data.bow_shots || 0; this.bowHits = data.bow_hits || 0; - this.bowAccuracy = divide(this.bowHits, this.bowShots); + this.bowAccuracy = Divide(this.bowHits, this.bowShots); this.healthRegenerated = data.health_regenerated || 0; this.goldenApplesEatan = data.golden_apples_eaten || 0; this.uhc = new DuelsUHC(data); diff --git a/src/structures/MiniGames/MegaWalls.ts b/src/structures/MiniGames/MegaWalls.ts index ed2c13c..6803eab 100644 --- a/src/structures/MiniGames/MegaWalls.ts +++ b/src/structures/MiniGames/MegaWalls.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class MegaWallsModeStats { kills: number; @@ -25,14 +25,14 @@ class MegaWallsModeStats { this.kills = data[`${kit}kills_${mode}`] || 0; this.assists = data[`${kit}assists_${mode}`] || 0; this.deaths = data[`${kit}deaths_${mode}`] || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data[`${kit}wins_${mode}`] || 0; this.losses = data[`${kit}losses_${mode}`] || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.finalKills = data[`${kit}final_kills_${mode}`] || 0; this.finalAssists = data[`${kit}final_assists_${mode}`] || 0; this.finalDeaths = data[`${kit}final_deaths_${mode}`] || 0; - this.finalKDRatio = divide(this.finalKills, this.finalDeaths); + this.finalKDRatio = Divide(this.finalKills, this.finalDeaths); this.playedGames = data[`${kit}games_played_${mode}`] || 0; this.witherDamage = data[`${kit}wither_damage_${mode}`] || 0; this.defenderKills = data[`${kit}defender_kills_${mode}`] || 0; @@ -69,14 +69,14 @@ class MegaWallsKitStats { this.kills = data[`${kit}_kills`] || 0; this.assists = data[`${kit}_assists`] || 0; this.deaths = data[`${kit}_deaths`] || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data[`${kit}_wins`] || 0; this.losses = data[`${kit}_losses`] || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.finalKills = data[`${kit}_final_kills`] || 0; this.finalAssists = data[`${kit}_final_assists`] || 0; this.finalDeaths = data[`${kit}_final_deaths`] || 0; - this.finalKDRatio = divide(this.finalKills, this.finalDeaths); + this.finalKDRatio = Divide(this.finalKills, this.finalDeaths); this.playedGames = data[`${kit}_games_played`] || 0; this.witherDamage = data[`${kit}_wither_damage`] || 0; this.defenderKills = data[`${kit}_defender_kills`] || 0; @@ -149,14 +149,14 @@ class MegaWalls { this.kills = data.kills || 0; this.assists = data.assists || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.wins || 0; this.losses = data.losses || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.finalKills = (data.final_kills || 0) + (data.finalkills || 0); this.finalAssists = (data.final_assists || 0) + (data.finalassists || 0); this.finalDeaths = (data.final_deaths || 0) + (data.finalDeaths || 0); - this.finalKDRatio = divide(this.finalKills, this.finalDeaths); + this.finalKDRatio = Divide(this.finalKills, this.finalDeaths); this.playedGames = data.games_played || 0; this.witherDamage = (data.wither_damage || 0) + (data.witherDamager || 0); this.defenderKills = data.defender_kills || 0; diff --git a/src/structures/MiniGames/MurderMystery.ts b/src/structures/MiniGames/MurderMystery.ts index 5de106e..5a168dd 100644 --- a/src/structures/MiniGames/MurderMystery.ts +++ b/src/structures/MiniGames/MurderMystery.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; /** * MurderMystery stats by gamemode @@ -27,7 +27,7 @@ class MurderMysteryModeStats { this.trapKills = data[`trap_kills_${gamemode}`] || 0; this.deaths = data[`deaths_${gamemode}`] || 0; this.suicides = data[`suicides_${gamemode}`] || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data[`wins_${gamemode}`] || 0; this.winsAsDetective = data[`detective_wins_${gamemode}`] || 0; this.winsAsMurderer = data[`murderer_wins_${gamemode}`] || 0; @@ -74,7 +74,7 @@ class MurderMystery { this.bowKills = data.bow_kills || 0; this.killsAsMurderer = data.kills_as_murderer || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.winsAsMurderer = data.murderer_wins || 0; this.winsAsDetective = data.detective_wins || 0; this.winsAsHero = data.was_hero || 0; diff --git a/src/structures/MiniGames/Paintball.ts b/src/structures/MiniGames/Paintball.ts index c174c19..d690a26 100644 --- a/src/structures/MiniGames/Paintball.ts +++ b/src/structures/MiniGames/Paintball.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; /** * Paintball class */ @@ -22,7 +22,7 @@ class Paintball { this.coins = data.coins || 0; this.kills = data.kills || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.wins || 0; this.shotsFired = data.shots_fired || 0; this.killstreaks = data.killstreaks || 0; diff --git a/src/structures/MiniGames/Pit.ts b/src/structures/MiniGames/Pit.ts index 9740902..7902d24 100644 --- a/src/structures/MiniGames/Pit.ts +++ b/src/structures/MiniGames/Pit.ts @@ -1,7 +1,7 @@ import { decode } from '../../utils/SkyblockUtils'; import PitInventoryItem from './PitInventoryItem'; import Constants from '../../utils/Constants'; -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; export interface PitArmor { helmet: PitInventoryItem | null; @@ -52,26 +52,26 @@ class Pit { ) ?? 0; this.kills = data.pit_stats_ptl?.kills || 0; this.deaths = data.pit_stats_ptl?.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.assists = data.pit_stats_ptl?.assists || 0; this.maxKillStreak = data.pit_stats_ptl?.max_streak || 0; this.playtime = (data.pit_stats_ptl?.playtime_minutes || 0) * 60; this.joins = data.pit_stats_ptl?.joins || 0; this.damageReceived = data.pit_stats_ptl?.damage_received || 0; this.damageDealt = data.pit_stats_ptl?.damage_dealt || 0; - this.damageRatio = divide(this.damageDealt, this.damageReceived); + this.damageRatio = Divide(this.damageDealt, this.damageReceived); this.meleeDamageReceived = data.pit_stats_ptl?.melee_damage_received || 0; this.meleeDamageDealt = data.pit_stats_ptl?.melee_damage_dealt || 0; this.swordHits = data.pit_stats_ptl?.sword_hits || 0; this.leftClicks = data.pit_stats_ptl?.left_clicks || 0; - this.meleeAccuracy = divide(this.swordHits, this.leftClicks); - this.meleeDamageRatio = divide(this.meleeDamageDealt, this.meleeDamageReceived); + this.meleeAccuracy = Divide(this.swordHits, this.leftClicks); + this.meleeDamageRatio = Divide(this.meleeDamageDealt, this.meleeDamageReceived); this.bowDamageReceived = data.pit_stats_ptl?.bow_damage_received || 0; this.bowDamageDealt = data.pit_stats_ptl?.bow_damage_dealt || 0; this.arrowsHit = data.pit_stats_ptl?.arrow_hits || 0; this.arrowsFired = data.pit_stats_ptl?.arrows_fired || 0; - this.bowAccuracy = divide(this.arrowsHit, this.arrowsFired); - this.bowDamageRatio = divide(this.bowDamageDealt, this.bowDamageReceived); + this.bowAccuracy = Divide(this.arrowsHit, this.arrowsFired); + this.bowDamageRatio = Divide(this.bowDamageDealt, this.bowDamageReceived); this.goldenHeadsEaten = data.pit_stats_ptl?.ghead_eaten || 0; this.getInventory = async (): Promise => { let inventory = data.profile.inv_contents; diff --git a/src/structures/MiniGames/Quakecraft.ts b/src/structures/MiniGames/Quakecraft.ts index 4ec8ddf..36dcd43 100644 --- a/src/structures/MiniGames/Quakecraft.ts +++ b/src/structures/MiniGames/Quakecraft.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class QuakecraftMode { wins: number; @@ -14,7 +14,7 @@ class QuakecraftMode { this.wins = data[`wins${gamemode}`] || 0; this.kills = data[`kills${gamemode}`] || 0; this.deaths = data[`deaths${gamemode}`] || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.killstreaks = data[`killstreaks${gamemode}`] || 0; this.distanceTravelled = data[`distance_travelled${gamemode}`] || 0; this.shotsFired = data[`shots_fired${gamemode}`] || 0; @@ -53,7 +53,7 @@ class Quakecraft { this.wins = this.solo.wins + this.teams.wins; this.kills = this.solo.kills + this.teams.kills; this.deaths = this.solo.deaths + this.teams.deaths; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.killstreaks = this.solo.killstreaks + this.teams.killstreaks; this.distanceTravelled = this.solo.distanceTravelled + this.teams.distanceTravelled; this.shotsFired = this.solo.shotsFired + this.teams.shotsFired; diff --git a/src/structures/MiniGames/SkyWars.ts b/src/structures/MiniGames/SkyWars.ts index cee2206..67f835b 100644 --- a/src/structures/MiniGames/SkyWars.ts +++ b/src/structures/MiniGames/SkyWars.ts @@ -1,5 +1,5 @@ import { removeSnakeCaseString } from '../../utils/removeSnakeCase'; -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; export type SkyWarsPrestige = | 'Iron' @@ -78,10 +78,10 @@ class SkywarsMode { constructor(data: Record, gamemode: string) { this.kills = data[`kills_${gamemode}`] || 0; this.deaths = data[`deaths_${gamemode}`] || 0; - this.KDRatio = divide(data.kills, data.deaths); + this.KDRatio = Divide(data.kills, data.deaths); this.wins = data[`wins_${gamemode}`] || 0; this.losses = data[`losses_${gamemode}`] || 0; - this.WLRatio = divide(data.wins, data.losses); + this.WLRatio = Divide(data.wins, data.losses); } } class SkywarsModeStats { @@ -119,10 +119,10 @@ class SkywarsModeStats { this.mobKills = data[`mob_kills_${gamemode}`] || 0; this.assists = data[`assists_${gamemode}`] || 0; this.deaths = data[`deaths_${gamemode}`] || 0; - this.KDRatio = divide(data.kills, data.deaths); + this.KDRatio = Divide(data.kills, data.deaths); this.wins = data[`wins_${gamemode}`] || 0; this.losses = data[`losses_${gamemode}`] || 0; - this.WLRatio = divide(data.wins, data.losses); + this.WLRatio = Divide(data.wins, data.losses); this.gamesPlayed = data[`games_${gamemode}`] || 0; this.survivedPlayers = data[`survived_players_${gamemode}`] || 0; this.chestsOpened = data[`chests_opened_${gamemode}`] || 0; @@ -131,7 +131,7 @@ class SkywarsModeStats { this.longestBowShot = data[`longest_bow_shot_${gamemode}`] || 0; this.arrowsShot = data[`arrows_shot_${gamemode}`] || 0; this.arrowsHit = data[`arrows_hit_${gamemode}`] || 0; - this.bowAccuracy = divide(this.arrowsHit, this.arrowsShot); + this.bowAccuracy = Divide(this.arrowsHit, this.arrowsShot); this.fastestWin = data[`fastest_win_${gamemode}`] || 0; this.heads = data[`heads_${gamemode}`] || 0; } @@ -275,10 +275,10 @@ class SkyWars { this.mobKills = data.mob_kills || 0; this.assists = data.assists || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(data.kills, data.deaths); + this.KDRatio = Divide(data.kills, data.deaths); this.wins = data.wins || 0; this.losses = data.losses || 0; - this.WLRatio = divide(data.wins, data.losses); + this.WLRatio = Divide(data.wins, data.losses); this.gamesPlayed = data.games || 0; this.survivedPlayers = data.survived_players || 0; this.chestsOpened = data.chests_opened || 0; @@ -287,7 +287,7 @@ class SkyWars { this.longestBowShot = data.longest_bow_shot || 0; this.arrowsShot = data.arrows_shot || 0; this.arrowsHit = data.arrows_hit || 0; - this.bowAccuracy = divide(this.arrowsHit, this.arrowsShot); + this.bowAccuracy = Divide(this.arrowsHit, this.arrowsShot); this.fastestWin = data.fastest_win || 0; this.heads = data.heads || 0; this.blocksPlaced = data.blocks_placed || 0; diff --git a/src/structures/MiniGames/SmashHeroes.ts b/src/structures/MiniGames/SmashHeroes.ts index 3d0d9bb..23dcf3f 100644 --- a/src/structures/MiniGames/SmashHeroes.ts +++ b/src/structures/MiniGames/SmashHeroes.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class SmashHeroesMode { kills: number; @@ -10,10 +10,10 @@ class SmashHeroesMode { constructor(data: Record, mode: string) { this.kills = data[`kills_${mode}`] || 0; this.deaths = data[`deaths_${mode}`] || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data[`wins_${mode}`] || 0; this.losses = data[`losses_${mode}`] || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); } } @@ -37,10 +37,10 @@ class SmashHeoresHero { this.playedGames = data.class_stats?.[hero]?.games || 0; this.kills = data.class_stats?.[hero]?.kills || 0; this.deaths = data.class_stats?.[hero]?.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.class_stats?.[hero]?.wins || 0; this.losses = data.class_stats?.[hero]?.losses || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); } } @@ -86,10 +86,10 @@ class SmashHeroes { this.playedGames = data.games || 0; this.kills = data.kills || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.wins || 0; this.losses = data.losses || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.smashed = data.smashed || 0; this['1v1v1v1'] = new SmashHeroesMode(data, 'normal'); this['2v2'] = new SmashHeroesMode(data, '2v2'); diff --git a/src/structures/MiniGames/SpeedUHC.ts b/src/structures/MiniGames/SpeedUHC.ts index fee40f2..e210ef6 100644 --- a/src/structures/MiniGames/SpeedUHC.ts +++ b/src/structures/MiniGames/SpeedUHC.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class SpeedUHCMode { kills: number; @@ -50,10 +50,10 @@ class SpeedUHC { this.coins = data.coins || 0; this.kills = data.kills || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.wins || 0; this.losses = data.losses || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.playedGames = data.games || 0; this.winstreak = data.win_streak || 0; this.killstreak = data.killstreak || 0; diff --git a/src/structures/MiniGames/TNTGames.ts b/src/structures/MiniGames/TNTGames.ts index 226c94f..aa68b06 100644 --- a/src/structures/MiniGames/TNTGames.ts +++ b/src/structures/MiniGames/TNTGames.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class TNTRun { wins: number; @@ -34,7 +34,7 @@ class PVPRun { this.bestTime = data.record_pvprun || 0; this.kills = data.kills_pvprun || 0; this.deaths = data.deaths_pvprun || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.regeneration = data.new_pvprun_regeneration || 0; this.notoriety = data.new_pvprun_notoriety || 0; this.fortitude = data.new_pvprun_fortitude || 0; @@ -68,7 +68,7 @@ class TNTTag { this.wins = data.wins_tntag || 0; this.kills = data.kills_tntag || 0; this.deaths = data.deaths_tntag || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.speed = data.new_tntag_speedy || 0; this.blastProtection = data.tag_blastprotection || 0; this.speedItUp = data.tag_speeditup || 0; @@ -91,7 +91,7 @@ class TNTWizards { this.kills = data.kills_capture || 0; this.assists = data.assists_capture || 0; this.deaths = data.deaths_capture || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.points = data.points_capture || 0; this.kineticHealing = data.kinetic_healing_capture || 0; this.airTime = data.air_time_capture || 0; diff --git a/src/structures/MiniGames/UHC.ts b/src/structures/MiniGames/UHC.ts index cf6e49e..8d0618c 100644 --- a/src/structures/MiniGames/UHC.ts +++ b/src/structures/MiniGames/UHC.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; function getStarLevel(kills: number, wins: number) { const sum = Number(kills) + wins * 10; @@ -143,7 +143,7 @@ class UHC { /** * @type {KDRatio:number} */ - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); /** * @type {headsEaten:number} */ diff --git a/src/structures/MiniGames/VampireZ.ts b/src/structures/MiniGames/VampireZ.ts index afc6473..0abe7db 100644 --- a/src/structures/MiniGames/VampireZ.ts +++ b/src/structures/MiniGames/VampireZ.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class VampireZRole { kills: number; @@ -8,7 +8,7 @@ class VampireZRole { constructor(data: Record, role: string) { this.kills = data[`${role}_kills`]; this.deaths = data[`${role}_deaths`]; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data[`${role}_wins`]; } } @@ -36,7 +36,7 @@ class VampireZ { this.vampire = new VampireZRole(data, 'vampire'); this.kills = this.human.kills + this.vampire.kills; this.deaths = this.human.deaths + this.vampire.deaths; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = this.human.wins + this.vampire.wins; } } diff --git a/src/structures/MiniGames/Walls.ts b/src/structures/MiniGames/Walls.ts index 99a6dbe..32e0b93 100644 --- a/src/structures/MiniGames/Walls.ts +++ b/src/structures/MiniGames/Walls.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; /** * Walls class */ @@ -15,10 +15,10 @@ class Walls { this.coins = data.coins || 0; this.kills = data.kills || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.wins || 0; this.losses = data.losses || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.assists = data.assists || 0; } } diff --git a/src/structures/MiniGames/Warlords.ts b/src/structures/MiniGames/Warlords.ts index 6366b9b..4825cdc 100644 --- a/src/structures/MiniGames/Warlords.ts +++ b/src/structures/MiniGames/Warlords.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; class WarlordsClass { wins: number; @@ -11,7 +11,7 @@ class WarlordsClass { constructor(data: Record, className: string) { this.wins = data[`wins_${className}`] || 0; this.losses = data[`losses_${className}`] || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.gamesPlayed = data[`${className}_plays`]; this.damage = data[`damage_${className}`] || 0; this.heal = data[`heal_${className}`] || 0; @@ -53,10 +53,10 @@ class Warlords { this.coins = data.coins || 0; this.kills = data.kills || 0; this.deaths = data.deaths || 0; - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); this.wins = data.wins || 0; this.losses = data.losses || 0; - this.WLRatio = divide(this.wins, this.losses); + this.WLRatio = Divide(this.wins, this.losses); this.winstreak = data.win_streak || 0; this.assists = data.assists || 0; this.class = data.chosen_class || ''; diff --git a/src/structures/MiniGames/WoolWars.ts b/src/structures/MiniGames/WoolWars.ts index 6dd403b..979b0b5 100644 --- a/src/structures/MiniGames/WoolWars.ts +++ b/src/structures/MiniGames/WoolWars.ts @@ -1,4 +1,4 @@ -import divide from '../../utils/divide'; +import Divide from '../../utils/Divide'; export interface WoolWarsStats { wins: number; @@ -40,10 +40,10 @@ function generateStatsFor(data: Record, className: string): WoolWar gamesPlayed: workingData.games_played || 0, woolsPlaced: workingData.wool_placed || 0, blocksBroken: workingData.blocks_broken || 0, - placeBreakRatio: divide(workingData.wool_placed || 0, workingData.blocks_broken || 0), + placeBreakRatio: Divide(workingData.wool_placed || 0, workingData.blocks_broken || 0), kills: workingData.kills || 0, deaths: workingData.deaths || 0, - KDRatio: divide(workingData.kills, workingData.deaths), + KDRatio: Divide(workingData.kills, workingData.deaths), assists: workingData.assists || 0, powerups: workingData.powerups_gotten || 0 }; @@ -127,7 +127,7 @@ class WoolWars { * placeBreakRatio * @type {placeBreakRatio:number} */ - this.placeBreakRatio = divide(this.woolsPlaced, this.blocksBroken); + this.placeBreakRatio = Divide(this.woolsPlaced, this.blocksBroken); /** * kills * @type {kills:number} @@ -142,7 +142,7 @@ class WoolWars { * KDRatio * @type {KDRatio:number} */ - this.KDRatio = divide(this.kills, this.deaths); + this.KDRatio = Divide(this.kills, this.deaths); /** * assists * @type {assists:number} diff --git a/src/typings/Client.d.ts b/src/typings/Client.d.ts index 447fb03..877fabc 100644 --- a/src/typings/Client.d.ts +++ b/src/typings/Client.d.ts @@ -3,7 +3,7 @@ export interface ClientOptions { cacheTime?: number; cacheMaxKeys?: number; cacheCheckPeriod?: number; - rateLimit?: 'AUTO' | 'HARD' | 'NONE'; + rateLimit?: 'AUTO' | 'NONE'; silent?: boolean; checkForUpdates?: boolean; checkForUpdatesInterval?: number; diff --git a/src/utils/arrayTools.ts b/src/utils/arrayTools.ts deleted file mode 100644 index 06b0f0d..0000000 --- a/src/utils/arrayTools.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const isStrArray = (input: string) => Array.isArray(input) || 'string' === typeof input; -export const strToArray = (input: string) => [input].flat(); diff --git a/src/utils/divide.ts b/src/utils/divide.ts index 323819d..b580b14 100644 --- a/src/utils/divide.ts +++ b/src/utils/divide.ts @@ -1,4 +1,4 @@ -export default function divide(a: number = 0, b: number = 1): number { +export default function Divide(a: number, b: number): number { const out: number = Number(((a || 0) / (b || 0)).toFixed(2)) || 0; if (isFinite(out)) return out; return a; diff --git a/src/utils/romanize.ts b/src/utils/romanize.ts index 27a0c56..6e7e46f 100644 --- a/src/utils/romanize.ts +++ b/src/utils/romanize.ts @@ -1,4 +1,4 @@ -export default function (num: number): string { +export default function Romanize(num: number | string): string { const digits = String(Number(num)).split(''); const key = [ '',