feat: NCS-11 50-move rule #9

Merged
Janis merged 12 commits from feat/NCS-11 into main 2026-04-01 10:36:24 +02:00
2 changed files with 14 additions and 1 deletions
Showing only changes of commit 396940da43 - Show all commits
@@ -22,7 +22,8 @@ object PgnExporter:
if blackMoveStr.isEmpty then s"$moveNum. $whiteMoveStr"
else s"$moveNum. $whiteMoveStr $blackMoveStr"
moveLines.mkString(" ") + " *"
val termination = headers.getOrElse("Result", "*")
moveLines.mkString(" ") + s" $termination"
if headerLines.isEmpty then moveText
else if moveText.isEmpty then headerLines
@@ -100,3 +100,15 @@ class PgnExporterTest extends AnyFunSuite with Matchers:
pgn should include ("e2e4")
pgn should not include ("=")
}
test("exportGame uses Result header as termination marker"):
val history = GameHistory()
.addMove(HistoryMove(Square(File.E, Rank.R2), Square(File.E, Rank.R4), None))
val pgn = PgnExporter.exportGame(Map("Result" -> "1/2-1/2"), history)
pgn should endWith("1/2-1/2")
test("exportGame with no Result header still uses * as default"):
val history = GameHistory()
.addMove(HistoryMove(Square(File.E, Rank.R2), Square(File.E, Rank.R4), None))
val pgn = PgnExporter.exportGame(Map.empty, history)
pgn shouldBe "1. e2e4 *"