/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="eValidPawnPromotion">  Possible pawn promotions in the current context</param>
 public QueryPawnPromotionTypeEventArgs(ChessBoard.ValidPawnPromotionE eValidPawnPromotion)
 {
     ValidPawnPromotion = eValidPawnPromotion; PawnPromotionType = ChessBoard.MoveTypeE.Normal;
 }
Example #2
0
        /// <summary>
        /// Find a move using the specification
        /// </summary>
        /// <param name="ePlayerColor">     Color moving</param>
        /// <param name="ePiece">           Piece moving</param>
        /// <param name="iStartCol">        Starting column of the move or -1 if not specified</param>
        /// <param name="iStartRow">        Starting row of the move or -1 if not specified</param>
        /// <param name="iEndPos">          Ending position of the move</param>
        /// <param name="eMoveType">        Type of move. Use for discriminating between different pawn promotion.</param>
        /// <param name="strMove">          Move</param>
        /// <param name="iTruncated">       Truncated count</param>
        /// <param name="movePos">          Move position</param>
        /// <returns>
        /// Moving position or -1 if error
        /// </returns>
        private int FindPieceMove(ChessBoard.PlayerColorE ePlayerColor, ChessBoard.PieceE ePiece, int iStartCol, int iStartRow, int iEndPos, ChessBoard.MoveTypeE eMoveType, string strMove, ref int iTruncated, ref ChessBoard.MovePosS movePos)
        {
            int iRetVal = -1;
            List <ChessBoard.MovePosS> arrMovePos;
            int iCol;
            int iRow;

            ePiece     = ePiece | ((ePlayerColor == ChessBoard.PlayerColorE.Black) ? ChessBoard.PieceE.Black : ChessBoard.PieceE.White);
            arrMovePos = m_chessBoard.EnumMoveList(ePlayerColor);
            foreach (ChessBoard.MovePosS move in arrMovePos)
            {
                if ((int)move.EndPos == iEndPos && m_chessBoard[(int)move.StartPos] == ePiece)
                {
                    if (eMoveType == ChessBoard.MoveTypeE.Normal || (move.Type & ChessBoard.MoveTypeE.MoveTypeMask) == eMoveType)
                    {
                        iCol = (int)move.StartPos & 7;
                        iRow = (int)move.StartPos >> 3;
                        if ((iStartCol == -1 || iStartCol == iCol) &&
                            (iStartRow == -1 || iStartRow == iRow))
                        {
                            if (iRetVal != -1)
                            {
                                throw new PgnParserException("More then one piece found for this move - " + strMove, GetCodeInError());
                            }
                            movePos = move;
                            iRetVal = (int)move.StartPos + ((int)move.EndPos << 8);
                            m_chessBoard.DoMove(move);
                        }
                    }
                }
            }
            if (iRetVal == -1)
            {
                if (m_bDiagnose)
                {
                    throw new PgnParserException("Unable to find compatible move - " + strMove, GetCodeInError());
                }
                iTruncated++;
            }
            return(iRetVal);
        }