mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-06 07:01:36 +01:00
adapt to refactor 2020 of skillbird
This commit is contained in:
36
player.py
Normal file
36
player.py
Normal 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)
|
||||
Reference in New Issue
Block a user