コード例 #1
0
 public CharBoard CreateLoot(Random random, Encounter value)
 {
     return(new CharBoard(
                CharCells.Select(c => c.WithLoot(random, value)),
                PossibleWords,
                NextSelectionIndex
                ));
 }
コード例 #2
0
        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>());
        }
コード例 #3
0
        internal Maybe <CharBoard> UndoLastSelection()
        {
            var mLastSelected = CharCells
                                .OrderByDescending(c => c.SelectionIndex.HasValue ? c.SelectionIndex.Value : -1)
                                .FirstOrDefault(v => v.SelectionIndex.HasValue)
                                .ToMaybe();

            if (!mLastSelected.HasValue)
            {
                return(Maybe.None <CharBoard>());
            }

            var lastSelected = mLastSelected.Value;

            var newCells = CharCells.Select(c => c == lastSelected ? lastSelected.Deselect() : c);

            return(new CharBoard(newCells, PossibleWords, NextSelectionIndex - 1).ToMaybe());
        }