Merge pull request #9005 from benediktwerner/fix-no-fen-imports

Fix no-FEN imports
pull/9027/head
Thibault Duplessis 2021-05-25 09:34:16 +02:00 committed by GitHub
commit 09837c660b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 13 deletions

View File

@ -390,7 +390,7 @@ final class GameRepo(val coll: Coll)(implicit ec: scala.concurrent.ExecutionCont
else g
val userIds = g2.userIds.distinct
val fen: Option[FEN] = initialFen orElse {
(!g2.variant.standardInitialPosition)
(g2.variant.fromPosition || g2.variant.chess960)
.option(Forsyth >> g2.chess)
.filterNot(_.initial)
}

View File

@ -30,11 +30,4 @@ private object Chess960 {
case _ => false
}(Rank.Eighth)
}
def fixVariantName(v: String) =
v.toLowerCase match {
case "chess 960" => "chess960"
case "fisherandom" => "chess960" // I swear, sometimes...
case _ => v
}
}

View File

@ -55,12 +55,11 @@ case class ImportData(pgn: String, analyse: Option[String]) {
}
def preprocess(user: Option[String]): Validated[String, Preprocessed] = ImporterForm.catchOverflow { () =>
Parser.full(pgn) flatMap { parsed =>
Parser.full(pgn) map { parsed =>
Reader.fullWithSans(
pgn,
sans => sans.copy(value = sans.value take maxPlies),
Tags.empty
) map evenIncomplete map { case replay @ Replay(setup, _, state) =>
parsed,
sans => sans.copy(value = sans.value take maxPlies)
) pipe evenIncomplete pipe { case replay @ Replay(setup, _, state) =>
val initBoard = parsed.tags.fen flatMap Forsyth.<< map (_.board)
val fromPosition = initBoard.nonEmpty && !parsed.tags.fen.exists(_.initial)
val variant = {