diff --git a/src/controller/Game.java b/src/controller/Game.java index 61d983a..d60aaba 100755 --- a/src/controller/Game.java +++ b/src/controller/Game.java @@ -20,10 +20,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); @@ -51,18 +47,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() { @@ -90,7 +79,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; @@ -105,8 +94,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 da97c3b..3e205ca 100755 --- a/src/model/Board.java +++ b/src/model/Board.java @@ -172,9 +172,10 @@ public void jump(Move jump) { .setLocation(new Location(jump.destination.row, jump.destination.column)); Piece moved = representation[jump.destination.row][jump.destination.column]; - this.lastPieceMoved = moved; + this.lastPieceMoved = moved; this.lastMove = jump; this.resetMovesSinceCapture(); + } /** @@ -350,10 +351,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 990e5b4..5276e1e 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); }