Exemplo n.º 1
0
        private bool CheckForOpponent(PieceColor pColor, Player aPlayer)
        {
            ArrayList TargetList     = new ArrayList();
            ArrayList tempTargetList = new ArrayList();

            ArrayList tempList;
            Piece     OpponentKingPiece;

            if (pColor == PieceColor.WHITE)
            {
                tempList          = WhitePieceList;
                OpponentKingPiece = BlackKingPiece;
            }
            else
            {
                tempList          = BlackPieceList;
                OpponentKingPiece = WhiteKingPiece;
            }

            for (int i = 0; i < PieceCount; i++)
            {
                Piece piece = (Piece)tempList[i];

                if (piece != null)
                {
                    Block block = piece.GetContainerBlock();
                    if (block != null)
                    {
                        PositionCalculator posCalculator = PosCalculatorFactory.GetPositionCalculator(piece.GetPieceType(), aPlayer);
                        tempTargetList = posCalculator.CalculatePositions(block, true);

                        TargetList.AddRange(tempTargetList);
                    }
                }
                tempTargetList.Clear();
            }

            return(IsKingInDanger(OpponentKingPiece, TargetList));
        }