diff --git a/src/main/ts/chessboard.ts b/src/main/ts/chessboard.ts index 7fd02d97caa9852efa4cae16e3ff6b5a4acd7366..83d4af9c50d6c114534a51d181c7795a7a03454c 100644 --- a/src/main/ts/chessboard.ts +++ b/src/main/ts/chessboard.ts @@ -88,23 +88,23 @@ export function createInitialChessboard(): Chessboard { putPieceAtCoordinate(chessboard, 3, 0, pieces.whiteQueen); putPieceAtCoordinate(chessboard, 3, 7, pieces.blackQueen); - // Bishops - putPieceAtCoordinate(chessboard, 2, 0, pieces.whiteBishop); - putPieceAtCoordinate(chessboard, 2, 7, pieces.blackBishop); - putPieceAtCoordinate(chessboard, 5, 0, pieces.whiteBishop); - putPieceAtCoordinate(chessboard, 5, 7, pieces.blackBishop); - - // Knights - putPieceAtCoordinate(chessboard, 1, 0, pieces.whiteKnight); - putPieceAtCoordinate(chessboard, 1, 7, pieces.blackKnight); - putPieceAtCoordinate(chessboard, 6, 0, pieces.whiteKnight); - putPieceAtCoordinate(chessboard, 6, 7, pieces.blackKnight); - - // Roocks - putPieceAtCoordinate(chessboard, 0, 0, pieces.whiteRoock); - putPieceAtCoordinate(chessboard, 0, 7, pieces.blackRoock); - putPieceAtCoordinate(chessboard, 7, 0, pieces.whiteRoock); - putPieceAtCoordinate(chessboard, 7, 7, pieces.blackRoock); + // Princesss + putPieceAtCoordinate(chessboard, 2, 0, pieces.whitePrincess); + putPieceAtCoordinate(chessboard, 2, 7, pieces.blackPrincess); + putPieceAtCoordinate(chessboard, 5, 0, pieces.whitePrincess); + putPieceAtCoordinate(chessboard, 5, 7, pieces.blackPrincess); + + // Camels + putPieceAtCoordinate(chessboard, 1, 0, pieces.whiteCamel); + putPieceAtCoordinate(chessboard, 1, 7, pieces.blackCamel); + putPieceAtCoordinate(chessboard, 6, 0, pieces.whiteCamel); + putPieceAtCoordinate(chessboard, 6, 7, pieces.blackCamel); + + // Empresss + putPieceAtCoordinate(chessboard, 0, 0, pieces.whiteEmpress); + putPieceAtCoordinate(chessboard, 0, 7, pieces.blackEmpress); + putPieceAtCoordinate(chessboard, 7, 0, pieces.whiteEmpress); + putPieceAtCoordinate(chessboard, 7, 7, pieces.blackEmpress); return chessboard; } diff --git a/src/main/ts/move-validation.ts b/src/main/ts/move-validation.ts index 4fdfa878548c6515a199b68b7909c1f4b27d341e..4dc18502acedb5b8d4e641faf61f2a09f3c2041b 100644 --- a/src/main/ts/move-validation.ts +++ b/src/main/ts/move-validation.ts @@ -93,44 +93,47 @@ export function queenMove(board: Chessboard, move: Move): boolean { } /** - * Checks whether a Rook can perform a given move. - * A rook can move any number of squares along a rank or file, + * Checks whether a Empress can perform a given move. + * An empress can move any number of squares along a rank or file, * but cannot leap over other pieces. * * @param board The chessboard of the current game * @param move */ -export function rookMove(board: Chessboard, move: Move): boolean { +export function empressMove(board: Chessboard, move: Move): boolean { // #TODO: Implement this function return true; } /** - * Checks whether a Bishop can perform a given move. - * A bishop can move any number of squares diagonally, + * Checks whether a Princess can perform a given move. + * A princess can move any number of squares diagonally, * but cannot leap over other pieces. + * A princess can also move to any of the closest squares that are not on the + * same rank, file, or diagonal. (Thus the move forms an "L"-shape: + * two squares vertically and one square horizontally, or two + * squares horizontally and one square vertically.) * * @param board The chessboard of the current game * @param move */ -export function bishopMove(board: Chessboard, move: Move): boolean { +export function princessMove(board: Chessboard, move: Move): boolean { // #TODO: Implement this function return true; } /** - * Checks whether a Knight can perform a given move. - * A knight moves to any of the closest squares that are not on the - * same rank, file, or diagonal. (Thus the move forms an "L"-shape: - * two squares vertically and one square horizontally, or two + * Checks whether a Camel can perform a given move. + * The Camel move forms an "L"-shape: + * three squares vertically and one square horizontally, or three * squares horizontally and one square vertically.) * - * The knight is the only piece that can leap over other pieces. + * The camel is the only piece that can leap over other pieces. * * @param board The chessboard of the current game * @param move */ -export function knightMove(board: Chessboard, move: Move): boolean { +export function camelMove(board: Chessboard, move: Move): boolean { // #TODO: Implement this function return true; } \ No newline at end of file diff --git a/src/main/ts/movements.ts b/src/main/ts/movements.ts index d8a59f6b7562cab431dcb2931150828fc17fdd91..40e118600ee81be06836d293d3d6395540ba1df3 100644 --- a/src/main/ts/movements.ts +++ b/src/main/ts/movements.ts @@ -88,18 +88,18 @@ function isMovePossible(chessboard : Chessboard, move : Move): boolean { let piece : Piece = square.piece!; switch(piece) { - case pieces.whitePawn : return isPossible.whitePawnMove(chessboard, move); - case pieces.blackPawn : return isPossible.blackPawnMove(chessboard, move); - case pieces.whiteKing : return isPossible.kingMove(chessboard, move); - case pieces.whiteQueen : return isPossible.queenMove(chessboard, move); - case pieces.whiteBishop: return isPossible.bishopMove(chessboard, move); - case pieces.whiteKnight: return isPossible.knightMove(chessboard, move); - case pieces.whiteRoock : return isPossible.rookMove(chessboard, move); - case pieces.blackKing : return isPossible.kingMove(chessboard, move); - case pieces.blackQueen : return isPossible.queenMove(chessboard, move); - case pieces.blackBishop: return isPossible.bishopMove(chessboard, move); - case pieces.blackKnight: return isPossible.knightMove(chessboard, move); - case pieces.blackRoock : return isPossible.rookMove(chessboard, move); + case pieces.whitePawn : return isPossible.whitePawnMove(chessboard, move); + case pieces.blackPawn : return isPossible.blackPawnMove(chessboard, move); + case pieces.whiteKing : return isPossible.kingMove(chessboard, move); + case pieces.whiteQueen : return isPossible.queenMove(chessboard, move); + case pieces.whitePrincess : return isPossible.princessMove(chessboard, move); + case pieces.whiteCamel : return isPossible.camelMove(chessboard, move); + case pieces.whiteEmpress : return isPossible.empressMove(chessboard, move); + case pieces.blackKing : return isPossible.kingMove(chessboard, move); + case pieces.blackQueen : return isPossible.queenMove(chessboard, move); + case pieces.blackPrincess : return isPossible.princessMove(chessboard, move); + case pieces.blackCamel : return isPossible.camelMove(chessboard, move); + case pieces.blackEmpress : return isPossible.empressMove(chessboard, move); } return false; diff --git a/src/main/ts/piece.ts b/src/main/ts/piece.ts index 10ee61f4cb7c9cc6b3c3a6d87a198d4abb16cad3..e73268604243a0814ccd9781e63ec44dc71d424e 100644 --- a/src/main/ts/piece.ts +++ b/src/main/ts/piece.ts @@ -8,16 +8,16 @@ export interface Piece { name : string, } -export const whitePawn : Piece = {symbol : "♙", name: "White Pawn", isWhite : true}; -export const whiteKing : Piece = {symbol : "♔", name: "White Pawn", isWhite : true}; -export const whiteQueen : Piece = {symbol : "♕", name: "White Pawn", isWhite : true}; -export const whiteRoock : Piece = {symbol : "♖", name: "White Pawn", isWhite : true}; -export const whiteKnight : Piece = {symbol : "♘", name: "White Pawn", isWhite : true}; -export const whiteBishop : Piece = {symbol : "♗", name: "White Pawn", isWhite : true}; +export const whitePawn : Piece = {symbol : "♙", name: "White Pawn", isWhite : true}; +export const whiteKing : Piece = {symbol : "♔", name: "White King", isWhite : true}; +export const whiteQueen : Piece = {symbol : "♕", name: "White Queen", isWhite : true}; +export const whiteEmpress : Piece = {symbol : "♖", name: "White Empress", isWhite : true}; +export const whiteCamel : Piece = {symbol : "♘", name: "White Camel", isWhite : true}; +export const whitePrincess : Piece = {symbol : "♗", name: "White Princess",isWhite : true}; -export const blackPawn : Piece = {symbol : "♟", name: "Black Pawn", isWhite : false}; -export const blackKing : Piece = {symbol : "♚", name: "Black Pawn", isWhite : false}; -export const blackQueen : Piece = {symbol : "♛", name: "Black Pawn", isWhite : false}; -export const blackRoock : Piece = {symbol : "♜", name: "Black Pawn", isWhite : false}; -export const blackKnight : Piece = {symbol : "♞", name: "Black Pawn", isWhite : false}; -export const blackBishop : Piece = {symbol : "♝", name: "Black Pawn", isWhite : false}; \ No newline at end of file +export const blackPawn : Piece = {symbol : "♟", name: "Black Pawn", isWhite : false}; +export const blackKing : Piece = {symbol : "♚", name: "Black King", isWhite : false}; +export const blackQueen : Piece = {symbol : "♛", name: "Black Queen", isWhite : false}; +export const blackEmpress : Piece = {symbol : "♜", name: "Black Empress", isWhite : false}; +export const blackCamel : Piece = {symbol : "♞", name: "Black Camel", isWhite : false}; +export const blackPrincess : Piece = {symbol : "♝", name: "Black Princess",isWhite : false}; \ No newline at end of file diff --git a/src/test/ts/knight-move-validation.spec.ts b/src/test/ts/camel-move-validation.spec.ts similarity index 52% rename from src/test/ts/knight-move-validation.spec.ts rename to src/test/ts/camel-move-validation.spec.ts index 884d7ccfd678c180597a777e54d6ec588bc42457..478abe00141af755227c08199865a1606175a857 100644 --- a/src/test/ts/knight-move-validation.spec.ts +++ b/src/test/ts/camel-move-validation.spec.ts @@ -3,49 +3,49 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess let chessboard : Chessboard; -export class TestKnightMoves { +export class TestCamelMoves { @Setup beforeEach() { // TODO: // Initialize an empty chessboard } - @Test("A Knight can move two squares horizontally and one square vertically") - testCanMoveTwoHorizontalAndOneVertical() { + @Test("A Camel can move three squares horizontally and one square vertically") + testCanMoveThreeHorizontalAndOneVertical() { // TODO: } - @Test("A Knight can move two squares vertically and one square horizontally") - testCanMoveTwoVerticalAndOneHorizontal() { + @Test("A Camel can move three squares vertically and one square horizontally") + testCanMoveThreeVerticalAndOneHorizontal() { // TODO: } - @Test("A Knight can leap other pieces") + @Test("A Camel can leap other pieces") testCanLeapOtherPieces() { // TODO: } - @Test("A Knight cannot move diagonally") + @Test("A Camel cannot move diagonally") testCannotMoveDiagonally() { // TODO: } - @Test("A Knight cannot move horizontally") + @Test("A Camel cannot move horizontally") testCannotMoveHorizontally() { // TODO: } - @Test("A Knight cannot move vertically") + @Test("A Camel cannot move vertically") testCannotMoveVertically() { // TODO: } - @Test("A Knight can capture a piece from another color") + @Test("A Camel can capture a piece from another color") testCanCaptureAnotherColor() { // TODO: } - @Test("A Knight cannot capture a piece from the same color") + @Test("A Camel cannot capture a piece from the same color") testCannotCaptureSameColor() { // TODO: } diff --git a/src/test/ts/rook-move-validation.spec.ts b/src/test/ts/empress-move-validation.spec.ts similarity index 69% rename from src/test/ts/rook-move-validation.spec.ts rename to src/test/ts/empress-move-validation.spec.ts index a4e6e23be2ad39beca2d9a62f91721a5ddecab96..fc8c0ff2e9f6ad5d0b62f3806c6f128a3bd7dd5e 100644 --- a/src/test/ts/rook-move-validation.spec.ts +++ b/src/test/ts/empress-move-validation.spec.ts @@ -3,48 +3,48 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess let chessboard : Chessboard; -export class TestRookMoves { +export class TestEmpressMoves { @Setup beforeEach() { // TODO: // Initialize an empty chessboard - // Place a white Rook on E4 + // Place a white Empress on E4 } - @Test("A rook can move horizontally") + @Test("A Empress can move horizontally") testCanMoveHorizontally() { // TODO: // Check the following moves are possible: moveE4_H4, moveE4_A4 } - @Test("A rook can move vertically") + @Test("A Empress can move vertically") testCanMoveVertically() { // TODO: // Check the following moves are possible: moveE4_E1, moveE4_E8 } - @Test("A rook cannot move diagonally") - testCannotMoveDiagonally() { + @Test("A Empress can move diagonally") + testCanMoveDiagonally() { // TODO: - // Check the following moves are impossible: + // Check the following moves are possible: // moveE4_A8, moveE4_B1, moveE4_H7, moveE4_H1 } - @Test("A rook can capture a piece from different color") + @Test("A Empress can capture a piece from different color") testCanCaptureDifferentColor() { // TODO: // Place a black Pawn on H4 // Check the move moveE4_H4 is possible } - @Test("A rook cannot capture a piece from the same color") + @Test("A Empress cannot capture a piece from the same color") testCannotCaptureSameColor() { // TODO: // Place a white Pawn on H4 // Check the move moveE4_H4 is impossible } - @Test("A Rook cannot leap other pieces") + @Test("A Empress cannot leap other pieces") testCannotLeap() { // TODO: // Place a black Pawn on F4 diff --git a/src/test/ts/pawn-move-validation.spec.ts b/src/test/ts/pawn-move-validation.spec.ts index f27a7ef2bb37652ee3721b6721793097c7048ec5..8e953b7cd85313a5776cc0d42d208bf8c5a8b358 100644 --- a/src/test/ts/pawn-move-validation.spec.ts +++ b/src/test/ts/pawn-move-validation.spec.ts @@ -15,6 +15,8 @@ const positionA8 : Position = position(0, 7) // A8 const positionB1 : Position = position(1, 0) // B1 const positionB2 : Position = position(1, 1) // B2 +const positionB3 : Position = position(1, 2) // B3 +const positionB5 : Position = position(1, 4) // B5 const positionB6 : Position = position(1, 5) // B6 const positionC3 : Position = position(2, 1) // C3 @@ -23,21 +25,31 @@ const positionC5 : Position = position(2, 4) // C5 const positionC6 : Position = position(2, 5) // C6 const positionC7 : Position = position(2, 6) // C7 +const positionD1 : Position = position(3, 0) // D1 const positionD2 : Position = position(3, 1) // D2 const positionD3 : Position = position(3, 2) // D3 const positionD4 : Position = position(3, 3) // D4 const positionD5 : Position = position(3, 4) // D5 const positionD6 : Position = position(3, 5) // D6 +const positionD7 : Position = position(3, 6) // D7 + + const positionE1 : Position = position(4, 0) // E1 const positionE4 : Position = position(4, 3) // E4 const positionE8 : Position = position(4, 7) // E8 + +const positionF1 : Position = position(5, 0) // F1 const positionF2 : Position = position(5, 1) // F2 const positionF6 : Position = position(5, 5) // F6 +const positionF7 : Position = position(5, 6) // F7 const positionG3 : Position = position(6, 2) // G3 const positionG5 : Position = position(6, 4) // G5 + const positionH1 : Position = position(7, 0) // H1 +const positionH3 : Position = position(7, 2) // H3 const positionH4 : Position = position(7, 3) // H4 -const positionH7 : Position = position(7, 8) // H7 +const positionH5 : Position = position(7, 4) // H5 +const positionH7 : Position = position(7, 6) // H7 // Horizontal moves const moveE4_H4 : Move = move(positionE4, positionH4); @@ -53,15 +65,15 @@ const moveE4_B1 : Move = move(positionE4, positionB1); const moveE4_H7 : Move = move(positionE4, positionH7); const moveE4_H1 : Move = move(positionE4, positionH1); -// Knight moves -const moveE4_F6 : Move = move(positionE4, positionF6); -const moveE4_G5 : Move = move(positionE4, positionG5); -const moveE4_F2 : Move = move(positionE4, positionF2); -const moveE4_G3 : Move = move(positionE4, positionG3); -const moveE4_D2 : Move = move(positionE4, positionD2); -const moveE4_C3 : Move = move(positionE4, positionC3); -const moveE4_C5 : Move = move(positionE4, positionC5); -const moveE4_D6 : Move = move(positionE4, positionD6); +// Camel moves +const moveE4_F7 : Move = move(positionE4, positionF7); +const moveE4_H5 : Move = move(positionE4, positionH5); +const moveE4_F1 : Move = move(positionE4, positionF1); +const moveE4_H3 : Move = move(positionE4, positionH3); +const moveE4_D1 : Move = move(positionE4, positionD1); +const moveE4_B3 : Move = move(positionE4, positionB3); +const moveE4_B5 : Move = move(positionE4, positionB5); +const moveE4_D7 : Move = move(positionE4, positionD7); // Impossible moves const moveE4_C7 : Move = move(positionE4, positionC7); diff --git a/src/test/ts/bishop-move-validation.spec.ts b/src/test/ts/princess-move-validation.spec.ts similarity index 56% rename from src/test/ts/bishop-move-validation.spec.ts rename to src/test/ts/princess-move-validation.spec.ts index 45f6cba356f829e8a3cea00bed934937b8904b97..bc3217028578c152f532e43a28df0b7cc7b57543 100644 --- a/src/test/ts/bishop-move-validation.spec.ts +++ b/src/test/ts/princess-move-validation.spec.ts @@ -3,51 +3,66 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess let chessboard : Chessboard; -export class TestBishopMoves { +export class TestPrincessMoves { @Setup beforeEach() { // TODO: // Initialize an empty chessboard - // Place a black Bishop on E4 + // Place a black Princess on E4 } - @Test("A Bishop can move diagonally") + @Test("A Princess can move diagonally") testCanMoveDiagonally() { // TODO: // Check the following moves are possible: // moveE4_A8, moveE4_B1, moveE4_H7, moveE4_H1 } - @Test("A Bishop cannot move horizontally") + @Test("A Princess can move three squares horizontally and one square vertically") + testCanMoveTwoHorizontalAndOneVertical() { + // TODO + } + + @Test("A Princess can move three squares vertically and one square horizontally") + testCanMoveTwoVerticalAndOneHorizontal() { + // TODO + } + + @Test("A Princess cannot move horizontally") testCannotMoveHorizontally() { // TODO: // Check the following moves are impossible: moveE4_H4, moveE4_A4 } - @Test("A Bishop cannot move vertically") + @Test("A Princess cannot move vertically") testCannotMoveVertically() { // TODO: // Check the following moves are impossible: moveE4_E1, moveE4_E8 } - @Test("A Bishop can capture a piece from another color") + @Test("A Princess can capture a piece from another color") testCanCaptureDifferentColor() { // TODO: // Place a white Pawn on A8 // Check the move moveE4_A8 is possible } - @Test("A Bishop cannot capture a piece from the same color") + @Test("A Princess cannot capture a piece from the same color") testCannotCaptureSameColor() { // TODO: // Place a black Pawn on A8 // Check the move moveE4_A8 is impossible } - @Test("A Bishop cannot leap other pieces") - testCannotLeap() { + @Test("A Princess cannot leap other pieces") + testCannotLeapDiagonally() { // TODO: // Place a white Pawn on C6 // Check the move moveE4_A8 is impossible } + + @Test("A Princess can leap other pieces when moving in L ") + testCanLeapOtherPiecesWhenMovingInL() { + // TODO: + } }