Revert "Add elo diff to lobby filters WIP"

This reverts commit e0e4b33414.
pull/83/head
Thibault Duplessis 2013-01-02 05:13:10 +01:00
parent dc2cc4910c
commit 400685ea13
4 changed files with 11 additions and 23 deletions

View File

@ -6,30 +6,26 @@ import chess.{ Variant, Mode, Speed }
case class FilterConfig(
variant: Option[Variant],
mode: Option[Mode],
speed: Option[Speed],
eloDiff: Int) {
speed: Option[Speed]) {
def withModeCasual = copy(mode = Mode.Casual.some)
def encode = RawFilterConfig(
v = ~variant.map(_.id),
m = mode.map(_.id) | -1,
s = ~speed.map(_.id),
e = eloDiff
s = ~speed.map(_.id)
)
def >> = (
variant map (_.id),
mode map (_.id),
speed map (_.id),
eloDiff
speed map (_.id)
).some
def render = Map(
"variant" -> variant.map(_.toString),
"mode" -> mode.map(_.toString),
"speed" -> speed.map(_.id),
"eloDiff" -> eloDiff
"speed" -> speed.map(_.id)
)
}
@ -38,19 +34,16 @@ object FilterConfig {
val default = FilterConfig(
variant = none,
mode = none,
speed = none,
eloDiff = 0)
speed = none)
val variants = 0 :: Config.variants
val modes = -1 :: Mode.all.map(_.id)
val speeds = 0 :: Config.speeds
val eloDiffs = 0 :: 100 :: 200 :: 300 :: 500 :: Nil
def <<(v: Option[Int], m: Option[Int], s: Option[Int], e: Int) = new FilterConfig(
def <<(v: Option[Int], m: Option[Int], s: Option[Int]) = new FilterConfig(
variant = v flatMap Variant.apply,
mode = m flatMap Mode.apply,
speed = s flatMap Speed.apply,
eloDiff = e
speed = s flatMap Speed.apply
)
import com.mongodb.casbah.Imports._
@ -60,17 +53,15 @@ object FilterConfig {
variant filter.getAs[Int]("v")
mode filter.getAs[Int]("m")
speed filter.getAs[Int]("s")
eloDiff = ~filter.getAs[Int]("e")
config RawFilterConfig(variant, mode, speed, eloDiff).decode
config RawFilterConfig(variant, mode, speed).decode
} yield config
}
private[setup] case class RawFilterConfig(v: Int, m: Int, s: Int, e: Int) {
private[setup] case class RawFilterConfig(v: Int, m: Int, s: Int) {
def decode = FilterConfig(
variant = Variant(v),
mode = Mode(m),
speed = Speed(s),
eloDiff = e
speed = Speed(s)
).some
}

View File

@ -21,8 +21,7 @@ private[setup] final class FormFactory(
mapping(
"variant" -> optional(variant),
"mode" -> mode(ctx.isAuth),
"speed" -> optional(speed),
"eloDiff" -> eloDiff
"speed" -> optional(speed)
)(FilterConfig.<<)(_.>>)
)

View File

@ -19,5 +19,4 @@ object Mappings {
val color = nonEmptyText.verifying(Color.names contains _)
val level = number.verifying(AiConfig.levels contains _)
val speed = number.verifying(Config.speeds contains _)
val eloDiff = number.verifying(FilterConfig.eloDiffs contains _)
}

1
todo
View File

@ -53,4 +53,3 @@ make signup more visible
traduction intégrale
block user creation from an IP
mute IP
fast join game = creator not redirected properly?