display round rating diff

This commit is contained in:
Thibault Duplessis 2014-10-19 22:30:09 +02:00
parent 58c6633896
commit 26024678fd
2 changed files with 12 additions and 0 deletions

View file

@ -68,6 +68,7 @@ final class JsonView(
"version" -> version,
"spectator" -> false,
"user" -> playerUser.map { userJsonView(_, true) },
"ratingDiff" -> player.ratingDiff,
"offeringRematch" -> player.isOfferingRematch.option(true),
"offeringDraw" -> player.isOfferingDraw.option(true),
"proposingTakeback" -> player.isProposingTakeback.option(true),
@ -78,6 +79,7 @@ final class JsonView(
"color" -> opponent.color.name,
"ai" -> opponent.aiLevel,
"user" -> opponentUser.map { userJsonView(_, true) },
"ratingDiff" -> opponent.ratingDiff,
"offeringRematch" -> opponent.isOfferingRematch.option(true),
"offeringDraw" -> opponent.isOfferingDraw.option(true),
"proposingTakeback" -> opponent.isProposingTakeback.option(true),
@ -154,6 +156,7 @@ final class JsonView(
"spectator" -> true,
"ai" -> player.aiLevel,
"user" -> playerUser.map { userJsonView(_, true) },
"ratingDiff" -> player.ratingDiff,
"onGame" -> !playerGone,
"hold" -> (withBlurs option hold(player)),
"blurs" -> (withBlurs option blurs(game, player))
@ -162,6 +165,7 @@ final class JsonView(
"color" -> opponent.color.name,
"ai" -> opponent.aiLevel,
"user" -> opponentUser.map { userJsonView(_, true) },
"ratingDiff" -> opponent.ratingDiff,
"onGame" -> !opponentGone,
"hold" -> (withBlurs option hold(opponent)),
"blurs" -> (withBlurs option blurs(game, opponent))

View file

@ -8,6 +8,13 @@ function getPlayerRating(ctrl, player) {
}
}
function ratingDiff(player) {
if (typeof player.ratingDiff === 'undefined') return null;
if (player.ratingDiff === 0) return m('span.rp.null', 0);
if (player.ratingDiff > 0) return m('span.rp.up', '+' + player.ratingDiff);
if (player.ratingDiff < 0) return m('span.rp.down', player.ratingDiff);
}
module.exports = function(ctrl, player, klass) {
var rating = player.user ? player.user.perfs[ctrl.data.game.perf].rating : null;
return player.user ? [
@ -23,6 +30,7 @@ module.exports = function(ctrl, player, klass) {
}, [
(player.user.title ? player.user.title + ' ' : '') + player.user.username,
rating ? ' (' + rating + ')' : '',
ratingDiff(player),
player.engine ? m('span[data-icon=j]', {
title: ctrl.trans('thisPlayerUsesChessComputerAssistance')
}) : null