Skip to content
Varunalingam V edited this page Oct 19, 2020 · 4 revisions

Pieces

The Khet game has 6 types of Pieces

1. Pharoh

It is the main Piece if it is Destroyed the Game Ends
It can be hit in any direction

2. Sphinx

this piece cannot move and this piece fires the laser for the player
It cannot be destroyed by laser

3. Scarab

It reflects laser by 90 degrees thus can never be destroyed
It can swap itself with any of its adjacent pieces

4. Obleisk

It can be hit from any direction and gets destroyed
The rotation of this piece doesn't matter cuz it symmetrical about 2 axes

5. Pyramid

It can be hit in 2 directions and reflects ray in other 2 directions

6. Anubis

It can be hit in 3 sides and cannot be hit in its face side and the laser won't pass through if it hits the face side.

All the 6 types have 3 arguments which are passed to its's base class.
playerId, position and rotation

Piece (abstract class)

All pieces are sub classes of this Piece Class

Constructor

it has 4 arguments

type

it tells about the type of piece

playerId

it tells about the owner of this piece

position

it tells about the current position of the piece

rotation

it tells about the amount of rotation is the piece's north from the north of the board

methods

movePiece(position)

moves the piece to the specified position

rotatePiece(amount)

rotates the piece by amount

abstract methods

attackFrom(rayDirection)

it calculates whether the ray hits the piece or reflects from the piece, if Reflects tells the direction of exit based on board's north

abstract variables

canReplace

it tells whether or not the piece can Replace other pieces to its position