feat: NCS-11 derive PGN termination marker from Result header
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,8 @@ object PgnExporter:
|
|||||||
if blackMoveStr.isEmpty then s"$moveNum. $whiteMoveStr"
|
if blackMoveStr.isEmpty then s"$moveNum. $whiteMoveStr"
|
||||||
else s"$moveNum. $whiteMoveStr $blackMoveStr"
|
else s"$moveNum. $whiteMoveStr $blackMoveStr"
|
||||||
|
|
||||||
moveLines.mkString(" ") + " *"
|
val termination = headers.getOrElse("Result", "*")
|
||||||
|
moveLines.mkString(" ") + s" $termination"
|
||||||
|
|
||||||
if headerLines.isEmpty then moveText
|
if headerLines.isEmpty then moveText
|
||||||
else if moveText.isEmpty then headerLines
|
else if moveText.isEmpty then headerLines
|
||||||
|
|||||||
@@ -100,3 +100,15 @@ class PgnExporterTest extends AnyFunSuite with Matchers:
|
|||||||
pgn should include ("e2e4")
|
pgn should include ("e2e4")
|
||||||
pgn should not include ("=")
|
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 *"
|
||||||
|
|||||||
Reference in New Issue
Block a user