style: replace .isDefined/.get with pattern matching in PgnParser
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user