From 06670c573ec3368ad06689ef56c37adefa8ff672 Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Thu, 19 Sep 2019 19:58:29 +0200 Subject: [PATCH] feat: add kda for each match --- client/src/components/Match.vue | 3 ++- client/src/helpers/summoner.js | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/client/src/components/Match.vue b/client/src/components/Match.vue index dde926e..df3c52e 100644 --- a/client/src/components/Match.vue +++ b/client/src/components/Match.vue @@ -41,7 +41,7 @@ :style="{background: `url(${data.secondaryRune}) center/cover`}" > -
+
{{ data.kills }} / @@ -49,6 +49,7 @@ / {{ data.assists }}
+
{{ data.kda }} KDA
diff --git a/client/src/helpers/summoner.js b/client/src/helpers/summoner.js index 27d65f0..65a1b2e 100644 --- a/client/src/helpers/summoner.js +++ b/client/src/helpers/summoner.js @@ -21,7 +21,7 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) { soloQ.rankImgLink = getRankImg(soloQStats) soloQ.wins = soloQStats.wins soloQ.losses = soloQStats.losses - soloQ.winrate = (soloQ.wins * 100 / (soloQ.wins + soloQ.losses)).toFixed(1) + '%' + soloQ.winrate = +(soloQ.wins * 100 / (soloQ.wins + soloQ.losses)).toFixed(1) + '%' soloQ.lp = soloQStats.leaguePoints } @@ -60,9 +60,9 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) { const kills = player.stats.kills const deaths = player.stats.deaths const assists = player.stats.assists - const kda = ((kills + assists) / deaths).toFixed(2) + const kda = +(deaths === 0 ? 0 : ((kills + assists) / deaths)).toFixed(2) const level = player.stats.champLevel - const damage = (player.stats.totalDamageDealtToChampions / 1000).toFixed(1) + 'k' + const damage = +(player.stats.totalDamageDealtToChampions / 1000).toFixed(1) + 'k' const primaryRuneCategory = runesInfos.find(r => r.id === player.stats.perkPrimaryStyle) let primaryRune @@ -83,7 +83,7 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) { } return prev + current.stats.kills }, 0) - const kp = ((kills + assists) * 100 / totalKills).toFixed(1) + '%' + const kp = +((kills + assists) * 100 / totalKills).toFixed(1) + '%' const items = [] for (let i = 0; i < 6; i++) { @@ -91,7 +91,7 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) { items.push(getItemLink(player.stats[currentItem])) } - const gold = (player.stats.goldEarned / 1000).toFixed(1) + 'k' + const gold = +(player.stats.goldEarned / 1000).toFixed(1) + 'k' const minions = player.stats.totalMinionsKilled + player.stats.neutralMinionsKilled const firstSum = player.spell1Id