- Abra um terminal (Git Bash é o recomendado, pois é colorido)
- Entre no diretório /bin do projeto, no meu caso
~/eclipse-workspace/chess-system/bin
- Após entrar no diretório, digite
Java application/Program
para rodar a aplicação (obs: estou utilizando o Java SE 11) - O resultado esperado será esse, conforme o 1° Tela Inicial exibe abaixo:
1° Tela Inicial | 2° Selecione a peça origem (Source) | 3° Selecione a peça destino (Target) | 4° Peça movida, turno/player trocado |
---|---|---|---|
- Observações: 📝
- Peças: Peão, Torre, Cavalo, Bispo, Rainha e Rei
Pawn(Peão) | Rook(Torre) | Knight(Cavalo) | Bishop(Bispo) | Queen(Rainha) | King(Rei) |
---|---|---|---|---|---|
P | R | N | B | Q | K |
- A mecânica do jogo é baseada em linhas(1, 2, 3, 4, 5, 6, 7, 8) e colunas(a, b, c, d, e, f, g, h)
- Para escolher uma peça é necessário selecionar primeiramente a coluna e logo em seguida(sem espaços) selecionar a linha, exemplo: c2
- Em Captured pieces o jogo armazena as peças capturadas.
- O Turn exibe o turno(rodada) em que o jogo está.
- Waiting player exibe qual é o jogador a jogar a próxima peça.
- Source é a origem, ou seja, a peça no qual o jogador irá jogar.
- Target é o destino, ou seja, o local no qual o jogador irá mover a peça.
- O jogo possui sistema de Check e CheckMate
- Alguns movimentos especiais:
- Castling(Roque)
- En Passant
- Promotion(Promoção)
Checklist:
- Class Position [public]
- OOP Topics:
- Encapsulation
- Constructors
- ToString (Object/overriding)
Checklist:
- Classes Piece, Board [public]
- OOP Topics:
- Associations
- Encapsulation / Access Modifiers
- Data Structures Topics:
- Matrix
8 - - - - - - - -
7 - - - - - - - -
6 - - - - - - - -
5 - - - - - - - -
4 - - - - - - - -
3 - - - - - - - -
2 - - - - - - - -
1 - - - - - - - -
a b c d e f g h
Checklist:
- Methods: Board.Piece(row, column) and Board.Piece(position)
- Enum Chess.Color
- Class Chess.ChessPiece [public]
- Class Chess.ChessMatch [public]
- Class ChessConsole.UI
- OOP Topics:
- Enumerations
- Encapsulation / Access Modifiers
- Inheritance
- Downcasting
- Static members
- Layers pattern
- Data Structures Topics:
- Matrix
Checklist:
- Method: Board.PlacePiece(piece, position)
- Classes: Rook, King [public]
- Method: ChessMatch.InitialSetup
- OOP Topics:
- Inheritance
- Overriding
- Polymorphism (ToString)
Checklist:
- Class BoardException [public]
- Methods: Board.PositionExists, Board.ThereIsAPiece
- Implement defensive programming in Board methods
- OOP Topics:
- Exceptions
- Constructors (a string must be informed to the exception)
Checklist:
- Class ChessException [public]
- Class ChessPosition [public]
- Refactor ChessMatch.InitialSetup
- OOP Topics:
- Exceptions
- Encapsulation
- Constructors (a string must be informed to the exception)
- Overriding
- Static members
- Layers pattern
Color in terminal:
- Windows: Git Bash
- Mac: Google "osx terminal color"
Checklist:
- Place more pieces on the board
- Distinguish piece colors in UI.PrintPiece method
Checklist:
- Method Board.RemovePiece
- Method UI.ReadChessPosition
- Method ChessMatch.PerformChessMove
- Method ChessMatch.MakeMove
- Method ChessMatch.ValidadeSourcePosition
- Write basic logic on Program.cs
- OOP Topics:
- Exceptions
- Encapsulation
Clear screen using Java:
// https://stackoverflow.com/questions/2979383/java-clear-the-console
public static void clearScreen() {
System.out.print("\033[H\033[2J");
System.out.flush();
}
Checklist:
- ChessException
- InputMismatchException
Checklist:
-
Methods in Piece:
- PossibleMoves [abstract]
- PossibleMove
- IsThereAnyPossibleMove
-
Basic PossibleMove implementation for Rook and King
-
Update ChessMatch.ValidadeSourcePosition
-
OOP Topics:
- Abstract method / class
- Exceptions
Checklist:
- Method ChessPiece.IsThereOpponentPiece(position) [protected]
- Implement Rook.PossibleMoves
- Method ChessMatch.ValidateTargetPosition
- OOP Topics:
- Polymorphism
- Encapsulation / access modifiers [protected]
- Exceptions
Checklist:
- Method ChessMatch.PossibleMoves
- Method UI.PrintBoard [overload]
- Refactor main program logic
- OOP Topics:
- Overloading
Checklist:
- Method King.CanMove(position) [private]
- Implement King.PossibleMoves
- OOP Topics:
- Encapsulation
- Polymorphism
Checklist:
- Class ChessMatch:
- Properties Turn, CurrentPlayer [private set]
- Method NextTurn [private]
- Update PerformChessMove
- Update ValidadeSourcePosition
- Method UI.PrintMatch
- OOP Topics:
- Encapsulation
- Exceptions
Checklist:
- Method UI.PrintCapturedPieces
- Update UI.PrintMatch
- Update Program logic
- Lists in ChessMatch: _piecesOnTheBoard, _capturedPieces
- Update constructor
- Update PlaceNewPiece
- Update MakeMove
- OOP Topics:
- Encapsulation
- Constructors
- Data Structures Topics:
- List
Rules:
- Check means your king is under threat by at least one opponent piece
- You can't put yourself in check
Checklist:
- Property ChessPiece.ChessPosition [get]
- Class ChessMatch:
- Method UndoMove
- Property Check [private set]
- Method Opponent [private]
- Method King(color) [private]
- Method TestCheck
- Update PerformChessMove
- Update UI.PrintMatch
Checklist:
- Class ChessMatch:
- Property Checkmate [private set]
- Method TestCheckmate [private]
- Update PerformChessMove
- Update UI.PrintMatch
- Update Program logic
Checklist:
- Class ChessPiece:
- Property MoveCount [private set]
- Method IncreaseMoveCount [internal]
- Method DecreaseMoveCount [internal]
- Class ChessMatch:
- Update MakeMove
- Update UndoMove
- OOP Topics:
- Encapsulation
Checklist:
- Class Pawn
- Update ChessMatch.InitialSetup
- OOP Topics:
- Encapsulation
- Inheritance
- Polymorphism
Checklist:
- Class Bishop
- Update ChessMatch.InitialSetup
- OOP Topics:
- Encapsulation
- Inheritance
- Polymorphism
Checklist:
- Class Knight
- Update ChessMatch.InitialSetup
- OOP Topics:
- Encapsulation
- Inheritance
- Polymorphism
Checklist:
- Class Queen
- Update ChessMatch.InitialSetup
- OOP Topics:
- Encapsulation
- Inheritance
- Polymorphism
Checklist:
- Update King
- Update ChessMatch.MakeMove
- Update ChessMatch.UndoMove
Checklist:
- Register a pawn which can be captured by en passant on next turn
- Property ChessMatch.EnPassantVulnerable
- Update ChessMatch.PerformChessMove
- Update Pawn.PossibleMoves
- Update ChessMatch.MakeMove
- Update ChessMatch.UndoMove
- Update ChessMatch.InitialSetup
Checklist:
- Property ChessMatch.Promoted
- Update ChessMatch.PerformChessMove
- Method ChessMatch.ReplacePromotedPiece
- Update Program logic