steal hooks for the pool - WIP
This commit is contained in:
parent
b24cded1dc
commit
f5f6c146b6
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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] = {
|
||||
|
|
5
modules/pool/src/main/PoolHook.scala
Normal file
5
modules/pool/src/main/PoolHook.scala
Normal file
|
@ -0,0 +1,5 @@
|
|||
package lila.pool
|
||||
|
||||
case class PoolHook(
|
||||
hookId: String,
|
||||
member: PoolMember)
|
|
@ -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) = (
|
||||
|
|
Loading…
Reference in a new issue