Skip to content

Commit 033fd13

Browse files
chore: codestyle
1 parent 5d63998 commit 033fd13

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/main/scala/abalone/Board.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ case class Board(
2020

2121
def piecesOf(player: Player): PieceMap = pieces.filter(_._2.is(player))
2222

23-
def isEmptySquare(pos: Option[Pos]): Boolean = pos match {
24-
case Some(pos) => !this.pieces.contains(pos)
25-
case None => false
26-
}
23+
def isEmptySquare(pos: Option[Pos]): Boolean = pos.fold(false)(!this.pieces.contains(_))
2724

2825
def withHistory(h: History): Board = copy(history = h)
2926
def updateHistory(f: History => History) = copy(history = f(history))

src/main/scala/abalone/Pos.scala

+5-7
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ case class Pos private (index: Int) extends AnyVal {
195195

196196
// NOTE - *neighbourhood
197197
// these below only work for neighbour pos but that's probably fine as in Abalone we only move to (potentially extended) neighbourhood
198-
def dir(dir: Option[String]): Option[Pos] = {
198+
def dir(dir: Option[String]): Option[Pos] =
199199
dir match {
200200
case Some("left") => this.left
201201
case Some("downLeft") => this.downLeft
@@ -205,8 +205,8 @@ case class Pos private (index: Int) extends AnyVal {
205205
case Some("upRight") => this.upRight
206206
case _ => None
207207
}
208-
}
209-
def dir(pos: Pos): Option[String] = {
208+
209+
def dir(pos: Pos): Option[String] =
210210
(pos.file.index - this.file.index, pos.rank.index - this.rank.index) match {
211211
case (0, 1) => Some("upLeft")
212212
case (0, -1) => Some("downRight")
@@ -216,10 +216,8 @@ case class Pos private (index: Int) extends AnyVal {
216216
case (-1, -1) => Some("downLeft")
217217
case _ => None
218218
}
219-
}
220-
def isInLine(pos1: Pos, pos2: Pos): Boolean = {
221-
this.dir(pos1) == pos1.dir(pos2)
222-
}
219+
220+
def isInLine(pos1: Pos, pos2: Pos): Boolean = this.dir(pos1) == pos1.dir(pos2)
223221
// *end of note about neighbourhood
224222

225223
@inline def file = File of this // column (as if it was an index in a 1D array)

0 commit comments

Comments
 (0)