Board - Varunalingam/Khet GitHub Wiki

Board : BoardInterface

The Board Class contains data of all the pieces in the board in that specific instant.

It also handles the user interaction with the pieces in the game.

private Variables

moves

contains list of all possible relative positions for one move of a piece

pieces

contains list of all pieces in the given board

private Methods

###updateHighlightedPositions (position) it is local method to update the highlighted positions stored in the highlightPositions

BoardInterface (interface)

The Board Interface is the base class for any board in the khet game.

Variables

highlightPositions

It Stores the Currently highlighted positions of the board in form of a LiveData of List of Positions

selectedPiece

It Stores the Currently selected Piece by the user in form of a LiveData of Pieces

laserPath

It Stores the path of Laser when the Laser is Fired in form of a LiveData of List of Positions

currentPlayer

It Stores the Current Player in form of LiveData of Player

Methods

getPiece(position) : Piece

This Method returns the Piece's Class's Instance if there exists a piece in the position

selectPiece(position)

This Method selects the Piece for the given player if there exits this player's piece and updates selected piece

resetSelection

Makes the Selected Piece Null

onClick(position)

performs actions on the based on the click position and selected piece

rotatePiece(amount)

Rotates the selectedPiece by amount

shootLaser(player)

shoots the laser for the player

resetLaser

resets the laser path

getState

return the current state of all the pieces in List of Pieces

completeMove

completes the turn and switches currentPlayer to next player