public Maybe <CharBoard> MakeAutoLetterSelection(char letter) { var maybeOpenCell = CharCells.FirstOrDefault(c => !c.IsSelected && c.Value == letter).ToMaybe(); if (maybeOpenCell.HasValue) { var newCell = maybeOpenCell.Value.Select(NextSelectionIndex); var newCells = CharCells.Select(c => c == maybeOpenCell.Value ? newCell : c); return(new CharBoard(newCells, PossibleWords, NextSelectionIndex + 1).ToMaybe()); } return(Maybe.None <CharBoard>()); }
public Maybe <CharCell> GetSelectionAtWordIndex(int index) { var selectionIndex = index - 2; return(CharCells.FirstOrDefault(cs => cs.SelectionIndex.ValueOr(() => - 1) == selectionIndex).ToMaybe()); }