private bool IsValidWord(Word word) { int letterCount = word.LetterPoints.Count; for (int index = 0; index < letterCount - 1; index++) { LetterPoint firstLetterPoint = word.LetterPoints[index]; LetterPoint secondLetterPoint = word.LetterPoints[index + 1]; if (!AreNeighbors(firstLetterPoint.Point, secondLetterPoint.Point)) { return(false); } } return(true); }
private void FixColumn(Board board, List <LetterPoint> letterPoints) { LetterPoint[] lettersWithValues = letterPoints.Where(lp => lp.Letter.HasValue).OrderByDescending(lp => lp.Point.X).ToArray(); int numLettersWithValues = lettersWithValues.Length; int y = letterPoints.First().Point.Y; // Getting the correct y - same for all letters int maxX = board.Size - 1; int currentX = maxX; // Shift them all down for (int index = 0; index < numLettersWithValues; index++) { LetterPoint lp = lettersWithValues[index]; board[currentX, y] = lp.Letter; currentX--; } // Remove the rest for (int x = currentX; x >= 0; x--) { board[x, y] = null; } }
private IEnumerable <LetterPoint> GetLettersAtOrAbove(Board board, LetterPoint letterPoint) { IEnumerable <LetterPoint> letterPoints = board.Where(lp => (lp.Point.Y == letterPoint.Point.Y && lp.Point.X < letterPoint.Point.X) || (lp.Point.X == letterPoint.Point.X && lp.Point.Y == letterPoint.Point.Y)); return(letterPoints); }
private void RemoveLetter(Board newBoard, LetterPoint letterPoint) { newBoard[letterPoint.Point.X, letterPoint.Point.Y] = null; }