From 6a2a4b6fa0a646b1b084828d9ac0146d671ed491 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Fri, 18 Dec 2020 11:57:04 +0100 Subject: [PATCH] visual improvements, migrate main view to dataTable --- MapSummary.py | 20 ++++++++++-- player.py | 1 + server.py | 5 +++ static/buttons.js | 8 +++-- static/site.css | 8 +++++ templates/base.html | 48 ++++++++++++++++------------ templates/footer.html | 4 +-- templates/maps.html | 53 +++++++++++++++---------------- templates/navbar.html | 4 +-- templates/navbar_leaderboard.html | 4 +-- 10 files changed, 96 insertions(+), 59 deletions(-) diff --git a/MapSummary.py b/MapSummary.py index 759ab56..c4d1ada 100644 --- a/MapSummary.py +++ b/MapSummary.py @@ -39,10 +39,24 @@ class MapSummary: self.averageTime = datetime.timedelta(seconds=int(averageSeconds)) mapper = [ 1 if x == 0 else -1 for x in self.predictions ] + reverseMapper = [ 1 if x == 0 else 0 for x in self.predictions ] self.ratingSystemDeviation = 0 - for i in range(0, len(self.confidence)): - self.ratingSystemDeviation += mapper[i] * self.confidence[i] - self.ratingSystemDeviation /= self.totalGames + + confidenceCutoff = 60 + confidenceTupels = list(filter(lambda x: x[1] > confidenceCutoff, + zip(reverseMapper, self.confidence))) + + mapperTupels = list(filter(lambda x: x[1] > confidenceCutoff, + zip(mapper, self.confidence))) + + for i in range(0, len(mapperTupels)): + self.ratingSystemDeviation += mapperTupels[i][0] * max(100, 50+mapperTupels[i][1]) + + self.ratingSystemDeviation /= len(mapperTupels) + self.predictionCorrectPercentage = sum([x[0] for x in confidenceTupels]) + self.predictionCorrectPercentage /= len(confidenceTupels) + self.predictionCorrectPercentage *= 100 + self.predictionCorrectPercentage = round(self.predictionCorrectPercentage) except ZeroDivisionError: pass diff --git a/player.py b/player.py index 2a40f9c..e9f6293 100644 --- a/player.py +++ b/player.py @@ -18,6 +18,7 @@ class PlayerInLeaderboard: self.mu = mu self.sigma = sigma self.rating = int(self.mu) - 2*int(self.sigma) + self.ratingStr = str(self.rating) self.games = int(games) self.wins = int(wins) self.loses = self.games - self.wins diff --git a/server.py b/server.py index f7d4300..438ac84 100755 --- a/server.py +++ b/server.py @@ -66,6 +66,11 @@ def maps(): roundsWithMap = list(filter(lambda r: r.mapName == mapName , rounds)) maps += [MapSummary.MapSummary(roundsWithMap)] + allMaps = MapSummary.MapSummary(rounds) + allMaps.mapName = "All Maps*" + maps += [allMaps] + + mapsFiltered = filter(lambda x: x.mapName, maps) return flask.render_template("maps.html", maps=mapsFiltered) diff --git a/static/buttons.js b/static/buttons.js index 30f796a..9f4d302 100644 --- a/static/buttons.js +++ b/static/buttons.js @@ -22,11 +22,13 @@ if(isLastPage){ } /* if request was a playersearch, move to player */ -targetPlayerElements = document.getElementsByClassName("targetPlayer") -if(targetPlayerElements.length == 1){ +targetPlayer = document.getElementById("targetPlayer") +if(targetPlayer){ /* scrollIntoView broken on android?? wtf */ scrollOptions = {beahviour: "smooth", block:"center"} - targetPlayerElements[0].scrollIntoView(scrollOptions); + targetPlayer.scrollIntoView(scrollOptions); + targetPlayer.style.background = "green"; + targetPlayer.children.forEach(c => c.style.borderColor="green") } /* alert on mobile devices if player was not found */ diff --git a/static/site.css b/static/site.css index f70acda..54835ad 100644 --- a/static/site.css +++ b/static/site.css @@ -250,3 +250,11 @@ body{ .hover-to-75:hover{ opacity: 0.75; } +.patreon{ + background: #d71d1d; + padding-left: 0.5vw; + padding-right: 0.5vw; + border-radius: 10px; + font-style: italic; + font-weight: bold; +} diff --git a/templates/base.html b/templates/base.html index c7886c2..bbddef4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -6,27 +6,35 @@ {% include "default_head_content.html" %} - + {% include 'navbar_leaderboard.html' %} -
-
{{ columNames }}
- {% for player in playerList %} - {% set count = loop.index + start %} - {% if count % 2 == 0 %} - - {% else %} - - {% endif %} - {% endfor %} - {{ endOfBoardIndicator }} + +
+ + + + + + + + + + + + {% for p in playerList %} + {% set count = loop.index + start %} + + + + + + + + {% endfor %} + +
RankPlayerGamesRatingWinratio %
{{ count }}{{ p.name }}{{ p.games }}{{ p.rating }}{{ p.winratio }}%
+ {{ endOfBoardIndicator }}
{% include 'footer.html' %} diff --git a/templates/footer.html b/templates/footer.html index bfd24f2..2bcc866 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -2,8 +2,8 @@ Impressum/Legal - How does it work? + class="footerLink mid" href="steam://connect/athq.de/:27026"> + Join the Server! Star on GitHub
diff --git a/templates/maps.html b/templates/maps.html index c740d48..fa6ce5a 100644 --- a/templates/maps.html +++ b/templates/maps.html @@ -3,24 +3,7 @@ Maps - - - - - - - - - - - - - - - - - - + {% include "default_head_content.html" %} {% include 'navbar.html' %} @@ -34,34 +17,50 @@ Insurgent Win Security Win Average Time - Rating System Deviation* + Rating System Performance {% for m in maps %} - + {{ m.mapName }} {{ m.totalGames }} {{ '%0.2f' | format(m.insurgentWinPercent) }}% {{ '%0.2f' | format(m.securityWinPercent) }}% {{ m.averageTime }} - {% if m.ratingSystemDeviation >= 0 %} - +{{ '%0.2f' | format(m.ratingSystemDeviation) }}% + {% if m.ratingSystemDeviation == 0 or m.predictionCorrectPercentage == 0%} + N/A + {% elif m.ratingSystemDeviation >= 0 %} + + +{{ '%0.2f' | format(m.ratingSystemDeviation) }}% + ({{ m.predictionCorrectPercentage }}% Correct) {% else %} - {{ '%0.2f' | format(m.ratingSystemDeviation) }}% + + {{ '%0.2f' | format(m.ratingSystemDeviation) }}% + ({{ m.predictionCorrectPercentage }}% Correct) {% endif %} + {# #} {% endfor %} -
-

- *Rating System Deviation: Percentage difference between the ratio of correctly predicted games by the rating system, to the average confidence of those predictions. For example: 10 games played, 6 games correctly predicted based on ratings with an average confidence of 50% is +20% deviation. -

+
+ + *Map Tracking was only implemented recently, that is why there are many rounds without a recorded mapname. +
{% include 'footer.html' %} + diff --git a/templates/navbar.html b/templates/navbar.html index 56d42a6..acea55e 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -27,8 +27,8 @@ Server 2