Skip to content

Commit

Permalink
Fixed more merge conflicts, everything is good now.
Browse files Browse the repository at this point in the history
  • Loading branch information
john committed Apr 29, 2016
1 parent 760ed8f commit 76ea71e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 120 deletions.
60 changes: 1 addition & 59 deletions src/model/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,65 +213,7 @@ public ArrayList<Move> generateRegularMovesForPiece(Piece p) {
return avail_moves;
}

/**
<<<<<<< HEAD
=======
* Generates the frontier for movement for all pieces.
* @param color
* @return
*/
public ArrayList<Board> generateMoveFrontier(Color color) {
ArrayList<Board> frontier = new ArrayList<Board>();
for (int i = 0; i < BOARD_SIZE; ++i) {
for (int j = 0; j < BOARD_SIZE; ++j) {
Piece p = this.representation[i][j];
if(null != p && p.getColor() == color) {
ArrayList<Move> moves = generateMoves(this.representation[i][j]);
for (Move move : moves) {
Board board = new Board(this);
board.move(move);
frontier.add(board);
}
}
}
}
return frontier;
}

public void move(Move move) {
representation[move.destination.row][move.destination.column]
= representation[move.source.row][move.source.column];
representation[move.source.row][move.source.column] = null;
representation[move.destination.row][move.destination.column]
.setLocation(new Location(move.destination.row, move.destination.column));
Piece moved = representation[move.destination.row][move.destination.column];
this.lastPieceMoved = moved;
this.lastMove = move;
}

/**
* Move the jumper and erase the jumpee.
* @param jump
*/
public void jump(Move jump) {
representation
[(jump.destination.row + jump.source.row)/2]
[(jump.destination.column + jump.source.column)/2] = null; // monkey
representation[jump.destination.row][jump.destination.column] =
representation[jump.source.row][jump.source.column];
representation[jump.source.row][jump.source.column] = null;
representation[jump.destination.row][jump.destination.column]
.setLocation(new Location(jump.destination.row, jump.destination.column));

Piece moved = representation[jump.destination.row][jump.destination.column];
this.lastPieceMoved = moved;
this.lastMove = jump;
this.resetMovesSinceCapture();

}

/**
>>>>>>> 430f2be346c625bc746ce1659838d93253901c11
/**
* Returns the possible jumps a piece can take.
* @param color
* @return
Expand Down
7 changes: 0 additions & 7 deletions src/view/GameEventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,7 @@ public void keyPressed(KeyEvent arg0) {}

@Override
public void keyReleased(KeyEvent e) {
<<<<<<< HEAD

=======
if(e.getKeyCode() == KeyEvent.VK_ENTER && gamePanel.moveReady()) {
gamePanel.moveSelectedPiece();
gamePanel.updateMoveMessage();
}
>>>>>>> 430f2be346c625bc746ce1659838d93253901c11
}

@Override
Expand Down
50 changes: 3 additions & 47 deletions src/view/GamePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@
import javax.swing.JLabel;
import javax.swing.JPanel;

<<<<<<< HEAD
import controller.Game;
import controller.GameConstants;
import model.Color;
import model.Location;
import model.Move;
import model.Piece;
import model.Type;
=======
import model.Color;
import model.Location;
import model.Move;
import controller.Game;
>>>>>>> 430f2be346c625bc746ce1659838d93253901c11


/**
* Represents the panel which will hold all of the graphical
Expand Down Expand Up @@ -130,8 +122,7 @@ public void highlightValidDestinations(Location source) {
public void dehighlightValidDestinations() {
canvas.invalidateAllSquares();
}

<<<<<<< HEAD

public void movePiece(Move move) {
if (move.isJump()) {
int monkeyRow = (move.destination.row + move.source.row)/2;
Expand All @@ -146,19 +137,11 @@ public void movePiece(Move move) {
if (canPromote(canvas.getSquare(move.destination))) {
canvas.getSquare(move.destination).promotePiece();
}
=======
public Location getMoveSource(){
return moveSource.getCellLocation();
}

public Location getMoveDestination(){
return moveDestination.getCellLocation();
>>>>>>> 430f2be346c625bc746ce1659838d93253901c11
}


public void moveSelectedPiece() {
<<<<<<< HEAD

/* Create the move */
Move move = new Move(moveSource.getCellLocation(), moveDestination.getCellLocation());

Expand Down Expand Up @@ -197,33 +180,6 @@ public void resetMove() {
moveDestination.setSelected(false);
moveSource = null;
moveDestination = null;
=======
Move move = new Move(getMoveSource(), getMoveDestination());
game.movePiece(move);

canvas.moveChecker(getMoveSource(), getMoveDestination());
dehighlightAllSquares();

if(move.isJump()) {
Location monkeyLoc = new Location((move.destination.row
+ move.source.row)/2,
(move.source.column
+ move.destination.column) / 2);
System.out.println(monkeyLoc);
removePiece(monkeyLoc);
moveSource.setSelected(false);
//moveDestination.setSelected(false);
moveSource = null;
//moveDestination = null;

} else {
moveSource.setSelected(false);
moveDestination.setSelected(false);
moveSource = null;
moveDestination = null;
game.switchTurn();
}
>>>>>>> 430f2be346c625bc746ce1659838d93253901c11
}

public boolean canPromote(Square square) {
Expand Down
7 changes: 0 additions & 7 deletions src/view/Square.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ public void dehighlight() {
public Color getPieceColor() {
return pieceColor;
}
<<<<<<< HEAD


public void placePiece(Color color) {
this.hasPiece = true;
Expand All @@ -200,11 +198,6 @@ public Color removePiece() {
return color;
}

=======

public void dehighlight() {
this.setBorder(null);
>>>>>>> 430f2be346c625bc746ce1659838d93253901c11

public void setKing(boolean king) {
this.king = king;
Expand Down

0 comments on commit 76ea71e

Please sign in to comment.