diff options
Diffstat (limited to 'src/main/scala/me/robbyzambito/othello/game/Player.scala')
-rw-r--r-- | src/main/scala/me/robbyzambito/othello/game/Player.scala | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/scala/me/robbyzambito/othello/game/Player.scala b/src/main/scala/me/robbyzambito/othello/game/Player.scala index 7abf3d2..925f7d2 100644 --- a/src/main/scala/me/robbyzambito/othello/game/Player.scala +++ b/src/main/scala/me/robbyzambito/othello/game/Player.scala @@ -2,6 +2,16 @@ package me.robbyzambito.othello.game import scala.util.Try +/** + * Represents a party which is partaking in the game. + * Both the AI and the end user are instances of Player. + * + * Written by Robby Zambito + * Written on 11/20/2019 + * Targeting Scala 2.13.1 + * + * @param color The color of the player. + */ abstract class Player(val color: Position) { def nextMove(board: Board): Move @@ -59,7 +69,7 @@ abstract class Player(val color: Position) { } else List.empty } - // Check can move left or right + // Check can move down or up val changes = checkInDirection(rowCount, 1) ::: checkInDirection(rowCount, -1) if (changes.nonEmpty) Some(Move(rowCount, colCount, changes)) @@ -75,8 +85,7 @@ abstract class Player(val color: Position) { Some( Move(rowCount, colCount, - acc.map(_.takenPositions).getOrElse(List.empty) ::: vert.map(_.takenPositions).getOrElse(List.empty) - ) + acc.map(_.takenPositions).getOrElse(List.empty) ::: vert.map(_.takenPositions).getOrElse(List.empty)) ) else None }).flatten |