1
0
mirror of https://gitlab.com/Deukhoofd/BattleSim.git synced 2025-09-01 16:37:20 +00:00

Overhauled leaderboard screen

This commit is contained in:
Deukhoofd 2016-02-28 03:18:28 +01:00
parent 7107926865
commit a7ee5c24ab
6 changed files with 174 additions and 76 deletions

View File

@ -1,58 +1,127 @@
style style
body { @font-face {
font-family: Verdana; font-family: 'origicideregular';
font-size: 13px; src: url('http://p-insurgence.com/fonts/Origicide-webfont.eot');
background: #eee; src: url('http://p-insurgence.com/fonts/Origicide-webfont.eot?#iefix') format('embedded-opentype'),
} url('http://p-insurgence.com/fonts/Origicide-webfont.woff') format('woff'),
td { url('http://p-insurgence.com/fonts/Origicide-webfont.ttf') format('truetype'),
padding: 10px; url('http://p-insurgence.com/fonts/Origicide-webfont.svg#origicideregular') format('svg');
} font-weight: normal;
tr { font-style: normal;
background-color: #d3d3d3; }
} body {
table { font-family: 'Helvetica Neue', Helvetica, Arial;
border: 2px solid gray; font-size: 14px;
border-radius: 10px; line-height: 20px;
text-align: center; font-weight: 400;
margin-left: auto; color: #3b3b3b;
margin-right: auto; -webkit-font-smoothing: antialiased;
border-collapse: collapse; font-smoothing: antialiased;
border-style: hidden; background: #2b2b2b;
box-shadow: 0 0 0 1px #666; }
} .wrapper {
tr:nth-child(even) { margin: 0 auto;
background-color: #c3c3c3; padding: 40px;
} max-width: 800px;
th{ }
width: 200px; table {
border-bottom: 1px solid gray; margin: 0 0 40px 0;
} width: 100%;
table tr:first-child th:first-child, box-shadow: 0 1px 3px rgba(0,0,0,0.2);
table.Info tr:first-child td:first-child { display: table;
border-top-left-radius: 10px; }
} @media screen and (max-width: 580px) {
table tr:first-child th:last-child, .table {
table.Info tr:first-child td:last-child { display: block;
border-top-right-radius: 10px; }
} }
.row {
display: table-row;
background: #f6f6f6;
}
.row:nth-of-type(odd) {
background: #e9e9e9;
}
.row.header {
font-weight: 900;
color: #fff;
background: #ea6153;
}
.row.header.name {
font-family: 'origicideregular';
font-size: large;
font-weight: 100;
}
.row.green {
background: #27ae60;
}
.row.blue {
background: #2980b9;
}
@media screen and (max-width: 580px) {
.row {
padding: 8px 0;
display: block;
}
}
.cell {
padding: 6px 12px;
display: table-cell;
width: 50px;
}
@media screen and (max-width: 580px) {
.cell {
padding: 2px 12px;
display: block;
}
}
a {
color: black;
text-decoration: none;
}
.crown {
vertical-align: bottom;
width: 25px;
float: right;
}
table tr:last-child td:first-child {
border-bottom-left-radius: 10px;
}
table tr:last-child td:last-child {
border-bottom-right-radius: 10px;
}
div div
table .wrapper
thead .table
tr .row.header.name
th Rank .cell
th Player .cell Insurgence
th Score .cell OU
tbody .cell
.cell
.row.header
.cell
| Rank
.cell
| Player
.cell
| Score
.cell
| Win Ratio
.cell
| Total Battles
each member, i in players each member, i in players
tr .row
td #{i + 1} .cell
td #{member.username} | #{i + 1}
td #{member.score} if i == 0
img.crown(src="../Sprites/images/goldcrown.png")
else if i == 1
img.crown(src="../Sprites/images/silvercrown.png")
else if i == 2
img.crown(src="../Sprites/images/bronzecrown.png")
.cell
| <a href=http://forums.p-insurgence.com/users/#{member.username}>#{member.username}</a>
.cell
| #{member.score}
- var totalbattles = member.ratio.win + member.ratio.draw + member.ratio.lose
- var winratio = ((member.ratio.win / totalbattles) * 100).toFixed(2)
.cell
| #{winratio}%
.cell
| #{totalbattles}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -65,19 +65,31 @@ CLIENT_VERSION = assets.getVersion()
page = req.param('page') page = req.param('page')
perPage = req.param('per_page') perPage = req.param('per_page')
ratings.listRatings page, perPage, (err, results) -> ratings.listRatings page, perPage, (err, results) ->
if err temparr = results.map((e) -> e.username)
res.json(500, err.message) ratioarr = []
else ratings.getRatios temparr, (err, ratios)->
res.render('leaderboard.jade', players: results) for username in temparr
index = temparr.indexOf(username)
results[index].ratio = ratios[username]
if err
res.json(500, err.message)
else
res.render('leaderboard.jade', players: results)
app.get '/leaderboard/json', (req, res) -> app.get '/leaderboard/json', (req, res) ->
page = req.param('page') page = req.param('page')
perPage = req.param('per_page') perPage = req.param('per_page')
ratings.listRatings page, perPage, (err, results) -> ratings.listRatings page, perPage, (err, results) ->
if err temparr = results.map((e) -> e.username)
res.json(500, err.message) ratioarr = []
else ratings.getRatios temparr, (err, ratios)->
res.json(players: results) for username in temparr
index = temparr.indexOf(username)
results[index].ratio = ratios[username]
if err
res.json(500, err.message)
else
res.json(players: results)
app.get '/pokeuse/json', (req, res) -> app.get '/pokeuse/json', (req, res) ->
user= req.user user= req.user

View File

@ -14,7 +14,7 @@ RATINGS_SUBKEYS = {}
for attribute in RATINGS_ATTRIBUTES for attribute in RATINGS_ATTRIBUTES
RATINGS_SUBKEYS[attribute] = [RATINGS_KEY, attribute].join(':') RATINGS_SUBKEYS[attribute] = [RATINGS_KEY, attribute].join(':')
RATINGS_MAXKEY = "ratings:max" RATINGS_MAXKEY = "ratings:max"
RATINGS_PER_PAGE = 15 RATINGS_PER_PAGE = 20
ALGORITHM_OPTIONS = ALGORITHM_OPTIONS =
systemConstant: 0.2 # Glicko2 tau systemConstant: 0.2 # Glicko2 tau
@ -203,6 +203,35 @@ updateMaxStreak = (id, next) =>
return next(err) if err return next(err) if err
updateMaxRatings(idArray, next) updateMaxRatings(idArray, next)
@getRatio = (id, next) ->
id = id.toLowerCase()
multi = redis.multi()
for attribute, key of RATIOS_SUBKEYS
multi = multi.hget(key, id)
multi.exec (err, results) ->
return next(err) if err
hash = {}
for attribute, i in RATIOS_ATTRIBUTES
hash[attribute] = Number(results[i]) || 0
return next(null, hash)
@getRatios = (users, next) ->
multi = redis.multi()
for id in users
for attribute, key of RATIOS_SUBKEYS
multi = multi.hget(key, id)
multi.exec (err, results) ->
return next(err) if err
hasharray = {}
iter = 0
for id, i in users
hash = {}
for attribute, j in RATIOS_ATTRIBUTES
hash[attribute] = Number(results[iter]) || 0
iter++
hasharray[id] = hash
next(null, hasharray)
@listRatings = (page = 1, perPage = RATINGS_PER_PAGE, next) -> @listRatings = (page = 1, perPage = RATINGS_PER_PAGE, next) ->
if arguments.length == 2 && typeof perPage == 'function' if arguments.length == 2 && typeof perPage == 'function'
[perPage, next] = [RATINGS_PER_PAGE, perPage] [perPage, next] = [RATINGS_PER_PAGE, perPage]
@ -218,18 +247,6 @@ updateMaxStreak = (id, next) =>
array.push(username: username, score: score) array.push(username: username, score: score)
next(null, array) next(null, array)
@getRatio = (id, next) ->
id = id.toLowerCase()
multi = redis.multi()
for attribute, key of RATIOS_SUBKEYS
multi = multi.hget(key, id)
multi.exec (err, results) ->
return next(err) if err
hash = {}
for attribute, i in RATIOS_ATTRIBUTES
hash[attribute] = Number(results[i]) || 0
return next(null, hash)
@getStreak = (id, next) -> @getStreak = (id, next) ->
id = id.toLowerCase() id = id.toLowerCase()
multi = redis.multi() multi = redis.multi()