Added log resetting, disabled resizing in MainFrame

This commit is contained in:
Kai S. K. Engelbart 2019-07-25 21:38:49 +02:00
parent c0479b88b6
commit 20ccb2aeef
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
4 changed files with 17 additions and 11 deletions

View File

@ -168,8 +168,6 @@ public class Board implements Cloneable {
// Move the rook // Move the rook
Move rookMove = move.dest.x == 6 ? new Move(5, move.pos.y, 7, move.pos.y) // Kingside Move rookMove = move.dest.x == 6 ? new Move(5, move.pos.y, 7, move.pos.y) // Kingside
: new Move(3, move.pos.y, 0, move.pos.y); // Queenside : new Move(3, move.pos.y, 0, move.pos.y); // Queenside
// Move the rook
setDest(rookMove, getPos(rookMove)); setDest(rookMove, getPos(rookMove));
setPos(rookMove, null); setPos(rookMove, null);
@ -278,7 +276,8 @@ public class Board implements Cloneable {
public GameState getGameEventType(Color color) { public GameState getGameEventType(Color color) {
return checkCheck(color) ? checkCheckmate(color) ? GameState.CHECKMATE : GameState.CHECK return checkCheck(color) ? checkCheckmate(color) ? GameState.CHECKMATE : GameState.CHECK
: getMoves(color).isEmpty() ? GameState.STALEMATE : GameState.NORMAL; : getMoves(color).isEmpty() || log.getLast().halfmoveClock >= 50 ? GameState.STALEMATE
: GameState.NORMAL;
} }
/** /**
@ -369,6 +368,8 @@ public class Board implements Cloneable {
blackCastling.put(Type.QUEEN, true); blackCastling.put(Type.QUEEN, true);
castlingRights.put(Color.WHITE, whiteCastling); castlingRights.put(Color.WHITE, whiteCastling);
castlingRights.put(Color.BLACK, blackCastling); castlingRights.put(Color.BLACK, blackCastling);
log.reset();
} }
/** /**

View File

@ -49,6 +49,11 @@ public class Log implements Cloneable {
} }
} }
public void reset() {
moves.clear();
activeColor = Color.WHITE;
}
@Override @Override
public Object clone() { public Object clone() {
Log log = null; Log log = null;

View File

@ -55,7 +55,7 @@ public class MainWindow {
*/ */
private void initialize() { private void initialize() {
mframe = new JFrame("Chess by Kai S. K. Engelbart"); mframe = new JFrame("Chess by Kai S. K. Engelbart");
mframe.setResizable(true); mframe.setResizable(false);
mframe.setBounds(100, 100, 494, 565); mframe.setBounds(100, 100, 494, 565);
mframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);