示例#1
0
        public void CheckIfMated()
        {
            if (Square.IsThreatened &&
                Square.ThreatenedBy.Any(sq => sq.PieceOnSquare.Color == Color))
            {
                int movesCounter = regularlMoves.Count + captureMoves.Count;

                foreach (Square s in regularlMoves)
                {
                    if (s.IsThreatened)
                    {
                        movesCounter--;
                    }
                }

                foreach (Square s in captureMoves)
                {
                    if (s.IsThreatened)
                    {
                        movesCounter--;
                    }
                }

                if (movesCounter == 0)
                {
                    Board.GameOver();
                }
            }
        }
示例#2
0
        private void CapturePiece()
        {
            Piece capturingPiece = Board.SelectedPiece;

            Source = null;

            if (GetType() == typeof(King))
            {
                Board.GameOver();
            }

            capturingPiece.Move(capturingPiece.Square, Square);

            if (GetType() == typeof(King))
            {
                Board.GameOver();
            }
        }