gj-boomlings-api 1.0.1 → 1.0.2
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/docs/dlLevel.md +4 -4
- package/docs/objects/level.md +9 -9
- package/functions/dlLevel.js +100 -180
- package/index.js +4 -1
- package/misc/decodeLevel.js +0 -2
- package/misc/decodeMapPack.js +32 -20
- package/package.json +1 -1
package/docs/dlLevel.md
CHANGED
|
@@ -21,8 +21,8 @@ gd.dlLevel(58825144).then(console.log);
|
|
|
21
21
|
level_version: 2,
|
|
22
22
|
difficulty: 'Extreme Demon',
|
|
23
23
|
stars: 10,
|
|
24
|
-
downloads:
|
|
25
|
-
likes:
|
|
24
|
+
downloads: 2640560,
|
|
25
|
+
likes: 107918,
|
|
26
26
|
disliked: false,
|
|
27
27
|
length: 'XL',
|
|
28
28
|
password: '000007',
|
|
@@ -30,8 +30,8 @@ gd.dlLevel(58825144).then(console.log);
|
|
|
30
30
|
featured: false,
|
|
31
31
|
epic: false,
|
|
32
32
|
objects: 37838,
|
|
33
|
-
uploaded: '
|
|
34
|
-
updated: '
|
|
33
|
+
uploaded: '3 years',
|
|
34
|
+
updated: '3 years',
|
|
35
35
|
stars_requested: 10,
|
|
36
36
|
game_version: '2.1',
|
|
37
37
|
ldm: false,
|
package/docs/objects/level.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Level object
|
|
2
2
|
|
|
3
|
-
Used by
|
|
3
|
+
Used by `dlLevel()`, `getLevelByID()` and `getUserLevels()`.
|
|
4
4
|
|
|
5
5
|
## Example
|
|
6
6
|
```
|
|
@@ -12,8 +12,8 @@ Used by ```dlLevel()```.
|
|
|
12
12
|
level_version: 2,
|
|
13
13
|
difficulty: 'Extreme Demon',
|
|
14
14
|
stars: 10,
|
|
15
|
-
downloads:
|
|
16
|
-
likes:
|
|
15
|
+
downloads: 2640560,
|
|
16
|
+
likes: 107918,
|
|
17
17
|
disliked: false,
|
|
18
18
|
length: 'XL',
|
|
19
19
|
password: '000007',
|
|
@@ -21,8 +21,8 @@ Used by ```dlLevel()```.
|
|
|
21
21
|
featured: false,
|
|
22
22
|
epic: false,
|
|
23
23
|
objects: 37838,
|
|
24
|
-
uploaded: '
|
|
25
|
-
updated: '
|
|
24
|
+
uploaded: '3 years',
|
|
25
|
+
updated: '3 years',
|
|
26
26
|
stars_requested: 10,
|
|
27
27
|
game_version: '2.1',
|
|
28
28
|
ldm: false,
|
|
@@ -60,11 +60,11 @@ Used by ```dlLevel()```.
|
|
|
60
60
|
|
|
61
61
|
```likes``` - the amount of level likes.
|
|
62
62
|
|
|
63
|
-
```disliked``` - a boolean that shows if the level is disliked. Returns
|
|
63
|
+
```disliked``` - a boolean that shows if the level is disliked. Returns `true` if the like amount is negative, otherwise it's `false`.
|
|
64
64
|
|
|
65
65
|
```length``` - the level length.
|
|
66
66
|
|
|
67
|
-
```password``` - the level password. It may return
|
|
67
|
+
```password``` - the level password. It may return `''` (an empty string) if the level is not copyable, or `'1'` if the level is free to copy.
|
|
68
68
|
|
|
69
69
|
```demon``` - a boolean that shows if the level is demon.
|
|
70
70
|
|
|
@@ -78,13 +78,13 @@ Used by ```dlLevel()```.
|
|
|
78
78
|
|
|
79
79
|
```updated``` - when the level has been last updated.
|
|
80
80
|
|
|
81
|
-
```stars_requested``` - basically how many stars the creator has requested. Returns
|
|
81
|
+
```stars_requested``` - basically how many stars the creator has requested. Returns`0` if no stars have been requested.
|
|
82
82
|
|
|
83
83
|
```game_version``` - the version required to play the level. Returns `Pre-1.7` if the level has been uploaded or last updated earlier, than 1.7 came out.
|
|
84
84
|
|
|
85
85
|
```ldm``` - a boolean that shows if the level has a "Low Detail Mode" checkbox.
|
|
86
86
|
|
|
87
|
-
```copied``` - the original level ID, that got copied. Returns
|
|
87
|
+
```copied``` - the original level ID, that got copied. Returns `0` if the level is already original.
|
|
88
88
|
|
|
89
89
|
```two_p``` - a boolean that shows if the level is in the 2-player mode.
|
|
90
90
|
|
package/functions/dlLevel.js
CHANGED
|
@@ -4,6 +4,7 @@ module.exports = {
|
|
|
4
4
|
const bs = require("js-base64")
|
|
5
5
|
if(!level || level == "") throw new Error("Please provide a level ID.");
|
|
6
6
|
if(isNaN(level)) throw new Error("The level parameter should be a number.");
|
|
7
|
+
|
|
7
8
|
const axios = require("axios");
|
|
8
9
|
const { headers, server } = require("../config.json");
|
|
9
10
|
|
|
@@ -22,40 +23,63 @@ module.exports = {
|
|
|
22
23
|
headers: headers
|
|
23
24
|
})
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
let
|
|
35
|
-
let
|
|
36
|
-
let
|
|
37
|
-
let
|
|
38
|
-
let
|
|
39
|
-
let
|
|
40
|
-
let
|
|
41
|
-
let
|
|
42
|
-
let
|
|
43
|
-
let
|
|
44
|
-
let
|
|
45
|
-
let
|
|
46
|
-
let
|
|
47
|
-
let
|
|
48
|
-
let
|
|
49
|
-
let
|
|
50
|
-
let
|
|
51
|
-
let
|
|
52
|
-
let
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
26
|
+
let spl = res.data.split(":");
|
|
27
|
+
let levelInfo = [];
|
|
28
|
+
for(let i =0;i<spl.length;i++) {
|
|
29
|
+
if(i%2!=0) {
|
|
30
|
+
levelInfo.push(spl[i-1]+`:`+spl[i]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let id = levelInfo[0].split("1:")[1];
|
|
35
|
+
let name = levelInfo[1].split("2:")[1];
|
|
36
|
+
let description = bs.decode(levelInfo[2].split("3:")[1])
|
|
37
|
+
let version = levelInfo[4].split("5:")[1];
|
|
38
|
+
let difficulty = levelInfo[7].split("9:")[1];
|
|
39
|
+
let downloads = levelInfo[8].split("10:")[1];
|
|
40
|
+
let officialSong = levelInfo[9].split("12:")[1];
|
|
41
|
+
let gameVersion = levelInfo[10].split("13:")[1];
|
|
42
|
+
let likes = levelInfo[11].split("14:")[1];
|
|
43
|
+
let demonBool = levelInfo[12].split("17:")[1];
|
|
44
|
+
let stars = levelInfo[15].split("18:")[1];
|
|
45
|
+
let ftrd = levelInfo[16].split("19:")[1];
|
|
46
|
+
let epic = levelInfo[17].split("42:")[1];
|
|
47
|
+
let objects = levelInfo[18].split("45:")[1];
|
|
48
|
+
let length = levelInfo[19].split("15:")[1];
|
|
49
|
+
let copiedID = levelInfo[20].split("30:")[1];
|
|
50
|
+
let twoPlayer = levelInfo[21].split("31:")[1];
|
|
51
|
+
let uploaded = levelInfo[22].split("28:")[1];
|
|
52
|
+
let updated = levelInfo[23].split("29:")[1];
|
|
53
|
+
let customSong = levelInfo[24].split("35:")[1];
|
|
54
|
+
let coins = levelInfo[26].split("37:")[1];
|
|
55
|
+
let verifiedCoins = levelInfo[27].split("38:")[1];
|
|
56
|
+
let starsRequested = levelInfo[28].split("39:")[1];
|
|
57
|
+
let ldm = levelInfo[31].split("40:")[1];
|
|
58
|
+
let password = xor.decrypt(levelInfo[32].split("27:")[1].split("#")[0], 26364);
|
|
59
|
+
|
|
60
|
+
let disliked = false;
|
|
61
|
+
if(likes.includes("-")) disliked = true;
|
|
62
|
+
|
|
63
|
+
if(verifiedCoins == "0") verifiedCoins = false;
|
|
64
|
+
if(verifiedCoins == "1") verifiedCoins = true;
|
|
65
|
+
|
|
66
|
+
let demonBoolDecoding = {
|
|
67
|
+
'1': true,
|
|
68
|
+
'': false,
|
|
69
|
+
'0': false
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let featuredDecoding = {
|
|
73
|
+
"0": false,
|
|
74
|
+
"1": true,
|
|
75
|
+
undefined: true
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let featured = featuredDecoding[ftrd];
|
|
79
|
+
if(featured == undefined) featured = true;
|
|
57
80
|
|
|
58
81
|
let difficultyDecoding = {
|
|
82
|
+
"-10": "Auto",
|
|
59
83
|
"0": "Unrated",
|
|
60
84
|
"10": "Easy",
|
|
61
85
|
"20": "Normal",
|
|
@@ -64,7 +88,7 @@ module.exports = {
|
|
|
64
88
|
"50": "Insane"
|
|
65
89
|
}
|
|
66
90
|
|
|
67
|
-
if(
|
|
91
|
+
if(demonBoolDecoding[demonBool] == true) {
|
|
68
92
|
difficultyDecoding = {
|
|
69
93
|
"10": "Easy Demon",
|
|
70
94
|
"20": "Medium Demon",
|
|
@@ -73,28 +97,7 @@ module.exports = {
|
|
|
73
97
|
"50": "Extreme Demon"
|
|
74
98
|
}
|
|
75
99
|
}
|
|
76
|
-
|
|
77
|
-
const binaryBool = {
|
|
78
|
-
undefined: false,
|
|
79
|
-
"0": false,
|
|
80
|
-
"1": true
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const featuredDecoding = {
|
|
84
|
-
undefined: true,
|
|
85
|
-
"0": false,
|
|
86
|
-
"1": true
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
let featured = featuredDecoding[split12.split(":42:")[0]];
|
|
90
|
-
if(featured == undefined) featured = true;
|
|
91
|
-
|
|
92
|
-
let demonBool = binaryBool[split11.split(":43:")[0]];
|
|
93
|
-
if(split11.split(":43:")[0] == "") demonBool = false;
|
|
94
|
-
|
|
95
|
-
let ldm = binaryBool[split18.split(":27")[0]]
|
|
96
|
-
if(ldm == undefined) ldm = false;
|
|
97
|
-
|
|
100
|
+
|
|
98
101
|
const lengthDecoding = {
|
|
99
102
|
"0": "Tiny",
|
|
100
103
|
"1": "Short",
|
|
@@ -102,59 +105,15 @@ module.exports = {
|
|
|
102
105
|
"3": "Long",
|
|
103
106
|
"4": "XL"
|
|
104
107
|
}
|
|
105
|
-
if(lengthDecoding[split9.split(":30:")[0]] == undefined) split9 = res.data.split(":15:")[2];
|
|
106
|
-
|
|
107
|
-
let desc = bs.decode(split3.split(":4:")[0].replace(/_/g, '/').replace(/-/g, '+'));
|
|
108
|
-
if(desc == "") desc = "(No description provided)"
|
|
109
|
-
|
|
110
|
-
let likes = split8.split(":17:")[0];
|
|
111
|
-
let dislikedBool;
|
|
112
|
-
if(likes.includes("-")) {
|
|
113
|
-
dislikedBool = true;
|
|
114
|
-
} else {
|
|
115
|
-
dislikedBool = false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const decryptedPass = xor.decrypt(split10, 26364);
|
|
119
|
-
if (decryptedPass.length > 1) split10 = decryptedPass.slice(1);
|
|
120
|
-
else split10 = decryptedPass;
|
|
121
|
-
if (decryptedPass.length > 7) split10 = "Non-copyable";
|
|
122
|
-
|
|
123
|
-
const authData = {
|
|
124
|
-
gameVersion: 21,
|
|
125
|
-
binaryVersion: 35,
|
|
126
|
-
gdw: 0,
|
|
127
|
-
str: split23.split(":8:")[0],
|
|
128
|
-
secret: "Wmfd2893gb7"
|
|
129
|
-
}
|
|
130
|
-
let auth = await axios.post(server + "getGJUsers20.php", authData, {
|
|
131
|
-
headers: headers
|
|
132
|
-
})
|
|
133
|
-
let authname;
|
|
134
|
-
if(auth.data == "-1") {
|
|
135
|
-
authname = "-"
|
|
136
|
-
} else if(!auth.data.startsWith("-")) {
|
|
137
|
-
authname = auth.data.split("1:")[1].split(":2:")[0];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const { getSongInfo } = require("./getSongInfo.js");
|
|
141
|
-
const { getOfficialSongInfo } = require("./getOfficialSongInfo.js");
|
|
142
|
-
let song;
|
|
143
|
-
|
|
144
|
-
let copiedId = split19.split(":31:")[0];
|
|
145
|
-
if(copiedId.includes(":")) split19 = res.data.split(":30:")[2];
|
|
146
|
-
|
|
147
|
-
let starsCount = split6.split(":19:")[0];
|
|
148
|
-
if(starsCount.includes(":")) split6 = res.data.split(":18:")[2];
|
|
149
108
|
|
|
150
109
|
const decodeGameVersion = {
|
|
151
|
-
"1": "1.
|
|
152
|
-
"2": "1.
|
|
153
|
-
"3": "1.
|
|
154
|
-
"4": "1.
|
|
155
|
-
"5": "1.
|
|
156
|
-
"6": "1.
|
|
157
|
-
"7": "1.
|
|
110
|
+
"1": "Pre-1.7",
|
|
111
|
+
"2": "Pre-1.7",
|
|
112
|
+
"3": "Pre-1.7",
|
|
113
|
+
"4": "Pre-1.7",
|
|
114
|
+
"5": "Pre-1.7",
|
|
115
|
+
"6": "Pre-1.7",
|
|
116
|
+
"7": "Pre-1.7",
|
|
158
117
|
"10": "1.7",
|
|
159
118
|
"18": "1.8",
|
|
160
119
|
"19": "1.9",
|
|
@@ -162,79 +121,40 @@ module.exports = {
|
|
|
162
121
|
"21": "2.1"
|
|
163
122
|
}
|
|
164
123
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
let
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
} else if(split25.split(":13:")[0] != "0" && split26.split(":36:")[0] == "0") {
|
|
204
|
-
song = getOfficialSongInfo(offSongID);
|
|
205
|
-
} else if(split25.split(":13:")[0] == "0" && split26.split(":36:")[0] == "0") {
|
|
206
|
-
song = getOfficialSongInfo(1);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const result = {
|
|
210
|
-
"id": Number(split1.split(":2:")[0]),
|
|
211
|
-
"name": split2.split(":3:")[0].toString(),
|
|
212
|
-
"description": desc.trim(),
|
|
213
|
-
"creator": authname,
|
|
214
|
-
"level_version": Number(split4.split(":6:")[0]),
|
|
215
|
-
"difficulty": difficultyDecoding[split5.split(":10:")[0]].toString(),
|
|
216
|
-
"stars": Number(split6.split(":19:")[0]),
|
|
217
|
-
"downloads": Number(split7.split(":12:")[0]),
|
|
218
|
-
"likes": Number(likes),
|
|
219
|
-
"disliked": dislikedBool,
|
|
220
|
-
"length": lengthDecoding[split9.split(":30:")[0]],
|
|
221
|
-
"password": split10,
|
|
222
|
-
"demon": demonBool,
|
|
223
|
-
"featured": featured,
|
|
224
|
-
"epic": featuredDecoding[split13.split(":45:")[0]],
|
|
225
|
-
"objects": Number(objs),
|
|
226
|
-
"uploaded": split15.split(":29:")[0],
|
|
227
|
-
"updated": split16.split(":35:")[0],
|
|
228
|
-
"stars_requested": Number(split17.split(":46:")[0]),
|
|
229
|
-
"game_version": decodeGameVersion[split24.split(":14:")[0]],
|
|
230
|
-
"ldm": ldm,
|
|
231
|
-
"copied": Number(split19.split(":31:")[0]),
|
|
232
|
-
"two_p": binaryBool[split20.split(":28:")[0]],
|
|
233
|
-
"coins": Number(split21.split(":38:")[0]),
|
|
234
|
-
"verified_coins": binaryBool[split22.split(":39:")[0]],
|
|
235
|
-
"song": song
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return result;
|
|
124
|
+
if(description == '') description = "(No description provided)";
|
|
125
|
+
|
|
126
|
+
const { getLevelByID } = require("./getLevelByID.js");
|
|
127
|
+
let basicInfoAboutLevel = await getLevelByID(id);
|
|
128
|
+
|
|
129
|
+
const result = {
|
|
130
|
+
id: Number(id),
|
|
131
|
+
name: name,
|
|
132
|
+
description: description,
|
|
133
|
+
creator: basicInfoAboutLevel.creator,
|
|
134
|
+
level_version: Number(version),
|
|
135
|
+
difficulty: difficultyDecoding[difficulty],
|
|
136
|
+
stars: Number(stars),
|
|
137
|
+
downloads: Number(downloads),
|
|
138
|
+
likes: Number(likes),
|
|
139
|
+
disliked: disliked,
|
|
140
|
+
length: lengthDecoding[length],
|
|
141
|
+
password: password.replace("1", ""),
|
|
142
|
+
demon: demonBoolDecoding[demonBool],
|
|
143
|
+
featured: featured,
|
|
144
|
+
epic: demonBoolDecoding[epic],
|
|
145
|
+
objects: Number(objects),
|
|
146
|
+
uploaded: uploaded,
|
|
147
|
+
updated: updated,
|
|
148
|
+
stars_requested: Number(starsRequested),
|
|
149
|
+
game_version: decodeGameVersion[gameVersion],
|
|
150
|
+
ldm: demonBoolDecoding[ldm],
|
|
151
|
+
copied: Number(copiedID),
|
|
152
|
+
two_p: demonBoolDecoding[twoPlayer],
|
|
153
|
+
coins: Number(coins),
|
|
154
|
+
verified_coins: verifiedCoins,
|
|
155
|
+
song: basicInfoAboutLevel.song,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return result;
|
|
239
159
|
}
|
|
240
160
|
}
|
package/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
console.log('\x1b[32m%s\x1b[40m', 'Thanks for using gj-boomlings-api!\nhttps://github.com/shikoshib/gj-boomlings-api');
|
|
2
|
+
console.log('\x1b[37m%s\x1b[0m', '');
|
|
3
|
+
|
|
1
4
|
const { dlLevel } = require("./functions/dlLevel.js");
|
|
2
5
|
const { getSongInfo } = require("./functions/getSongInfo.js");
|
|
3
6
|
const { getOfficialSongInfo } = require("./functions/getOfficialSongInfo.js");
|
|
@@ -23,7 +26,7 @@ const { deleteAccountPost } = require("./functions/deleteAccountPost.js");
|
|
|
23
26
|
const { getUserLevels } = require("./functions/getUserLevels.js");
|
|
24
27
|
const { searchLevels } = require("./functions/searchLevels.js");
|
|
25
28
|
|
|
26
|
-
module.exports.dlLevel = dlLevel;
|
|
29
|
+
module.exports.dlLevel = dlLevel;
|
|
27
30
|
module.exports.getSongInfo = getSongInfo;
|
|
28
31
|
module.exports.getOfficialSongInfo = getOfficialSongInfo;
|
|
29
32
|
module.exports.decURLSafeBase64 = decURLSafeBase64;
|
package/misc/decodeLevel.js
CHANGED
package/misc/decodeMapPack.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
decodeMapPack:
|
|
3
3
|
function(mp) {
|
|
4
|
-
let name = mp.split(":2:")[1].split(":3:")[0];
|
|
5
|
-
let unarrayedList = mp.split(":3:")[1].split(":4:")[0].split(":4")[0];
|
|
6
|
-
let stars = mp.split(":4:")[1].split(":5:")[0];
|
|
7
|
-
let coins = mp.split(":5:")[1].split(":6:")[0];
|
|
8
|
-
let difficulty = mp.split(":6:")[1].split(":7:")[0];
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
let spl = mp.split(':');
|
|
6
|
+
let mpInfo = [];
|
|
7
|
+
for(let i =0;i<spl.length;i++) {
|
|
8
|
+
if(i%2!=0) {
|
|
9
|
+
mpInfo.push(spl[i-1]+`:`+spl[i]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
11
12
|
|
|
13
|
+
let mappackID = mpInfo[0].split("1:")[1];
|
|
14
|
+
let name = mpInfo[1].split("2:")[1];
|
|
15
|
+
let unarrayedList = mpInfo[2].split("3:")[1];
|
|
16
|
+
let stars = mpInfo[3].split("4:")[1];
|
|
17
|
+
let coins = mpInfo[4].split("5:")[1];
|
|
18
|
+
let difficulty = mpInfo[5].split("6:")[1];
|
|
19
|
+
let txtCol = mpInfo[6].split("7:")[1];
|
|
20
|
+
let barCol = mpInfo[7].split("8:")[1];
|
|
21
|
+
|
|
12
22
|
let firstLvl = unarrayedList.split(",")[0];
|
|
13
23
|
let secondLvl = unarrayedList.split(",")[1].split(",")[0];
|
|
14
24
|
let thirdLvl = unarrayedList.split(",")[2].split(",")[0];
|
|
15
25
|
|
|
16
|
-
if(name.includes(":")) name = name.split("2:")[1]
|
|
17
|
-
|
|
18
26
|
let difficultyDecoder = {
|
|
19
27
|
"0": "Auto",
|
|
20
28
|
"1": "Easy",
|
|
@@ -29,25 +37,29 @@ module.exports = {
|
|
|
29
37
|
"10": "Extreme Demon",
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
function rgbToHEX(color) {
|
|
41
|
+
let r = color.split(",")[0];
|
|
42
|
+
let g = color.split(",")[1].split(",")[0];
|
|
43
|
+
let b = color.split(",")[2];
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
if(coins.includes(":")) {
|
|
38
|
-
coins = mp.split(":5:")[2].split(":6:")[0];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
45
|
+
if(b.includes("#")) b = b.split("#")[0]
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
let rHex = Number(r).toString(16);
|
|
48
|
+
let gHex = Number(g).toString(16);
|
|
49
|
+
let bHex = Number(b).toString(16);
|
|
50
|
+
|
|
51
|
+
return `#${rHex.length == 1 ? "0" + rHex : rHex}${gHex.length == 1 ? "0" + gHex : gHex}${bHex.length == 1 ? "0" + bHex : bHex}`.toUpperCase();
|
|
52
|
+
}
|
|
45
53
|
|
|
46
54
|
const result = {
|
|
47
55
|
name: name,
|
|
56
|
+
id: Number(mappackID),
|
|
48
57
|
levels: [Number(firstLvl),Number(secondLvl),Number(thirdLvl)],
|
|
49
58
|
stars: Number(stars),
|
|
50
|
-
coins: Number(coins)
|
|
59
|
+
coins: Number(coins),
|
|
60
|
+
difficulty: difficultyDecoder[difficulty],
|
|
61
|
+
textColor: rgbToHEX(txtCol),
|
|
62
|
+
barColor: rgbToHEX(barCol)
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
return result;
|