Class Board

java.lang.Object
  extended by Board

public class Board
extends java.lang.Object

Since:
24/11/2009 notice: it's important to notice that x is equal to board row and y is equal to board column.
Author:
Petri Tuononen

Constructor Summary
Board()
          Constructor.
 
Method Summary
 void addPiece(Piece p)
          Add new piece on the board
 java.lang.String coordinatesToNotation(int x, int y)
          Forms notation from x and y.
 void emptyBoard()
          Clear the board from pieces.
 Piece getPiece(int x, int y, int color)
          Returns piece with given coordinates and color.
 java.util.ArrayList<Piece> getPieces()
          Get all pieces as an arraylist.
 java.util.ArrayList<Piece> getPiecesFromOneSide(int color)
          Get pieces from only one black or white as an arraylist.
 void loadGame()
          Loads game state from a file.
 Index notationToIndex(java.lang.String notation)
          Converts e.g. c5 to row4 col2 so that saves row and column number to Index object.
 Piece notationToPiece(java.lang.String notation)
          Get piece based on notation.
 void promotePawnsToQueen(int color)
          Promote all certain color pawns in enemy's end.
 void promotePiece(int x, int y, int type)
          Promote piece with certain coordinates to certain type.
 void removePiece(int x, int y)
          Removes piece from the board.
 void removePiece(java.lang.String notation)
          Removes piece from the board.
 void saveGame()
          Saves game state to a file.
 void setPieces(java.util.ArrayList<Piece> pieces)
          Set arraylist wich contains all pieces.
 void showGameState()
          Shows the current game state which is 8x8 board with pieces on it.
 void showGameStateWithNotation()
          Shows the current game state which is 8x8 board with pieces on it.
 void updateGameState()
          Updates the current game state.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Board

public Board()
Constructor.

Method Detail

showGameState

public void showGameState()
Shows the current game state which is 8x8 board with pieces on it.


showGameStateWithNotation

public void showGameStateWithNotation()
Shows the current game state which is 8x8 board with pieces on it. Shows notation on each side.


coordinatesToNotation

public java.lang.String coordinatesToNotation(int x,
                                              int y)
Forms notation from x and y.

Parameters:
x -
y -
Returns:
string

notationToIndex

public Index notationToIndex(java.lang.String notation)
Converts e.g. c5 to row4 col2 so that saves row and column number to Index object.

Parameters:
notation -
Returns:
Index

notationToPiece

public Piece notationToPiece(java.lang.String notation)
Get piece based on notation.

Parameters:
notation -
Returns:
Piece

removePiece

public void removePiece(int x,
                        int y)
Removes piece from the board.

Parameters:
x -
y -

removePiece

public void removePiece(java.lang.String notation)
Removes piece from the board.

Parameters:
notation -

addPiece

public void addPiece(Piece p)
Add new piece on the board

Parameters:
p -

emptyBoard

public void emptyBoard()
Clear the board from pieces.


saveGame

public void saveGame()
Saves game state to a file.


loadGame

public void loadGame()
Loads game state from a file.


updateGameState

public void updateGameState()
Updates the current game state.


getPieces

public java.util.ArrayList<Piece> getPieces()
Get all pieces as an arraylist.


getPiecesFromOneSide

public java.util.ArrayList<Piece> getPiecesFromOneSide(int color)
Get pieces from only one black or white as an arraylist.

Parameters:
color -

setPieces

public void setPieces(java.util.ArrayList<Piece> pieces)
Set arraylist wich contains all pieces.

Parameters:
pieces -

promotePiece

public void promotePiece(int x,
                         int y,
                         int type)
Promote piece with certain coordinates to certain type.

Parameters:
x -
y -
type -

promotePawnsToQueen

public void promotePawnsToQueen(int color)
Promote all certain color pawns in enemy's end.

Parameters:
color -

getPiece

public Piece getPiece(int x,
                      int y,
                      int color)
Returns piece with given coordinates and color.

Parameters:
x -
y -
color -
Returns:
Piece