Skip to content

Commit

Permalink
Revert "fixed the null piece error"
Browse files Browse the repository at this point in the history
This reverts commit c88621f.
  • Loading branch information
Aaron committed Apr 29, 2016
1 parent 362502e commit 8f1f9d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
27 changes: 8 additions & 19 deletions src/controller/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ public Game(Board board) {
current_turn = Color.BLACK;
}

public ArrayList<Move> getMoveFrontier(Color color) {
return board.generateAllPossibleMoves(color);
}

public void movePiece(Move move) {
if (move.isJump()) {
board.jump(move);
Expand Down Expand Up @@ -52,18 +48,11 @@ public ArrayList<Move> getAvailableMoves(Location source) {
}
return jumpset;
}

Piece movee = board.getPiece(source);
ArrayList<Move> moves = this.getMoveFrontier(movee.getColor());

ArrayList<Move> moves_of_movee = new ArrayList<Move>();

for (Move move : moves) {
if (move.source.equals(movee.getLocation())) {
moves_of_movee.add(move);
}
}
return moves_of_movee;
ArrayList<Move> moves = board.generateMoves(board.getPiece(source));
ArrayList<Move> jumps = board.generateJumpMoves(board.getPiece(source));
ArrayList<Move> allMoves = new ArrayList<Move>(moves);
allMoves.addAll(jumps);
return allMoves;
}

public void playVsThunk() {
Expand Down Expand Up @@ -91,7 +80,7 @@ public void playVsThunk() {
panel.moveArbitraryPiece(jump);
}
else {
ArrayList<Move> moveset = this.getMoveFrontier(THUNK_COLOR);
ArrayList<Move> moveset = board.generateAllPossibleMoves(THUNK_COLOR);
if (moveset.isEmpty()) {
System.out.println("Thunk is out of moves.");
break;
Expand All @@ -106,8 +95,8 @@ public void playVsThunk() {
}
}
if (this.current_turn == USER_COLOR) {
ArrayList<Move> moveset = this.getMoveFrontier(USER_COLOR);
if (moveset.isEmpty()) break;
//ArrayList<Move> moveset = board.generateAllPossibleMoves(USER_COLOR);
//if (moveset.isEmpty()) break;
}

//board.print();
Expand Down
6 changes: 0 additions & 6 deletions src/model/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ public void jump(Move jump) {

Piece moved = representation[jump.destination.row][jump.destination.column];
this.lastPieceMoved = moved;

this.resetMovesSinceCapture();
}

/**
Expand Down Expand Up @@ -346,10 +344,6 @@ public int getMovesSinceCapture() {
return this.movesSinceCapture;
}

private void resetMovesSinceCapture() {
this.movesSinceCapture = 0;
}

public Piece getLastPieceMoved() {
return this.lastPieceMoved;
}
Expand Down
5 changes: 2 additions & 3 deletions src/view/Square.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ public void setPiece(Checker piece) {
}

public void removePiece() {
if (null != this.piece) {
this.remove(this.piece);
}

this.remove(this.piece);
}


Expand Down

0 comments on commit 8f1f9d0

Please sign in to comment.