Interface GameBoard
- All Superinterfaces:
JsonSerializable
- All Known Implementing Classes:
GameBoardLocalImpl
Represents a game board for a game. The game board has a square dimension and contains a grid of
game pieces. This interface defines the operations that can be performed on the game board.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionConverts the game board to a JSON string representation for serialization.Returns a list of available moves on the game board.String[]content()intReturns the dimension of the game board, which is the number of rows or columns.booleanChecks if the given player has a winning chain of connected game pieces on the game board.booleanChecks if there are any available moves on the game board.booleanChecks if the given player is present at the given location on the game board.default booleanisEmpty()booleanisValidMove(int location) Checks if the given location on the game board is a valid move (i.e.toString()Returns a string representation of the game board for presentation to the player.static GameBoardwithDimension(int dimension) Creates a newGameBoardinstance with the given dimension.Creates a newGameBoardinstance with the given player's move made at the specified location within the game board dimension x dimension
-
Field Details
-
log
-
useNative
-
-
Method Details
-
isValidMove
boolean isValidMove(int location) Checks if the given location on the game board is a valid move (i.e. an available location).- Parameters:
location- the location on the game board to check- Returns:
- true if the location is a valid move, false otherwise
-
availableMoves
-
isEmpty
default boolean isEmpty() -
hasPlayer
Checks if the given player is present at the given location on the game board.- Parameters:
playerMarker- the marker representing the player to checklocation- the location on the game board to check- Returns:
- true if the player is present at the given location, false otherwise
-
hasChain
Checks if the given player has a winning chain of connected game pieces on the game board.- Parameters:
playerMarker- the marker representing the player to check for a chain- Returns:
- true if the player has a chain of connected game pieces, false otherwise
-
hasMovesAvailable
boolean hasMovesAvailable()Checks if there are any available moves on the game board.- Returns:
- true if there are any available moves, false otherwise
-
withMove
Creates a newGameBoardinstance with the given player's move made at the specified location within the game board dimension x dimension- Parameters:
playerMarker- the marker representing the player making the movelocation- the location on the game board where the player is making the move- Returns:
- a ne
GameBoardinstance with the player's move applied
-
dimension
int dimension()Returns the dimension of the game board, which is the number of rows or columns.- Returns:
- the dimension of the game board
-
asJsonString
String asJsonString()Converts the game board to a JSON string representation for serialization. Format corresponds to the following JSON schema with content as a 1D array of strings of size dimension x dimension.
{ "dimension": int, "content": [ string, string, ..., string ] } }- Specified by:
asJsonStringin interfaceJsonSerializable- Returns:
- the game board as a JSON string
- See Also:
-
toString
-
withDimension
-
content
String[] content()
-