summaryrefslogtreecommitdiff
path: root/src/maps/maps.js
blob: 0b121cdfe6ffb619a0f9dc8b748504b87ca733a1 (plain)
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
const rarities = require('./rarities.json');

function getTalentName(talent) {
  if (talent == 'NoTalent' || talent == '' || talent == undefined) {
    return 'No Talent';
  }

  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) {
  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 getHero(actor) {
  return actor.substring(1, actor.length - 1);
}

module.exports = {
  getTalentName,
  getTalentRarity,
  getHero,
};