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

Variable Index

 o BISHOP
 o bishopMoves
These are the relative coordinates where bishop can move.
 o BLACK
 o DRAW
 o ERRMESG
Errormessage body
 o GAMEOVER
This is added to turn-variable so that WHITE+GAMEOVER is white victory and BLACK+GAMEOVER is black victory.
 o IMAGENAME
These are the names of the gif-files that hold the pieceimages.
 o KING
 o KNIGHT
 o knightMoves
These are the relative coordinates where knight can move.
 o LONGFORT
 o PAWN
 o PIECES
Images of all pieces.
 o QUEEN
 o ROOK
 o rookMoves
These are the relative coordinates where rook can move.
 o SHORTFORT
 o side
Side of the piece.
 o type
Type of the piece.
 o TYPECHARS
These are the characters to identify the pieces
 o WHITE
Indexies for pieces

Constructor Index

 o Piece(int, int)
Creates a new piece, with specified type and side.

Method Index

 o addImage(int, int, Image)
This is ment for Applet and Application to add the images upon initialization.
 o getIcon()
This gives the white pawn (used as an icon in application).
 o getImage()
Get image of the piece.
 o getSide()
Query side of the piece.
 o getType()
Query type of the piece.
 o getTypeChar()
Query type of the piece.
 o readExternal(ObjectInput)
Reading Piece from ObjectInput.
 o toString()
 o writeExternal(ObjectOutput)
Writing Piece-object to ObjectOutput.

Variables

 o ERRMESG
 static final String ERRMESG
Errormessage body

 o rookMoves
 static final int rookMoves[][]
These are the relative coordinates where rook can move.

 o bishopMoves
 static final int bishopMoves[][]
These are the relative coordinates where bishop can move.

 o knightMoves
 static final int knightMoves[][]
These are the relative coordinates where knight can move.

 o 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.

 o IMAGENAME
 public static final String IMAGENAME[][]
These are the names of the gif-files that hold the pieceimages.

 o TYPECHARS
 static final char TYPECHARS[]
These are the characters to identify the pieces

 o WHITE
 static final int WHITE
Indexies for pieces

 o BLACK
 static final int BLACK
 o GAMEOVER
 static final int GAMEOVER
This is added to turn-variable so that WHITE+GAMEOVER is white victory and BLACK+GAMEOVER is black victory.

 o DRAW
 static final int DRAW
 o KING
 static final int KING
 o QUEEN
 static final int QUEEN
 o ROOK
 static final int ROOK
 o BISHOP
 static final int BISHOP
 o KNIGHT
 static final int KNIGHT
 o PAWN
 static final int PAWN
 o LONGFORT
 static final int LONGFORT
 o SHORTFORT
 static final int SHORTFORT
 o side
 private int side
Side of the piece. White or black.

 o type
 private int type
Type of the piece. See final static fields.

Constructors

 o 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.

Methods

 o 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.
 o getIcon
 static Image getIcon()
This gives the white pawn (used as an icon in application). Throws ArrayIndexOutOfBoundsException if PIECES is not initialized.

 o writeExternal
 public void writeExternal(ObjectOutput out) throws IOException
Writing Piece-object to ObjectOutput.

 o readExternal
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
Reading Piece from ObjectInput.

 o getType
 int getType()
Query type of the piece.

Returns:
Type of the piece.
 o getTypeChar
 char getTypeChar()
Query type of the piece.

Returns:
Character representing the type of this piece.
 o getSide
 int getSide()
Query side of the piece. Black or white.

Returns:
Side of the piece.
 o getImage
 Image getImage()
Get image of the piece.

Returns:
Image of the piece.
 o toString
 public String toString()
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index