示例#1
0
 public Word(string name)
 {
     Name      = name;
     NameCords = new CordsLetterTable();
     ListOfIntersectingWordsPerLetter = null;
     LettersInWord = null;
     IsHorizontal  = false;
     IsVertical    = false;
     IsAdded       = false;
     IsValid       = false;
 }
示例#2
0
 public LetterCheck(int index, int count, char lett)
 {
     IterationsLeftOrAbove  = index;
     LengthOfWord           = count;
     IterationsRightOrBelow = count - index;
     Letter               = lett;
     Valid                = false;
     ExistingLetterRow    = 0;
     ExistingLetterColumn = 0;
     IsHorizontal         = false;
     IsVertical           = false;
     Name  = "";
     Added = false;
     AllCoordinatesOfLettersInName = new CordsLetterTable();
 }
示例#3
0
        public char[,] AddRootWord()
        {
            var dictList = WordList.Table;
            Dictionary <string, int> bestWordDict = new Dictionary <string, int>();
            Dictionary <char, int>   points       = new Dictionary <char, int>();
            //int scoreWords = 0;
            CordsLetterTable cl       = new CordsLetterTable();
            char             keyindic = 'A';
            int    x           = 0;
            int    y           = 0;
            int    startX      = 0;
            int    startY      = 0;
            string highestWord = "";

            char[] wordCharArray = new char[0];

            //put the points table into a dictionary
            foreach (var val in Config.IntersectingPointsPerLetter)
            {
                points.Add(keyindic, val);
                keyindic++;
            }

            //get random name from wordlist
            foreach (var n in dictList)
            {
                NamesList.Add(n.Key);
            }

            bool OK = false;

            while (OK == false)
            {
                int r = rnd.Next(NamesList.Count);
                highestWord = NamesList[r];
                int lengthOfWord = highestWord.Length;

                //set the cords of the grid so the word is placed in the centre

                int row = Convert.ToInt16(RowsAndColumns.Rows);
                int col = Convert.ToInt16(RowsAndColumns.Columns);
                x      = rnd.Next(2, row);
                y      = rnd.Next(2, col);
                startX = x;
                startY = y;

                //create a char arrayu of the name
                wordCharArray = highestWord.ToCharArray();

                for (int a = 0; a < wordCharArray.Length; a++)
                //foreach(var l in wordCharArray)
                {
                    if (Grid[x, y] == '*')
                    {
                        OK = false;
                        break;
                    }
                    else
                    {
                        OK = true;
                        y  = y + 1;
                        continue;
                    }
                }
            }

            //add the word to the grid
            foreach (var letter in wordCharArray)
            {
                Grid[startX, startY] = letter;
                Coordinate c = new Coordinate(startX, startY);
                cl.Add(c, letter);
                startY = startY + 1;
            }

            //add the name, letters and coords of each letter to the table
            //add properties to the object
            LetterCordsForWordsInGrid.Add(highestWord, cl);

            Score = LetterCordsForWordsInGrid.Keys.Count * Config.PointsPerWord;

            var objKey = WordList.Table[highestWord];
            Dictionary <char, List <string> > objDict = new Dictionary <char, List <string> >();

            foreach (var key in objKey)
            {
                objDict.Add(key.Key, key.Value);
            }

            var cor = LetterCordsForWordsInGrid[highestWord];
            Dictionary <Coordinate, char> objCor = new Dictionary <Coordinate, char>();

            foreach (var res in cor)
            {
                objCor.Add(res.Key, res.Value);
            }

            LastWordEntered wordObj = new LastWordEntered(highestWord, objDict, objCor);

            WordsInserted.Add(wordObj);

            WordList.Table.Remove(highestWord);

            RootWord = highestWord;

            WordsInGrid.Add(highestWord);

            Counter++;


            return(Grid);
        }