update multielo
This commit is contained in:
parent
71937598aa
commit
9dcbd11ff3
|
@ -1 +1 @@
|
|||
Subproject commit d26a1d7648c32cd26e463256c6206e73d1449512
|
||||
Subproject commit 8575c75138c073fe88e3ef3fe518926bf0374cbe
|
|
@ -1,10 +1,8 @@
|
|||
package lila.round
|
||||
|
||||
import scalaz.{ OptionTs, Success }
|
||||
|
||||
import chess.Color._
|
||||
import chess.Status._
|
||||
import chess.{ EloCalculator, Status, Color }
|
||||
import chess.{ EloCalculator, Status, Color, Speed }
|
||||
import lila.db.api._
|
||||
import lila.game.tube.gameTube
|
||||
import lila.game.{ GameRepo, Game, Pov, Event }
|
||||
|
@ -12,6 +10,7 @@ import lila.hub.actorApi.round._
|
|||
import lila.i18n.I18nKey.{ Select ⇒ SelectI18nKey }
|
||||
import lila.user.tube.userTube
|
||||
import lila.user.{ User, UserRepo, EloUpdater }
|
||||
import scalaz.{ OptionTs, Success }
|
||||
|
||||
private[round] final class Finisher(
|
||||
tournamentOrganizer: lila.hub.ActorLazyRef,
|
||||
|
@ -62,9 +61,15 @@ private[round] final class Finisher(
|
|||
val (whiteDiff, blackDiff) = (whiteElo - whiteUser.elo, blackElo - blackUser.elo)
|
||||
val cheaterWin = (whiteDiff > 0 && whiteUser.engine) || (blackDiff > 0 && blackUser.engine)
|
||||
(!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))
|
||||
|
||||
GameRepo.setEloDiffs(game.id, whiteDiff, blackDiff) >>
|
||||
eloUpdater.game(whiteUser, whiteElo, blackUser.elo) >>
|
||||
eloUpdater.game(blackUser, blackElo, whiteUser.elo)
|
||||
eloUpdater.game(whiteUser, whiteElo, blackUser.elo, speed.shortName, newWhiteSe) >>
|
||||
eloUpdater.game(blackUser, blackElo, whiteUser.elo, speed.shortName, newBlackSe)
|
||||
} inject true.some
|
||||
}
|
||||
} yield ()).value.void
|
||||
|
|
|
@ -2,7 +2,7 @@ package lila.user
|
|||
|
||||
final class EloUpdater(floor: Int) {
|
||||
|
||||
def game(user: User, elo: Int, speed: String, se: SpeedElo, opponentElo: Int): Funit = math.max(elo, floor) |> { newElo ⇒
|
||||
def game(user: User, elo: Int, opponentElo: Int, speed: String, se: SpeedElo): Funit = math.max(elo, floor) |> { newElo ⇒
|
||||
UserRepo.setElo(user.id, newElo, speed, se) >>
|
||||
HistoryRepo.addEntry(user.id, newElo, opponentElo.some)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue