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,164 +1,208 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
const constants = require('./Constants');
|
|
3
|
-
module.exports = {
|
|
4
|
-
async decode
|
|
5
|
-
const nbt = require('prismarine-nbt');
|
|
6
|
-
const parseNbt =
|
|
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
|
|
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
|
-
|
|
26
|
-
xpTable = constants.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
+
};
|
package/src/utils/arrayTools.js
CHANGED
|
@@ -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
|
+
};
|
package/src/utils/divide.js
CHANGED
|
@@ -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
|
+
};
|
package/src/utils/guildExp.js
CHANGED
|
@@ -1,67 +1,57 @@
|
|
|
1
|
-
const dateRegExp = /(\d{4})-(\d{2})-(\d{2})/;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
date
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 };
|
package/src/utils/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
};
|
package/src/utils/isGuildID.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports = (id) => {
|
|
2
|
-
return id.length === 24;
|
|
3
|
-
};
|
|
1
|
+
module.exports = (id) => {
|
|
2
|
+
return id.length === 24;
|
|
3
|
+
};
|
package/src/utils/isUUID.js
CHANGED
|
@@ -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
|
+
};
|
package/src/utils/oscillation.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 };
|