Example #1
0
        Cell FindKingCell(BoardCell[,] boardCells)
        {
            for (int row = 0; row < 8; row++)
            {
                for (int column = 0; column < 8; column++)
                {
                    BaseChessman chessman = boardCells[row, column].Chessman;

                    if (chessman is King && chessman.Color == Color)
                    {
                        return(new Cell(row, column));
                    }
                }
            }

            throw new ArgumentException("King has not found.");
        }
Example #2
0
        static List <Cell> FindEnemyAcceptableCells(BoardCell[,] boardCells, Color color)
        {
            var enemyAcceptableCells = new List <Cell>();

            for (var row = 0; row < 8; row++)
            {
                for (var column = 0; column < 8; column++)
                {
                    BaseChessman chessman = boardCells[row, column].Chessman;

                    if (chessman == null || chessman.Color == color || chessman is King)
                    {
                        continue;
                    }

                    var cell = new Cell(row, column);
                    enemyAcceptableCells.AddRange(chessman.GetAcceptableCells(boardCells, cell, false));
                }
            }

            return(enemyAcceptableCells);
        }