bool IsPlayPossible(OthelloColor color) { foreach (var cell in _board.Where(c => c.Disc == null)) { var acs = GetAdjacentCells(cell); var starts = acs.Where(c => c.Disc != null && c.Disc.DiscColor == color.GetOpposite()).ToList(); if (!starts.Any()) { continue; } var spokes = GetSpokes(cell, starts); if (spokes.Any()) { return(true); } } return(false); }
List <CellRatingModel> GetPlayableCells(OthelloColor color) { // new class e.g. CellRating? var cells = new List <CellRatingModel>(); foreach (var cell in _board.Where(c => c.Disc == null)) { var acs = GetAdjacentCells(cell); var starts = acs.Where(c => c.Disc != null && c.Disc.DiscColor == color.GetOpposite()).ToList(); if (!starts.Any()) { continue; } var spokes = GetSpokes(cell, starts); if (!spokes.Any()) { continue; } // get zone // get points - (length of spokes * 2) + 1 ? var points = spokes.Sum(s => s.Count * 2) + 1; var cr = new CellRatingModel() { Cell = cell, Points = points }; cells.Add(cr); } return(cells); }