aboutsummaryrefslogtreecommitdiff
path: root/build/cleaners/skyblock/stats.js
diff options
context:
space:
mode:
Diffstat (limited to 'build/cleaners/skyblock/stats.js')
-rw-r--r--build/cleaners/skyblock/stats.js91
1 files changed, 0 insertions, 91 deletions
diff --git a/build/cleaners/skyblock/stats.js b/build/cleaners/skyblock/stats.js
deleted file mode 100644
index 361f1ba..0000000
--- a/build/cleaners/skyblock/stats.js
+++ /dev/null
@@ -1,91 +0,0 @@
-const statCategories = {
- 'deaths': ['deaths_', 'deaths'],
- 'kills': ['kills_', 'kills'],
- 'fishing': ['items_fished_', 'items_fished', 'shredder_'],
- 'auctions': ['auctions_'],
- 'races': ['_best_time', '_best_time_2'],
- 'mythos': ['mythos_burrows_', 'mythos_kills'],
- 'collection': ['collection_'],
- 'skills': ['skill_'],
- 'slayer': ['slayer_'],
- 'misc': null // everything else goes here
-};
-export function categorizeStat(statNameRaw) {
- // 'deaths_void'
- for (const statCategory in statCategories) {
- // 'deaths'
- const statCategoryMatchers = statCategories[statCategory];
- if (statCategoryMatchers == null) {
- // If it's null, just go with this. Can only ever be 'misc'
- return {
- category: statCategory,
- name: statNameRaw
- };
- }
- for (const categoryMatch of statCategoryMatchers) {
- // ['deaths_']
- let trailingEnd = categoryMatch[0] === '_';
- let trailingStart = categoryMatch.substr(-1) === '_';
- if (trailingStart && statNameRaw.startsWith(categoryMatch)) {
- return {
- category: statCategory,
- name: statNameRaw.substr(categoryMatch.length)
- };
- }
- else if (trailingEnd && statNameRaw.endsWith(categoryMatch)) {
- return {
- category: statCategory,
- name: statNameRaw.substr(0, statNameRaw.length - categoryMatch.length)
- };
- }
- else if (statNameRaw == categoryMatch) {
- // if it matches exactly, we don't know the name. will be defaulted to category later on
- return {
- category: statCategory,
- name: null
- };
- }
- }
- }
- // this should never happen, as it'll default to misc and return if nothing is found
- return {
- category: null,
- name: statNameRaw
- };
-}
-export const statUnits = {
- time: ['_best_time', '_best_time_2'],
- date: ['first_join'],
- coins: ['purse'],
- leaderboards: ['leaderboards_count', 'top_1_leaderboards_count']
-};
-export function getStatUnit(name) {
- for (const [unitName, statMatchers] of Object.entries(statUnits)) {
- for (const statMatch of statMatchers) {
- let trailingEnd = statMatch[0] === '_';
- let trailingStart = statMatch.substr(-1) === '_';
- if ((trailingStart && name.startsWith(statMatch))
- || (trailingEnd && name.endsWith(statMatch))
- || (name == statMatch))
- return unitName;
- }
- }
- return null;
-}
-export function cleanProfileStats(data) {
- // TODO: add type for statsRaw (probably in hypixelApi.ts since its coming from there)
- const stats = [];
- const rawStats = data?.stats ?? {};
- for (const statNameRaw in rawStats) {
- const statValue = rawStats[statNameRaw];
- let { category: statCategory, name: statName } = categorizeStat(statNameRaw);
- stats.push({
- categorizedName: statName ?? 'total',
- value: statValue,
- rawName: statNameRaw,
- category: statCategory,
- unit: getStatUnit(statNameRaw) ?? null
- });
- }
- return stats;
-}