Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider ea0c65f9 rédigé par Enora LANGARD's avatar Enora LANGARD
Parcourir les fichiers

Mise à jour

parent 8938bc3b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -102,7 +102,7 @@ export function queenMove(board: Chessboard, move: Move): boolean { ...@@ -102,7 +102,7 @@ export function queenMove(board: Chessboard, move: Move): boolean {
*/ */
export function empressMove(board: Chessboard, move: Move): boolean { export function empressMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function // #TODO: Implement this function
return true; return move.from.rank === move.to.rank;
} }
/** /**
......
import { Expect, Test, Setup} from "alsatian"; import { Expect, Test, Setup} from "alsatian";
import { Chessboard, createEmptyChessboard, putPiece } from '../../main/ts/chessboard'; import * as isPossible from '../../main/ts/move-validation'
import * as pieces from '../../main/ts/piece'
import { Chessboard, createEmptyChessboard, putPiece, pieceAtPosition } from '../../main/ts/chessboard';
import {Position, position} from '../../main/ts/position';
import { Move, move } from '../../main/ts/movements';
let chessboard : Chessboard; let chessboard : Chessboard;
const positionA4 : Position = position(0, 3) // A4
const positionA5 : Position = position(0, 4) // A5
const positionA6 : Position = position(0, 5) // A6
const positionA7 : Position = position(0, 6) // A7
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
const positionC4 : Position = position(2, 3) // C4
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 positionH5 : Position = position(7, 4) // H5
const positionH7 : Position = position(7, 6) // H7
// Horizontal moves
const moveE4_H4 : Move = move(positionE4, positionH4);
const moveE4_A4 : Move = move(positionE4, positionA4);
// Vertical moves
const moveE4_E1 : Move = move(positionE4, positionE1);
const moveE4_E8 : Move = move(positionE4, positionE8);
export class TestEmpressMoves { export class TestEmpressMoves {
@Setup @Setup
beforeEach() { beforeEach() {
// TODO: chessboard = createEmptyChessboard ();
// Initialize an empty chessboard
// Place a white Empress on E4 //La variable "positionE4" a été crée au début du module pour simplifier le code des tests
//Place une Impératrice sur la case E4 de l'échiquier vide
putPiece(chessboard, positionE4, pieces.blackEmpress)
} }
@Test("An Empress can move horizontally") @Test("An Empress can move horizontally")
testCanMoveHorizontally() { testCanMoveHorizontally() {
Expect(isPossible.empressMove(chessboard, moveE4_H4)).toBeTruthy();
Expect(isPossible.empressMove(chessboard, moveE4_A4)).toBeTruthy();
// TODO: // TODO:
// Check the following moves are possible: moveE4_H4, moveE4_A4 // Check the following moves are possible: moveE4_H4, moveE4_A4
} }
@Test("A Empress can move vertically") @Test("A Empress can move vertically")
testCanMoveVertically() { testCanMoveVertically() {
// TODO: Expect(isPossible.empressMove(chessboard, moveE4_E8)).toBeTruthy();
Expect(isPossible.empressMove(chessboard, moveE4_E1)).toBeTruthy();
// Check the following moves are possible: moveE4_E1, moveE4_E8 // Check the following moves are possible: moveE4_E1, moveE4_E8
} }
...@@ -78,3 +142,5 @@ export class TestEmpressMoves { ...@@ -78,3 +142,5 @@ export class TestEmpressMoves {
// Check the move moveE4_E1 is impossible // Check the move moveE4_E1 is impossible
} }
} }
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter