diff --git a/src/main/scala/Chess.scala b/src/main/scala/Chess.scala index a1608a76..c804bf59 100644 --- a/src/main/scala/Chess.scala +++ b/src/main/scala/Chess.scala @@ -46,13 +46,10 @@ object Chess: ) def apply(req: ClientOut.Opening): Option[ClientIn.OpeningMsg] = - if Variant.list.openingSensibleVariants(req.variant) - then - OpeningDb - .findByEpdFen(req.fen) - .map: - ClientIn.OpeningMsg(req.path, _) - else None + Option + .when(Variant.list.openingSensibleVariants(req.variant))(req.fen) + .flatMap(OpeningDb.findByEpdFen) + .map(ClientIn.OpeningMsg(req.path, _)) private def makeNode( game: chess.Game,