@@ -2,6 +2,7 @@ package chess
22package format .pgn
33
44import monocle .syntax .all .*
5+ import cats .syntax .all .*
56
67type PgnTree = Node [Move ]
78
@@ -55,19 +56,19 @@ case class Move(
5556 glyphs : Glyphs = Glyphs .empty,
5657 opening : Option [String ] = None ,
5758 result : Option [String ] = None ,
58- // time left for the user who made the move, after he made it
59- secondsLeft : Option [Int ] = None ,
59+ secondsLeft : Option [ Int ] = None , // %clk clock in seconds for the move player , after the move
60+ moveTime : Option [Int ] = None , // %emt estimated move time in seconds
6061 variationComments : List [Comment ] = Nil
6162):
6263
63- private def clockString : Option [String ] =
64- secondsLeft.map(seconds => " [%clk " + Move .formatPgnSeconds(seconds) + " ]" )
64+ private def clockString : Option [String ] = List (
65+ secondsLeft.map(seconds => " [%clk " + Move .formatPgnSeconds(seconds) + " ]" ),
66+ moveTime.map(seconds => " [%emt " + Move .formatPgnSeconds(seconds) + " ]" )
67+ ).flatten.some.filter(_.nonEmpty).map(_.mkString(" " ))
6568
66- def hasComment =
67- comments.nonEmpty || secondsLeft.isDefined
69+ def hasComment = comments.nonEmpty || secondsLeft.isDefined || moveTime.isDefined
6870
69- private def nonEmpty =
70- comments.nonEmpty || secondsLeft.isDefined || opening.isDefined || result.isDefined
71+ private def nonEmpty = hasComment || opening.isDefined || result.isDefined
7172
7273 private def appendSanStr (builder : StringBuilder ): Unit =
7374 builder.append(san.value)
0 commit comments