Skip to content

Commit 875aaa0

Browse files
committed
Move.moveTime, 17.0.1
1 parent 281351f commit 875aaa0

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
inThisBuild(
22
Seq(
33
scalaVersion := "3.6.2",
4-
version := "17.0.0",
4+
version := "17.0.1",
55
organization := "org.lichess",
66
licenses += ("MIT" -> url("https://opensource.org/licenses/MIT")),
77
publishTo := Option(Resolver.file("file", new File(sys.props.getOrElse("publishTo", "")))),

core/src/main/scala/format/pgn/Pgn.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package chess
22
package format.pgn
33

44
import monocle.syntax.all.*
5+
import cats.syntax.all.*
56

67
type 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)

core/src/main/scala/format/pgn/parsingModel.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ case class PgnNodeData(
2828
san = x.toSanStr,
2929
comments = comments,
3030
glyphs = glyphs,
31-
opening = None,
32-
result = None,
33-
secondsLeft = None,
3431
variationComments = variationComments
3532
)
3633
)

test-kit/src/main/scala/chess/ChessTreeArbitraries.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ object ChessTreeArbitraries:
8888
comments <- genComments(5)
8989
glyphs <- Gen.someOf(Glyphs.all).map(xs => Glyphs.fromList(xs.toList))
9090
clock <- Gen.posNum[Int]
91-
yield WithMove(move, PgnMove(move.san, comments, glyphs, None, None, clock.some, Nil))
91+
yield WithMove(move, PgnMove(move.san, comments, glyphs, secondsLeft = clock.some))
9292

9393
def genNode[A: Generator](value: A, variations: List[A] = Nil): Gen[Node[A]] =
9494
value.next.flatMap: nextSeeds =>

0 commit comments

Comments
 (0)