Commit 5aa08fcb authored by hamed's avatar hamed

Final Ver2

parent 66d91632
...@@ -142,6 +142,20 @@ public class Board { ...@@ -142,6 +142,20 @@ public class Board {
} }
return false; return false;
} }
public boolean checkGameOver(boolean isWhite){
if(!KishCheck(isWhite)) return false;
if(isWhite){
if(whiteKing.moves().isEmpty()){
return true;
}
}
else {
if(blackKing.moves().isEmpty()) {
return true;
}
}
return false;
}
public Piece[][] getBoard() { public Piece[][] getBoard() {
return board; return board;
} }
......
...@@ -150,9 +150,16 @@ public class ChessFrame extends JFrame implements MouseListener, MouseMotionList ...@@ -150,9 +150,16 @@ public class ChessFrame extends JFrame implements MouseListener, MouseMotionList
g.setFont(new Font("Arial", Font.BOLD, 18)); g.setFont(new Font("Arial", Font.BOLD, 18));
if(b.KishCheck(true)){ if(b.KishCheck(true)){
g.drawString("Kish of White King ...", WIDTH + WIDTH_2 / 3, yBias+HEIGHT / 2); g.drawString("Kish of White King ...", WIDTH + WIDTH_2 / 3, yBias+HEIGHT / 2);
if(b.checkGameOver(true)){
g.drawString("Black Color is Win ...", WIDTH + WIDTH_2 / 3, yBias+yBias+HEIGHT / 2);
}
}else if(b.KishCheck(false)){ }else if(b.KishCheck(false)){
g.drawString("Kish of Black King ...", WIDTH + WIDTH_2 / 3, yBias+HEIGHT / 2); g.drawString("Kish of Black King ...", WIDTH + WIDTH_2 / 3, yBias+HEIGHT / 2);
if(b.checkGameOver(false)){
g.drawString("White Color is Win ...", WIDTH + WIDTH_2 / 3, yBias+yBias+HEIGHT / 2);
}
}else if(b.isWhiteMove()) { }else if(b.isWhiteMove()) {
g.drawString("White Turn...", WIDTH + WIDTH_2 / 3, yBias+HEIGHT / 2); g.drawString("White Turn...", WIDTH + WIDTH_2 / 3, yBias+HEIGHT / 2);
}else if(!b.isWhiteMove()) { }else if(!b.isWhiteMove()) {
......
...@@ -14,7 +14,7 @@ public class Bishop extends Piece { ...@@ -14,7 +14,7 @@ public class Bishop extends Piece {
public Bishop(int x, int y, boolean isWhite, Board board) { public Bishop(int x, int y, boolean isWhite, Board board) {
super(x, y, isWhite, board); super(x, y, isWhite, board);
} }
@Override @Override
public boolean isValidMove(int dx, int dy) { public boolean isValidMove(int dx, int dy) {
// if(!isCanMove(dx, dy)) return false; // if(!isCanMove(dx, dy)) return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment