@@ -18,12 +18,12 @@ final class PgnDump(
18
18
19
19
import PgnDump ._
20
20
21
- def apply (game : Game ) : Fu [ Pgn ] =
22
- tags(game) map { ts =>
23
- val fenSituation = ts find (_.name == Tag .FEN ) flatMap { case Tag (_, fen) => Forsyth <<< fen }
24
- val moves2 = (~ fenSituation.map(_.situation.color.black)).fold(" .." :: game.pgnMoves, game.pgnMoves)
25
- Pgn (ts, turns(moves2, fenSituation.map(_.fullMoveNumber) | 1 ))
26
- }
21
+ def apply (game : Game , initialFen : Option [ String ]) : Pgn = {
22
+ val ts = tags(game, initialFen)
23
+ val fenSituation = ts find (_.name == Tag .FEN ) flatMap { case Tag (_, fen) => Forsyth <<< fen }
24
+ val moves2 = (~ fenSituation.map(_.situation.color.black)).fold(" .." :: game.pgnMoves, game.pgnMoves)
25
+ Pgn (ts, turns(moves2, fenSituation.map(_.fullMoveNumber) | 1 ))
26
+ }
27
27
28
28
def filename (game : Game ): String = gameLightUsers(game) match {
29
29
case (wu, bu) => " lichess_pgn_%s_%s_vs_%s.%s.pgn" .format(
@@ -47,28 +47,25 @@ final class PgnDump(
47
47
48
48
private val customStartPosition : Set [Variant ] = Set (Variant .Chess960 , Variant .FromPosition )
49
49
50
- private def tags (game : Game ): Fu [List [Tag ]] = gameLightUsers(game) match {
51
- case (wu, bu) =>
52
- (game.variant.standard.fold(fuccess(none), GameRepo initialFen game.id)) map { initialFen =>
53
- List (
54
- Tag (_.Event , game.rated.fold(" Rated game" , " Casual game" )),
55
- Tag (_.Site , gameUrl(game.id)),
56
- Tag (_.Date , dateFormat.print(game.createdAt)),
57
- Tag (_.White , player(game.whitePlayer, wu)),
58
- Tag (_.Black , player(game.blackPlayer, bu)),
59
- Tag (_.Result , result(game)),
60
- Tag (" WhiteElo" , rating(game.whitePlayer)),
61
- Tag (" BlackElo" , rating(game.blackPlayer)),
62
- Tag (" PlyCount" , game.turns),
63
- Tag (_.Variant , game.variant.name.capitalize),
64
- Tag (_.TimeControl , game.clock.fold(" -" ) { c => s " ${c.limit}+ ${c.increment}" }),
65
- Tag (_.ECO , game.opening.fold(" ?" )(_.code)),
66
- Tag (_.Opening , game.opening.fold(" ?" )(_.name))
67
- ) ::: customStartPosition(game.variant).?? (List (
68
- Tag (_.FEN , initialFen | " ?" ),
69
- Tag (" SetUp" , " 1" )
70
- ))
71
- }
50
+ private def tags (game : Game , initialFen : Option [String ]): List [Tag ] = gameLightUsers(game) match {
51
+ case (wu, bu) => List (
52
+ Tag (_.Event , game.rated.fold(" Rated game" , " Casual game" )),
53
+ Tag (_.Site , gameUrl(game.id)),
54
+ Tag (_.Date , dateFormat.print(game.createdAt)),
55
+ Tag (_.White , player(game.whitePlayer, wu)),
56
+ Tag (_.Black , player(game.blackPlayer, bu)),
57
+ Tag (_.Result , result(game)),
58
+ Tag (" WhiteElo" , rating(game.whitePlayer)),
59
+ Tag (" BlackElo" , rating(game.blackPlayer)),
60
+ Tag (" PlyCount" , game.turns),
61
+ Tag (_.Variant , game.variant.name.capitalize),
62
+ Tag (_.TimeControl , game.clock.fold(" -" ) { c => s " ${c.limit}+ ${c.increment}" }),
63
+ Tag (_.ECO , game.opening.fold(" ?" )(_.code)),
64
+ Tag (_.Opening , game.opening.fold(" ?" )(_.name))
65
+ ) ::: customStartPosition(game.variant).?? (List (
66
+ Tag (_.FEN , initialFen | " ?" ),
67
+ Tag (" SetUp" , " 1" )
68
+ ))
72
69
}
73
70
74
71
private def turns (moves : List [String ], from : Int ): List [chessPgn.Turn ] =
0 commit comments