{master} fix PGN export of masters explorer games

deepcrayonfish^2
Thibault Duplessis 2021-11-08 12:08:19 +01:00
parent 51605e46f1
commit 79ed95d366
2 changed files with 6 additions and 4 deletions

View File

@ -57,10 +57,12 @@ final class PgnDump(
private def gameLightUsers(game: Game): Fu[(Option[LightUser], Option[LightUser])] =
(game.whitePlayer.userId ?? lightUserApi.async) zip (game.blackPlayer.userId ?? lightUserApi.async)
private def rating(p: Player) = p.rating.fold("?")(_.toString)
private def rating(p: Player) = p.rating.orElse(p.nameSplit.flatMap(_._2)).fold("?")(_.toString)
def player(p: Player, u: Option[LightUser]) =
p.aiLevel.fold(u.fold(p.name | lila.user.User.anonymous)(_.name))("lichess AI level " + _)
p.aiLevel.fold(u.fold(p.nameSplit.map(_._1).orElse(p.name) | lila.user.User.anonymous)(_.name))(
"lichess AI level " + _
)
private val customStartPosition: Set[chess.variant.Variant] =
Set(chess.variant.Chess960, chess.variant.FromPosition, chess.variant.Horde, chess.variant.RacingKings)

View File

@ -60,8 +60,8 @@ case class Player(
def nameSplit: Option[(String, Option[Int])] =
name map {
case Player.nameSplitRegex(n, r) => n -> r.toIntOption
case n => n -> none
case Player.nameSplitRegex(n, r) => n.trim -> r.toIntOption
case n => n -> none
}
def before(other: Player) =