-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add chess board situation interface
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
chess/src/main/scala/io/github/chess/model/situations/Check.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.github.chess.model.situations | ||
import io.github.chess.model.ChessGameStatus | ||
|
||
/** | ||
* The "check" situation in a chess game is when the king can be captured | ||
* by the opponent in the next turn. | ||
*/ | ||
class Check extends ChessBoardSituation: | ||
override def checkOn(state: ChessGameStatus): Boolean = ??? |
10 changes: 10 additions & 0 deletions
10
chess/src/main/scala/io/github/chess/model/situations/CheckMate.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.chess.model.situations | ||
|
||
import io.github.chess.model.ChessGameStatus | ||
|
||
/** | ||
* The "checkmate" situation in a chess game is when the king is always captured | ||
* by the opponent in the next turn. | ||
*/ | ||
class CheckMate extends ChessBoardSituation: | ||
override def checkOn(state: ChessGameStatus): Boolean = ??? |
13 changes: 13 additions & 0 deletions
13
chess/src/main/scala/io/github/chess/model/situations/ChessBoardSituation.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.github.chess.model.situations | ||
|
||
import io.github.chess.model.ChessGameStatus | ||
|
||
/** | ||
* Situation in a game of chess (i.e.: check, checkmate, stalemate...). | ||
*/ | ||
trait ChessBoardSituation: | ||
/** | ||
* @param state the specified state of the game | ||
* @return true if the game in the specified state is in this situation, false otherwise. | ||
*/ | ||
def checkOn(state: ChessGameStatus): Boolean |
10 changes: 10 additions & 0 deletions
10
chess/src/main/scala/io/github/chess/model/situations/Stalemate.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.chess.model.situations | ||
|
||
import io.github.chess.model.{ChessBoard, ChessGameStatus} | ||
|
||
/** | ||
* The "stalemate" situation is when the current player cannot move any | ||
* pieces, but there's no checkmate. | ||
*/ | ||
class Stalemate extends ChessBoardSituation: | ||
override def checkOn(state: ChessGameStatus): Boolean = ??? |