From 33be21df9b747e59a9fba63229a7a8ecd9ad144b Mon Sep 17 00:00:00 2001 From: legonzaur Date: Sat, 15 Apr 2023 12:22:39 +0200 Subject: [PATCH] fix Infinity KD and user number starting at 0 --- src/components/PlayerList.vue | 65 ++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/src/components/PlayerList.vue b/src/components/PlayerList.vue index cc01d8d..8d15155 100644 --- a/src/components/PlayerList.vue +++ b/src/components/PlayerList.vue @@ -2,20 +2,24 @@
- Username + Username K D K/D - max distance - average distance + max distance + average distance
-
-
{{ index }}
+
+
{{ index+1 }}
{{ players[playerId].username }}
{{ players[playerId].kills }}
{{ players[playerId].deaths }}
-
{{ Math.round(players[playerId].kills / players[playerId].deaths * 100) / 100 }}
+
{{ Math.round(players[playerId].kills / Math.max(1, players[playerId].deaths) * 100) / 100 }}
{{ players[playerId].max_kill_distance }}
{{ Math.round(players[playerId].avg_kill_distance * 100) / 100 }}
@@ -81,8 +85,8 @@ export default defineComponent({ } let varA, varB if (arg === 'k/d') { - varA = this.players[a].kills / this.players[a].deaths - varB = this.players[b].kills / this.players[b].deaths + varA = this.players[a].kills / Math.max(1, this.players[a].deaths) + varB = this.players[b].kills / Math.max(1, this.players[b].deaths) } else { varA = this.players[a][arg] varB = this.players[b][arg] @@ -145,20 +149,22 @@ export default defineComponent({ margin: 0; /* border: 2px solid transparent; */ transition: border .25s; - height:2em; -} -.playerHeaders{ - position:sticky; - top:0; - height:3em; + height: 2em; } -.playerHeaders>span{ - padding:.5em .8em 0 .25em; +.playerHeaders { + position: sticky; + top: 0; + height: 3em; } + +.playerHeaders>span { + padding: .5em .8em 0 .25em; +} + .playerRow>div { - padding:.5em .8em 0 .25em; - overflow:hidden; + padding: .5em .8em 0 .25em; + overflow: hidden; } .playerHeaders, @@ -181,17 +187,22 @@ export default defineComponent({ } .playerHeaders>span:last-child { - width:100%; + width: 100%; } @media only screen and (max-width: 600px) { - .playerRow>div:nth-child(6), .playerHeaders>span:nth-child(6),.playerRow>div:nth-child(7), .playerHeaders>span:nth-child(7) { - display: none; + + .playerRow>div:nth-child(6), + .playerHeaders>span:nth-child(6), + .playerRow>div:nth-child(7), + .playerHeaders>span:nth-child(7) { + display: none; } + .playerRow, -.playerHeaders{ - grid-template-columns: 4ch 20ch 6ch 6ch 1fr; -} + .playerHeaders { + grid-template-columns: 4ch 20ch 6ch 6ch 1fr; + } } .player span { @@ -200,6 +211,4 @@ export default defineComponent({ .selected { background: var(--comment) !important; -} - - +}