adapt to refactor 2020 of skillbird

This commit is contained in:
Yannik Schmidt
2020-06-16 23:23:09 +02:00
parent f08da7b2cd
commit 8ad6ae21e3
3 changed files with 105 additions and 61 deletions

36
player.py Normal file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/python3
import flask
class PlayerInLeaderboard:
def __init__(self, dbRow):
'''Initialize a player object later to be serialized to HTML'''
playerID, name, lastGame, wins, mu, sigma, games = dbRow
# set relevant values #
self.name = name
self.playerID = playerID
self.mu = mu
self.sigma = sigma
self.rating = int(self.mu) - int(self.sigma)
self.games = int(games)
self.wins = int(wins)
self.loses = self.games - self.wins
# determine winratio #
if self.games == 0:
self.winratio = "N/A"
else:
self.winratio = str(int(self.wins/self.games * 100))
def getLineHTML(self, rank):
'''Build a single line for a specific player in the leaderboard'''
string = flask.render_template("playerLine.html", \
playerRank = rank, \
playerName = self.name, \
playerRating = self.rating, \
playerGames = self.games, \
playerWinratio = self.winratio)
return flask.Markup(string)