A simple chess game for the SAE2.01
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Yannis DOUMIR FERNANDES fc35bb62fc
continuous-integration/drone/push Build is passing Details
merging conflict
1 year ago
Documentation/doxygen add doxyfile 1 year ago
Doxygen Upload files to 'Doxygen' 1 year ago
GP start databinding 1 year ago
src merging conflict 1 year ago
.drone.yml Merging dev in master 1 year ago
.gitignore Initial commit 1 year ago
README.md Mise à jour de 'README.md' 1 year ago

README.md


Logo

The Chess

The Chess is an application designed for chess enthusiasts. If you are a fan of strategy and critical thinking, The Chess is the perfect app to help you improve your game and challenge your friends.

Link to documentation

Static Badge Quality Gate Status Maintainability Rating

Table of Contents

The Project

[to be completed]

Technologies Used

Current state

The chess is a project in its early stages.

Features Explanation State
Piece Movement Management Each type of piece (King, Queen, Rook, Knight, Bishop, Pawn) has its own movement logic implemented. For example, the King can move one square in any direction, the Queen can move in any direction without distance limit, etc.
Movement Exception Handling We have set up exceptions to handle invalid movements. For example, if the bishop tries to move in a non-diagonal direction, an InvalidMovementException is thrown.
Calculation of Possible Moves For each piece, we have a PossibleMoves method that calculates all the squares to which the piece can legally move.
Unit Testing We have written unit tests to verify the validity of all pieces movements. These tests check valid moves, invalid moves, and possible moves.
Piece Color Management Each piece has a color (white or black) that is used to determine possible moves and to check if a piece can be captured.
Check The Check function verifies if a King is in check. It examines all possible moves of the opposing pieces to see if any of them can reach the King.
Checkmate The Checkmate function verifies if a player is in checkmate. It examines all possible moves of the king and its allied pieces to see if the check can be avoided. If no move can avoid the check, the player is in checkmate. We can have a checkmate, but if the king is stuck between other pieces, the player cannot move those pieces to try to free the king.
Piece Capture Pieces can be captured by moving to a square occupied by an opposing piece.
First Move For pawns and rooks, there is special logic for their first move. For example, a pawn can move two squares on its first move.
Pawn Promotion When a pawn reaches the last row of the board, it can be promoted to another piece (Queen, Rook, Knight, Bishop).
Player Management he game manages two players, alternating turns between them.
Move Validation Before making a move, the game checks if the move is valid according to chess rules.
Game Events The game triggers events when a pawn can be promoted or when a player wins the game.
Chessboard Management The chessboard is represented by an 8x8 matrix, and each square can contain a piece or be empty.

How to Play

User Registration and Login

Before you can start playing the game, you will be asked to log in. Here's how you can do it: However, you can register or start a game without a password.

User Login

To register as a new user, you will be asked to enter a unique username and a password. In our application, there are 2 users saved. They are:

  • Username: MatheoB, Password: chef
  • Username: MatheoH, Password: proMac.

If you enter an incorrect username or password, you will be asked to try again.

Exiting the Game

If you want to exit the game, you can do so by selecting the 'Exit' option from the main menu.

Welcome to the Chess Game!
Please select an option:
1. Register
2. Login
3. Exit
> 3
Thank you for playing the Chess Game. Goodbye!

Actually to chose an option we don't have to type 3, 2, etc... You just have to press your arrow key and press enter to chose an option.

Starting the Game

When you start the game, you will be presented with a chessboard. The chessboard is an 8x8 grid, with each cell identified by a unique coordinate. The horizontal axis is labeled from 'a' to 'h' and the vertical axis is labeled from '1' to '8'.

The game will start with Player 1's turn.

Moving a Piece

When it's your turn, you will be asked to enter the position of the piece you want to move. The position should be entered in the format of a letter followed by a number (e.g., 'a1', 'f7').

For example, if you want to move the piece at position 'e2', you would type 'e2' and press enter.

The game will then ask you to enter the destination for the piece. Again, you should enter the destination in the same format. For example, if you want to move the piece from 'e2' to 'e4', you would type 'e4' and press enter.

If the move is valid, the piece will be moved to the new position. If the move is not valid, you will be asked to enter a different move.

Here's an example :

   a   b   c   d   e   f   g   h
 +---+---+---+---+---+---+---+---+
8 | R | C | B | Q | K | B | C | R | 8
 +---+---+---+---+---+---+---+---+
7 | P | P | P | P | P | P | P | P | 7
 +---+---+---+---+---+---+---+---+
6 |   |   |   |   |   |   |   |   | 6
 +---+---+---+---+---+---+---+---+
5 |   |   |   |   |   |   |   |   | 5
 +---+---+---+---+---+---+---+---+
4 |   |   |   |   |   |   |   |   | 4
 +---+---+---+---+---+---+---+---+
3 |   |   |   |   |   |   |   |   | 3
 +---+---+---+---+---+---+---+---+
2 | P | P | P | P | P | P | P | P | 2
 +---+---+---+---+---+---+---+---+
1 | R | C | B | Q | K | B | C | R | 1
 +---+---+---+---+---+---+---+---+
   a   b   c   d   e   f   g   h
   
Player 1's turn
Enter the position of the piece you want to move (a1, f7 ...):

Capturing a Piece

If your piece's move ends on a square occupied by an opponent's piece, the opponent's piece is captured and removed from the game.

Check and Checkmate

If your move places the opponent's king under attack, that's called "check". If your opponent's king is in check, they must make a move that eliminates the threat of capture on the next move. If they cannot do so, that's called "checkmate", and you win the game.

Pawn Promotion

If a pawn reaches the opposite side of the board, it can be promoted to any other piece (except the king). The game will ask you to choose between 'Queen', 'Rook', 'Bishop', or 'Knight'. Type your choice and press enter.

Here's how it looks in the game:

Ending the Game

The game ends when a player is checkmated (or if a player resigns. To resign, type 'resign' instead of a move.)

Remember, the goal of the game is to checkmate your opponent's king. Good luck!

Contributing

Prerequisites

All contributions you make are greatly appreciated.

  • If you have any suggestions, feel free to open an issue to discuss it or create a merge request directly.
  • Create an individual merge request for each suggestion.

Creating a Merge Request

  1. Fork the project
  2. Create your feature branch:
$ git checkout -b feature/awesomeFeature
  1. Make your changes:
$ git commit -m 'Add a new feature'
  1. Push to the branch:
$ git push origin feature/awesomeFeature
  1. Open a merge request

Contributors