Exemplo n.º 1
0
        public int columnIndex(Piece piece)
        {
            PieceType type  = piece.getPieceType();
            Sides     color = piece.getSide();
            int       index = 0;

            if (color == Sides.BLACK)
            {
                index += 6;
            }
            if (type == PieceType.KING)
            {
                return(0 + index);
            }
            else if (type == PieceType.QUEEN)
            {
                return(1 + index);
            }
            else if (type == PieceType.ROOK)
            {
                return(2 + index);
            }
            else if (type == PieceType.BISHOP)
            {
                return(3 + index);
            }
            else if (type == PieceType.KNIGHT)
            {
                return(4 + index);
            }
            return(5 + index);
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!(obj is Piece))
            {
                return(false);
            }

            Piece otherPiece = obj as Piece;

            return(this.piecePosition == otherPiece.getPiecePosition() &&
                   this.pieceSide == otherPiece.getSide() &&
                   this.type == otherPiece.getPieceType() &&
                   this.isFirstMove() == otherPiece.isFirstMove());
        }
Exemplo n.º 3
0
        private int index(Piece piece, int numPieces)
        {
            PieceType type = piece.getPieceType();

            if (type == PieceType.KING)
            {
                if (numPieces < 8)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            else if (type == PieceType.QUEEN)
            {
                return(2);
            }
            else if (type == PieceType.ROOK)
            {
                return(3);
            }
            else if (type == PieceType.KNIGHT)
            {
                return(4);
            }
            else if (type == PieceType.BISHOP)
            {
                return(5);
            }
            else
            {
                return(6);
            }
        }