steal hooks for the pool - WIP

This commit is contained in:
Thibault Duplessis 2016-12-05 18:52:55 +01:00
parent b24cded1dc
commit f5f6c146b6
4 changed files with 26 additions and 2 deletions

View file

@ -72,11 +72,25 @@ case class Hook(
def randomColor = color == "random"
lazy val poolCompatible =
lazy val compatibleWithPools =
realMode.rated && realVariant.standard && randomColor &&
lila.pool.PoolList.clockStringSet.contains(clock.show)
def likePoolFiveO = poolCompatible && clock.show == "5+0"
def compatibleWithPool(poolClock: chess.Clock.Config) =
compatibleWithPools && clock == poolClock
def likePoolFiveO = compatibleWithPools && clock.show == "5+0"
def toPool = lila.pool.PoolHook(
hookId = id,
member = lila.pool.PoolMember(
userId = user.??(_.id),
socketId = lila.socket.Socket.Uid(uid),
rating = rating | lila.rating.Glicko.defaultIntRating,
ratingRange = realRatingRange,
engine = user.??(_.engine),
blocking = lila.pool.PoolMember.BlockedUsers(user.??(_.blocking)),
since = createdAt))
private lazy val speed = Speed(clock)
}

View file

@ -42,6 +42,9 @@ object HookRepo {
partition(_.createdAt isAfter limit)
}
def poolHooks(poolClock: chess.Clock.Config): Vector[lila.pool.PoolHook] =
hooks.filter(_ compatibleWithPool poolClock).map(_.toPool)
// keeps hooks that hold true
// returns removed hooks
private def partition(f: Hook => Boolean): Vector[Hook] = {

View file

@ -0,0 +1,5 @@
package lila.pool
case class PoolHook(
hookId: String,
member: PoolMember)

View file

@ -41,6 +41,8 @@ case object Glicko {
val default = Glicko(1500d, 350d, 0.06d)
val defaultIntRating = default.rating.toInt
val provisionalDeviation = 110
def range(rating: Double, deviation: Double) = (