Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CSE-4705-Checkers/src/player/Player.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
46 lines (37 sloc)
1012 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package player; | |
import java.util.ArrayList; | |
import model.Board; | |
import model.Color; | |
import model.Location; | |
import model.Move; | |
public class Player { | |
protected Color color; | |
protected Board board; | |
protected boolean inJumpSequence; | |
public Player(Color color, Board board) { | |
this.color = color; | |
this.board = board; | |
this.inJumpSequence = false; | |
} | |
//Sorry that I had to make this, it's needed to make life easier on | |
//The server side | |
public void setColor(Color newColor){ | |
this.color = newColor; | |
} | |
public boolean isInJumpSequence() { | |
return inJumpSequence; | |
} | |
public ArrayList<Move> getAllAvailableMoves() { | |
return board.generateAllMoves(color); | |
} | |
public ArrayList<Move> getAllAvailableJumpMoves() { | |
return board.generateAllJumpMoves(color); | |
} | |
public ArrayList<Move> getAvailableMoves(Location source) { | |
if (inJumpSequence) { | |
return board.generateJumpMovesForPiece(board.getPiece(source)); | |
} else { | |
return board.generateMovesForPiece(board.getPiece(source)); | |
} | |
} | |
} |