From 3997c94ff3fcc7257574e8e8333f98b4c7e2b5c2 Mon Sep 17 00:00:00 2001 From: David ??? <86541514+DavidModzz@users.noreply.github.com> Date: Mon, 11 Mar 2024 20:48:04 -0300 Subject: [PATCH 1/5] fix bestTrophies and threeCrownWins --- player.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/player.js b/player.js index 1971fb3..db249c8 100644 --- a/player.js +++ b/player.js @@ -111,8 +111,8 @@ class LeagueStats { } class Player { - constructor(tag, name, expLevel, expPoints, totalExpPoints, starPoints, trophies, trophyRecord, - battleCount, wins, threeCrowns, losses, challengeCardsWon, challengeBattleCount, + constructor(tag, name, expLevel, expPoints, totalExpPoints, starPoints, trophies, bestTrophies, + battleCount, wins, threeCrownWins, losses, challengeCardsWon, challengeBattleCount, tournamentCardsWon, tournamentBattleCount, role, donations, donationsReceived, totalDonations, warDayWins, clanCardsCollected, clan, arena, leagueStats, badges, achievements, cards, favouriteCard) { @@ -123,10 +123,10 @@ class Player { this.totalExpPoints = totalExpPoints; this.starPoints = starPoints; this.trophies = trophies; - this.trophyRecord = trophyRecord; + this.bestTrophies = bestTrophies; this.battleCount = battleCount; this.wins = wins; - this.threeCrowns = threeCrowns; + this.threeCrownWins = threeCrownWins; this.losses = losses; this.challengeCardsWon = challengeCardsWon; this.challengeBattleCount = challengeBattleCount; @@ -156,10 +156,10 @@ class Player { jsonObject.totalExpPoints, jsonObject.starPoints, jsonObject.trophies, - jsonObject.trophyRecord, + jsonObject.bestTrophies, jsonObject.battleCount, jsonObject.wins, - jsonObject.threeCrowns, + jsonObject.threeCrownWins, jsonObject.losses, jsonObject.challengeCardsWon, jsonObject.challengeBattleCount, From bb3494774caeea4a9dab436a82d313c5c9d5bf0a Mon Sep 17 00:00:00 2001 From: David ??? <86541514+DavidModzz@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:02:35 -0300 Subject: [PATCH 2/5] added draws --- player.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/player.js b/player.js index db249c8..d7d160f 100644 --- a/player.js +++ b/player.js @@ -128,6 +128,7 @@ class Player { this.wins = wins; this.threeCrownWins = threeCrownWins; this.losses = losses; + this.draws = battleCount - (wins + losses); this.challengeCardsWon = challengeCardsWon; this.challengeBattleCount = challengeBattleCount; this.tournamentCardsWon = tournamentCardsWon; @@ -171,7 +172,7 @@ class Player { jsonObject.totalDonations, jsonObject.warDayWins, jsonObject.clanCardsCollected, - jsonObject.clan ? jsonObject.clan.name : 'not in a clan', + jsonObject.clan ? jsonObject.clan.name : 'Sin clan', jsonObject.arena.name, LeagueStats.fromJSON(jsonObject.leagueStatistics), jsonObject.badges.map(Badge.fromJSON), From 08dd8ef633db482443606ce9c080b9db63c576a6 Mon Sep 17 00:00:00 2001 From: David ??? <86541514+DavidModzz@users.noreply.github.com> Date: Mon, 11 Mar 2024 22:57:37 -0300 Subject: [PATCH 3/5] added Clan info --- clan.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 clan.js diff --git a/clan.js b/clan.js new file mode 100644 index 0000000..37b684c --- /dev/null +++ b/clan.js @@ -0,0 +1,41 @@ +class Clan { + constructor(tag, name, type, description, badgeId, clanScore, clanWarTrophies, location, requiredTrophies, donationsPerWeek, members, memberList) { + this.tag = tag; + this.name = name; + this.type = type; + this.description = description; + this.badgeId = badgeId; + this.clanScore = clanScore; + this.clanWarTrophies = clanWarTrophies; + this.location = location; + this.requiredTrophies = requiredTrophies; + this.donationsPerWeek = donationsPerWeek; + this.members = members; + this.memberList = memberList; + } + + static fromJSON(jsonObject) { + return new Clan( + jsonObject.tag, + jsonObject.name, + jsonObject.type, + jsonObject.description, + jsonObject.badgeId, + jsonObject.clanScore, + jsonObject.clanWarTrophies, + jsonObject.location, + jsonObject.requiredTrophies, + jsonObject.donationsPerWeek, + jsonObject.members, + jsonObject.memberList + ); + } + + toString() { + return this.name; + } + +} + + +module.exports = {Clan}; \ No newline at end of file From 497cc8eba2d78c6fe8c14c5ed9dd4f61f6969e65 Mon Sep 17 00:00:00 2001 From: David ??? <86541514+DavidModzz@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:00:56 -0300 Subject: [PATCH 4/5] added Clan info --- client.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client.js b/client.js index c018122..9c8f351 100644 --- a/client.js +++ b/client.js @@ -2,6 +2,7 @@ const { Connector} = require('./connector'); const { Card } = require('./card'); const { ChallengeView } = require('./challenge'); const { Player } = require('./player'); +const { Clan } = require('./clan'); const { BattleLog } = require('./battle'); const { Location, ClanRanking } = require('./location'); const { PlayerRanking } = require('./season'); @@ -65,6 +66,13 @@ class Client { .map(Location.fromJSON); } + async getClan(tag) { + // Allow getClan to be called on a tagged object + tag = this.argumentToString(`getClan(${tag})`, tag, 'tag'); + const clan = await this.connector.request(['clans', tag]); + return Clan.fromJSON(clan); + } + async getClanRanks(locationId, clanWars = false, limit = undefined) { // Allow getClanRanks to be called on an identified object locationId = this.argumentToString(`getClanRanks(${location}, ${clanWars}, ${limit})`, locationId, 'id'); From f8545c144a778276a463980a198b71c2aacdadea Mon Sep 17 00:00:00 2001 From: David ??? <86541514+DavidModzz@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:03:31 -0300 Subject: [PATCH 5/5] added Clan info --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0ceea83..2633c66 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ client.getPlayerRanks('2023-03') > Get a list of all locations in the game +* **getClan**(tag) + +> Get all information about a specific clan + * **getClanRanks**(locationId, clanWars = false, limit = undefined) > Get a ranking of all clans in a certain location, either by clan ranking or by clan-war ranking