style: replace .isDefined/.get with pattern matching in PgnParser

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-28 19:20:43 +01:00
parent 58a962cf98
commit 9b857f93ae
@@ -43,11 +43,9 @@ object PgnParser:
parseAlgebraicMove(token, board, history, color) match
case None => state // unrecognised token — skip silently
case Some(move) =>
val newBoard =
if move.castleSide.isDefined then
board.withCastle(color, move.castleSide.get)
else
board.withMove(move.from, move.to)._1
val newBoard = move.castleSide match
case Some(side) => board.withCastle(color, side)
case None => board.withMove(move.from, move.to)._1
val newHistory = history.addMove(move)
(newBoard, newHistory, color.opposite, acc :+ move)