|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.view.View
android.widget.ImageView
us.the.mac.board.Board.Piece
public abstract static class Board.Piece
This class contains all the general functions of a piece.
It is used as a parent class of other types of pieces (Knight, Pawn, etc.),
and contains all the board data.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class android.widget.ImageView |
|---|
ImageView.ScaleType |
| Nested classes/interfaces inherited from class android.view.View |
|---|
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener |
| Field Summary | |
|---|---|
protected ArrayList<Board.PGNEvent> |
alternateLineHistory
|
protected Board.Color |
color
|
protected int |
cur_pos
|
protected byte[] |
FILE_A
|
protected byte[] |
FILE_B
|
protected byte[] |
FILE_G
|
protected byte[] |
FILE_H
|
static int |
INVALID_MOVE
The constant that disallows a piece to move. It can be used in conjunction with the move_# variables |
protected ArrayList<Board.PGNEvent> |
mainLineHistory
|
int |
move_1
|
int |
move_2
|
int |
move_3
|
int |
move_4
|
int |
move_5
|
int |
move_6
|
int |
move_7
|
int |
move_8
|
static int |
MOVE_DOWN
The constant that allows a piece to move down. It can be used in conjunction with other MOVE constants |
static int |
MOVE_DOWN_LEFT
The constant that allows a piece to move down and to the left. It can be used in conjunction with other MOVE constants |
static int |
MOVE_DOWN_RIGHT
The constant that allows a piece to move down and to the right. It can be used in conjunction with other MOVE constants |
static int |
MOVE_LEFT
The constant that allows a piece to move to the left. It can be used in conjunction with other MOVE constants |
static int |
MOVE_RIGHT
The constant that allows a piece to move to the right. It can be used in conjunction with other MOVE constants |
static int |
MOVE_UP
The constant that allows a piece to move up. It can be used in conjunction with other MOVE constants |
static int |
MOVE_UP_LEFT
The constant that allows a piece to move up and to the left. It can be used in conjunction with other MOVE constants |
static int |
MOVE_UP_RIGHT
The constant that allows a piece to move up and to the right. It can be used in conjunction with other MOVE constants |
| Constructor Summary | |
|---|---|
Board.Piece(Board.Piece original)
This constructor is used to copy piece data from an existing Piece. |
|
Board.Piece(Context context,
AttributeSet attrs)
This constructor is used to create a Piece from android xml layout files. |
|
| Method Summary | |
|---|---|
void |
addPiece(Board.Piece piece)
|
void |
deselectCurrentPiece()
|
protected abstract int |
firstColor()
This firstColor method is used to create an image of this Piece's R.drawable.resources. |
protected int |
fromCurPos(int move)
This method is used to assign the location of the possible moves for a Piece. |
static Board.Piece |
getPieceAt(int p)
This method accesses the squares container and returns its piece |
static boolean |
hasSelectedPiece()
|
protected void |
invalidateSquares()
|
protected boolean |
isLegal(Board.Square square)
|
boolean |
isOpponent(Board.Color other)
This method depicts whether the passed color is the opponent's |
protected void |
moveTo(int move)
This sets up a move position for the piece |
protected abstract String |
pieceLetter()
This pieceLetter method is used to designate the Piece's letter for PGN format. |
void |
promoteTo(Board.Piece p)
This method accepts the new piece to promote to |
protected void |
resetPossibleMove(int move)
This resets the move at the passed position to no longer be displayed |
protected void |
resetPossibleMoves()
|
protected abstract int |
secondColor()
This secondColor method is used to create an image of this Piece's R.drawable.resources. |
static Board.Piece |
selectedPiece()
|
void |
selectPiece()
|
void |
sendToBack()
|
protected void |
setUpLegalSquare(int move)
This sets up a move position as a legal square to be displayed |
protected void |
setUpLegalSquares()
This sets up a move position as a legal square to be displayed |
abstract void |
setUpMoves()
This is called each time a piece moves, and should use the MOVE constants (MOVE_UP, etc.). |
protected void |
showMoves()
|
String |
toString()
|
| Methods inherited from class android.widget.ImageView |
|---|
clearColorFilter, drawableStateChanged, getBaseline, getDrawable, getImageMatrix, getScaleType, invalidateDrawable, onCreateDrawableState, onDraw, onMeasure, onSetAlpha, setAdjustViewBounds, setAlpha, setColorFilter, setColorFilter, setColorFilter, setFrame, setImageBitmap, setImageDrawable, setImageLevel, setImageMatrix, setImageResource, setImageState, setImageURI, setMaxHeight, setMaxWidth, setScaleType, setSelected, verifyDrawable |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MOVE_RIGHT
public static final int MOVE_UP_RIGHT
public static final int MOVE_UP
public static final int MOVE_UP_LEFT
public static final int MOVE_LEFT
public static final int MOVE_DOWN_LEFT
public static final int MOVE_DOWN
public static final int MOVE_DOWN_RIGHT
public static final int INVALID_MOVE
protected Board.Color color
protected int cur_pos
protected ArrayList<Board.PGNEvent> mainLineHistory
protected ArrayList<Board.PGNEvent> alternateLineHistory
public int move_1
public int move_2
public int move_3
public int move_4
public int move_5
public int move_6
public int move_7
public int move_8
protected final byte[] FILE_A
protected final byte[] FILE_B
protected final byte[] FILE_G
protected final byte[] FILE_H
| Constructor Detail |
|---|
public Board.Piece(Board.Piece original)
original - The new Piece to be promoted to
public Board.Piece(Context context,
AttributeSet attrs)
context - The Application/Activity contextattrs - The xml attributes passed (i.e. position/coordinate [a4])| Method Detail |
|---|
protected abstract int firstColor()
protected abstract int secondColor()
protected abstract String pieceLetter()
public void addPiece(Board.Piece piece)
public void selectPiece()
public void deselectCurrentPiece()
public void sendToBack()
public static boolean hasSelectedPiece()
public static Board.Piece selectedPiece()
public static Board.Piece getPieceAt(int p)
p - the position of the square to access
#Piece that is available, otherwise nullpublic boolean isOpponent(Board.Color other)
other - The color that is received
public void promoteTo(Board.Piece p)
p - The new Piece that is promoted toprotected boolean isLegal(Board.Square square)
square - The currently clicked square to check if it is a legal move
protected void resetPossibleMoves()
protected void resetPossibleMove(int move)
move - The current square to remove data fromprotected void setUpLegalSquares()
square - The current move to check if it is a legalprotected void setUpLegalSquare(int move)
move - The currently clicked square to check if it is a legal moveprotected void moveTo(int move)
move - The position/square to move toprotected void invalidateSquares()
protected void showMoves()
public abstract void setUpMoves()
14| 15| 16| 17| 18 ------------------ 6 | 7 | 8 | 9 | 10 ------------------ -2 |-1 |pos| 1 | 2 ------------------ -10 |-9 |-8 |-7 | 10 ------------------ -18 |-17|-16|-15|-14
protected int fromCurPos(int move)
move - The change from the original position (to make the move)public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||