Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 4328fb56 rédigé par Théo Winterhalter's avatar Théo Winterhalter
Parcourir les fichiers

Fix typos on pieces names

parent c2d55cbc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -119,7 +119,7 @@ Le traitement des déplacements se fait de la façon suivante:
5. Si le mouvement est possible, c'est à dire la fonction `isMovePossible()` retourne `true`, la fonction `processMove()` appelle la fonction `performMove(), qui effectue le déplacement.
Vous devez donc parcourir le module `move-validation` et implémenter les fonctions de validation contenant le commentaire "`// TODO:`".
Vous devez donc parcourir le module `move-validation` et implémenter les fonctions de validation contenant le commentaire "`// #TODO:`".
### Tests unitaires
......@@ -149,7 +149,7 @@ Vous devez procéder par itérations successives, n'essayez pas d'implémenter l
3. Exécutez les tests pour vérifier que la fonctionnalité marche correctement et la non-régression.
4. Recommencez avec la fonctionnalité suivante.
Par exemple, lorsque vous allez implémenter les fonctions qui valident le mouvement des tours (`blackRoockMove()` et `whiteRoockMove()`) , vous pouvez subdiviser leurs comportements en différentes fonctionnalités:
Par exemple, lorsque vous allez implémenter les fonctions qui valident le mouvement des tours (`blackRookMove()` et `whiteRookMove()`) , vous pouvez subdiviser leurs comportements en différentes fonctionnalités:
- Validation des mouvements horizontaux, sans se préoccuper des autres pièces.
- Validation des mouvements verticaux, toujours sans se préoccuper des autres pièces.
......@@ -165,7 +165,7 @@ Commencez par la 1e fonctionnalité, la validation des déplacements horizontaux
```ts
// Dans le fichier "move-validation.ts"
export function roockMove(board: Chessboard, move: Move): boolean {
export function rookMove(board: Chessboard, move: Move): boolean {
return move.from.rank === move.to.rank; // Si les lignes de début de fin sont les mêmes, le déplacement est horizontal
}
```
......@@ -174,7 +174,7 @@ export function roockMove(board: Chessboard, move: Move): boolean {
```ts
// Dans le fichier "move-validation-spec.ts"
describe("Test roockMove()", () => {
describe("Test rookMove()", () => {
// Fonction exécutée avant chaque test unitaires:
beforeEach( () => {
// Création d'un échiquier vide:
......@@ -189,18 +189,18 @@ describe("Test roockMove()", () => {
// Les variable "moveE4_H4" et "moveE4_14" ont été créées au début
// du module pour simplifier le code des tests.
// Le déplacement doit être possible:
expect(isPossible.roockMove(chessboard, moveE4_H4)).toBeTruthy();
expect(isPossible.roockMove(chessboard, moveE4_A4)).toBeTruthy();
expect(isPossible.rookMove(chessboard, moveE4_H4)).toBeTruthy();
expect(isPossible.rookMove(chessboard, moveE4_A4)).toBeTruthy();
});
```
#### Etape 2
Nouvelle fonctionnalité à implémenter: la validation des déplacements verticaux. Modifiez la fonction `roockMove()`:
Nouvelle fonctionnalité à implémenter: la validation des déplacements verticaux. Modifiez la fonction `rookMove()`:
```ts
// Dans le fichier "move-validation.ts"
export function roockMove(board: Chessboard, move: Move): boolean {
export function rookMove(board: Chessboard, move: Move): boolean {
return move.from.rank === move.to.rank || // Si les lignes de début de fin sont les mêmes, le déplacement est horizontal
move.from.file === move.to.file; // Si les colonnes de début de fin sont les mêmes, le déplacement est vertical
}
......@@ -210,7 +210,7 @@ export function roockMove(board: Chessboard, move: Move): boolean {
```ts
// Dans le fichier "move-validation-spec.ts"
describe("Test roockMove()", () => {
describe("Test rookMove()", () => {
beforeEach( () => { // Fonction exécutée avant chaque test unitaires
chessboard = createEmptyChessboard(); // Création d'un échiquier vide
});
......@@ -219,8 +219,8 @@ describe("Test roockMove()", () => {
});
it("A roock can move vertically", () => {
expect(isPossible.roockMove(chessboard, moveE4_E8)).toBeTruthy();
expect(isPossible.roockMove(chessboard, moveE4_E1)).toBeTruthy();
expect(isPossible.rookMove(chessboard, moveE4_E8)).toBeTruthy();
expect(isPossible.rookMove(chessboard, moveE4_E1)).toBeTruthy();
});
```
......
......@@ -346,9 +346,9 @@ describe("Test knightMove()", () => {
});
/**
* TODO: Unit tests for function roockMove()
* TODO: Unit tests for function rookMove()
*/
describe("Test roockMove()", () => {
describe("Test rookMove()", () => {
beforeEach( () => {
// TODO:
// Initialize an empty chessboard
......
......@@ -3,7 +3,7 @@ import { Move } from "./movements";
import { equals, left, right, bottom, top } from "./position";
/**
* Checks whether a Black Pown can perform a given move.
* Checks whether a Black Pawn can perform a given move.
* A pawn can move forward to the unoccupied square immediately in front of
* it on the same file, or on its first move it can advance two squares along
* the same file, provided both squares are unoccupied (black dots in the
......@@ -50,6 +50,7 @@ export function blackPawnMove(board: Chessboard, move: Move): boolean {
*/
export function whitePawnMove(board: Chessboard, move: Move): boolean {
// #TODO: Manage special 'En passant' move.
if (equals(move.to!, bottom(move.from!))) {
return isEmpty(board, move.to!);
}
......@@ -79,7 +80,7 @@ export function kingMove(board: Chessboard, move: Move): boolean {
}
/**
* Checks whether a Quenn can perform a given move.
* Checks whether a Queen can perform a given move.
* The queen combines the power of a rook and bishop and can move any
* number of squares along a rank, file, or diagonal, but cannot leap over other pieces.
*
......@@ -92,14 +93,14 @@ export function queenMove(board: Chessboard, move: Move): boolean {
}
/**
* Checks whether a Roock can perform a given move.
* Checks whether a Rook can perform a given move.
* A rook 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 roockMove(board: Chessboard, move: Move): boolean {
export function rookMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function
return true;
}
......@@ -118,7 +119,7 @@ export function bishopMove(board: Chessboard, move: Move): boolean {
}
/**
* Checks whether a knight can perform a given move.
* 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
......
......@@ -8,8 +8,8 @@ const VALID_MOVE_STRING: RegExp = new RegExp('([a-z]|[A-Z])([1-8])-([A-H]|[a-z])
export interface Move {
isValid : boolean;
from? : Position;
to? : Position;
from? : Position;
to? : Position;
}
/**
......@@ -27,7 +27,7 @@ export function move(from: Position, to: Position): Move {
/**
* Processes a move received from a client browser.
* If the move is valid and possible, the move is performed and this function
* returns true. Otherwiser, it returns false
* returns true. Otherwise, it returns false
*
* @param chessboard The chessboard for the current game
* @param moveString The string received from the client containing a move
......@@ -47,7 +47,7 @@ export function processMove(chessboard:Chessboard, moveString: string): boolean
/**
* Parses a string in the format "A1-F8" and returns a Move.
* If the format is not valid, returns a Move with isValid === true.
* If the format is not valid, returns a Move with isValid === false.
*
* @param movementString A 5 characters string containing a move
*/
......@@ -90,12 +90,12 @@ function isMovePossible(chessboard : Chessboard, move : Move): boolean {
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.roockMove(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.roockMove(chessboard, move);
case pieces.blackRoock : return isPossible.rookMove(chessboard, move);
}
return false;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter