public NumPieces GetNumPieces() { NumPieces numPiece = 0; switch (Type) { case PieceType.Pawn: numPiece = (Color == Color.White) ? NumPieces.WhitePawn : NumPieces.BlackPawn; break; case PieceType.Knight: numPiece = (Color == Color.White) ? NumPieces.WhiteKnight : NumPieces.BlackKnight; break; case PieceType.Bishop: numPiece = (Color == Color.White) ? NumPieces.WhiteBishop : NumPieces.BlackBishop; break; case PieceType.Rook: numPiece = (Color == Color.White) ? NumPieces.WhiteRook : NumPieces.BlackRook; break; case PieceType.Queen: numPiece = (Color == Color.White) ? NumPieces.WhiteQueen : NumPieces.BlackQueen; break; case PieceType.King: numPiece = (Color == Color.White) ? NumPieces.WhiteKing : NumPieces.BlackKing; break; } return(numPiece); }
public IPiece this[string positionString] { get { Position position = new Position(positionString); return(new Piece(Board[position.Row, position.Column])); } set { Piece piece = new Piece(value); NumPieces numPiece = piece.GetNumPieces(); SetPiece(positionString, numPiece); } }
public static void GetMoveList(Board board, int row, int column, NumPieces piece, Color color, MoveList moveList) { switch (piece) { case NumPieces.BlackKing: case NumPieces.WhiteKing: King.GetMoveList(board, row, column, color, moveList); break; case NumPieces.BlackRook: case NumPieces.WhiteRook: Rook.GetMoveList(board, row, column, color, moveList); break; } }
public static bool ExecuteMove(Board board, Move move) { int startRow = move.StartRow; int startColumn = move.StartColumn; int endRow = move.EndRow; int endColumn = move.EndColumn; NumPieces piece = board[startRow, startColumn]; board[endRow, endColumn] = piece; board[startRow, startColumn] = NumPieces.Empty; switch (piece) { case NumPieces.WhiteKing: King.MoveWhiteKing(board, endRow, endColumn); break; case NumPieces.BlackKing: King.MoveBlackKing(board, endRow, endColumn); break; case NumPieces.WhitePawn: break; case NumPieces.BlackPawn: break; case NumPieces.WhiteRook: Rook.MoveWhiteRook(board, startRow, startColumn); break; case NumPieces.BlackRook: Rook.MoveWhiteRook(board, startRow, startColumn); break; } return(true); }
public Piece(NumPieces piece) { switch (piece) { case NumPieces.WhitePawn: Type = PieceType.Pawn; Color = Color.White; break; case NumPieces.WhiteKnight: Type = PieceType.Knight; Color = Color.White; break; case NumPieces.WhiteKing: Type = PieceType.King; Color = Color.White; break; case NumPieces.WhiteQueen: Type = PieceType.Queen; Color = Color.White; break; case NumPieces.WhiteBishop: Type = PieceType.Bishop; Color = Color.White; break; case NumPieces.WhiteRook: Type = PieceType.Rook; Color = Color.White; break; case NumPieces.BlackPawn: Type = PieceType.Pawn; Color = Color.Black; break; case NumPieces.BlackKnight: Type = PieceType.Knight; Color = Color.Black; break; case NumPieces.BlackKing: Type = PieceType.King; Color = Color.Black; break; case NumPieces.BlackQueen: Type = PieceType.Queen; Color = Color.Black; break; case NumPieces.BlackBishop: Type = PieceType.Bishop; Color = Color.Black; break; case NumPieces.BlackRook: Type = PieceType.Rook; Color = Color.Black; break; } }
private void SetPiece(string positionString, NumPieces piece) { Position position = new Position(positionString); Board[position.Row, position.Column] = piece; }
public IPiece GetPiece(Position position) { NumPieces numPiece = Board[position.Row, position.Column]; return(new Piece(numPiece)); }