|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gChess.ChessBoard
public class ChessBoard
This class is effectively an array of ChessPiece objects. Also included are methods for finding legal moves and moving pieces.
Field Summary | |
---|---|
static int |
COLS
|
static int |
ROWS
|
Constructor Summary | |
---|---|
ChessBoard(ChessView view)
Creates a new chess board with width and height in pixels. |
Method Summary | |
---|---|
ChessPiece |
getPieceAt(Location loc)
|
ChessView |
getView()
|
boolean |
isOccupied(Location loc)
|
java.util.ArrayList<Location> |
locsInDirUntilBlocked(Location loc,
int direction,
int playerColor)
Grabs locations in a certain direction until it hits something: a wall, a ChessPiece, whatnot. |
void |
movePiece(ChessPiece cp,
Location loc)
wraps a call to the move method of the chess piece to be moved. |
void |
putPiece(ChessPiece cp,
Location loc)
|
void |
remove(Location loc)
|
ChessSquare |
squareAtCoords(int x,
int y)
This method WILL RETURN NULL if x,y are not on the board. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ROWS
public static final int COLS
Constructor Detail |
---|
public ChessBoard(ChessView view)
width
- height
- Method Detail |
---|
public ChessView getView()
public void movePiece(ChessPiece cp, Location loc)
cp
- public void remove(Location loc)
public ChessPiece getPieceAt(Location loc)
loc
-
null
if no ChessPiece at that locationpublic void putPiece(ChessPiece cp, Location loc)
public boolean isOccupied(Location loc)
loc
-
public java.util.ArrayList<Location> locsInDirUntilBlocked(Location loc, int direction, int playerColor)
loc
- - The starting Locationdirection
- - A member of the direction constants in LocationplayerColor
- - Either ChessPiece.BLACK or ChessPiece.WHITE
public ChessSquare squareAtCoords(int x, int y)
x
- y
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |