fix: NaN kda for champions stats

This commit is contained in:
Valentin Kaelin 2020-03-17 13:34:39 +01:00
parent eb40fb11af
commit 5b59f5b4cc
2 changed files with 5 additions and 1 deletions

View file

@ -271,11 +271,12 @@ export default {
}, },
updateChampionsList() { updateChampionsList() {
this.championsFull = this.champions.map((champ, index) => { this.championsFull = this.champions.map((champ, index) => {
let kda = champ.kills === 0 && champ.assists === 0 && champ.deaths === 0 ? 0 : (champ.kills + champ.assists) / champ.deaths
return { return {
...champ, ...champ,
winrate: champ.wins * 100 / champ.count, winrate: champ.wins * 100 / champ.count,
playrate: champ.count * 100 / this.totalGames, playrate: champ.count * 100 / this.totalGames,
kda: (champ.kills + champ.assists) / champ.deaths, kda,
index, index,
lastPlayed: timeDifference(champ.date), lastPlayed: timeDifference(champ.date),
show: true show: true

View file

@ -111,6 +111,9 @@ export default {
methods: { methods: {
kda(kills, deaths, assists) { kda(kills, deaths, assists) {
if (kills === 0 && deaths === 0 && assists === 0) {
return 0
}
return this.$options.filters.round((kills + assists) / deaths) return this.$options.filters.round((kills + assists) / deaths)
}, },
widthBar(value, total) { widthBar(value, total) {