Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AvaAvarai committed Aug 20, 2023
1 parent f1e68e2 commit abfa9e9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Binary file renamed MyChessApp.jar → jChess.jar
Binary file not shown.
20 changes: 5 additions & 15 deletions src/main/java/ChessApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class ChessApp {
private PieceColor playerColor;

public ChessApp() {
frame = new JFrame("Java Chess");
ImageIcon appIcon = new ImageIcon(getClass().getResource("/icons/king_black.png"));
frame = new JFrame("jChess");
ImageIcon appIcon = new ImageIcon(getClass().getResource("/icons/king_black_icon.png"));
frame.setIconImage(appIcon.getImage());
playerColor = StartMenu.showMenu();

Expand Down Expand Up @@ -170,7 +170,7 @@ private void handleSquareClicked(int row, int col) {
movePieceToSquare(row, col);
unhighlightAllSquares();
selectedPiece = null; // Reset for the next selection

checkGameOverConditions();
if (playerColor == PieceColor.WHITE) {
executeRandomComputerMove(PieceColor.BLACK);
} else if (playerColor == PieceColor.BLACK) {
Expand Down Expand Up @@ -272,16 +272,6 @@ private List<Move> getAllLegalMovesForComputer(PieceColor computerColor) {

return legalMoves;
}

private static class Move {
Point start;
Point end;

Move(Point start, Point end) {
this.start = start;
this.end = end;
}
}

private void showEndGamePopup(String title, String message) {
// Load and scale the black king icon
Expand Down Expand Up @@ -313,11 +303,11 @@ private void executeRandomComputerMove(PieceColor computerColor) {

private void declareStalemate() {
ImageIcon icon = new ImageIcon(getClass().getResource("/icons/king_black.png"));
ImageIcon scaledIcon = new ImageIcon(icon.getImage().getScaledInstance(15, 25, Image.SCALE_SMOOTH));
ImageIcon scaledIcon = new ImageIcon(icon.getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH));

Object[] options = {"Restart", "Exit"};
int choice = JOptionPane.showOptionDialog(frame,
"The game is a stalemate! What would you like to do next?",
"The game is a stalemate...",
"Stalemate",
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE,
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/Move.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import java.awt.Point;

public class Move {
Point start;
Point end;

Move(Point start, Point end) {
this.start = start;
this.end = end;
}
}
Binary file added src/main/resources/icons/king_black_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit abfa9e9

Please sign in to comment.