From 62abcb8f563edcd639b5dc36b6467debbfbd3215 Mon Sep 17 00:00:00 2001 From: schneefux Date: Thu, 10 May 2018 13:15:41 +0200 Subject: fix 'NoTalen' strings --- src/maps/maps.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/maps') diff --git a/src/maps/maps.js b/src/maps/maps.js index 1571806..0b121cd 100644 --- a/src/maps/maps.js +++ b/src/maps/maps.js @@ -1,5 +1,17 @@ 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'; @@ -19,6 +31,7 @@ function getHero(actor) { } module.exports = { + getTalentName, getTalentRarity, getHero, }; -- cgit v1.3.1