All Packages Class Hierarchy This Package Previous Next Index
Class kpalin.alabra.Piece
java.lang.Object
|
+----kpalin.alabra.Piece
- public class Piece
- extends Object
- implements Serializable
This is a datastructure representing the chess pieces. Also the images
of the pieces are generated and stored here as static data.
- Author:
- Kimmo Palin
- See Also:
- PieceImageMemData, ChessSettings
-
BISHOP
-
-
bishopMoves
- These are the relative coordinates where bishop can move.
-
BLACK
-
-
DRAW
-
-
ERRMESG
- Errormessage body
-
GAMEOVER
- This is added to turn-variable so that WHITE+GAMEOVER is white victory
and BLACK+GAMEOVER is black victory.
-
IMAGENAME
- These are the names of the gif-files that hold the pieceimages.
-
KING
-
-
KNIGHT
-
-
knightMoves
- These are the relative coordinates where knight can move.
-
LONGFORT
-
-
PAWN
-
-
PIECES
- Images of all pieces.
-
QUEEN
-
-
ROOK
-
-
rookMoves
- These are the relative coordinates where rook can move.
-
SHORTFORT
-
-
side
- Side of the piece.
-
type
- Type of the piece.
-
TYPECHARS
- These are the characters to identify the pieces
-
WHITE
- Indexies for pieces
-
Piece(int, int)
- Creates a new piece, with specified type and side.
-
addImage(int, int, Image)
- This is ment for Applet and Application to add the images upon
initialization.
-
getIcon()
- This gives the white pawn (used as an icon in application).
-
getImage()
- Get image of the piece.
-
getSide()
- Query side of the piece.
-
getType()
- Query type of the piece.
-
getTypeChar()
- Query type of the piece.
-
readExternal(ObjectInput)
- Reading Piece from ObjectInput.
-
toString()
-
-
writeExternal(ObjectOutput)
- Writing Piece-object to ObjectOutput.
ERRMESG
static final String ERRMESG
- Errormessage body
rookMoves
static final int rookMoves[][]
- These are the relative coordinates where rook can move.
bishopMoves
static final int bishopMoves[][]
- These are the relative coordinates where bishop can move.
knightMoves
static final int knightMoves[][]
- These are the relative coordinates where knight can move.
PIECES
private static Image PIECES[][]
- Images of all pieces. Just stored here. Use accessories to add
images. Can't make this final 'cause of initialization difficulties.
IMAGENAME
public static final String IMAGENAME[][]
- These are the names of the gif-files that hold the pieceimages.
TYPECHARS
static final char TYPECHARS[]
- These are the characters to identify the pieces
WHITE
static final int WHITE
- Indexies for pieces
BLACK
static final int BLACK
GAMEOVER
static final int GAMEOVER
- This is added to turn-variable so that WHITE+GAMEOVER is white victory
and BLACK+GAMEOVER is black victory.
DRAW
static final int DRAW
KING
static final int KING
QUEEN
static final int QUEEN
ROOK
static final int ROOK
BISHOP
static final int BISHOP
KNIGHT
static final int KNIGHT
PAWN
static final int PAWN
LONGFORT
static final int LONGFORT
SHORTFORT
static final int SHORTFORT
side
private int side
- Side of the piece. White or black.
type
private int type
- Type of the piece. See final static fields.
Piece
Piece(int bw,
int piece) throws Exception
- Creates a new piece, with specified type and side. If the parameters
are not valid, throws exception.
- Parameters:
- bw - Side of the piece. Black or white.
- piece - Type of the piece.
- Throws: Exception
- Error if you want to do inexistent piece.
addImage
public static void addImage(int s,
int t,
Image i)
- This is ment for Applet and Application to add the images upon
initialization.
- Parameters:
- s - Side.
- t - Type.
- i - Image of the piece.
getIcon
static Image getIcon()
- This gives the white pawn (used as an icon in application).
Throws ArrayIndexOutOfBoundsException if PIECES is not
initialized.
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Writing Piece-object to ObjectOutput.
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Reading Piece from ObjectInput.
getType
int getType()
- Query type of the piece.
- Returns:
- Type of the piece.
getTypeChar
char getTypeChar()
- Query type of the piece.
- Returns:
- Character representing the type of this piece.
getSide
int getSide()
- Query side of the piece. Black or white.
- Returns:
- Side of the piece.
getImage
Image getImage()
- Get image of the piece.
- Returns:
- Image of the piece.
toString
public String toString()
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index