diff --git a/app/ai/stockfish/Ai.scala b/app/ai/stockfish/Ai.scala index 0680846877..02f317f976 100644 --- a/app/ai/stockfish/Ai.scala +++ b/app/ai/stockfish/Ai.scala @@ -26,7 +26,7 @@ final class Ai(server: Server) extends lila.ai.Ai with Stockfish { server.analyse(pgn, initialFen) private def withValidSituation[A](dbGame: DbGame)(op: ⇒ Future[Valid[A]]): Future[Valid[A]] = - if (dbGame.toChess.situation.playable) op + if (dbGame.toChess.situation playable true) op else Future { !!("Invalid game situation: " + dbGame.toChess.situation) } private implicit val executor = Akka.system.dispatcher diff --git a/app/controllers/Setup.scala b/app/controllers/Setup.scala index a6e7898ac3..c18db51692 100644 --- a/app/controllers/Setup.scala +++ b/app/controllers/Setup.scala @@ -115,7 +115,8 @@ object Setup extends LilaController with TheftPrevention with RoundEventPerforme for { fen ← get("fen") parsed ← chess.format.Forsyth <<< fen - if parsed.situation.playable + strict = get("strict").isDefined + if (parsed.situation playable strict) validated = chess.format.Forsyth >> parsed } yield """
""".format( parsed.situation.color.name, validated) diff --git a/app/setup/FormFactory.scala b/app/setup/FormFactory.scala index 0e0ff7f5e0..0e20534d2a 100644 --- a/app/setup/FormFactory.scala +++ b/app/setup/FormFactory.scala @@ -47,7 +47,7 @@ private[setup] final class FormFactory( "increment" -> increment, "level" -> level, "color" -> color, - "fen" -> fen + "fen" -> fen(true) )(AiConfig.<<)(_.>>) ) @@ -69,7 +69,7 @@ private[setup] final class FormFactory( "increment" -> increment, "mode" -> mode(ctx.isAuth), "color" -> color, - "fen" -> fen + "fen" -> fen(false) )(FriendConfig.<<)(_.>>) verifying ("Invalid clock", _.validClock) ) diff --git a/app/setup/Mappings.scala b/app/setup/Mappings.scala index 8d7d1ad8e7..e857c0c25d 100644 --- a/app/setup/Mappings.scala +++ b/app/setup/Mappings.scala @@ -23,7 +23,7 @@ object Mappings { val speed = number.verifying(Config.speeds contains _) val eloDiff = number.verifying(FilterConfig.eloDiffs contains _) - val fen = optional { - nonEmptyText verifying { source ⇒ ~(Forsyth <<< source).map(_.situation.playable) } + def fen(strict: Boolean) = optional { + nonEmptyText verifying { source ⇒ ~(Forsyth <<< source).map(_.situation playable strict) } } } diff --git a/app/views/setup/ai.scala.html b/app/views/setup/ai.scala.html index 9be2dda322..2b7b7a8a15 100644 --- a/app/views/setup/ai.scala.html +++ b/app/views/setup/ai.scala.html @@ -4,7 +4,7 @@ -@fenInput(form("fen")) +@fenInput(form("fen"), true) @setup.clock(form, lila.setup.AiConfig) @trans.level()