Commit 8bea0348 authored by Gerson Sunyé's avatar Gerson Sunyé
Browse files

Several changes to reflect the new fairy pieces

- Replace Knight by the Camel
- Replace Bishop by the Princess
- Replace Rook by the Empress
parent aea0c54b
...@@ -88,23 +88,23 @@ export function createInitialChessboard(): Chessboard { ...@@ -88,23 +88,23 @@ export function createInitialChessboard(): Chessboard {
putPieceAtCoordinate(chessboard, 3, 0, pieces.whiteQueen); putPieceAtCoordinate(chessboard, 3, 0, pieces.whiteQueen);
putPieceAtCoordinate(chessboard, 3, 7, pieces.blackQueen); putPieceAtCoordinate(chessboard, 3, 7, pieces.blackQueen);
// Bishops // Princesss
putPieceAtCoordinate(chessboard, 2, 0, pieces.whiteBishop); putPieceAtCoordinate(chessboard, 2, 0, pieces.whitePrincess);
putPieceAtCoordinate(chessboard, 2, 7, pieces.blackBishop); putPieceAtCoordinate(chessboard, 2, 7, pieces.blackPrincess);
putPieceAtCoordinate(chessboard, 5, 0, pieces.whiteBishop); putPieceAtCoordinate(chessboard, 5, 0, pieces.whitePrincess);
putPieceAtCoordinate(chessboard, 5, 7, pieces.blackBishop); putPieceAtCoordinate(chessboard, 5, 7, pieces.blackPrincess);
// Knights // Camels
putPieceAtCoordinate(chessboard, 1, 0, pieces.whiteKnight); putPieceAtCoordinate(chessboard, 1, 0, pieces.whiteCamel);
putPieceAtCoordinate(chessboard, 1, 7, pieces.blackKnight); putPieceAtCoordinate(chessboard, 1, 7, pieces.blackCamel);
putPieceAtCoordinate(chessboard, 6, 0, pieces.whiteKnight); putPieceAtCoordinate(chessboard, 6, 0, pieces.whiteCamel);
putPieceAtCoordinate(chessboard, 6, 7, pieces.blackKnight); putPieceAtCoordinate(chessboard, 6, 7, pieces.blackCamel);
// Roocks // Empresss
putPieceAtCoordinate(chessboard, 0, 0, pieces.whiteRoock); putPieceAtCoordinate(chessboard, 0, 0, pieces.whiteEmpress);
putPieceAtCoordinate(chessboard, 0, 7, pieces.blackRoock); putPieceAtCoordinate(chessboard, 0, 7, pieces.blackEmpress);
putPieceAtCoordinate(chessboard, 7, 0, pieces.whiteRoock); putPieceAtCoordinate(chessboard, 7, 0, pieces.whiteEmpress);
putPieceAtCoordinate(chessboard, 7, 7, pieces.blackRoock); putPieceAtCoordinate(chessboard, 7, 7, pieces.blackEmpress);
return chessboard; return chessboard;
} }
......
...@@ -93,44 +93,47 @@ export function queenMove(board: Chessboard, move: Move): boolean { ...@@ -93,44 +93,47 @@ export function queenMove(board: Chessboard, move: Move): boolean {
} }
/** /**
* Checks whether a Rook can perform a given move. * Checks whether a Empress can perform a given move.
* A rook can move any number of squares along a rank or file, * An empress can move any number of squares along a rank or file,
* but cannot leap over other pieces. * but cannot leap over other pieces.
* *
* @param board The chessboard of the current game * @param board The chessboard of the current game
* @param move * @param move
*/ */
export function rookMove(board: Chessboard, move: Move): boolean { export function empressMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function // #TODO: Implement this function
return true; return true;
} }
/** /**
* Checks whether a Bishop can perform a given move. * Checks whether a Princess can perform a given move.
* A bishop can move any number of squares diagonally, * A princess can move any number of squares diagonally,
* but cannot leap over other pieces. * 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 board The chessboard of the current game
* @param move * @param move
*/ */
export function bishopMove(board: Chessboard, move: Move): boolean { export function princessMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function // #TODO: Implement this function
return true; return true;
} }
/** /**
* Checks whether a Knight can perform a given move. * Checks whether a Camel can perform a given move.
* A knight moves to any of the closest squares that are not on the * The Camel move forms an "L"-shape:
* same rank, file, or diagonal. (Thus the move forms an "L"-shape: * three squares vertically and one square horizontally, or three
* two squares vertically and one square horizontally, or two
* squares horizontally and one square vertically.) * 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 board The chessboard of the current game
* @param move * @param move
*/ */
export function knightMove(board: Chessboard, move: Move): boolean { export function camelMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function // #TODO: Implement this function
return true; return true;
} }
\ No newline at end of file
...@@ -88,18 +88,18 @@ function isMovePossible(chessboard : Chessboard, move : Move): boolean { ...@@ -88,18 +88,18 @@ function isMovePossible(chessboard : Chessboard, move : Move): boolean {
let piece : Piece = square.piece!; let piece : Piece = square.piece!;
switch(piece) { switch(piece) {
case pieces.whitePawn : return isPossible.whitePawnMove(chessboard, move); case pieces.whitePawn : return isPossible.whitePawnMove(chessboard, move);
case pieces.blackPawn : return isPossible.blackPawnMove(chessboard, move); case pieces.blackPawn : return isPossible.blackPawnMove(chessboard, move);
case pieces.whiteKing : return isPossible.kingMove(chessboard, move); case pieces.whiteKing : return isPossible.kingMove(chessboard, move);
case pieces.whiteQueen : return isPossible.queenMove(chessboard, move); case pieces.whiteQueen : return isPossible.queenMove(chessboard, move);
case pieces.whiteBishop: return isPossible.bishopMove(chessboard, move); case pieces.whitePrincess : return isPossible.princessMove(chessboard, move);
case pieces.whiteKnight: return isPossible.knightMove(chessboard, move); case pieces.whiteCamel : return isPossible.camelMove(chessboard, move);
case pieces.whiteRoock : return isPossible.rookMove(chessboard, move); case pieces.whiteEmpress : return isPossible.empressMove(chessboard, move);
case pieces.blackKing : return isPossible.kingMove(chessboard, move); case pieces.blackKing : return isPossible.kingMove(chessboard, move);
case pieces.blackQueen : return isPossible.queenMove(chessboard, move); case pieces.blackQueen : return isPossible.queenMove(chessboard, move);
case pieces.blackBishop: return isPossible.bishopMove(chessboard, move); case pieces.blackPrincess : return isPossible.princessMove(chessboard, move);
case pieces.blackKnight: return isPossible.knightMove(chessboard, move); case pieces.blackCamel : return isPossible.camelMove(chessboard, move);
case pieces.blackRoock : return isPossible.rookMove(chessboard, move); case pieces.blackEmpress : return isPossible.empressMove(chessboard, move);
} }
return false; return false;
......
...@@ -8,16 +8,16 @@ export interface Piece { ...@@ -8,16 +8,16 @@ export interface Piece {
name : string, name : string,
} }
export const whitePawn : Piece = {symbol : "", name: "White Pawn", isWhite : true}; export const whitePawn : Piece = {symbol : "", name: "White Pawn", isWhite : true};
export const whiteKing : Piece = {symbol : "", name: "White Pawn", isWhite : true}; export const whiteKing : Piece = {symbol : "", name: "White King", isWhite : true};
export const whiteQueen : Piece = {symbol : "", name: "White Pawn", isWhite : true}; export const whiteQueen : Piece = {symbol : "", name: "White Queen", isWhite : true};
export const whiteRoock : Piece = {symbol : "", name: "White Pawn", isWhite : true}; export const whiteEmpress : Piece = {symbol : "", name: "White Empress", isWhite : true};
export const whiteKnight : Piece = {symbol : "", name: "White Pawn", isWhite : true}; export const whiteCamel : Piece = {symbol : "", name: "White Camel", isWhite : true};
export const whiteBishop : Piece = {symbol : "", name: "White Pawn", isWhite : true}; export const whitePrincess : Piece = {symbol : "", name: "White Princess",isWhite : true};
export const blackPawn : Piece = {symbol : "", name: "Black Pawn", isWhite : false}; export const blackPawn : Piece = {symbol : "", name: "Black Pawn", isWhite : false};
export const blackKing : Piece = {symbol : "", name: "Black Pawn", isWhite : false}; export const blackKing : Piece = {symbol : "", name: "Black King", isWhite : false};
export const blackQueen : Piece = {symbol : "", name: "Black Pawn", isWhite : false}; export const blackQueen : Piece = {symbol : "", name: "Black Queen", isWhite : false};
export const blackRoock : Piece = {symbol : "", name: "Black Pawn", isWhite : false}; export const blackEmpress : Piece = {symbol : "", name: "Black Empress", isWhite : false};
export const blackKnight : Piece = {symbol : "", name: "Black Pawn", isWhite : false}; export const blackCamel : Piece = {symbol : "", name: "Black Camel", isWhite : false};
export const blackBishop : Piece = {symbol : "", name: "Black Pawn", isWhite : false}; export const blackPrincess : Piece = {symbol : "", name: "Black Princess",isWhite : false};
\ No newline at end of file \ No newline at end of file
...@@ -3,49 +3,49 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess ...@@ -3,49 +3,49 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess
let chessboard : Chessboard; let chessboard : Chessboard;
export class TestKnightMoves { export class TestCamelMoves {
@Setup @Setup
beforeEach() { beforeEach() {
// TODO: // TODO:
// Initialize an empty chessboard // Initialize an empty chessboard
} }
@Test("A Knight can move two squares horizontally and one square vertically") @Test("A Camel can move three squares horizontally and one square vertically")
testCanMoveTwoHorizontalAndOneVertical() { testCanMoveThreeHorizontalAndOneVertical() {
// TODO: // TODO:
} }
@Test("A Knight can move two squares vertically and one square horizontally") @Test("A Camel can move three squares vertically and one square horizontally")
testCanMoveTwoVerticalAndOneHorizontal() { testCanMoveThreeVerticalAndOneHorizontal() {
// TODO: // TODO:
} }
@Test("A Knight can leap other pieces") @Test("A Camel can leap other pieces")
testCanLeapOtherPieces() { testCanLeapOtherPieces() {
// TODO: // TODO:
} }
@Test("A Knight cannot move diagonally") @Test("A Camel cannot move diagonally")
testCannotMoveDiagonally() { testCannotMoveDiagonally() {
// TODO: // TODO:
} }
@Test("A Knight cannot move horizontally") @Test("A Camel cannot move horizontally")
testCannotMoveHorizontally() { testCannotMoveHorizontally() {
// TODO: // TODO:
} }
@Test("A Knight cannot move vertically") @Test("A Camel cannot move vertically")
testCannotMoveVertically() { testCannotMoveVertically() {
// TODO: // TODO:
} }
@Test("A Knight can capture a piece from another color") @Test("A Camel can capture a piece from another color")
testCanCaptureAnotherColor() { testCanCaptureAnotherColor() {
// TODO: // TODO:
} }
@Test("A Knight cannot capture a piece from the same color") @Test("A Camel cannot capture a piece from the same color")
testCannotCaptureSameColor() { testCannotCaptureSameColor() {
// TODO: // TODO:
} }
......
...@@ -3,48 +3,48 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess ...@@ -3,48 +3,48 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess
let chessboard : Chessboard; let chessboard : Chessboard;
export class TestRookMoves { export class TestEmpressMoves {
@Setup @Setup
beforeEach() { beforeEach() {
// TODO: // TODO:
// Initialize an empty chessboard // 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() { testCanMoveHorizontally() {
// TODO: // TODO:
// Check the following moves are possible: moveE4_H4, moveE4_A4 // Check the following moves are possible: moveE4_H4, moveE4_A4
} }
@Test("A rook can move vertically") @Test("A Empress can move vertically")
testCanMoveVertically() { testCanMoveVertically() {
// TODO: // TODO:
// Check the following moves are possible: moveE4_E1, moveE4_E8 // Check the following moves are possible: moveE4_E1, moveE4_E8
} }
@Test("A rook cannot move diagonally") @Test("A Empress can move diagonally")
testCannotMoveDiagonally() { testCanMoveDiagonally() {
// TODO: // TODO:
// Check the following moves are impossible: // Check the following moves are possible:
// moveE4_A8, moveE4_B1, moveE4_H7, moveE4_H1 // 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() { testCanCaptureDifferentColor() {
// TODO: // TODO:
// Place a black Pawn on H4 // Place a black Pawn on H4
// Check the move moveE4_H4 is possible // 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() { testCannotCaptureSameColor() {
// TODO: // TODO:
// Place a white Pawn on H4 // Place a white Pawn on H4
// Check the move moveE4_H4 is impossible // Check the move moveE4_H4 is impossible
} }
@Test("A Rook cannot leap other pieces") @Test("A Empress cannot leap other pieces")
testCannotLeap() { testCannotLeap() {
// TODO: // TODO:
// Place a black Pawn on F4 // Place a black Pawn on F4
......
...@@ -15,6 +15,8 @@ const positionA8 : Position = position(0, 7) // A8 ...@@ -15,6 +15,8 @@ const positionA8 : Position = position(0, 7) // A8
const positionB1 : Position = position(1, 0) // B1 const positionB1 : Position = position(1, 0) // B1
const positionB2 : Position = position(1, 1) // B2 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 positionB6 : Position = position(1, 5) // B6
const positionC3 : Position = position(2, 1) // C3 const positionC3 : Position = position(2, 1) // C3
...@@ -23,21 +25,31 @@ const positionC5 : Position = position(2, 4) // C5 ...@@ -23,21 +25,31 @@ const positionC5 : Position = position(2, 4) // C5
const positionC6 : Position = position(2, 5) // C6 const positionC6 : Position = position(2, 5) // C6
const positionC7 : Position = position(2, 6) // C7 const positionC7 : Position = position(2, 6) // C7
const positionD1 : Position = position(3, 0) // D1
const positionD2 : Position = position(3, 1) // D2 const positionD2 : Position = position(3, 1) // D2
const positionD3 : Position = position(3, 2) // D3 const positionD3 : Position = position(3, 2) // D3
const positionD4 : Position = position(3, 3) // D4 const positionD4 : Position = position(3, 3) // D4
const positionD5 : Position = position(3, 4) // D5 const positionD5 : Position = position(3, 4) // D5
const positionD6 : Position = position(3, 5) // D6 const positionD6 : Position = position(3, 5) // D6
const positionD7 : Position = position(3, 6) // D7
const positionE1 : Position = position(4, 0) // E1 const positionE1 : Position = position(4, 0) // E1
const positionE4 : Position = position(4, 3) // E4 const positionE4 : Position = position(4, 3) // E4
const positionE8 : Position = position(4, 7) // E8 const positionE8 : Position = position(4, 7) // E8
const positionF1 : Position = position(5, 0) // F1
const positionF2 : Position = position(5, 1) // F2 const positionF2 : Position = position(5, 1) // F2
const positionF6 : Position = position(5, 5) // F6 const positionF6 : Position = position(5, 5) // F6
const positionF7 : Position = position(5, 6) // F7
const positionG3 : Position = position(6, 2) // G3 const positionG3 : Position = position(6, 2) // G3
const positionG5 : Position = position(6, 4) // G5 const positionG5 : Position = position(6, 4) // G5
const positionH1 : Position = position(7, 0) // H1 const positionH1 : Position = position(7, 0) // H1
const positionH3 : Position = position(7, 2) // H3
const positionH4 : Position = position(7, 3) // H4 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 // Horizontal moves
const moveE4_H4 : Move = move(positionE4, positionH4); const moveE4_H4 : Move = move(positionE4, positionH4);
...@@ -53,15 +65,15 @@ const moveE4_B1 : Move = move(positionE4, positionB1); ...@@ -53,15 +65,15 @@ const moveE4_B1 : Move = move(positionE4, positionB1);
const moveE4_H7 : Move = move(positionE4, positionH7); const moveE4_H7 : Move = move(positionE4, positionH7);
const moveE4_H1 : Move = move(positionE4, positionH1); const moveE4_H1 : Move = move(positionE4, positionH1);
// Knight moves // Camel moves
const moveE4_F6 : Move = move(positionE4, positionF6); const moveE4_F7 : Move = move(positionE4, positionF7);
const moveE4_G5 : Move = move(positionE4, positionG5); const moveE4_H5 : Move = move(positionE4, positionH5);
const moveE4_F2 : Move = move(positionE4, positionF2); const moveE4_F1 : Move = move(positionE4, positionF1);
const moveE4_G3 : Move = move(positionE4, positionG3); const moveE4_H3 : Move = move(positionE4, positionH3);
const moveE4_D2 : Move = move(positionE4, positionD2); const moveE4_D1 : Move = move(positionE4, positionD1);
const moveE4_C3 : Move = move(positionE4, positionC3); const moveE4_B3 : Move = move(positionE4, positionB3);
const moveE4_C5 : Move = move(positionE4, positionC5); const moveE4_B5 : Move = move(positionE4, positionB5);
const moveE4_D6 : Move = move(positionE4, positionD6); const moveE4_D7 : Move = move(positionE4, positionD7);
// Impossible moves // Impossible moves
const moveE4_C7 : Move = move(positionE4, positionC7); const moveE4_C7 : Move = move(positionE4, positionC7);
......
...@@ -3,51 +3,66 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess ...@@ -3,51 +3,66 @@ import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chess
let chessboard : Chessboard; let chessboard : Chessboard;
export class TestBishopMoves { export class TestPrincessMoves {
@Setup @Setup
beforeEach() { beforeEach() {
// TODO: // TODO:
// Initialize an empty chessboard // 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() { testCanMoveDiagonally() {
// TODO: // TODO:
// Check the following moves are possible: // Check the following moves are possible:
// moveE4_A8, moveE4_B1, moveE4_H7, moveE4_H1 // 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() { testCannotMoveHorizontally() {
// TODO: // TODO:
// Check the following moves are impossible: moveE4_H4, moveE4_A4 // Check the following moves are impossible: moveE4_H4, moveE4_A4
} }
@Test("A Bishop cannot move vertically") @Test("A Princess cannot move vertically")
testCannotMoveVertically() { testCannotMoveVertically() {
// TODO: // TODO:
// Check the following moves are impossible: moveE4_E1, moveE4_E8 // 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() { testCanCaptureDifferentColor() {
// TODO: // TODO:
// Place a white Pawn on A8 // Place a white Pawn on A8
// Check the move moveE4_A8 is possible // 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() { testCannotCaptureSameColor() {
// TODO: // TODO:
// Place a black Pawn on A8 // Place a black Pawn on A8
// Check the move moveE4_A8 is impossible // Check the move moveE4_A8 is impossible
} }
@Test("A Bishop cannot leap other pieces") @Test("A Princess cannot leap other pieces")
testCannotLeap() { testCannotLeapDiagonally() {
// TODO: // TODO:
// Place a white Pawn on C6 // Place a white Pawn on C6
// Check the move moveE4_A8 is impossible // Check the move moveE4_A8 is impossible
} }
@Test("A Princess can leap other pieces when moving in L ")
testCanLeapOtherPiecesWhenMovingInL() {
// TODO:
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment