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.
Files changed (105) hide show
  1. package/.prettierrc +13 -0
  2. package/README.md +28 -16
  3. package/package.json +60 -58
  4. package/src/API/getAPIStatus.js +8 -7
  5. package/src/API/getBoosters.js +6 -5
  6. package/src/API/getGameCounts.js +6 -5
  7. package/src/API/getGuild.js +18 -17
  8. package/src/API/getLeaderboards.js +13 -12
  9. package/src/API/getPlayer.js +22 -26
  10. package/src/API/getRecentGames.js +18 -17
  11. package/src/API/getServerInfo.js +66 -77
  12. package/src/API/getStatus.js +8 -7
  13. package/src/API/getWatchdogStats.js +6 -5
  14. package/src/API/index.js +19 -9
  15. package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -9
  16. package/src/API/skyblock/getSkyblockAuctions.js +64 -64
  17. package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -10
  18. package/src/API/skyblock/getSkyblockBazaar.js +10 -9
  19. package/src/API/skyblock/getSkyblockMember.js +28 -24
  20. package/src/API/skyblock/getSkyblockNews.js +6 -5
  21. package/src/API/skyblock/getSkyblockProfiles.js +44 -40
  22. package/src/Client.js +406 -430
  23. package/src/Errors.js +44 -38
  24. package/src/Private/defaultCache.js +77 -0
  25. package/src/Private/rateLimit.js +79 -98
  26. package/src/Private/requests.js +65 -39
  27. package/src/Private/updater.js +45 -42
  28. package/src/Private/uuidCache.js +37 -33
  29. package/src/Private/validate.js +97 -97
  30. package/src/index.js +82 -83
  31. package/src/structures/APIIncident.js +78 -78
  32. package/src/structures/APIStatus.js +47 -47
  33. package/src/structures/Boosters/Booster.js +83 -87
  34. package/src/structures/Color.js +129 -129
  35. package/src/structures/Game.js +164 -160
  36. package/src/structures/GameCounts.js +151 -151
  37. package/src/structures/Guild/Guild.js +204 -218
  38. package/src/structures/Guild/GuildMember.js +66 -66
  39. package/src/structures/Guild/GuildRank.js +48 -48
  40. package/src/structures/ItemBytes.js +33 -36
  41. package/src/structures/Leaderboard.js +31 -31
  42. package/src/structures/MiniGames/Arcade.js +567 -569
  43. package/src/structures/MiniGames/ArenaBrawl.js +52 -56
  44. package/src/structures/MiniGames/BedWars.js +423 -329
  45. package/src/structures/MiniGames/BlitzSurvivalGames.js +172 -148
  46. package/src/structures/MiniGames/BuildBattle.js +53 -53
  47. package/src/structures/MiniGames/CopsAndCrims.js +90 -90
  48. package/src/structures/MiniGames/Duels.js +694 -460
  49. package/src/structures/MiniGames/MegaWalls.js +137 -137
  50. package/src/structures/MiniGames/MurderMystery.js +93 -93
  51. package/src/structures/MiniGames/Paintball.js +67 -67
  52. package/src/structures/MiniGames/Pit.js +19 -19
  53. package/src/structures/MiniGames/Quakecraft.js +101 -101
  54. package/src/structures/MiniGames/SkyWars.js +508 -559
  55. package/src/structures/MiniGames/SmashHeroes.js +144 -151
  56. package/src/structures/MiniGames/SpeedUHC.js +115 -57
  57. package/src/structures/MiniGames/TNTGames.js +116 -116
  58. package/src/structures/MiniGames/TurboKartRacers.js +201 -71
  59. package/src/structures/MiniGames/UHC.js +164 -143
  60. package/src/structures/MiniGames/VampireZ.js +60 -60
  61. package/src/structures/MiniGames/Walls.js +52 -52
  62. package/src/structures/MiniGames/Warlords.js +62 -62
  63. package/src/structures/MiniGames/WoolWars.js +123 -0
  64. package/src/structures/Pet.js +96 -97
  65. package/src/structures/Pets.js +64 -64
  66. package/src/structures/Player.js +433 -453
  67. package/src/structures/PlayerCosmetics.js +100 -95
  68. package/src/structures/RecentGame.js +57 -57
  69. package/src/structures/ServerInfo.js +78 -78
  70. package/src/structures/SkyBlock/Auctions/Auction.js +104 -104
  71. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +54 -54
  72. package/src/structures/SkyBlock/Auctions/BaseAuction.js +45 -45
  73. package/src/structures/SkyBlock/Auctions/Bid.js +48 -48
  74. package/src/structures/SkyBlock/Auctions/PartialAuction.js +25 -25
  75. package/src/structures/SkyBlock/Bazzar/Order.js +38 -38
  76. package/src/structures/SkyBlock/Bazzar/Product.js +53 -53
  77. package/src/structures/SkyBlock/News/SkyblockNews.js +60 -68
  78. package/src/structures/SkyBlock/SkyblockInventoryItem.js +124 -102
  79. package/src/structures/SkyBlock/SkyblockMember.js +820 -675
  80. package/src/structures/SkyBlock/SkyblockPet.js +71 -71
  81. package/src/structures/SkyBlock/SkyblockProfile.js +60 -60
  82. package/src/structures/Status.js +41 -41
  83. package/src/structures/Watchdog/Stats.js +36 -36
  84. package/src/utils/Constants.js +2789 -795
  85. package/src/utils/SkyblockUtils.js +208 -164
  86. package/src/utils/arrayTools.js +4 -4
  87. package/src/utils/divide.js +5 -5
  88. package/src/utils/guildExp.js +57 -67
  89. package/src/utils/index.js +13 -9
  90. package/src/utils/isGuildID.js +3 -3
  91. package/src/utils/isUUID.js +5 -5
  92. package/src/utils/oscillation.js +15 -23
  93. package/src/utils/removeSnakeCase.js +22 -35
  94. package/src/utils/rgbToHexColor.js +8 -0
  95. package/src/utils/romanize.js +11 -0
  96. package/src/utils/toIGN.js +20 -20
  97. package/src/utils/toUuid.js +19 -19
  98. package/src/utils/varInt.js +17 -21
  99. package/typings/index.d.ts +3532 -2625
  100. package/src/API/getFriends.js +0 -13
  101. package/src/API/getKeyInfo.js +0 -9
  102. package/src/API/getRankedSkyWars.js +0 -10
  103. package/src/structures/Friend.js +0 -38
  104. package/src/structures/KeyInfo.js +0 -42
  105. package/src/structures/MiniGames/SkyWarsRanked.js +0 -45
@@ -1,164 +1,208 @@
1
- /* eslint-disable camelcase */
2
- const constants = require('./Constants');
3
- module.exports = {
4
- async decode (base64) {
5
- const nbt = require('prismarine-nbt');
6
- const parseNbt = (require('util')).promisify(nbt.parse);
7
- const buffer = Buffer.from(base64, 'base64');
8
- let data = await parseNbt(buffer);
9
- data = nbt.simplify(data);
10
- const newdata = [];
11
- for (let i = 0; i < data.i.length; i++) {
12
- newdata.push(data.i[i]);
13
- }
14
- return newdata;
15
- },
16
- getLevelByXp (xp, type, levelCap) {
17
- let xpTable;
18
- switch (type) {
19
- case 'runecrafting':
20
- xpTable = constants.runecrafting_xp;
21
- break;
22
- case 'dungeons':
23
- xpTable = constants.dungeon_xp;
24
- break;
25
- default:
26
- xpTable = constants.leveling_xp;
27
- }
28
- let maxLevel = Math.max(...Object.keys(xpTable));
29
- if (constants.skills_cap[type] > maxLevel) {
30
- xpTable = Object.assign(constants.xp_past_50, xpTable);
31
- maxLevel = typeof levelCap === 'number' ?
32
- maxLevel + levelCap :
33
- Math.max(...Object.keys(xpTable));
34
- }
35
- if (isNaN(xp)) {
36
- return {
37
- xp: 0,
38
- level: 0,
39
- maxLevel,
40
- xpCurrent: 0,
41
- xpForNext: xpTable[1],
42
- progress: 0
43
- };
44
- }
45
- let xpTotal = 0;
46
- let level = 0;
47
- let xpForNext = 0;
48
- for (let x = 1; x <= maxLevel; x++) {
49
- xpTotal += xpTable[x];
50
- if (xpTotal > xp) {
51
- xpTotal -= xpTable[x];
52
- break;
53
- } else {
54
- level = x;
55
- }
56
- }
57
- const xpCurrent = Math.floor(xp - xpTotal);
58
- if (level < maxLevel) xpForNext = Math.ceil(xpTable[level + 1]);
59
- const progress = Math.floor((Math.max(0, Math.min(xpCurrent / xpForNext, 1))) * 100);
60
- return {
61
- xp,
62
- level,
63
- maxLevel,
64
- xpCurrent,
65
- xpForNext,
66
- progress
67
- };
68
- },
69
- getLevelByAchievement (achievementLevel, type) {
70
- let xpTable = constants.leveling_xp;
71
- let maxLevel = Math.max(...Object.keys(xpTable));
72
- if (constants.skills_cap[type] > maxLevel && type in constants.skills_achievements) {
73
- xpTable = Object.assign(constants.xp_past_50, xpTable);
74
- maxLevel = Math.max(...Object.keys(xpTable));
75
- }
76
- if (isNaN(achievementLevel)) {
77
- return {
78
- xp: 0,
79
- level: 0,
80
- maxLevel,
81
- xpCurrent: 0,
82
- xpForNext: xpTable[1],
83
- progress: 0
84
- };
85
- }
86
- let xpTotal = 0;
87
- let xpForNext = 0;
88
- for (let x = 1; x <= achievementLevel; x++) {
89
- xpTotal += xpTable[x];
90
- }
91
- if (achievementLevel < maxLevel) xpForNext = Math.ceil(xpTable[achievementLevel + 1]);
92
- return {
93
- xp: xpTotal,
94
- level: achievementLevel,
95
- maxLevel,
96
- xpCurrent: 0,
97
- xpForNext,
98
- progress: 0
99
- };
100
- },
101
- getSlayerLevel (slayer) {
102
- if (!slayer) {
103
- return {
104
- xp: 0,
105
- tier1: 0,
106
- tier2: 0,
107
- tier3: 0,
108
- tier4: 0,
109
- tier5: 0,
110
- level: 0
111
- };
112
- }
113
- const { claimed_levels } = slayer;
114
- let level = 0;
115
- for (const level_name in claimed_levels) {
116
- if (Object.prototype.hasOwnProperty.call(claimed_levels, level_name)) {
117
- const _level = parseInt(level_name.split('_').pop(), 10);
118
- if (_level > level) {
119
- level = _level;
120
- }
121
- }
122
- }
123
- return {
124
- xp: slayer.xp || 0,
125
- tier1: slayer.boss_kills_tier_0 || 0,
126
- tier2: slayer.boss_kills_tier_1 || 0,
127
- tier3: slayer.boss_kills_tier_2 || 0,
128
- tier4: slayer.boss_kills_tier_3 || 0,
129
- tier5: slayer.boss_kills_tier_4 || 0,
130
- level
131
- };
132
- },
133
- getSlayerLevelByXp (xp) {
134
- const { slayer_xp } = constants;
135
- const maxLevel = Math.max(...Object.keys(slayer_xp));
136
- let level = 0;
137
- for (let x = 1; x <= maxLevel && slayer_xp[x] <= xp; x++) {
138
- level = x;
139
- }
140
- return level;
141
- },
142
- getBonusStat (level, skill, max, incremention) {
143
- const skill_stats = constants.bonus_stats[skill];
144
- const steps = Object.keys(skill_stats).sort((a, b) => Number(a) - Number(b)).map((a) => Number(a));
145
- const bonus = Object.assign({}, constants.stat_template);
146
- for (let x = steps[0]; x <= max; x += incremention) {
147
- if (level < x) {
148
- break;
149
- }
150
- const skill_step = steps.slice().reverse().find((a) => a <= x);
151
- const skill_bonus = skill_stats[skill_step];
152
- for (const skill in skill_bonus) {
153
- if (Object.prototype.hasOwnProperty.call(skill_bonus, skill)) {
154
- bonus[skill] += skill_bonus[skill];
155
- }
156
- }
157
- }
158
- return bonus;
159
- },
160
- getEffectiveHealth (health, defense) {
161
- if (defense <= 0) return health;
162
- return Math.round(health * (1 + defense / 100));
163
- }
164
- };
1
+ /* eslint-disable camelcase */
2
+ const constants = require('./Constants');
3
+ module.exports = {
4
+ async decode(base64, isBuffer = false) {
5
+ const nbt = require('prismarine-nbt');
6
+ const parseNbt = require('util').promisify(nbt.parse);
7
+ const buffer = isBuffer ? base64 : Buffer.from(base64, 'base64');
8
+ let data = await parseNbt(buffer);
9
+ data = nbt.simplify(data);
10
+ const newdata = [];
11
+ for (let i = 0; i < data.i.length; i++) {
12
+ newdata.push(data.i[i]);
13
+ }
14
+ return newdata;
15
+ },
16
+ getLevelByXp(xp, type, levelCap) {
17
+ let xpTable;
18
+ switch (type) {
19
+ case 'runecrafting':
20
+ xpTable = constants.runecrafting_xp;
21
+ break;
22
+ case 'dungeons':
23
+ xpTable = constants.dungeon_xp;
24
+ break;
25
+ case 'hotm':
26
+ xpTable = constants.hotm_xp;
27
+ break;
28
+ default:
29
+ xpTable = constants.leveling_xp;
30
+ }
31
+ let maxLevel = Math.max(...Object.keys(xpTable));
32
+ if ((constants.skills_cap[type] ?? maxLevel) > maxLevel) {
33
+ xpTable = Object.assign(constants.xp_past_50, xpTable);
34
+ maxLevel = typeof levelCap === 'number' ? maxLevel + levelCap : Math.max(...Object.keys(xpTable));
35
+ }
36
+ if (isNaN(xp)) {
37
+ return {
38
+ xp: 0,
39
+ level: 0,
40
+ maxLevel,
41
+ xpCurrent: 0,
42
+ xpForNext: xpTable[1],
43
+ progress: 0
44
+ };
45
+ }
46
+ let xpTotal = 0;
47
+ let level = 0;
48
+ let xpForNext = 0;
49
+ for (let x = 1; x <= maxLevel; x++) {
50
+ if (!xpTable[x]) continue;
51
+ xpTotal += xpTable[x];
52
+ if (xpTotal > xp) {
53
+ xpTotal -= xpTable[x];
54
+ break;
55
+ } else {
56
+ level = x;
57
+ }
58
+ }
59
+ const xpCurrent = Math.floor(xp - xpTotal);
60
+ if (level < maxLevel) xpForNext = Math.ceil(xpTable[level + 1]);
61
+ const progress = Math.floor(Math.max(0, Math.min(xpCurrent / xpForNext, 1)) * 100 * 10) / 10;
62
+
63
+ return {
64
+ xp,
65
+ level,
66
+ maxLevel,
67
+ xpCurrent,
68
+ xpForNext,
69
+ progress
70
+ };
71
+ },
72
+ getLevelByAchievement(achievementLevel, type) {
73
+ let xpTable = constants.leveling_xp;
74
+ let maxLevel = Math.max(...Object.keys(xpTable));
75
+ if (constants.skills_cap[type] > maxLevel && type in constants.skills_achievements) {
76
+ xpTable = Object.assign(constants.xp_past_50, xpTable);
77
+ maxLevel = Math.max(...Object.keys(xpTable));
78
+ }
79
+ if (isNaN(achievementLevel)) {
80
+ return {
81
+ xp: 0,
82
+ level: 0,
83
+ maxLevel,
84
+ xpCurrent: 0,
85
+ xpForNext: xpTable[1],
86
+ progress: 0
87
+ };
88
+ }
89
+ let xpTotal = 0;
90
+ let xpForNext = 0;
91
+ for (let x = 1; x <= achievementLevel; x++) {
92
+ xpTotal += xpTable[x];
93
+ }
94
+ if (achievementLevel < maxLevel) xpForNext = Math.ceil(xpTable[achievementLevel + 1]);
95
+ return {
96
+ xp: xpTotal,
97
+ level: achievementLevel,
98
+ maxLevel,
99
+ xpCurrent: 0,
100
+ xpForNext,
101
+ progress: 0
102
+ };
103
+ },
104
+ getSlayerLevel(slayer) {
105
+ if (!slayer) {
106
+ return {
107
+ xp: 0,
108
+ tier1: 0,
109
+ tier2: 0,
110
+ tier3: 0,
111
+ tier4: 0,
112
+ tier5: 0,
113
+ level: 0
114
+ };
115
+ }
116
+ const { claimed_levels } = slayer;
117
+ let level = 0;
118
+ for (const level_name in claimed_levels) {
119
+ if (Object.prototype.hasOwnProperty.call(claimed_levels, level_name)) {
120
+ const _level = parseInt(level_name.replace('_special', '').split('_').pop(), 10);
121
+ if (_level > level) {
122
+ level = _level;
123
+ }
124
+ }
125
+ }
126
+ return {
127
+ xp: slayer.xp || 0,
128
+ tier1: slayer.boss_kills_tier_0 || 0,
129
+ tier2: slayer.boss_kills_tier_1 || 0,
130
+ tier3: slayer.boss_kills_tier_2 || 0,
131
+ tier4: slayer.boss_kills_tier_3 || 0,
132
+ tier5: slayer.boss_kills_tier_4 || 0,
133
+ level
134
+ };
135
+ },
136
+ getSlayerLevelByXp(xp) {
137
+ const { slayer_xp } = constants;
138
+ const maxLevel = Math.max(...Object.keys(slayer_xp));
139
+ let level = 0;
140
+ for (let x = 1; x <= maxLevel && slayer_xp[x] <= xp; x++) {
141
+ level = x;
142
+ }
143
+ return level;
144
+ },
145
+ getBonusStat(level, skill, max, incremention) {
146
+ const skill_stats = constants.bonus_stats[skill];
147
+ const steps = Object.keys(skill_stats)
148
+ .sort((a, b) => Number(a) - Number(b))
149
+ .map((a) => Number(a));
150
+ const bonus = Object.assign({}, constants.stat_template);
151
+ for (let x = steps[0]; x <= max; x += incremention) {
152
+ if (level < x) {
153
+ break;
154
+ }
155
+ const skill_step = steps
156
+ .slice()
157
+ .reverse()
158
+ .find((a) => a <= x);
159
+ const skill_bonus = skill_stats[skill_step];
160
+ for (const skill in skill_bonus) {
161
+ if (Object.prototype.hasOwnProperty.call(skill_bonus, skill)) {
162
+ bonus[skill] += skill_bonus[skill];
163
+ }
164
+ }
165
+ }
166
+ return bonus;
167
+ },
168
+ getEffectiveHealth(health, defense) {
169
+ if (defense <= 0) return health;
170
+ return Math.round(health * (1 + defense / 100));
171
+ },
172
+ getMemberStats(obj) {
173
+ return Object.keys(obj).reduce(
174
+ (result, currentKey) => {
175
+ const key = currentKey.replace(/_[a-z]/gi, (match) => match[1].toUpperCase());
176
+
177
+ if (currentKey.startsWith('kills') || currentKey.startsWith('deaths')) {
178
+ const category = currentKey.startsWith('kills') ? 'kills' : 'deaths';
179
+ const subKey = key === category ? 'total' : key;
180
+
181
+ result[category][
182
+ subKey.replace(category, (sub, _, key) => {
183
+ return key[sub.length].toLowerCase() + key.slice(sub.length + 1);
184
+ })
185
+ ] = obj[currentKey];
186
+ } else {
187
+ result[key] = obj[currentKey];
188
+ }
189
+
190
+ return result;
191
+ },
192
+ { kills: {}, deaths: {} }
193
+ );
194
+ },
195
+ getTrophyFishRank(level) {
196
+ if (level === 1) {
197
+ return 'Bronze';
198
+ } else if (level === 2) {
199
+ return 'Silver';
200
+ } else if (level === 3) {
201
+ return 'Gold';
202
+ } else if (level === 4) {
203
+ return 'Diamond';
204
+ } else {
205
+ return 'Bronze';
206
+ }
207
+ }
208
+ };
@@ -1,4 +1,4 @@
1
- module.exports = {
2
- isStrArray: (input) => Array.isArray(input) || typeof input === 'string',
3
- strToArray: (input) => [input].flat()
4
- };
1
+ module.exports = {
2
+ isStrArray: (input) => Array.isArray(input) || typeof input === 'string',
3
+ strToArray: (input) => [input].flat()
4
+ };
@@ -1,5 +1,5 @@
1
- module.exports = (a=0, b=1) => {
2
- const out = +((a || 0) / (b || 0)).toFixed(2) || 0;
3
- if (isFinite(out)) return out;
4
- return a;
5
- };
1
+ module.exports = (a = 0, b = 1) => {
2
+ const out = +((a || 0) / (b || 0)).toFixed(2) || 0;
3
+ if (isFinite(out)) return out;
4
+ return a;
5
+ };
@@ -1,67 +1,57 @@
1
- const dateRegExp = /(\d{4})-(\d{2})-(\d{2})/;
2
- /**
3
- * Parses exp history
4
- * @param {object} historyData History data from the API
5
- * @returns {ExpHistory[]} Array of ExpHistory
6
- */
7
- function parseHistory(historyData) {
8
- return Object.entries(historyData).map((x, index) => ({
9
- day: x[0],
10
- date: parseDate(x[0].match(dateRegExp).slice(1).map((x) => parseInt(x, 10))) || undefined,
11
- exp: x[1] || 0,
12
- totalExp: Object.values(historyData).slice(0, index + 1).reduce((pV, cV) => pV + cV, 0)
13
- }));
14
- }
15
-
16
- /**
17
- * Parses date
18
- * Because hypixel's oscillation precises that exp resets at 5 am UTC, the hour is set accordingly
19
- * @param {number[]} date Date from regexp
20
- * @returns {Date} Parsed Date
21
- */
22
- function parseDate(date) {
23
- date[1] -= 1;
24
- return new Date(Math.round(new Date(new Date().setUTCFullYear(...date)).setUTCHours(5, 0, 0) / 1000) * 1000);
25
- }
26
-
27
- /**
28
- * Converts guild exp to guild level ( possible rewrite )
29
- * @param {number} exp Experience
30
- * @return {number}
31
- */
32
- function getGuildLevel(exp) {
33
- if (exp < 100000) {
34
- return 0;
35
- } else if (exp < 250000) {
36
- return 1;
37
- } else if (exp < 500000) {
38
- return 2;
39
- } else if (exp < 1000000) {
40
- return 3;
41
- } else if (exp < 1750000) {
42
- return 4;
43
- } else if (exp < 2750000) {
44
- return 5;
45
- } else if (exp < 4000000) {
46
- return 6;
47
- } else if (exp < 5500000) {
48
- return 7;
49
- } else if (exp < 7500000) {
50
- return 8;
51
- } else if (exp >= 7500000) {
52
- if (exp < 15000000) {
53
- return Math.floor((exp - 7500000) / 2500000) + 9;
54
- } else {
55
- return Math.floor((exp - 15000000) / 3000000) + 12;
56
- }
57
- }
58
- }
59
-
60
- /**
61
- * @typedef {object} ExpHistory
62
- * @property {string} day String Date ( unparsed )
63
- * @property {Date} date Parsed Date
64
- * @property {number} exp Experience of the day
65
- * @property {number} totalExp Experience earned from day 0 to this day
66
- */
67
- module.exports = {parseHistory, getGuildLevel};
1
+ const dateRegExp = /(\d{4})-(\d{2})-(\d{2})/;
2
+ // eslint-disable-next-line require-jsdoc
3
+ function parseHistory(historyData) {
4
+ return Object.entries(historyData).map((x, index) => ({
5
+ day: x[0],
6
+ date:
7
+ parseDate(
8
+ x[0]
9
+ .match(dateRegExp)
10
+ .slice(1)
11
+ .map((x) => parseInt(x, 10))
12
+ ) || undefined,
13
+ exp: x[1] || 0,
14
+ totalExp: Object.values(historyData)
15
+ .slice(0, index + 1)
16
+ .reduce((pV, cV) => pV + cV, 0)
17
+ }));
18
+ }
19
+
20
+ // eslint-disable-next-line require-jsdoc
21
+ function parseDate(date) {
22
+ date[1] -= 1;
23
+ return new Date(Math.round(new Date(new Date().setUTCFullYear(...date)).setUTCHours(5, 0, 0) / 1000) * 1000);
24
+ }
25
+
26
+ // eslint-disable-next-line require-jsdoc
27
+ function getGuildLevel(exp) {
28
+ const EXP_NEEDED = [100000, 150000, 250000, 500000, 750000, 1000000, 1250000, 1500000, 2000000, 2500000, 2500000, 2500000, 2500000, 2500000, 3000000];
29
+
30
+ let level = 0;
31
+
32
+ for (let i = 0; i <= 1000; i += 1) {
33
+ let need = 0;
34
+ if (i >= EXP_NEEDED.length) {
35
+ need = EXP_NEEDED[EXP_NEEDED.length - 1];
36
+ } else {
37
+ need = EXP_NEEDED[i];
38
+ }
39
+
40
+ if (exp - need < 0) {
41
+ return Math.round((level + exp / need) * 100) / 100;
42
+ }
43
+ level += 1;
44
+ exp -= need;
45
+ }
46
+
47
+ return 1000;
48
+ }
49
+
50
+ /**
51
+ * @typedef {object} ExpHistory
52
+ * @property {string} day String Date ( unparsed )
53
+ * @property {Date} date Parsed Date
54
+ * @property {number} exp Experience of the day
55
+ * @property {number} totalExp Experience earned from day 0 to this day
56
+ */
57
+ module.exports = { parseHistory, getGuildLevel };
@@ -1,9 +1,13 @@
1
- /* eslint-disable no-extend-native */
2
- const fs = require('fs');
3
- // eslint-disable-next-line no-path-concat
4
- const curDir = __dirname + '/';
5
- module.exports = Array.from(fs.readdirSync(curDir, { withFileTypes: true }))
6
- .filter((x) => x.name !== 'index.js')
7
- .map((x) => x.isDirectory() ? Array.from(fs.readdirSync(curDir + x.name)).map((y) => ([y.split('.')[0], x.name + '/' + y])) : [[x.name.split('.')[0], x.name]])
8
- .flat(1)
9
- .reduce((pV, cV) => Object.assign(pV, { [cV[0]]: require(curDir + cV[1]) }), {});
1
+ module.exports = {
2
+ arrayTool: require('./arrayTools'),
3
+ Constants: require('./Constants'),
4
+ divide: require('./divide'),
5
+ isGuildID: require('./isGuildID'),
6
+ isUUID: require('./isUUID'),
7
+ oscillation: require('./oscillation'),
8
+ removeSnakeCase: require('./removeSnakeCase'),
9
+ SkyblockUtils: require('./SkyblockUtils'),
10
+ toIGN: require('./toIGN'),
11
+ toUuid: require('./toUuid'),
12
+ varInt: require('./varInt')
13
+ };
@@ -1,3 +1,3 @@
1
- module.exports = (id) => {
2
- return id.length === 24;
3
- };
1
+ module.exports = (id) => {
2
+ return id.length === 24;
3
+ };
@@ -1,5 +1,5 @@
1
- module.exports = (uuid) => {
2
- const regexp = /^[0-9a-f]{32}$/i;
3
- uuid = uuid.replace(/-/g, '');
4
- return regexp.test(uuid);
5
- };
1
+ module.exports = (uuid) => {
2
+ const regexp = /^[0-9a-f]{32}$/i;
3
+ uuid = uuid.replace(/-/g, '');
4
+ return regexp.test(uuid);
5
+ };
@@ -1,23 +1,15 @@
1
- // See https://github.com/HypixelDev/PublicAPI/blob/db26b5fd3b7bb29da14e40e6d211143ec44a4519/Documentation/misc/Oscillation.md
2
- // Month oscillation started in December 2014, so every month that is pair ( odd in js!! ) is month A
3
- // Weekly oscillation started... just refer to the code in the docs
4
- /**
5
- * Checks if month is A or B
6
- * @param {number|Date} [date] Timestamp or date, defaults to now
7
- * @return {'a'|'b'}
8
- */
9
- function monthAB (date = Date.now()) {
10
- return new Date(date).getMonth() % 2 ? 'a' : 'b';
11
- }
12
-
13
- const weeklyOscillationStart = 1417237200000;
14
- /**
15
- * Checks if week is A or B
16
- * @param {number|Date} [date] Timestamp or date, defaults to now
17
- * @return {'a'|'b'}
18
- */
19
- function weekAB (date = Date.now()) {
20
- return (Math.abs(new Date(date).getTime() - weeklyOscillationStart) / 604800000) % 2 ? 'a' : 'b';
21
- }
22
-
23
- module.exports = { monthAB, weekAB };
1
+ // See https://github.com/HypixelDev/PublicAPI/blob/db26b5fd3b7bb29da14e40e6d211143ec44a4519/Documentation/misc/Oscillation.md
2
+ // Month oscillation started in December 2014, so every month that is pair ( odd in js!! ) is month A
3
+ // Weekly oscillation started... just refer to the code in the docs
4
+ // eslint-disable-next-line require-jsdoc
5
+ function monthAB(date = Date.now()) {
6
+ return new Date(date).getMonth() % 2 ? 'a' : 'b';
7
+ }
8
+
9
+ const weeklyOscillationStart = 1417237200000;
10
+ // eslint-disable-next-line require-jsdoc
11
+ function weekAB(date = Date.now()) {
12
+ return (Math.abs(new Date(date).getTime() - weeklyOscillationStart) / 604800000) % 2 ? 'a' : 'b';
13
+ }
14
+
15
+ module.exports = { monthAB, weekAB };