From 0278b3934cc42131aa688a88daf03d55db533dc9 Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Sun, 22 Sep 2019 17:39:29 +0200 Subject: [PATCH] fix: calculation of the kda --- client/src/components/Match.vue | 9 +++++++++ client/src/helpers/summoner.js | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/client/src/components/Match.vue b/client/src/components/Match.vue index 13ce65c..e944de6 100644 --- a/client/src/components/Match.vue +++ b/client/src/components/Match.vue @@ -112,6 +112,7 @@ > {{ ally.name }}
state.roles }), + }, + + methods: { + isSummonerProfile(allyName) { + return { + 'font-bold': this.$route.params.name.toLowerCase() === allyName.toLowerCase() + } + } } } diff --git a/client/src/helpers/summoner.js b/client/src/helpers/summoner.js index 3cdf24f..52321e0 100644 --- a/client/src/helpers/summoner.js +++ b/client/src/helpers/summoner.js @@ -52,7 +52,12 @@ export function createSummonerData(RiotData, championsInfos, runesInfos) { const kills = player.stats.kills const deaths = player.stats.deaths const assists = player.stats.assists - const kda = +(deaths === 0 ? 0 : ((kills + assists) / deaths)).toFixed(2) + let kda + if (kills + assists !== 0 && deaths === 0) { + kda = '∞' + } else { + kda = +(deaths === 0 ? 0 : ((kills + assists) / deaths)).toFixed(2) + } const level = player.stats.champLevel const damage = +(player.stats.totalDamageDealtToChampions / 1000).toFixed(1) + 'k' @@ -167,6 +172,6 @@ function getSummonerLink(id) { } function sortTeamByRole(a, b) { - const sortingArr = [ 'TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'SUPPORT'] + const sortingArr = ['TOP', 'JUNGLE', 'MIDDLE', 'BOTTOM', 'SUPPORT'] return sortingArr.indexOf(a.role) - sortingArr.indexOf(b.role) }