aboutsummaryrefslogtreecommitdiff
path: root/build/cleaners/rank.js
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-02-13 14:14:50 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-02-13 14:14:50 -0600
commitf3e74e786df8e11f85ec895e0750df8ab124b475 (patch)
tree25c53f6452c0e75ad8f8c1290f70d9da8e46261f /build/cleaners/rank.js
parent52e38809212133ef673d11bfa96ba3bb43c3644c (diff)
downloadskyblock-api-f3e74e786df8e11f85ec895e0750df8ab124b475.tar.gz
skyblock-api-f3e74e786df8e11f85ec895e0750df8ab124b475.tar.bz2
skyblock-api-f3e74e786df8e11f85ec895e0750df8ab124b475.zip
add compiled code in build folder
Diffstat (limited to 'build/cleaners/rank.js')
-rw-r--r--build/cleaners/rank.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/build/cleaners/rank.js b/build/cleaners/rank.js
new file mode 100644
index 0000000..875d2db
--- /dev/null
+++ b/build/cleaners/rank.js
@@ -0,0 +1,55 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.parseRank = void 0;
+const util_1 = require("../util");
+const rankColors = {
+ 'NONE': '7',
+ 'VIP': 'a',
+ 'VIP+': 'a',
+ 'MVP': 'b',
+ 'MVP+': 'b',
+ 'MVP++': '6',
+ 'YOUTUBE': 'c',
+ 'HELPER': '9',
+ 'MODERATOR': '2',
+ 'ADMIN': 'c'
+};
+/** Response cleaning (reformatting to be nicer) */
+function parseRank({ packageRank, newPackageRank, monthlyPackageRank, rankPlusColor, rank, prefix }) {
+ let name;
+ let color;
+ let colored;
+ if (prefix) { // derive values from prefix
+ colored = prefix;
+ color = util_1.minecraftColorCodes[colored.match(/§./)[0][1]];
+ name = colored.replace(/§./g, '').replace(/[\[\]]/g, '');
+ }
+ else {
+ name = rank
+ || newPackageRank.replace('_PLUS', '+')
+ || packageRank.replace('_PLUS', '+')
+ || monthlyPackageRank;
+ // MVP++ is called Superstar for some reason
+ if (name === 'SUPERSTAR')
+ name = 'MVP++';
+ // YouTube rank is called YouTuber, change this to the proper name
+ else if (name === 'YOUTUBER')
+ name = 'YOUTUBE';
+ const plusColor = util_1.colorCodeFromName(rankPlusColor);
+ color = util_1.minecraftColorCodes[rankColors[name]];
+ const rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : '';
+ const nameWithoutPlus = name.split('+')[0];
+ const plusesInName = '+'.repeat(name.split('+').length - 1);
+ console.log(plusColor, nameWithoutPlus, plusesInName);
+ if (plusColor && plusesInName.length >= 1)
+ colored = `${rankColorPrefix}[${nameWithoutPlus}§${plusColor}${plusesInName}${rankColorPrefix}]`;
+ else
+ colored = `${rankColorPrefix}[${name}]`;
+ }
+ return {
+ name,
+ color,
+ colored
+ };
+}
+exports.parseRank = parseRank;