aboutsummaryrefslogtreecommitdiff
path: root/build/cleaners
diff options
context:
space:
mode:
authormat-1 <github@matdoes.dev>2021-02-14 20:33:11 +0000
committermat-1 <github@matdoes.dev>2021-02-14 20:33:11 +0000
commitc7af4d49db5d85bfa2bd7c716a950145f70833da (patch)
treed32b20b3984964efda42c6c5f697611a2c9e5f52 /build/cleaners
parent65afca6029649cc23655fac32a38ed413339ca72 (diff)
downloadskyblock-api-c7af4d49db5d85bfa2bd7c716a950145f70833da.tar.gz
skyblock-api-c7af4d49db5d85bfa2bd7c716a950145f70833da.tar.bz2
skyblock-api-c7af4d49db5d85bfa2bd7c716a950145f70833da.zip
Compiled TS into JS
Diffstat (limited to 'build/cleaners')
-rw-r--r--build/cleaners/skyblock/collections.js29
1 files changed, 22 insertions, 7 deletions
diff --git a/build/cleaners/skyblock/collections.js b/build/cleaners/skyblock/collections.js
index def7140..910f8fd 100644
--- a/build/cleaners/skyblock/collections.js
+++ b/build/cleaners/skyblock/collections.js
@@ -71,10 +71,20 @@ const COLLECTIONS = {
'lily_pad',
'ink_sac',
'sponge'
- ]
+ ],
+ // no item should be here, but in case a new collection is added itll default to this
+ 'unknown': []
};
+// get a category name (farming) from a collection name (wheat)
+function getCategory(collectionName) {
+ for (const categoryName in COLLECTIONS) {
+ const categoryItems = COLLECTIONS[categoryName];
+ if (categoryItems.includes(collectionName))
+ return categoryName;
+ }
+}
function cleanCollections(data) {
- var _a, _b;
+ var _a, _b, _c;
// collection tiers show up like this: [ GRAVEL_3, GOLD_INGOT_2, MELON_-1, LOG_2:1_7, RAW_FISH:3_-1]
// these tiers are the same for all players in a coop
const playerCollectionTiersRaw = (_a = data === null || data === void 0 ? void 0 : data.unlocked_coll_tiers) !== null && _a !== void 0 ? _a : [];
@@ -95,11 +105,16 @@ function cleanCollections(data) {
for (const collectionNameRaw in playerCollectionValuesRaw) {
const collectionValue = playerCollectionValuesRaw[collectionNameRaw];
const collectionName = itemId_1.cleanItemId(collectionNameRaw);
- playerCollectionValues.push({
- name: collectionName,
- xp: collectionValue,
- level: playerCollectionTiers[collectionName]
- });
+ const collectionLevel = playerCollectionTiers[collectionName];
+ const collectionCategory = (_c = getCategory(collectionName)) !== null && _c !== void 0 ? _c : 'unknown';
+ // in some very weird cases the collection level will be undefined, we should ignore these collections
+ if (collectionLevel !== undefined)
+ playerCollectionValues.push({
+ name: collectionName,
+ xp: collectionValue,
+ level: collectionLevel,
+ category: collectionCategory
+ });
}
return playerCollectionValues;
}