org.gChess
Class ChessPiece

java.lang.Object
  extended by org.gChess.ChessPiece
Direct Known Subclasses:
Bishop, King, Knight, Pawn, Queen, Rook

public abstract class ChessPiece
extends java.lang.Object

This class contains all the base methods for each chess piece


Field Summary
static int BLACK
          apparently enums don't play to happily with limited cpu cycles, so these will have to take up the slack.
static int WHITE
           
 
Constructor Summary
ChessPiece(int color, Location loc, ChessBoard cb)
           
 
Method Summary
 boolean canMove()
          return true if there are ANY valid locations we can move to; returns false otherwise.
 ChessBoard getBoard()
           
 int getColor()
           
 Drawable getImage()
           
 Location getLoc()
           
abstract  java.util.ArrayList<Location> getMoveLocations()
          This method DOES NOT check that all returned locations are not occupied.
 java.util.ArrayList<Location> getValidMoveLocations()
           
 void loadImage(int resource)
           
 void moveTo(Location loc)
           
 void setLoc(Location loc)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLACK

public static final int BLACK
apparently enums don't play to happily with limited cpu cycles, so these will have to take up the slack. These class vars are for determining the "team" aka color of a ChessPiece

See Also:
Constant Field Values

WHITE

public static final int WHITE
See Also:
Constant Field Values
Constructor Detail

ChessPiece

public ChessPiece(int color,
                  Location loc,
                  ChessBoard cb)
Method Detail

canMove

public boolean canMove()
return true if there are ANY valid locations we can move to; returns false otherwise.


getValidMoveLocations

public java.util.ArrayList<Location> getValidMoveLocations()
Returns:
an ArrayList of Locations that we can move to and that are not occupied.

moveTo

public void moveTo(Location loc)

getMoveLocations

public abstract java.util.ArrayList<Location> getMoveLocations()
This method DOES NOT check that all returned locations are not occupied.

Returns:
an ArrayList of Locations that this chess piece potentially could move to.

getLoc

public Location getLoc()

setLoc

public void setLoc(Location loc)

getColor

public int getColor()

getImage

public Drawable getImage()

loadImage

public void loadImage(int resource)

getBoard

public ChessBoard getBoard()