fix: calculation of the kda

This commit is contained in:
Valentin Kaelin 2019-09-22 17:39:29 +02:00
parent 920b271925
commit 0278b3934c
2 changed files with 16 additions and 2 deletions

View file

@ -112,6 +112,7 @@
>
<router-link
:to="{ name: 'summoner', params: { region: $route.params.region, name: ally.name }}"
:class="isSummonerProfile(ally.name)"
class="w-20 text-right overflow-hidden text-overflow whitespace-no-wrap text-sm text-blue-200 font-medium hover:text-blue-100"
>{{ ally.name }}</router-link>
<div
@ -167,6 +168,14 @@ export default {
...mapState({
roles: state => state.roles
}),
},
methods: {
isSummonerProfile(allyName) {
return {
'font-bold': this.$route.params.name.toLowerCase() === allyName.toLowerCase()
}
}
}
}
</script>

View file

@ -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)
}