Пример #1
0
 /// <summary>
 /// Determines wether a word exists in the dictionary, as a Word object.
 /// </summary>
 /// <param name="word">The word.</param>
 /// <returns><c>true</c> if the word is in the dictionary; otherwise, <c>false</c>.</returns>
 /// <remarks></remarks>
 public bool Exists(Word word)
 {
     return Exists(word.ToString());
 }
Пример #2
0
        /// <summary>
        /// Finds the new words placed on the board.
        /// </summary>
        /// <returns>A list of the new words found.</returns>
        /// <remarks></remarks>
        public List<Word> FindNewWords()
        {
            List<Word> newWords = new List<Word>();

            for (int r = 0; r < Board.Rows; r++)
            {
                Word cw = new Word(CurrentPlayer);
                bool seenNewLetter = false;

                for (int c = 0; c < Board.Cols; c++)
                {
                    if (!Board.Cells[c, r].IsEmpty && !Board.Cells[c, r].contents.IsPlaced) 
                        seenNewLetter = true;

                    if (!Board.Cells[c, r].IsEmpty) 
                        cw.Cells.Add(Board.Cells[c, r]);

                    if ((Board.Cells[c, r].IsEmpty || c == Board.Cols - 1) && cw.Cells.Count > 0)
                    {
                        if (seenNewLetter && cw.Cells.Count > 1)
                            newWords.Add(cw);

                        cw = new Word(CurrentPlayer);
                        seenNewLetter = false;
                        continue;
                    }
                }
            }

            for (int c = 0; c < Board.Cols; c++)
            {
                Word cw = new Word(CurrentPlayer);
                bool seenNewLetter = false;

                for (int r = 0; r < Board.Rows; r++)
                {
                    if (!Board.Cells[c, r].IsEmpty && !Board.Cells[c, r].contents.IsPlaced) 
                        seenNewLetter = true;

                    if (!Board.Cells[c, r].IsEmpty) 
                        cw.Cells.Add(Board.Cells[c, r]);

                    if ((Board.Cells[c, r].IsEmpty || r == Board.Rows - 1) && cw.Cells.Count > 0)
                    {
                        if (seenNewLetter && cw.Cells.Count > 1)
                            newWords.Add(cw);
                        cw = new Word(CurrentPlayer);
                        seenNewLetter = false;
                        continue;
                    }
                }
            }

            return newWords;

        }