fix multi elo calculations

This commit is contained in:
Thibault Duplessis 2013-07-21 12:29:20 +02:00
parent 9dcbd11ff3
commit 2bcd857bc5
2 changed files with 3 additions and 5 deletions

View file

@ -63,10 +63,8 @@ private[round] final class Finisher(
(!cheaterWin) ?? {
val speed = Speed(game.clock) |> { s (s == Speed.Unlimited).fold(Speed.Slow, s) }
val (whiteSe, blackSe) = (whiteUser.speedElos(speed), blackUser.speedElos(speed))
val (newWhiteSe, newBlackSe) = (
whiteSe.addGame(eloCalculator.calculate(whiteSe, blackSe, game.winnerColor)._1),
blackSe.addGame(eloCalculator.calculate(blackSe, whiteSe, game.winnerColor)._1))
val (whiteSeElo, blackSeElo) = eloCalculator.calculate(whiteSe, blackSe, game.winnerColor)
val (newWhiteSe, newBlackSe) = (whiteSe.addGame(whiteSeElo), blackSe.addGame(blackSeElo))
GameRepo.setEloDiffs(game.id, whiteDiff, blackDiff) >>
eloUpdater.game(whiteUser, whiteElo, blackUser.elo, speed.shortName, newWhiteSe) >>
eloUpdater.game(blackUser, blackElo, whiteUser.elo, speed.shortName, newBlackSe)

View file

@ -43,7 +43,7 @@ object UserRepo {
def setElo(id: ID, elo: Int, speed: String, se: SpeedElo): Funit = $update($select(id), $set(
"elo" -> elo,
"speedElos.%s".format(speed) -> se.nb,
"speedElos.%s.nb".format(speed) -> se.nb,
"speedElos.%s.elo".format(speed) -> se.elo
))