From 8f1f9d005cead44e89e07138e140a69706c8ed0b Mon Sep 17 00:00:00 2001 From: aah13002 Date: Fri, 29 Apr 2016 01:58:01 -0400 Subject: [PATCH] Revert "fixed the null piece error" This reverts commit c88621fc0d512dbc89593c82d8351f032263db19. --- src/controller/Game.java | 27 ++++++++------------------- src/model/Board.java | 6 ------ src/view/Square.java | 5 ++--- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/controller/Game.java b/src/controller/Game.java index afb92ea..8e5a462 100755 --- a/src/controller/Game.java +++ b/src/controller/Game.java @@ -21,10 +21,6 @@ public Game(Board board) { current_turn = Color.BLACK; } - public ArrayList getMoveFrontier(Color color) { - return board.generateAllPossibleMoves(color); - } - public void movePiece(Move move) { if (move.isJump()) { board.jump(move); @@ -52,18 +48,11 @@ public ArrayList getAvailableMoves(Location source) { } return jumpset; } - - Piece movee = board.getPiece(source); - ArrayList moves = this.getMoveFrontier(movee.getColor()); - - ArrayList moves_of_movee = new ArrayList(); - - for (Move move : moves) { - if (move.source.equals(movee.getLocation())) { - moves_of_movee.add(move); - } - } - return moves_of_movee; + ArrayList moves = board.generateMoves(board.getPiece(source)); + ArrayList jumps = board.generateJumpMoves(board.getPiece(source)); + ArrayList allMoves = new ArrayList(moves); + allMoves.addAll(jumps); + return allMoves; } public void playVsThunk() { @@ -91,7 +80,7 @@ public void playVsThunk() { panel.moveArbitraryPiece(jump); } else { - ArrayList moveset = this.getMoveFrontier(THUNK_COLOR); + ArrayList moveset = board.generateAllPossibleMoves(THUNK_COLOR); if (moveset.isEmpty()) { System.out.println("Thunk is out of moves."); break; @@ -106,8 +95,8 @@ public void playVsThunk() { } } if (this.current_turn == USER_COLOR) { - ArrayList moveset = this.getMoveFrontier(USER_COLOR); - if (moveset.isEmpty()) break; + //ArrayList moveset = board.generateAllPossibleMoves(USER_COLOR); + //if (moveset.isEmpty()) break; } //board.print(); diff --git a/src/model/Board.java b/src/model/Board.java index e8abdc1..fbb5ceb 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -169,8 +169,6 @@ public void jump(Move jump) { Piece moved = representation[jump.destination.row][jump.destination.column]; this.lastPieceMoved = moved; - - this.resetMovesSinceCapture(); } /** @@ -346,10 +344,6 @@ public int getMovesSinceCapture() { return this.movesSinceCapture; } - private void resetMovesSinceCapture() { - this.movesSinceCapture = 0; - } - public Piece getLastPieceMoved() { return this.lastPieceMoved; } diff --git a/src/view/Square.java b/src/view/Square.java index 6ef7e93..785ca8f 100644 --- a/src/view/Square.java +++ b/src/view/Square.java @@ -84,9 +84,8 @@ public void setPiece(Checker piece) { } public void removePiece() { - if (null != this.piece) { - this.remove(this.piece); - } + + this.remove(this.piece); }