add bugs to code that was working perfectly
This commit is contained in:
parent
92b303e101
commit
888861ae99
|
@ -24,7 +24,7 @@ private[importer] case class Result(status: Status, winner: Option[Color])
|
|||
case class Preprocessed(
|
||||
game: Game,
|
||||
replay: Replay,
|
||||
result: Option[Result],
|
||||
result: Result,
|
||||
initialFen: Option[FEN],
|
||||
parsed: ParsedPgn
|
||||
)
|
||||
|
@ -63,13 +63,14 @@ case class ImportData(pgn: String, analyse: Option[String]) {
|
|||
case Some(_) => Status.UnknownFinish
|
||||
}
|
||||
|
||||
val result = parsed.tags(_.Result) ifFalse game.situation.end collect {
|
||||
case "1-0" => Result(status, Color.White.some)
|
||||
case "0-1" => Result(status, Color.Black.some)
|
||||
case "*" => Result(Status.Started, none)
|
||||
case "1/2-1/2" if status == Status.Outoftime => Result(status, none)
|
||||
case "1/2-1/2" => Result(Status.Draw, none)
|
||||
}
|
||||
val result =
|
||||
parsed.tags.resultColor
|
||||
.ifFalse(game.situation.end)
|
||||
.fold(Result(Status.Started, none)) {
|
||||
case Some(color) => Result(status, color.some)
|
||||
case None if status == Status.Outoftime => Result(status, none)
|
||||
case None => Result(Status.Draw, none)
|
||||
}
|
||||
|
||||
val date = parsed.tags.anyDate
|
||||
|
||||
|
|
|
@ -19,21 +19,12 @@ final class Importer(
|
|||
def gameExists(processing: => Fu[Game]): Fu[Game] =
|
||||
GameRepo.findPgnImport(data.pgn) flatMap { _.fold(processing)(fuccess) }
|
||||
|
||||
def applyResult(game: Game, result: Option[Result], situation: Situation): Game =
|
||||
def applyResult(game: Game, result: Result, situation: Situation): Game =
|
||||
if (game.finished) game
|
||||
else situation.status match {
|
||||
case Some(status) => game.finish(status, situation.winner).game
|
||||
case _ => result.fold(game) {
|
||||
case Result(Status.Started, winner) => game.finish(Status.Started, winner).game
|
||||
case Result(Status.Aborted, winner) => game.finish(Status.Aborted, winner).game
|
||||
case Result(Status.Resign, winner) => game.finish(Status.Resign, winner).game
|
||||
case Result(Status.Timeout, winner) => game.finish(Status.Timeout, winner).game
|
||||
case Result(Status.Draw, _) => game.finish(Status.Draw, None).game
|
||||
case Result(Status.Outoftime, winner) => game.finish(Status.Outoftime, winner).game
|
||||
case Result(Status.Cheat, winner) => game.finish(Status.Cheat, winner).game
|
||||
case Result(Status.UnknownFinish, winner) => game.finish(Status.UnknownFinish, winner).game
|
||||
case _ => game
|
||||
}
|
||||
case Some(situationStatus) => game.finish(situationStatus, situation.winner).game
|
||||
case _ if result.status <= Status.Started => game
|
||||
case _ => game.finish(result.status, result.winner).game
|
||||
}
|
||||
|
||||
gameExists {
|
||||
|
|
|
@ -59,9 +59,9 @@ object PgnImport {
|
|||
)
|
||||
)
|
||||
val end: Option[End] = {
|
||||
(if (game.finished) game.status.some else result.map(_.status))
|
||||
(if (game.finished) game.status else result.status).some
|
||||
.filter(chess.Status.Aborted <=).map { status =>
|
||||
val winner = game.winnerColor orElse result.flatMap(_.winner)
|
||||
val winner = game.winnerColor orElse result.winner
|
||||
End(
|
||||
status = status,
|
||||
winner = winner,
|
||||
|
|
|
@ -29,7 +29,7 @@ object Dependencies {
|
|||
val hasher = "com.roundeights" %% "hasher" % "1.2.0"
|
||||
val jodaTime = "joda-time" % "joda-time" % "2.9.9"
|
||||
|
||||
val chess = "org.lichess" %% "scalachess" % "6.17"
|
||||
val chess = "org.lichess" %% "scalachess" % "6.18"
|
||||
val maxmind = "com.sanoma.cda" %% "maxmind-geoip2-scala" % "1.2.3-THIB"
|
||||
val prismic = "io.prismic" %% "scala-kit" % "1.2.11-THIB"
|
||||
val java8compat = "org.scala-lang.modules" %% "scala-java8-compat" % "0.8.0"
|
||||
|
|
Loading…
Reference in a new issue