diff --git a/src/main/scala/Board.scala b/src/main/scala/Board.scala index 2ffa28c0..cdf1feb8 100644 --- a/src/main/scala/Board.scala +++ b/src/main/scala/Board.scala @@ -86,7 +86,7 @@ case class Board( if v == Crazyhouse then copy(variant = v).ensureCrazyData else copy(variant = v) - def withCrazyData(data: Crazyhouse.Data) = copy(crazyData = Option(data)) + def withCrazyData(data: Crazyhouse.Data) = copy(crazyData = Some(data)) def withCrazyData(data: Option[Crazyhouse.Data]) = copy(crazyData = data) def withCrazyData(f: Crazyhouse.Data => Crazyhouse.Data): Board = withCrazyData(f(crazyData | Crazyhouse.Data.init)) diff --git a/src/main/scala/Clock.scala b/src/main/scala/Clock.scala index a023e98a..33527b0a 100644 --- a/src/main/scala/Clock.scala +++ b/src/main/scala/Clock.scala @@ -42,7 +42,7 @@ case class Clock( def isRunning = timer.isDefined - def start = if isRunning then this else copy(timer = Option(now)) + def start = if isRunning then this else copy(timer = Some(now)) def stop = timer.fold(this) { t => diff --git a/src/main/scala/Color.scala b/src/main/scala/Color.scala index 8ae556f4..0c830a05 100644 --- a/src/main/scala/Color.scala +++ b/src/main/scala/Color.scala @@ -43,13 +43,13 @@ enum Color(val name: String, val letter: Char) derives Eq: object Color: def fromName(n: String): Option[Color] = - if n == "white" then Option(White) - else if n == "black" then Option(Black) + if n == "white" then Some(White) + else if n == "black" then Some(Black) else None def apply(c: Char): Option[Color] = - if c == 'w' then Option(White) - else if c == 'b' then Option(Black) + if c == 'w' then Some(White) + else if c == 'b' then Some(Black) else None val white: Color = White diff --git a/src/main/scala/Drop.scala b/src/main/scala/Drop.scala index 02ed901d..157de86e 100644 --- a/src/main/scala/Drop.scala +++ b/src/main/scala/Drop.scala @@ -20,7 +20,7 @@ case class Drop( val board = after.variant.finalizeBoard( after updateHistory { h => h.copy( - lastMove = Option(Uci.Drop(piece.role, square)), + lastMove = Some(Uci.Drop(piece.role, square)), unmovedRooks = before.unmovedRooks, halfMoveClock = if piece.is(Pawn) then HalfMoveClock.initial else h.halfMoveClock + 1 ) diff --git a/src/main/scala/History.scala b/src/main/scala/History.scala index 77c5e1ef..95d99733 100644 --- a/src/main/scala/History.scala +++ b/src/main/scala/History.scala @@ -40,7 +40,7 @@ case class History( inline def withCastles(inline c: Castles) = copy(castles = c) - inline def withLastMove(inline m: Uci) = copy(lastMove = Option(m)) + inline def withLastMove(inline m: Uci) = copy(lastMove = Some(m)) def withCheck(color: Color, check: Check) = if check.yes then copy(checkCount = checkCount add color) else this diff --git a/src/main/scala/LagTracker.scala b/src/main/scala/LagTracker.scala index 2683f100..d5cf42c8 100644 --- a/src/main/scala/LagTracker.scala +++ b/src/main/scala/LagTracker.scala @@ -36,7 +36,7 @@ final case class LagTracker( val e = lagEstimator.record((lag atMost quotaMax).centis.toFloat) copy( lagEstimator = e, - compEstimate = Option(Centis.ofFloat(e.mean - .8f * e.deviation).nonNeg atMost quota) + compEstimate = Some(Centis.ofFloat(e.mean - .8f * e.deviation).nonNeg atMost quota) ) def moves = lagStats.samples diff --git a/src/main/scala/Move.scala b/src/main/scala/Move.scala index b0b3f6c4..6fda62dd 100644 --- a/src/main/scala/Move.scala +++ b/src/main/scala/Move.scala @@ -27,7 +27,7 @@ case class Move( val board = after.variant.finalizeBoard( after updateHistory { h1 => val h2 = h1.copy( - lastMove = Option(toUci), + lastMove = Some(toUci), unmovedRooks = before.unmovedRooks, halfMoveClock = if piece.is(Pawn) || captures || promotes then HalfMoveClock.initial @@ -117,7 +117,7 @@ case class Move( for b2 <- after take dest b3 <- b2.place(color - p, dest) - yield copy(after = b3, promotion = Option(p)) + yield copy(after = b3, promotion = Some(p)) else this.some inline def withAfter(newBoard: Board) = copy(after = newBoard) diff --git a/src/main/scala/MoveMetrics.scala b/src/main/scala/MoveMetrics.scala index a57f8f92..b5799197 100644 --- a/src/main/scala/MoveMetrics.scala +++ b/src/main/scala/MoveMetrics.scala @@ -8,7 +8,7 @@ case class MoveMetrics( // Calculate client reported lag given the server's duration for the move. def reportedLag(elapsed: Centis) = - clientMoveTime.fold(clientLag)(mt => Option(elapsed - mt)) + clientMoveTime.fold(clientLag)(mt => Some(elapsed - mt)) object MoveMetrics: val empty = MoveMetrics() diff --git a/src/main/scala/Role.scala b/src/main/scala/Role.scala index 62488a8e..ba4ab3df 100644 --- a/src/main/scala/Role.scala +++ b/src/main/scala/Role.scala @@ -57,11 +57,11 @@ object Role: def valueOf(r: Role): Option[Int] = r match - case Pawn => Option(1) - case Knight => Option(3) - case Bishop => Option(3) - case Rook => Option(5) - case Queen => Option(9) + case Pawn => Some(1) + case Knight => Some(3) + case Bishop => Some(3) + case Rook => Some(5) + case Queen => Some(9) case King => None case class ByRole[A](pawn: A, knight: A, bishop: A, rook: A, queen: A, king: A): diff --git a/src/main/scala/Situation.scala b/src/main/scala/Situation.scala index 4c8219da..c4b18a5f 100644 --- a/src/main/scala/Situation.scala +++ b/src/main/scala/Situation.scala @@ -287,7 +287,7 @@ case class Situation(board: Board, color: Color): ) private def normalMove(orig: Square, dest: Square, role: Role, capture: Boolean): Option[Move] = - val taken = if capture then Option(dest) else None + val taken = if capture then Some(dest) else None val after = if capture then board.taking(orig, dest, taken) else board.move(orig, dest) @@ -311,7 +311,7 @@ case class Situation(board: Board, color: Color): promotion: PromotableRole, capture: Boolean ): Option[Move] = - val taken = if capture then Option(dest) else None + val taken = if capture then Some(dest) else None board .promote(orig, dest, color - promotion) .map(board => diff --git a/src/main/scala/format/pgn/Binary.scala b/src/main/scala/format/pgn/Binary.scala index b17a3d0d..ea5541f0 100644 --- a/src/main/scala/format/pgn/Binary.scala +++ b/src/main/scala/format/pgn/Binary.scala @@ -124,7 +124,7 @@ object Binary: case SimplePieceR(piece, capture, square, check) => simplePiece(piece, square, capture, check) case FullPawnR(file, square, promotion, check) => - fullPawn(Option(file), square, check, Option(promotion)) + fullPawn(Some(file), square, check, Some(promotion)) case FullPieceR(piece, orig, capture, square, check) => fullPiece(piece, orig, square, capture, check) case DropR(role, square, check) => drop(role, square, check) diff --git a/test-kit/src/test/scala/AntichessVariantTest.scala b/test-kit/src/test/scala/AntichessVariantTest.scala index c5da8b07..7aecb88e 100644 --- a/test-kit/src/test/scala/AntichessVariantTest.scala +++ b/test-kit/src/test/scala/AntichessVariantTest.scala @@ -141,10 +141,10 @@ g4 {[%emt 0.200]} 34. Rxg4 {[%emt 0.172]} 0-1""" val position = EpdFen("8/5P2/8/2b5/8/8/4B3/8 w - -") val originalGame = fenToGame(position, Antichess) - val newGame = originalGame flatMap (_.apply(Square.F7, Square.F8, Option(King))) map (_._1) + val newGame = originalGame flatMap (_.apply(Square.F7, Square.F8, Some(King))) map (_._1) newGame must beRight: - (_: Game).board(Square.F8).mustEqual(Option(White - King)) + (_: Game).board(Square.F8).mustEqual(Some(White - King)) "deal with 2 white kings" in: val position = EpdFen("K3k1nr/p2q2pp/p2p1p2/8/2PP4/8/PP4PP/RNBQK1NR w - - 0 11") @@ -194,7 +194,7 @@ g4 {[%emt 0.200]} 34. Rxg4 {[%emt 0.172]} 0-1""" val position = EpdFen("8/6p1/4B1P1/4p3/4P3/8/2p5/8 b - - 1 28") val originalGame = fenToGame(position, Antichess) - val newGame = originalGame flatMap (_.apply(Square.C2, Square.C1, Option(Bishop))) map (_._1) + val newGame = originalGame flatMap (_.apply(Square.C2, Square.C1, Some(Bishop))) map (_._1) newGame must beRight.like { case (drawnGame: Game) => drawnGame.situation.end must beTrue @@ -206,7 +206,7 @@ g4 {[%emt 0.200]} 34. Rxg4 {[%emt 0.172]} 0-1""" val position = EpdFen("8/6p1/1B4P1/4p3/4P3/8/3p4/8 b - -") val originalGame = fenToGame(position, Antichess) - val newGame = originalGame flatMap (_.apply(Square.D2, Square.D1, Option(Bishop))) map (_._1) + val newGame = originalGame flatMap (_.apply(Square.D2, Square.D1, Some(Bishop))) map (_._1) newGame must beRight.like { case nonDrawnGame => nonDrawnGame.situation.end must beFalse diff --git a/test-kit/src/test/scala/BoardTest.scala b/test-kit/src/test/scala/BoardTest.scala index 9cfe70c7..1c4b8907 100644 --- a/test-kit/src/test/scala/BoardTest.scala +++ b/test-kit/src/test/scala/BoardTest.scala @@ -53,7 +53,7 @@ class BoardTest extends ChessTest: "allow a piece to be placed" in: board.place(White - Rook, E3) must beSome: - (_: Board)(E3) mustEqual Option(White - Rook) + (_: Board)(E3) mustEqual Some(White - Rook) "allow a piece to be taken" in: board take A1 must beSome: @@ -61,7 +61,7 @@ class BoardTest extends ChessTest: "allow a piece to move" in: board.move(E2, E4) must beSome: - (_: Board)(E4) mustEqual Option(White - Pawn) + (_: Board)(E4) mustEqual Some(White - Pawn) "not allow an empty position to move" in: board.move(E5, E6) must beNone @@ -75,7 +75,7 @@ class BoardTest extends ChessTest: _.place(White - Pawn, A3), _.move(A2, A4) ) must beSome: - (_: Board)(A4) mustEqual Option(White - Pawn) + (_: Board)(A4) mustEqual Some(White - Pawn) "fail on bad actions chain" in: makeEmptyBoard.seq( diff --git a/test-kit/src/test/scala/ChessTest.scala b/test-kit/src/test/scala/ChessTest.scala index c4415d53..edf096a6 100644 --- a/test-kit/src/test/scala/ChessTest.scala +++ b/test-kit/src/test/scala/ChessTest.scala @@ -49,7 +49,7 @@ trait ChessTest extends Specification with EitherMatchers: ): Either[ErrorStr, Game] = game(orig, dest, promotion).map(_._1) - def withClock(c: Clock) = game.copy(clock = Option(c)) + def withClock(c: Clock) = game.copy(clock = Some(c)) extension (sit: Situation) def movesAt(s: Square): List[Move] = diff --git a/test-kit/src/test/scala/ClockTest.scala b/test-kit/src/test/scala/ClockTest.scala index 6736ab6c..c9ea0e9a 100644 --- a/test-kit/src/test/scala/ClockTest.scala +++ b/test-kit/src/test/scala/ClockTest.scala @@ -32,10 +32,10 @@ class ClockTest extends ChessTest: val clock = Clock(5 * 60 * 1000, 0) val game = makeGame withClock clock.start "new game" in: - game.clock map { _.color } must_== Option(White) + game.clock map { _.color } must_== Some(White) "one move played" in: game.playMoves(E2 -> E4) must beRight.like { case g: Game => - g.clock map { _.color } must_== Option(Black) + g.clock map { _.color } must_== Some(Black) } "create a clock" should: "with time" in: @@ -47,7 +47,7 @@ class ClockTest extends ChessTest: "with 30 seconds" in: Clock(30, 0).limitInMinutes must_== 0.5 "lag compensation" should: - def durOf(lag: Int) = MoveMetrics(clientLag = Option(Centis(lag))) + def durOf(lag: Int) = MoveMetrics(clientLag = Some(Centis(lag))) def clockStep(clock: Clock, wait: Int, lags: Int*) = (lags.foldLeft(clock) { (clk, lag) => diff --git a/test-kit/src/test/scala/CrazyhouseDataTest.scala b/test-kit/src/test/scala/CrazyhouseDataTest.scala index ec624fff..0738720d 100644 --- a/test-kit/src/test/scala/CrazyhouseDataTest.scala +++ b/test-kit/src/test/scala/CrazyhouseDataTest.scala @@ -45,7 +45,7 @@ class CrazyhouseDataTest extends ScalaCheckSuite: } val result = ps .filter(_.role != King) - .foldLeft(Option(data)) { (data, piece) => + .foldLeft(Some(data)) { (data, piece) => data.flatMap(_.drop(!piece)) } result.isDefined && result.get.isEmpty diff --git a/test-kit/src/test/scala/PawnTest.scala b/test-kit/src/test/scala/PawnTest.scala index 0900313e..c6447af7 100644 --- a/test-kit/src/test/scala/PawnTest.scala +++ b/test-kit/src/test/scala/PawnTest.scala @@ -69,29 +69,29 @@ class PawnTest extends ChessTest: board destsFrom D5 must bePoss(D6) "with irrelevant history" in: board withHistory defaultHistory( - lastMove = Option(Uci.Move(A2, A4)) + lastMove = Some(Uci.Move(A2, A4)) ) destsFrom D5 must bePoss(D6) "with relevant history on the left" in: board withHistory defaultHistory( - lastMove = Option(Uci.Move(C7, C5)) + lastMove = Some(Uci.Move(C7, C5)) ) destsFrom D5 must bePoss(D6, C6) "with relevant history on the right" in: board withHistory defaultHistory( - lastMove = Option(Uci.Move(E7, E5)) + lastMove = Some(Uci.Move(E7, E5)) ) destsFrom D5 must bePoss(D6, E6) "enemy not-a-pawn" in: makeBoard( D5 -> White.pawn, E5 -> Black.rook ) withHistory defaultHistory( - lastMove = Option(Uci.Move(E7, E5)) + lastMove = Some(Uci.Move(E7, E5)) ) destsFrom D5 must bePoss(D6) "friend pawn (?!)" in: makeBoard( D5 -> White.pawn, E5 -> White.pawn ) withHistory defaultHistory( - lastMove = Option(Uci.Move(E7, E5)) + lastMove = Some(Uci.Move(E7, E5)) ) destsFrom D5 must bePoss(D6) "a black pawn" should: @@ -158,12 +158,12 @@ class PawnTest extends ChessTest: board destsFrom D4 must bePoss(D3) "with relevant history on the left" in: board withHistory defaultHistory( - lastMove = Option(Uci.Move(C2, C4)) + lastMove = Some(Uci.Move(C2, C4)) ) destsFrom D4 must bePoss(D3, C3) "enemy not-a-pawn" in: makeBoard( D4 -> Black.pawn, E4 -> White.rook ) withHistory defaultHistory( - lastMove = Option(Uci.Move(E2, E4)) + lastMove = Some(Uci.Move(E2, E4)) ) destsFrom D4 must bePoss(D3) diff --git a/test-kit/src/test/scala/PromotionTest.scala b/test-kit/src/test/scala/PromotionTest.scala index 6935764b..415f0ddf 100644 --- a/test-kit/src/test/scala/PromotionTest.scala +++ b/test-kit/src/test/scala/PromotionTest.scala @@ -12,6 +12,6 @@ class PromotionTest extends ChessTest: val fen = EpdFen("8/1P6/8/8/8/8/7k/1K6 w - -") val game = fenToGame(fen, Standard).toOption.get - val failureGame = game(Square.B7, Square.B8, Option(King)).map(_._1) + val failureGame = game(Square.B7, Square.B8, Some(King)).map(_._1) failureGame must beLeft diff --git a/test-kit/src/test/scala/RacingKingsVariantTest.scala b/test-kit/src/test/scala/RacingKingsVariantTest.scala index 2a4ef233..110686ed 100644 --- a/test-kit/src/test/scala/RacingKingsVariantTest.scala +++ b/test-kit/src/test/scala/RacingKingsVariantTest.scala @@ -17,37 +17,37 @@ class RacingKingsVariantTest extends ChessTest: val fenPosition = EpdFen("4krn1/K2b4/8/8/8/8/8/8 w - - 4 3") val game = fenToGame(fenPosition, RacingKings).toOption.get game.situation.end must beTrue - game.situation.winner mustEqual Option(Black) + game.situation.winner mustEqual Some(Black) "game end to black 2" in: val fenPosition = EpdFen("4brk1/8/5n2/K7/8/8/8/8 w - - 6 4") val game = fenToGame(fenPosition, RacingKings).toOption.get game.situation.end must beTrue - game.situation.winner mustEqual Option(Black) + game.situation.winner mustEqual Some(Black) "game end to black 3" in: val fenPosition = EpdFen("3kbrn1/8/8/K7/8/8/8/8 w - - 4 3") val game = fenToGame(fenPosition, RacingKings).toOption.get game.situation.end must beTrue - game.situation.winner mustEqual Option(Black) + game.situation.winner mustEqual Some(Black) "game end to black 4" in: val fenPosition = EpdFen("4brk1/4n3/8/K7/8/8/8/8 w - - 4 3") val game = fenToGame(fenPosition, RacingKings).toOption.get game.situation.end must beTrue - game.situation.winner mustEqual Option(Black) + game.situation.winner mustEqual Some(Black) "game end to white" in: val fenPosition = EpdFen("K3br2/5k2/8/8/6n1/8/8/8 w - - 4 3") val game = fenToGame(fenPosition, RacingKings).toOption.get game.situation.end must beTrue - game.situation.winner mustEqual Option(White) + game.situation.winner mustEqual Some(White) "game end to white 2" in: val fenPosition = EpdFen("K3b2r/5k2/5n2/8/8/8/8/8 w - - 4 3") val game = fenToGame(fenPosition, RacingKings).toOption.get game.situation.end must beTrue - game.situation.winner mustEqual Option(White) + game.situation.winner mustEqual Some(White) "game is draw if both kings are in 8th rank" in: val fenPosition = EpdFen("K3brk1/8/5n2/8/8/8/8/8 w - - 4 3") diff --git a/test-kit/src/test/scala/format/pgn/ParserTest.scala b/test-kit/src/test/scala/format/pgn/ParserTest.scala index d788bb89..65be4a04 100644 --- a/test-kit/src/test/scala/format/pgn/ParserTest.scala +++ b/test-kit/src/test/scala/format/pgn/ParserTest.scala @@ -47,13 +47,13 @@ class ParserTest extends ChessTest: "as a queen" in: parse("b8=Q ") must beRight.like: parsed => parsed.mainline.headOption must beSome { (san: San) => - san === Std(Square.B8, Pawn, promotion = Option(Queen)) + san === Std(Square.B8, Pawn, promotion = Some(Queen)) } "as a rook" in: parse("b8=R ") must beRight { (parsed: ParsedPgn) => parsed.mainline.headOption must beSome { (san: San) => - san.asInstanceOf[Std].promotion must_== Option(Rook) + san.asInstanceOf[Std].promotion must_== Some(Rook) } } @@ -97,7 +97,7 @@ class ParserTest extends ChessTest: "glyphs" in: parseMove("b8=B ") must beRight.like: node => - node.value.san === Std(Square.B8, Pawn, promotion = Option(Bishop)) + node.value.san === Std(Square.B8, Pawn, promotion = Some(Bishop)) parseMove("1. e4") must beRight.like: node => node.value.san must_== Std(Square.E4, Pawn) @@ -121,15 +121,15 @@ class ParserTest extends ChessTest: parse(withNag) must beRight parse("Ne7g6+! $13") must beRight.like: parsed => - parsed.metas.glyphs.move must_== Option(Glyph.MoveAssessment.good) - parsed.metas.glyphs.position must_== Option(Glyph.PositionAssessment.unclear) + parsed.metas.glyphs.move must_== Some(Glyph.MoveAssessment.good) + parsed.metas.glyphs.position must_== Some(Glyph.PositionAssessment.unclear) "non-nags" in: parse(withGlyphAnnotations) must beRight parse("Bxd3?? ∞") must beRight.like { parsed => - parsed.tree.firstMove.metas.glyphs.move must_== Option(Glyph.MoveAssessment.blunder) - parsed.tree.firstMove.metas.glyphs.position must_== Option(Glyph.PositionAssessment.unclear) + parsed.tree.firstMove.metas.glyphs.move must_== Some(Glyph.MoveAssessment.blunder) + parsed.tree.firstMove.metas.glyphs.position must_== Some(Glyph.PositionAssessment.unclear) } "comments" in: @@ -347,16 +347,16 @@ class ParserTest extends ChessTest: "year" in: "full date" in: parse(recentChessCom) must beRight.like { parsed => - parsed.tags.year must_== Option(2016) + parsed.tags.year must_== Some(2016) } "only year" in: parse(explorerPartialDate) must beRight.like { parsed => - parsed.tags.year must_== Option(1978) + parsed.tags.year must_== Some(1978) } "weird variant names" in: parse(stLouisFischerandom) must beRight.like { parsed => - parsed.tags.variant must_== Option(variant.Chess960) + parsed.tags.variant must_== Some(variant.Chess960) } "example from chessgames.com with weird comments" in: diff --git a/test-kit/src/test/scala/format/pgn/ReaderTest.scala b/test-kit/src/test/scala/format/pgn/ReaderTest.scala index 214c8d8a..114c76e8 100644 --- a/test-kit/src/test/scala/format/pgn/ReaderTest.scala +++ b/test-kit/src/test/scala/format/pgn/ReaderTest.scala @@ -64,7 +64,7 @@ class ReaderTest extends ChessTest: "promoting to a rook" in: Reader.full(fromLichessBadPromotion) must beRight.like { case Complete(replay) => replay.chronoMoves lift 10 must beSome: - (_: MoveOrDrop).fold(_.promotion, _ => None) must_== Option(Rook) + (_: MoveOrDrop).fold(_.promotion, _ => None) must_== Some(Rook) } "chessbase arrows" in: Reader.full(chessbaseArrows) must beRight diff --git a/test-kit/src/test/scala/format/pgn/TagTest.scala b/test-kit/src/test/scala/format/pgn/TagTest.scala index 02efb817..8177127d 100644 --- a/test-kit/src/test/scala/format/pgn/TagTest.scala +++ b/test-kit/src/test/scala/format/pgn/TagTest.scala @@ -40,4 +40,4 @@ class TagTest extends ChessTest: "test" should: "beSome" in: - Option(3) must beSome((_: Int) == 3) + Some(3) must beSome((_: Int) == 3)