From 9b857f93ae00dffd0bd74d4f0b070b6d9bc8abe1 Mon Sep 17 00:00:00 2001 From: Janis Date: Sat, 28 Mar 2026 19:20:43 +0100 Subject: [PATCH] style: replace .isDefined/.get with pattern matching in PgnParser Co-Authored-By: Claude Sonnet 4.6 --- .../main/scala/de/nowchess/chess/notation/PgnParser.scala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/core/src/main/scala/de/nowchess/chess/notation/PgnParser.scala b/modules/core/src/main/scala/de/nowchess/chess/notation/PgnParser.scala index 214a396..a362daf 100644 --- a/modules/core/src/main/scala/de/nowchess/chess/notation/PgnParser.scala +++ b/modules/core/src/main/scala/de/nowchess/chess/notation/PgnParser.scala @@ -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)