public static IEnumerable<IMove> GetAllMovesForPlayer(GameBoard board, PlayerColor player) { IEnumerable<GameField> fields = board.GetFieldsByPlayer(player); List<IMove> forcedMoves = new List<IMove>(); List<IMove> idleMoves = new List<IMove>(); bool forcedOnly; foreach (GameField f in fields) { var moves = GetAllMovesFromField(board, f.Position, out forcedOnly); if (forcedOnly) forcedMoves.AddRange(moves); else idleMoves.AddRange(moves); } if (forcedMoves.Count > 0) { int longest = 0; forcedMoves.ForEach(mv => { if (mv.Length > longest) longest = mv.Length; }); return forcedMoves.Where(mv => mv.Length == longest).ForEach<IMove, GameBoard>(SetMoveCaptures, board); } return idleMoves; }