strictness of board validation
parent
1e4bf5f442
commit
8789f1cae5
|
@ -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
|
||||
|
|
|
@ -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 """<div class="mini_board parse_fen" data-color="%s" data-fen="%s"></div> """.format(
|
||||
parsed.situation.color.name, validated)
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
|
||||
|
|
|
@ -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) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div class="variants buttons">
|
||||
@setup.radios(form("variant"), translatedVariantChoicesWithFen)
|
||||
</div>
|
||||
@fenInput(form("fen"))
|
||||
@fenInput(form("fen"), true)
|
||||
@setup.clock(form, lila.setup.AiConfig)
|
||||
@trans.level()
|
||||
<div class="level buttons">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@(field: play.api.data.Field)(implicit ctx: Context)
|
||||
@(field: play.api.data.Field, strict: Boolean)(implicit ctx: Context)
|
||||
|
||||
<div class="fen_position optional_config" data-validate-url="@routes.Setup.validateFen">
|
||||
<div class="fen_position optional_config" data-validate-url="@routes.Setup.validateFen@strict.fold("?strict=1", "")">
|
||||
@base.input(field, placeholder=trans.pasteTheFenStringHere.str().some)
|
||||
<div class="preview"></div>
|
||||
</div>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="variants buttons">
|
||||
@setup.radios(form("variant"), translatedVariantChoicesWithFen)
|
||||
</div>
|
||||
@fenInput(form("fen"))
|
||||
@fenInput(form("fen"), false)
|
||||
@setup.clock(form, lila.setup.FriendConfig)
|
||||
@if(ctx.isAuth) {
|
||||
<div class="mode_choice buttons">
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 195b624927560fa580daa0b54b5eb4c7c23bd582
|
||||
Subproject commit 5d7b1e1d42143c6a16cc11928ebd741c8ab4d973
|
Loading…
Reference in New Issue