Ejemplo n.º 1
0
 /// <summary>
 /// check if the king can be defeat by other chess piece
 /// </summary>
 /// <param name="theKing"></param>
 /// <returns></returns>
 private bool isKingDangerFromOtherChess(King theKing)
 {
     foreach (Control curCtr in this.panel1.Controls)
     {
         if (curCtr is BaseChess)
         {
             BaseChess tempChess    = (BaseChess)curCtr;
             ChessType oppositeType = _getOppositeType(theKing.Type);
             if (tempChess.Type == oppositeType)
             {
                 if (tempChess.obeyTheLimit(theKing.GridX, theKing.GridY))
                 {
                     showDangerInfo();
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// abandon
        /// </summary>
        /// <returns></returns>
        private bool isKingDanger()
        {
            //to do
            int gridX, gridY;

            gridX = gridY = -1;
            if (_currentActionType == ChessType.Red)
            {
                gridX = jiang.GridX;
                gridY = jiang.GridY;
            }
            else if (_currentActionType == ChessType.Black)
            {
                gridX = shuai.GridX;
                gridY = shuai.GridY;
            }

            if (_selectChess != null && _selectChess.obeyTheLimit(gridX, gridY))
            {
                return(true);
            }
            return(false);
        }