public void addWordToGrid(WordData word) { char[,] grid = getGridAsArray(); //Add new word, character-by-character. for (int i = 0; i < word.Length; i++) { if (word.Direction == Constants.HORIZONTAL_WORD) { grid[word.Y, word.X + i] = word.Text[i]; } else if (word.Direction == Constants.VERTICAL_WORD) { grid[word.Y + i, word.X] = word.Text[i]; } } //Add the word to the CrozzleMap (tracking) grid. crozzleMap.addWord(word, word.X, word.Y, word.Direction); //Clear the old grid. crozzleGrid.Clear(); //Add the temp grid with the new word, as the new grid. crozzleGrid.Add(grid); //Increment the word count. wordsInGridCount++; wordsInGrid.addWord(word); //Calculate the new grid score. calculateGridScore(); }
//Assign each word a score here based on the individual rules that apply. //Add WordData word to the word list. private void buildWordData(List <string> validWords) { if (crozzleGrid.Difficulty == Constants.EASY_DIFFICULTY) { foreach (string word in validWords) { //Create WordData, text and the score. completeWordList.addWord(new WordData(word, word.Length)); } } //Other difficulty levels here..... }
//Create a deep copy of the list. public WordDataList getCopy() { WordDataList deepCopiedList = new WordDataList(); foreach (WordData word in words) { string text = word.Text; int length = word.Length; WordData copiedWord = new WordData(text, length); deepCopiedList.addWord(copiedWord); } return(deepCopiedList); }