Skip to content

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
domenickd3 committed Apr 29, 2016
2 parents 6907b94 + 8f1f9d0 commit 430f2be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
27 changes: 8 additions & 19 deletions src/controller/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,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 @@ -51,18 +47,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 @@ -90,7 +79,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 @@ -105,8 +94,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
7 changes: 2 additions & 5 deletions src/model/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}

/**
Expand Down Expand Up @@ -350,10 +351,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 430f2be

Please sign in to comment.