hypixel-api-reborn 9.0.3 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +13 -0
- package/README.md +28 -16
- package/package.json +60 -58
- package/src/API/getAPIStatus.js +8 -7
- package/src/API/getBoosters.js +6 -5
- package/src/API/getGameCounts.js +6 -5
- package/src/API/getGuild.js +18 -17
- package/src/API/getLeaderboards.js +13 -12
- package/src/API/getPlayer.js +22 -26
- package/src/API/getRecentGames.js +18 -17
- package/src/API/getServerInfo.js +66 -77
- package/src/API/getStatus.js +8 -7
- package/src/API/getWatchdogStats.js +6 -5
- package/src/API/index.js +19 -9
- package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -9
- package/src/API/skyblock/getSkyblockAuctions.js +64 -64
- package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -10
- package/src/API/skyblock/getSkyblockBazaar.js +10 -9
- package/src/API/skyblock/getSkyblockMember.js +28 -24
- package/src/API/skyblock/getSkyblockNews.js +6 -5
- package/src/API/skyblock/getSkyblockProfiles.js +44 -40
- package/src/Client.js +406 -430
- package/src/Errors.js +44 -38
- package/src/Private/defaultCache.js +77 -0
- package/src/Private/rateLimit.js +79 -98
- package/src/Private/requests.js +65 -39
- package/src/Private/updater.js +45 -42
- package/src/Private/uuidCache.js +37 -33
- package/src/Private/validate.js +97 -97
- package/src/index.js +82 -83
- package/src/structures/APIIncident.js +78 -78
- package/src/structures/APIStatus.js +47 -47
- package/src/structures/Boosters/Booster.js +83 -87
- package/src/structures/Color.js +129 -129
- package/src/structures/Game.js +164 -160
- package/src/structures/GameCounts.js +151 -151
- package/src/structures/Guild/Guild.js +204 -218
- package/src/structures/Guild/GuildMember.js +66 -66
- package/src/structures/Guild/GuildRank.js +48 -48
- package/src/structures/ItemBytes.js +33 -36
- package/src/structures/Leaderboard.js +31 -31
- package/src/structures/MiniGames/Arcade.js +567 -569
- package/src/structures/MiniGames/ArenaBrawl.js +52 -56
- package/src/structures/MiniGames/BedWars.js +423 -329
- package/src/structures/MiniGames/BlitzSurvivalGames.js +172 -148
- package/src/structures/MiniGames/BuildBattle.js +53 -53
- package/src/structures/MiniGames/CopsAndCrims.js +90 -90
- package/src/structures/MiniGames/Duels.js +694 -460
- package/src/structures/MiniGames/MegaWalls.js +137 -137
- package/src/structures/MiniGames/MurderMystery.js +93 -93
- package/src/structures/MiniGames/Paintball.js +67 -67
- package/src/structures/MiniGames/Pit.js +19 -19
- package/src/structures/MiniGames/Quakecraft.js +101 -101
- package/src/structures/MiniGames/SkyWars.js +508 -559
- package/src/structures/MiniGames/SmashHeroes.js +144 -151
- package/src/structures/MiniGames/SpeedUHC.js +115 -57
- package/src/structures/MiniGames/TNTGames.js +116 -116
- package/src/structures/MiniGames/TurboKartRacers.js +201 -71
- package/src/structures/MiniGames/UHC.js +164 -143
- package/src/structures/MiniGames/VampireZ.js +60 -60
- package/src/structures/MiniGames/Walls.js +52 -52
- package/src/structures/MiniGames/Warlords.js +62 -62
- package/src/structures/MiniGames/WoolWars.js +123 -0
- package/src/structures/Pet.js +96 -97
- package/src/structures/Pets.js +64 -64
- package/src/structures/Player.js +433 -453
- package/src/structures/PlayerCosmetics.js +100 -95
- package/src/structures/RecentGame.js +57 -57
- package/src/structures/ServerInfo.js +78 -78
- package/src/structures/SkyBlock/Auctions/Auction.js +104 -104
- package/src/structures/SkyBlock/Auctions/AuctionInfo.js +54 -54
- package/src/structures/SkyBlock/Auctions/BaseAuction.js +45 -45
- package/src/structures/SkyBlock/Auctions/Bid.js +48 -48
- package/src/structures/SkyBlock/Auctions/PartialAuction.js +25 -25
- package/src/structures/SkyBlock/Bazzar/Order.js +38 -38
- package/src/structures/SkyBlock/Bazzar/Product.js +53 -53
- package/src/structures/SkyBlock/News/SkyblockNews.js +60 -68
- package/src/structures/SkyBlock/SkyblockInventoryItem.js +124 -102
- package/src/structures/SkyBlock/SkyblockMember.js +820 -675
- package/src/structures/SkyBlock/SkyblockPet.js +71 -71
- package/src/structures/SkyBlock/SkyblockProfile.js +60 -60
- package/src/structures/Status.js +41 -41
- package/src/structures/Watchdog/Stats.js +36 -36
- package/src/utils/Constants.js +2789 -795
- package/src/utils/SkyblockUtils.js +208 -164
- package/src/utils/arrayTools.js +4 -4
- package/src/utils/divide.js +5 -5
- package/src/utils/guildExp.js +57 -67
- package/src/utils/index.js +13 -9
- package/src/utils/isGuildID.js +3 -3
- package/src/utils/isUUID.js +5 -5
- package/src/utils/oscillation.js +15 -23
- package/src/utils/removeSnakeCase.js +22 -35
- package/src/utils/rgbToHexColor.js +8 -0
- package/src/utils/romanize.js +11 -0
- package/src/utils/toIGN.js +20 -20
- package/src/utils/toUuid.js +19 -19
- package/src/utils/varInt.js +17 -21
- package/typings/index.d.ts +3532 -2625
- package/src/API/getFriends.js +0 -13
- package/src/API/getKeyInfo.js +0 -9
- package/src/API/getRankedSkyWars.js +0 -10
- package/src/structures/Friend.js +0 -38
- package/src/structures/KeyInfo.js +0 -42
- package/src/structures/MiniGames/SkyWarsRanked.js +0 -45
|
@@ -1,218 +1,204 @@
|
|
|
1
|
-
const GuildMember = require('./GuildMember');
|
|
2
|
-
const GuildRank = require('./GuildRank');
|
|
3
|
-
const Color = require('../Color');
|
|
4
|
-
const Game = require('../Game');
|
|
5
|
-
const {getGuildLevel, parseHistory} = require('../../utils/guildExp');
|
|
6
|
-
/**
|
|
7
|
-
* Guild class
|
|
8
|
-
*/
|
|
9
|
-
class Guild {
|
|
10
|
-
/**
|
|
11
|
-
* @param {data} data Guild data
|
|
12
|
-
* @param {string} [me] Player uuid used to search for this guild
|
|
13
|
-
*/
|
|
14
|
-
constructor
|
|
15
|
-
/**
|
|
16
|
-
* Guild ID
|
|
17
|
-
* @type {string}
|
|
18
|
-
*/
|
|
19
|
-
this.id = data._id;
|
|
20
|
-
/**
|
|
21
|
-
* Guild name
|
|
22
|
-
* @type {String}
|
|
23
|
-
*/
|
|
24
|
-
this.name = data.name;
|
|
25
|
-
/**
|
|
26
|
-
* Guild description
|
|
27
|
-
* @type {String}
|
|
28
|
-
*/
|
|
29
|
-
this.description = data.description ? data.description : null;
|
|
30
|
-
/**
|
|
31
|
-
* Guild experience
|
|
32
|
-
* @type {Number}
|
|
33
|
-
*/
|
|
34
|
-
this.experience = data.exp || 0;
|
|
35
|
-
/**
|
|
36
|
-
* Guild level
|
|
37
|
-
* @type {Number}
|
|
38
|
-
*/
|
|
39
|
-
this.level = getGuildLevel(this.experience);
|
|
40
|
-
/**
|
|
41
|
-
* Guild members
|
|
42
|
-
* @type {Array<GuildMember>}
|
|
43
|
-
*/
|
|
44
|
-
this.members = members(data);
|
|
45
|
-
/**
|
|
46
|
-
* Me, if a player UUID is used to get the guild
|
|
47
|
-
* @type {GuildMember|null}
|
|
48
|
-
*/
|
|
49
|
-
this.me = this.members.find((member) => member.uuid === me);
|
|
50
|
-
/**
|
|
51
|
-
* Guild ranks
|
|
52
|
-
* @type {Array<GuildRank>}
|
|
53
|
-
*/
|
|
54
|
-
this.ranks = ranks(data);
|
|
55
|
-
/**
|
|
56
|
-
* The total guild experience earned in the last 7 days
|
|
57
|
-
* @author linearaccelerator
|
|
58
|
-
* @type {number}
|
|
59
|
-
*/
|
|
60
|
-
this.totalWeeklyGexp = totalWeeklyGexp(data);
|
|
61
|
-
/**
|
|
62
|
-
* An array containing all guild ranks sorted by newest
|
|
63
|
-
* @author linearaccelerator
|
|
64
|
-
* @return {Array<GuildRank>}
|
|
65
|
-
*/
|
|
66
|
-
this.getRanksByNewest = function () {
|
|
67
|
-
return this.ranks.length ? this.ranks.map((r) => new GuildRank(r)).sort((a, b) => b.createdAt - a.createdAt) : null;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* A map containing all guild members, keyed by their uuids
|
|
71
|
-
* @author linearaccelerator
|
|
72
|
-
* @return {Map<string, GuildMember>}
|
|
73
|
-
*/
|
|
74
|
-
this.getMemberUUIDMap = function () {
|
|
75
|
-
return this.members.length ? new Map(this.members.map((m) => [m.uuid, m])) : null;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Returns a guild rank by priority
|
|
79
|
-
* @author linearaccelerator
|
|
80
|
-
* @param {number} priority - The priority of the guild rank
|
|
81
|
-
* @return {GuildRank}
|
|
82
|
-
*/
|
|
83
|
-
this.getRankByPriority = function (priority) {
|
|
84
|
-
if (!this.ranks.length || !this.ranks.some((r) => r.priority === priority)) return null;
|
|
85
|
-
return new GuildRank(this.ranks.find((r) => r.priority === priority));
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Date of guild creation as timestamp
|
|
89
|
-
* @type {String}
|
|
90
|
-
*/
|
|
91
|
-
this.createdAtTimestamp = data.created;
|
|
92
|
-
/**
|
|
93
|
-
* Date of guild creation
|
|
94
|
-
* @type {Date}
|
|
95
|
-
*/
|
|
96
|
-
this.createdAt = new Date(data.created);
|
|
97
|
-
/**
|
|
98
|
-
* Whether this guild can be joined using /g join
|
|
99
|
-
* @type {boolean}
|
|
100
|
-
*/
|
|
101
|
-
this.joinable = data.joinable ? data.joinable : false;
|
|
102
|
-
/**
|
|
103
|
-
* Whether this guild is listed in the Guild Finder
|
|
104
|
-
* @type {boolean}
|
|
105
|
-
*/
|
|
106
|
-
this.publiclyListed = !!data.publiclyListed;
|
|
107
|
-
/**
|
|
108
|
-
* Timestamp guild chat will be unmuted at.
|
|
109
|
-
* @type {number|null}
|
|
110
|
-
*/
|
|
111
|
-
this.chatMuteUntilTimestamp = data.chatMute ? data.chatMute : null;
|
|
112
|
-
/**
|
|
113
|
-
* Timestamp guild chat will be unmuted at as Date.
|
|
114
|
-
* @type {Date|null}
|
|
115
|
-
*/
|
|
116
|
-
this.chatMuteUntil = data.chatMute ? new Date(data.chatMute) : null;
|
|
117
|
-
/**
|
|
118
|
-
* Timestamp guild chat will be unmuted at.
|
|
119
|
-
* @type {Array<{ Pattern: string, Color: string }>}
|
|
120
|
-
*/
|
|
121
|
-
this.banner = data.banner ? data.banner : null;
|
|
122
|
-
/**
|
|
123
|
-
* Guild tag
|
|
124
|
-
* @type {string}
|
|
125
|
-
*/
|
|
126
|
-
this.tag = data.tag ? data.tag : null;
|
|
127
|
-
/**
|
|
128
|
-
* Guild tag color
|
|
129
|
-
* @type {Color}
|
|
130
|
-
*/
|
|
131
|
-
this.tagColor = data.tagColor ? new Color(data.tagColor) : null;
|
|
132
|
-
/**
|
|
133
|
-
* Ranking in the number of guild coins owned in the legacy guild system. (0 - indexed)
|
|
134
|
-
* @deprecated
|
|
135
|
-
* @type {number}
|
|
136
|
-
*/
|
|
137
|
-
this.legacyRank = !isNaN(data.legacyRanking) ? parseInt(data.legacyRanking + 1, 10) : 0;
|
|
138
|
-
/**
|
|
139
|
-
* Experience history per day, resets at 5 am UTC. Please remember this is only an estimation based on the sum of every guild member's daily gexp.
|
|
140
|
-
* @type {Array<ExpHistory>}
|
|
141
|
-
*/
|
|
142
|
-
this.expHistory = calculateExpHistory(data);
|
|
143
|
-
/**
|
|
144
|
-
* Guild achievements
|
|
145
|
-
* @type {{winners: number, experienceKings: number, onlinePlayers: number}}
|
|
146
|
-
*/
|
|
147
|
-
this.achievements = {
|
|
148
|
-
winners: data.achievements ? data.achievements.WINNERS : 0,
|
|
149
|
-
experienceKings: data.achievements ? data.achievements.EXPERIENCE_KINGS : 0,
|
|
150
|
-
onlinePlayers: data.achievements ? data.achievements.ONLINE_PLAYERS : 0
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Guild preferred games
|
|
154
|
-
* @type {Array<Game>}
|
|
155
|
-
*/
|
|
156
|
-
this.preferredGames = data.preferredGames ? data.preferredGames.map((g) => new Game(g)) : [];
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Guild name
|
|
160
|
-
* @return {string}
|
|
161
|
-
*/
|
|
162
|
-
toString() {
|
|
163
|
-
return this.name;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* The Guild Master of the guild as a GuildMember
|
|
167
|
-
* @type {GuildMember}
|
|
168
|
-
*/
|
|
169
|
-
get guildMaster
|
|
170
|
-
return this.members.find((member) => member.rank === 'Guild Master' || member.rank === 'GUILDMASTER');
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
finalObj[day] = expLimit(gexp);
|
|
206
|
-
}
|
|
207
|
-
return parseHistory(finalObj);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Calculates and returns the exp after daily limit
|
|
211
|
-
* @param {number} exp Experience
|
|
212
|
-
* @return {number}
|
|
213
|
-
*/
|
|
214
|
-
function expLimit(exp) {
|
|
215
|
-
return exp > 2e5 ? (exp > 7e5 ? 2.5e5+Math.round(exp * 0.03) : 2e5 + Math.round((exp-2e5) / 10)) : exp;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
module.exports = Guild;
|
|
1
|
+
const GuildMember = require('./GuildMember');
|
|
2
|
+
const GuildRank = require('./GuildRank');
|
|
3
|
+
const Color = require('../Color');
|
|
4
|
+
const Game = require('../Game');
|
|
5
|
+
const { getGuildLevel, parseHistory } = require('../../utils/guildExp');
|
|
6
|
+
/**
|
|
7
|
+
* Guild class
|
|
8
|
+
*/
|
|
9
|
+
class Guild {
|
|
10
|
+
/**
|
|
11
|
+
* @param {data} data Guild data
|
|
12
|
+
* @param {string} [me] Player uuid used to search for this guild
|
|
13
|
+
*/
|
|
14
|
+
constructor(data, me = '') {
|
|
15
|
+
/**
|
|
16
|
+
* Guild ID
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
this.id = data._id;
|
|
20
|
+
/**
|
|
21
|
+
* Guild name
|
|
22
|
+
* @type {String}
|
|
23
|
+
*/
|
|
24
|
+
this.name = data.name;
|
|
25
|
+
/**
|
|
26
|
+
* Guild description
|
|
27
|
+
* @type {String}
|
|
28
|
+
*/
|
|
29
|
+
this.description = data.description ? data.description : null;
|
|
30
|
+
/**
|
|
31
|
+
* Guild experience
|
|
32
|
+
* @type {Number}
|
|
33
|
+
*/
|
|
34
|
+
this.experience = data.exp || 0;
|
|
35
|
+
/**
|
|
36
|
+
* Guild level
|
|
37
|
+
* @type {Number}
|
|
38
|
+
*/
|
|
39
|
+
this.level = getGuildLevel(this.experience);
|
|
40
|
+
/**
|
|
41
|
+
* Guild members
|
|
42
|
+
* @type {Array<GuildMember>}
|
|
43
|
+
*/
|
|
44
|
+
this.members = members(data);
|
|
45
|
+
/**
|
|
46
|
+
* Me, if a player UUID is used to get the guild
|
|
47
|
+
* @type {GuildMember|null}
|
|
48
|
+
*/
|
|
49
|
+
this.me = this.members.find((member) => member.uuid === me);
|
|
50
|
+
/**
|
|
51
|
+
* Guild ranks
|
|
52
|
+
* @type {Array<GuildRank>}
|
|
53
|
+
*/
|
|
54
|
+
this.ranks = ranks(data);
|
|
55
|
+
/**
|
|
56
|
+
* The total guild experience earned in the last 7 days
|
|
57
|
+
* @author linearaccelerator
|
|
58
|
+
* @type {number}
|
|
59
|
+
*/
|
|
60
|
+
this.totalWeeklyGexp = totalWeeklyGexp(data);
|
|
61
|
+
/**
|
|
62
|
+
* An array containing all guild ranks sorted by newest
|
|
63
|
+
* @author linearaccelerator
|
|
64
|
+
* @return {Array<GuildRank>}
|
|
65
|
+
*/
|
|
66
|
+
this.getRanksByNewest = function () {
|
|
67
|
+
return this.ranks.length ? this.ranks.map((r) => new GuildRank(r)).sort((a, b) => b.createdAt - a.createdAt) : null;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* A map containing all guild members, keyed by their uuids
|
|
71
|
+
* @author linearaccelerator
|
|
72
|
+
* @return {Map<string, GuildMember>}
|
|
73
|
+
*/
|
|
74
|
+
this.getMemberUUIDMap = function () {
|
|
75
|
+
return this.members.length ? new Map(this.members.map((m) => [m.uuid, m])) : null;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Returns a guild rank by priority
|
|
79
|
+
* @author linearaccelerator
|
|
80
|
+
* @param {number} priority - The priority of the guild rank
|
|
81
|
+
* @return {GuildRank}
|
|
82
|
+
*/
|
|
83
|
+
this.getRankByPriority = function (priority) {
|
|
84
|
+
if (!this.ranks.length || !this.ranks.some((r) => r.priority === priority)) return null;
|
|
85
|
+
return new GuildRank(this.ranks.find((r) => r.priority === priority));
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Date of guild creation as timestamp
|
|
89
|
+
* @type {String}
|
|
90
|
+
*/
|
|
91
|
+
this.createdAtTimestamp = data.created;
|
|
92
|
+
/**
|
|
93
|
+
* Date of guild creation
|
|
94
|
+
* @type {Date}
|
|
95
|
+
*/
|
|
96
|
+
this.createdAt = new Date(data.created);
|
|
97
|
+
/**
|
|
98
|
+
* Whether this guild can be joined using /g join
|
|
99
|
+
* @type {boolean}
|
|
100
|
+
*/
|
|
101
|
+
this.joinable = data.joinable ? data.joinable : false;
|
|
102
|
+
/**
|
|
103
|
+
* Whether this guild is listed in the Guild Finder
|
|
104
|
+
* @type {boolean}
|
|
105
|
+
*/
|
|
106
|
+
this.publiclyListed = !!data.publiclyListed;
|
|
107
|
+
/**
|
|
108
|
+
* Timestamp guild chat will be unmuted at.
|
|
109
|
+
* @type {number|null}
|
|
110
|
+
*/
|
|
111
|
+
this.chatMuteUntilTimestamp = data.chatMute ? data.chatMute : null;
|
|
112
|
+
/**
|
|
113
|
+
* Timestamp guild chat will be unmuted at as Date.
|
|
114
|
+
* @type {Date|null}
|
|
115
|
+
*/
|
|
116
|
+
this.chatMuteUntil = data.chatMute ? new Date(data.chatMute) : null;
|
|
117
|
+
/**
|
|
118
|
+
* Timestamp guild chat will be unmuted at.
|
|
119
|
+
* @type {Array<{ Pattern: string, Color: string }>}
|
|
120
|
+
*/
|
|
121
|
+
this.banner = data.banner ? data.banner : null;
|
|
122
|
+
/**
|
|
123
|
+
* Guild tag
|
|
124
|
+
* @type {string}
|
|
125
|
+
*/
|
|
126
|
+
this.tag = data.tag ? data.tag : null;
|
|
127
|
+
/**
|
|
128
|
+
* Guild tag color
|
|
129
|
+
* @type {Color}
|
|
130
|
+
*/
|
|
131
|
+
this.tagColor = data.tagColor ? new Color(data.tagColor) : null;
|
|
132
|
+
/**
|
|
133
|
+
* Ranking in the number of guild coins owned in the legacy guild system. (0 - indexed)
|
|
134
|
+
* @deprecated
|
|
135
|
+
* @type {number}
|
|
136
|
+
*/
|
|
137
|
+
this.legacyRank = !isNaN(data.legacyRanking) ? parseInt(data.legacyRanking + 1, 10) : 0;
|
|
138
|
+
/**
|
|
139
|
+
* Experience history per day, resets at 5 am UTC. Please remember this is only an estimation based on the sum of every guild member's daily gexp.
|
|
140
|
+
* @type {Array<ExpHistory>}
|
|
141
|
+
*/
|
|
142
|
+
this.expHistory = calculateExpHistory(data);
|
|
143
|
+
/**
|
|
144
|
+
* Guild achievements
|
|
145
|
+
* @type {{winners: number, experienceKings: number, onlinePlayers: number}}
|
|
146
|
+
*/
|
|
147
|
+
this.achievements = {
|
|
148
|
+
winners: data.achievements ? data.achievements.WINNERS : 0,
|
|
149
|
+
experienceKings: data.achievements ? data.achievements.EXPERIENCE_KINGS : 0,
|
|
150
|
+
onlinePlayers: data.achievements ? data.achievements.ONLINE_PLAYERS : 0
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Guild preferred games
|
|
154
|
+
* @type {Array<Game>}
|
|
155
|
+
*/
|
|
156
|
+
this.preferredGames = data.preferredGames ? data.preferredGames.map((g) => new Game(g)) : [];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Guild name
|
|
160
|
+
* @return {string}
|
|
161
|
+
*/
|
|
162
|
+
toString() {
|
|
163
|
+
return this.name;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The Guild Master of the guild as a GuildMember
|
|
167
|
+
* @type {GuildMember}
|
|
168
|
+
*/
|
|
169
|
+
get guildMaster() {
|
|
170
|
+
return this.members.find((member) => member.rank === 'Guild Master' || member.rank === 'GUILDMASTER');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// eslint-disable-next-line require-jsdoc
|
|
174
|
+
function members(data) {
|
|
175
|
+
return data.members.length ? data.members.map((m) => new GuildMember(m)) : [];
|
|
176
|
+
}
|
|
177
|
+
// eslint-disable-next-line require-jsdoc
|
|
178
|
+
function ranks(data) {
|
|
179
|
+
return data.ranks && data.ranks.length ? data.ranks.map((r) => new GuildRank(r)).sort((a, b) => a.priority - b.priority) : [];
|
|
180
|
+
}
|
|
181
|
+
// eslint-disable-next-line require-jsdoc
|
|
182
|
+
function totalWeeklyGexp(data) {
|
|
183
|
+
return members(data)
|
|
184
|
+
.map((m) => m.weeklyExperience)
|
|
185
|
+
.reduce((acc, cur) => acc + cur);
|
|
186
|
+
}
|
|
187
|
+
// eslint-disable-next-line require-jsdoc
|
|
188
|
+
function calculateExpHistory(data) {
|
|
189
|
+
const finalObj = {};
|
|
190
|
+
for (const day of Object.keys(data.members[0].expHistory)) {
|
|
191
|
+
let gexp = 0;
|
|
192
|
+
for (const member of data.members) {
|
|
193
|
+
gexp += member.expHistory[day] || 0;
|
|
194
|
+
}
|
|
195
|
+
finalObj[day] = expLimit(gexp);
|
|
196
|
+
}
|
|
197
|
+
return parseHistory(finalObj);
|
|
198
|
+
}
|
|
199
|
+
// eslint-disable-next-line require-jsdoc
|
|
200
|
+
function expLimit(exp) {
|
|
201
|
+
return exp > 2e5 ? (exp > 7e5 ? 2.5e5 + Math.round(exp * 0.03) : 2e5 + Math.round((exp - 2e5) / 10)) : exp;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
module.exports = Guild;
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
const {parseHistory} = require('../../utils/guildExp');
|
|
2
|
-
/**
|
|
3
|
-
* GuildMember class
|
|
4
|
-
*/
|
|
5
|
-
class GuildMember {
|
|
6
|
-
/**
|
|
7
|
-
* @param {data} data Guild member data
|
|
8
|
-
*/
|
|
9
|
-
constructor
|
|
10
|
-
/**
|
|
11
|
-
* Guild member UUID
|
|
12
|
-
* @type {String}
|
|
13
|
-
*/
|
|
14
|
-
this.uuid = data.uuid;
|
|
15
|
-
/**
|
|
16
|
-
* Timestamp this member joined at
|
|
17
|
-
* @type {Number}
|
|
18
|
-
*/
|
|
19
|
-
this.joinedAtTimestamp = data.joined;
|
|
20
|
-
/**
|
|
21
|
-
* Timestamp this member joined at as Date
|
|
22
|
-
* @type {Date}
|
|
23
|
-
*/
|
|
24
|
-
this.joinedAt = new Date(data.joined);
|
|
25
|
-
/**
|
|
26
|
-
* The number of challenges completed that count towards the current quest
|
|
27
|
-
* @type {Number}
|
|
28
|
-
*/
|
|
29
|
-
this.questParticipation = data.questParticipation || 0;
|
|
30
|
-
/**
|
|
31
|
-
* Member's rank
|
|
32
|
-
* @type {String}
|
|
33
|
-
*/
|
|
34
|
-
this.rank = data.rank;
|
|
35
|
-
/**
|
|
36
|
-
* Timestamp this member will be unmuted at ( if muted )
|
|
37
|
-
* @type {Number|null}
|
|
38
|
-
*/
|
|
39
|
-
this.mutedUntilTimestamp = data.mutedTill ? data.mutedTill : null;
|
|
40
|
-
/**
|
|
41
|
-
* Timestamp this member will be unmuted at as Date ( if muted )
|
|
42
|
-
* @type {Date|null}
|
|
43
|
-
*/
|
|
44
|
-
this.mutedUntil = data.mutedTill ? new Date(data.mutedTill) : null;
|
|
45
|
-
const xpCheck = data.expHistory && typeof Object.values(data.expHistory)[0] === 'number';
|
|
46
|
-
/**
|
|
47
|
-
* Experience history per day, resets at 5 am UTC
|
|
48
|
-
* @type {Array<ExpHistory>}
|
|
49
|
-
*/
|
|
50
|
-
this.expHistory = parseHistory(data.expHistory);
|
|
51
|
-
/**
|
|
52
|
-
* Experience per week, resets every Monday at 5 am UTC
|
|
53
|
-
* @type {Number}
|
|
54
|
-
*/
|
|
55
|
-
this.weeklyExperience = xpCheck ? Object.values(data.expHistory).reduce((pV, cV) => pV + cV, 0) : null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* UUID
|
|
59
|
-
* @return {string}
|
|
60
|
-
*/
|
|
61
|
-
toString() {
|
|
62
|
-
return this.uuid;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = GuildMember;
|
|
1
|
+
const { parseHistory } = require('../../utils/guildExp');
|
|
2
|
+
/**
|
|
3
|
+
* GuildMember class
|
|
4
|
+
*/
|
|
5
|
+
class GuildMember {
|
|
6
|
+
/**
|
|
7
|
+
* @param {data} data Guild member data
|
|
8
|
+
*/
|
|
9
|
+
constructor(data) {
|
|
10
|
+
/**
|
|
11
|
+
* Guild member UUID
|
|
12
|
+
* @type {String}
|
|
13
|
+
*/
|
|
14
|
+
this.uuid = data.uuid;
|
|
15
|
+
/**
|
|
16
|
+
* Timestamp this member joined at
|
|
17
|
+
* @type {Number}
|
|
18
|
+
*/
|
|
19
|
+
this.joinedAtTimestamp = data.joined;
|
|
20
|
+
/**
|
|
21
|
+
* Timestamp this member joined at as Date
|
|
22
|
+
* @type {Date}
|
|
23
|
+
*/
|
|
24
|
+
this.joinedAt = new Date(data.joined);
|
|
25
|
+
/**
|
|
26
|
+
* The number of challenges completed that count towards the current quest
|
|
27
|
+
* @type {Number}
|
|
28
|
+
*/
|
|
29
|
+
this.questParticipation = data.questParticipation || 0;
|
|
30
|
+
/**
|
|
31
|
+
* Member's rank
|
|
32
|
+
* @type {String}
|
|
33
|
+
*/
|
|
34
|
+
this.rank = data.rank;
|
|
35
|
+
/**
|
|
36
|
+
* Timestamp this member will be unmuted at ( if muted )
|
|
37
|
+
* @type {Number|null}
|
|
38
|
+
*/
|
|
39
|
+
this.mutedUntilTimestamp = data.mutedTill ? data.mutedTill : null;
|
|
40
|
+
/**
|
|
41
|
+
* Timestamp this member will be unmuted at as Date ( if muted )
|
|
42
|
+
* @type {Date|null}
|
|
43
|
+
*/
|
|
44
|
+
this.mutedUntil = data.mutedTill ? new Date(data.mutedTill) : null;
|
|
45
|
+
const xpCheck = data.expHistory && typeof Object.values(data.expHistory)[0] === 'number';
|
|
46
|
+
/**
|
|
47
|
+
* Experience history per day, resets at 5 am UTC
|
|
48
|
+
* @type {Array<ExpHistory>}
|
|
49
|
+
*/
|
|
50
|
+
this.expHistory = parseHistory(data.expHistory);
|
|
51
|
+
/**
|
|
52
|
+
* Experience per week, resets every Monday at 5 am UTC
|
|
53
|
+
* @type {Number}
|
|
54
|
+
*/
|
|
55
|
+
this.weeklyExperience = xpCheck ? Object.values(data.expHistory).reduce((pV, cV) => pV + cV, 0) : null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* UUID
|
|
59
|
+
* @return {string}
|
|
60
|
+
*/
|
|
61
|
+
toString() {
|
|
62
|
+
return this.uuid;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = GuildMember;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GuildRank class
|
|
3
|
-
*/
|
|
4
|
-
class GuildRank {
|
|
5
|
-
/**
|
|
6
|
-
* @param {data} data Guild rank data
|
|
7
|
-
*/
|
|
8
|
-
constructor
|
|
9
|
-
/**
|
|
10
|
-
* Guild rank name
|
|
11
|
-
* @type {String}
|
|
12
|
-
*/
|
|
13
|
-
this.name = data.name;
|
|
14
|
-
/**
|
|
15
|
-
* Whether this rank is the default rank a player gets when they join a guild
|
|
16
|
-
* @type {boolean}
|
|
17
|
-
*/
|
|
18
|
-
this.default = data.default;
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.tag = data.tag ? data.tag : null;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.createdAtTimestamp = data.created ? data.created : data.createdAtTimestamp;
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.createdAt = new Date(
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.priority = data.priority;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Rank Name
|
|
42
|
-
* @return {string}
|
|
43
|
-
*/
|
|
44
|
-
toString() {
|
|
45
|
-
return this.name;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
module.exports = GuildRank;
|
|
1
|
+
/**
|
|
2
|
+
* GuildRank class
|
|
3
|
+
*/
|
|
4
|
+
class GuildRank {
|
|
5
|
+
/**
|
|
6
|
+
* @param {data} data Guild rank data
|
|
7
|
+
*/
|
|
8
|
+
constructor(data) {
|
|
9
|
+
/**
|
|
10
|
+
* Guild rank name
|
|
11
|
+
* @type {String}
|
|
12
|
+
*/
|
|
13
|
+
this.name = data.name;
|
|
14
|
+
/**
|
|
15
|
+
* Whether this rank is the default rank a player gets when they join a guild
|
|
16
|
+
* @type {boolean}
|
|
17
|
+
*/
|
|
18
|
+
this.default = data.default;
|
|
19
|
+
/**
|
|
20
|
+
* Guild rank tag that appears in guild chat. null if none
|
|
21
|
+
* @type {string|null}
|
|
22
|
+
*/
|
|
23
|
+
this.tag = data.tag ? data.tag : null;
|
|
24
|
+
/**
|
|
25
|
+
* Timestamp this rank was created at
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
this.createdAtTimestamp = data.created ? data.created : data.createdAtTimestamp;
|
|
29
|
+
/**
|
|
30
|
+
* Timestamp this rank was created at as Date
|
|
31
|
+
* @type {Date}
|
|
32
|
+
*/
|
|
33
|
+
this.createdAt = new Date(data.created ? data.created : data.createdAtTimestamp);
|
|
34
|
+
/**
|
|
35
|
+
* Guild rank priority - Higher number = higher up in the hierarchy
|
|
36
|
+
* @type {number}
|
|
37
|
+
*/
|
|
38
|
+
this.priority = data.priority;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Rank Name
|
|
42
|
+
* @return {string}
|
|
43
|
+
*/
|
|
44
|
+
toString() {
|
|
45
|
+
return this.name;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
module.exports = GuildRank;
|