public IEnumerable <FigureOnCell> YieldFiguresOnCell()
 {
     foreach (Cell cell in Cell.YieldBoardCells())
     {
         if (GetFigureAtCell(cell).GetColor() == CurrentMoveColor)
         {
             yield return(new FigureOnCell(GetFigureAtCell(cell), cell));
         }
     }
 }
        private Cell FindEnemyKing()
        {
            Figure enemyKing = CurrentMoveColor == Color.White ?
                               Figure.blackKing : Figure.whiteKing;

            foreach (Cell cell in Cell.YieldBoardCells())
            {
                if (GetFigureAtCell(cell) == enemyKing)
                {
                    return(cell);
                }
            }
            return(Cell.none);
        }
Ejemplo n.º 3
0
 public IEnumerable <string> YieldValidMoves()
 {
     foreach (FigureOnCell fc in boardController.YieldFiguresOnCell())
     {
         foreach (Cell cell in Cell.YieldBoardCells())
         {
             foreach (Figure transformation in fc.figure.YieldTransformations(cell))
             {
                 MoveController mc = new MoveController(fc, cell, transformation);
                 if (moves.CanMove(mc))
                 {
                     if (!boardController.isCheckAfter(mc))
                     {
                         yield return(mc.ToString());
                     }
                 }
             }
         }
     }
 }