1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
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
|
const rarities = require('./rarities.json');
const names = require('./names.json');
const modes = require('./modes.json');
const RARITIES = ['None', 'Rare', 'Epic', 'Legendary'];
function getTalentName(talent) {
if (talent == 'NoTalent') {
return 'No Talent';
}
switch (talent.slice(talent.length - 7 - 1, talent.length - 1)) {
case 'TalentA':
case 'TalentB':
case 'TalentC':
if (Object.keys(names).includes(talent)) {
return names[talent];
} else {
return 'unknown';
}
default:
return talent.substring(talent.lastIndexOf('_') + 1, talent.length - 1) // snake case to words
.replace(/([A-Z])/g, (s) => ' ' + s.toLowerCase())
.split(' ') // capitalize first letter
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
.join(' ');
}
}
function getTalentRarity(talent) {
if (!talent || talent == 'NoTalent') {
return 'None';
}
switch (talent.slice(talent.length - 7 - 1, talent.length - 1)) {
case 'TalentA': return 'Rare';
case 'TalentB': return 'Epic';
case 'TalentC': return 'Legendary';
default:
if (Object.keys(rarities).includes(talent)) {
return rarities[talent];
} else {
return 'unknown';
}
}
}
function getMaxLevel(entry) {
switch (getTalentRarity(entry.Talent)) {
case 'unknown':
case 'None': return -1;
case 'Rare': return 20;
case 'Epic': return 10;
case 'Legendary': return 5;
}
};
function getScaledLevel(entry) {
if (['unknown', 'None'].includes(getTalentRarity(entry.Talent))) {
return 0;
}
return entry.Level / getMaxLevel(entry);
};
function getHero(actor) {
return actor.substring(1, actor.length - 1);
}
function getMode(mode) {
return modes[mode];
}
function hasTalents(mode) {
return ['blitz_pvp_ranked', 'casual_aral'].includes(mode);
}
function playersPerMatch(mode) {
return mode.includes('5v5')? 10 : 6;
}
module.exports = {
RARITIES,
getTalentName,
getTalentRarity,
getMaxLevel,
getScaledLevel,
getHero,
getMode,
hasTalents,
playersPerMatch,
};
|