/// <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); }
/// <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); }