@@ -3,6 +3,7 @@ package format.pgn
33
44import cats .syntax .all .*
55import monocle .syntax .all .*
6+ import scalalib .model .Seconds
67
78type PgnTree = Node [Move ]
89
@@ -56,17 +57,17 @@ case class Move(
5657 glyphs : Glyphs = Glyphs .empty,
5758 opening : Option [String ] = None ,
5859 result : Option [String ] = 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
60+ timeLeft : Option [Seconds ] = None , // %clk clock in seconds for the move player, after the move
61+ moveTime : Option [Seconds ] = None , // %emt estimated move time in seconds
6162 variationComments : List [Comment ] = Nil
6263):
6364
6465 private def clockString : Option [String ] = List (
65- secondsLeft .map(seconds => " [%clk " + Move .formatPgnSeconds(seconds) + " ]" ),
66+ timeLeft .map(seconds => " [%clk " + Move .formatPgnSeconds(seconds) + " ]" ),
6667 moveTime.map(seconds => " [%emt " + Move .formatPgnSeconds(seconds) + " ]" )
6768 ).flatten.some.filter(_.nonEmpty).map(_.mkString(" " ))
6869
69- def hasComment = comments.nonEmpty || secondsLeft .isDefined || moveTime.isDefined
70+ def hasComment = comments.nonEmpty || timeLeft .isDefined || moveTime.isDefined
7071
7172 private def nonEmpty = hasComment || opening.isDefined || result.isDefined
7273
@@ -99,6 +100,6 @@ object Move:
99100 private def noDoubleLineBreak (txt : String ) =
100101 noDoubleLineBreakRegex.replaceAllIn(txt, " \n " )
101102
102- def formatPgnSeconds (t : Int ): String =
103- val d = java.time.Duration .ofSeconds(t)
103+ def formatPgnSeconds (t : Seconds ): String =
104+ val d = java.time.Duration .ofSeconds(t.value )
104105 f " ${d.toHours}: ${d.toMinutesPart}%02d: ${d.toSecondsPart}%02d "
0 commit comments