private void AddWordToValidWordsIfValid(string partialWord) { if (!DawgWithAlphabet.IsWordValid(partialWord)) { return; } HorizontalBoardWord wordTiles = BoardWordRetriever.GetHorizontalWordTilesAtCoordinates(StartingBoardTile.X, StartingBoardTile.Y); ValidWords.Add(wordTiles); //Debug.WriteLine(wordTiles.GetWord()); }
public Dictionary <BoardTile, HashSet <char> > GetCrossChecksForBoardTiles(BoardTileCollection boardTileCollection) { BoardWordRetriever boardWordRetriever = new(Board); char[] charsFromAlphabet = DawgWithAlphabet.GetAlphabet(); HashSet <char> charsFromAlphabetHashSet = charsFromAlphabet.ToHashSet(); Dictionary <BoardTile, HashSet <char> > tilesAndTheirCrossChecks = new(); foreach (BoardTile boardTile in boardTileCollection) { if (boardTile.CharTile != null) { continue; } tilesAndTheirCrossChecks.Add(boardTile, new HashSet <char>()); BoardTileVerticalWordConnectionChecker verticallityChecker = new(Board); if (!verticallityChecker.BoardTileIsVerticallyPartOfAWord(boardTile.X, boardTile.Y)) { tilesAndTheirCrossChecks[boardTile] = charsFromAlphabetHashSet; continue; } foreach (char ch in charsFromAlphabet) { Board.PlaceCharTile(boardTile.X, boardTile.Y, ch); VerticalBoardWord verticalWord = boardWordRetriever.GetVerticalWordTilesAtCoordinates(boardTile.X, boardTile.Y); if (DawgWithAlphabet.IsWordValid(verticalWord.GetWord())) { tilesAndTheirCrossChecks[boardTile].Add(ch); } Board.RemoveCharTile(boardTile.X, boardTile.Y); } } return(tilesAndTheirCrossChecks); }