public Word TestTheLetterInWord(LetterAttributes lett, CoordsPointer c, Word aName, Word entry) { //check the grid for empty tiles and space for the word if (lett.IterationsLeftOrAbove == 0) //check if the intersecting letter in the word to be added is at the start { if (entry.IsHorizontal == true) { for (int x = 0; x < lett.IterationsRightOrBelow + 1; x++) //add an extra move to the left for white space around the letter { //check below the letter if (Grid[c.BelowLetter, lett.ExistingLetterColumn] == '\0' && Grid[c.BelowLetter, c.LeftOfLetter] == '\0' && Grid[c.BelowLetter, c.RightOfLetter] == '\0') { aName.IsValid = true; aName.IsVertical = true; c.BelowLetter++; //goin down so plus the index by 1 continue; } else { lett.Valid = false; return(aName); } } } } else { if (entry.IsHorizontal == true) { for (int x = 0; x < lett.IterationsRightOrBelow + 1; x++) //add an extra move to the left for white space around the letter { if (Grid[c.BelowLetter, lett.ExistingLetterColumn] == '\0' && Grid[c.BelowLetter, c.LeftOfLetter] == '\0' && Grid[c.BelowLetter, c.RightOfLetter] == '\0') { } else { lett.Valid = false; return(aName); } } } } return(aName); }
public Word CheckLettersInName(Word aName, char letterInExistingWord, Word entry, Coordinate letterCords) { var letterList = aName.LettersInWord.ToList(); foreach (var letter in letterList) { LetterAttributes lett = new LetterAttributes(letterList.IndexOf(letter), letterList.Count, letter); lett.ExistingLetterRow = letterCords.Row; lett.ExistingLetterColumn = letterCords.Column; CoordsPointer coordsP = new CoordsPointer(letterCords); if (lett.Letter == letterInExistingWord) { TestTheLetterInWord(lett, coordsP, aName, entry); } else { continue; } } return(entry); }