-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CS2113-T18-1] ChessMaster #19
base: master
Are you sure you want to change the base?
[CS2113-T18-1] ChessMaster #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good organisation of packages, use of exceptions, and documentations!
|
||
import java.util.ArrayList; | ||
|
||
public abstract class Player { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good choice of abstract class for player!
row = 0; | ||
} | ||
|
||
for (int tempRow = row; row < tempRow + 2; row++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would make more sense if tempRow was changed instead of row
public Move getNextMove(ChessBoard board) throws InvalidMoveException, NullPieceException, ParseCoordinateException{ | ||
String input = TextUI.getUserInput(); // Get user input | ||
try { | ||
Parser parser = new Parser(); | ||
Command command = parser.parseCommand(input, board); | ||
if (command instanceof AbortCommand) { | ||
return null; | ||
} | ||
return command.getMove(); | ||
|
||
} catch (ParseCoordinateException | NullPieceException e) { | ||
TextUI.printErrorMessage(e); | ||
} | ||
return new Move(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the catch clause intended to throw the same exception again after printing error message?
int colour = promoteFrom.getColour(); | ||
Coordinate position = promoteFrom.getPosition(); | ||
|
||
switch (promoteTo.toLowerCase()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good versatility
|
||
import java.util.ArrayList; | ||
|
||
public abstract class ChessPiece { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good use of abstract class for chess piece!
public static void saveBoard(ChessBoard board) throws SaveBoardException { | ||
|
||
try (FileWriter fileWriter = new FileWriter(filePath)){ | ||
for (int row = 0; row < 8; row++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try do define constants as final variables on top
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good that you've added help messages
Good use of documentation and comments in some parts to explain code
Try to keep the way of printing messages consistent, some use const final strings, others put the string directly in the methods
Keep the way of printing output consistent also, some classes are directly calling system.out.print
public static void main(String[] args) { | ||
new ChessMaster().run(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good abstraction of main
if (move == null) { | ||
throw new InvalidMoveException(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be more informative if you add a message argument to the exception or use a different exception
can also consider using assertion if this is intended to ensure code correctness
import chessmaster.pieces.Pawn; | ||
import chessmaster.ui.TextUI; | ||
|
||
public class ChessBoard { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class is doing a lot!
consider extracting parts that deal with pieces and moves
//gets all the moves for the current player | ||
ChessBoard board = tuple.getBoard(); | ||
Move[] moves = board.getAllMoves(color); | ||
assert moves.length > 0 : "No moves available for " + color + " at depth " + depth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can moves.length = 0 ever happen during use?
assert from != null && to != null : "Coordinates in Move should not be null!"; | ||
assert piece != null && !piece.isEmptyPiece() : "Chess piece in Move should not be null or empty!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these happen during run time?
private int[][] boardWeight = | ||
{{0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to initialise here right
ArrayList<Coordinate> flattenedCoordinates = new ArrayList<>(); | ||
|
||
for (Coordinate[] direction : availableCoordinates) { | ||
for (Coordinate possibleCoord : direction) { | ||
if (this.isMoveValid(possibleCoord, board)) { | ||
flattenedCoordinates.add(possibleCoord); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider refactoring this part if its used in many methods
docs/DeveloperGuide.md
Outdated
@@ -23,16 +137,29 @@ | |||
|Version| As a ... | I want to ... | So that I can ...| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it supposed to be formatted this way?
**API:** | ||
|
||
Below is a class diagram representing the Storage class. | ||
The Storage component is responsible for handling the storage and retrieval of chess game state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the StorageClass diagram be shown at the next line instead?
docs/DeveloperGuide.md
Outdated
|
||
![](StorageSequence.png) | ||
|
||
* Creates the necessary parent directories for the file and the file itself if they don't exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be helpful to provide more detailed explanations alongside the diagrams to offer readers a better understanding of creating parent directories, saving the ChessBoard state, resetting the game, and loading the state.
In order to handle user input into the program during the game, the `Parser` class was implemented. | ||
Below is a sequence diagram describing the process of handling user input passed from `Game`: | ||
|
||
![](images/ParseCommandSequence.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on the diagram and explanation of how the Parser class works! The visual representation along with the detailed step-by-step breakdown makes it easy to understand the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added review comments for DG
docs/StorageSequence.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sequence diagram seems too big, perhaps break down into the different method calls
docs/images/ParseCommandSequence.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/StorageSequence.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/StorageSequence.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall clean and neat!
|
||
chessMaster -> ui : shouldStartNewGame() | ||
activate ui | ||
user -> ui : "yes/no" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be the condition? Because its meaning kinda overlaps with Previous Board Exist, so maybe you should just use one of them
Command -> ChessBoard ++: showAvailableCoordinates | ||
ChessBoard -- | ||
Command -> ChessBoard ++: getAvailableCoordinatesString | ||
ChessBoard --> Command --: String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/StorageSequence.puml
Outdated
|
||
|
||
create Storage | ||
User -> Storage++ : new Storage(): String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how your code is implemented, but it seems a bit strange to me to have user calling the command to create a new Storage() object. Did you mean user will input a command which is received by a class and the class triggers the creation of storage object? If yes, what is the class that triggers the creation of storage object? Perhaps in your uml you should have an arrow pointing from the class to storage class instead?
docs/StorageSequence.puml
Outdated
Storage -> Storage++ : createChessMasterFile() | ||
Storage --> Storage-- | ||
create FileWriter | ||
Storage -> FileWriter++ : new FileWriter(): File |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start bug fix
Add `isChecked` and `isCheckMated` features
Fix minimax aggro
Fix User Guide formatting
Fix wrong color when player loses
Fix empty payload in moves command
Update docs
Update PPP
Ignore empty spaces in each `nextLine` method in `Storage` class
Update onx001.md
Fix bug with current turn in save
Add PPP link in AboutUs
Remove chessboard in storage
Remove json tag in code block
Add gameplay link
ChessMasterCLI is a command-line interface (CLI) chess game designed to make learning and training accessible for beginners while offering an engaging experience for all skill levels. This sleek and user-friendly chess simulator provides a platform for novice players to build their skills and understanding of the game.