Exemplo n.º 1
0
 public void LetterWheelInit(WordScapeWindow wordScapeWindow, WordContainer wordCont, GenGrid gridgen)
 {
     this.wordScapeWindow = wordScapeWindow;
     this._wordCont       = wordCont;
     this.gridgen         = gridgen;
     this.CreateCircle();
     wordScapeWindow.NumWordsFound = 0;
     _lstFoundWordsSoFar.Clear();
 }
Exemplo n.º 2
0
        private async void BtnPlayAgain_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.LenTargetWord >= 12)
                {
                    var ow = new Window()
                    {
                        Left   = this.Left,
                        Top    = this.Top,
                        Height = 300,
                        Width  = 800,
                    };
                    ow.Content = "Really ??";
                    ow.ShowDialog();
                    return;
                }
                this.BtnPlayAgain.IsEnabled    = false;
                this.wrdsSoFar.RenderTransform = Transform.Identity;

                await Task.Run(() =>
                {
                    this._wordGen = new WordGenerator(_Random)
                    {
                        _MinSubWordLen = MinSubWordLength
                    };
                    _WordCont = this._wordGen.GenerateWord(LenTargetWord);
                    _gridgen  = new GenGrid(maxX: 15, maxY: 15, _WordCont, this._wordGen._rand);
                    _gridgen.Generate();
                });

                FillGrid(_gridgen);
                NumWordsTotal = 0; // force prop changed
                NumWordsFound = 0;
                StrWordSoFar  = string.Empty;
                LstWrdsSoFar.Clear();
                CountDownTime = 0;
                //this.ltrWheel = new LetterWheel();
                //Grid.SetRow(this.ltrWheel, 3);
                this.ltrWheel.LetterWheelInit(this, _WordCont, _gridgen);
                TimerIsEnabled = true;
            }
            catch (Exception ex)
            {
                this.Content = ex.ToString();
            }
            this.BtnPlayAgain.IsEnabled = true;
        }
Exemplo n.º 3
0
 public GenGrid(int maxX, int maxY, WordContainer wordCont, Random rand)
 {
     this._random        = rand;
     this._wordContainer = wordCont;
     this._MaxY          = maxY;
     this._MaxX          = maxX;
     _tmpminX            = maxX;
     _tmpminY            = maxY;
     _tmpmaxX            = 0;
     _tmpmaxY            = 0;
     _chars = new char[_MaxX, _MaxY];
     for (int y = 0; y < _MaxY; y++)
     {
         for (int x = 0; x < _MaxX; x++)
         {
             _chars[x, y] = Blank;
         }
     }
 }
Exemplo n.º 4
0
        private WordContainer GenSubWords(string word)
        {
            var wc = new WordContainer()
            {
                InitialWord = word
            };

            DictionaryLib.DictionaryLib.PermuteString(word, LeftToRight: true, (str) =>
            {
                //if (!wc.subwords.Contains(str))
                //{
                //    wc.subwords.Add(str);
                //}
                //return true;
                for (int i = _MinSubWordLen; i < str.Length + 1; i++)
                {
                    var testWord = str.Substring(0, i);
                    var partial  = _dictionaryLibSmall.SeekWord(testWord, out var compResult);
                    wc.cntLookups++;
                    if (!string.IsNullOrEmpty(partial) && compResult == 0)
                    {
                        if (!wc.subwords.Contains(testWord))
                        {
                            wc.subwords.Add(testWord);
                        }
                    }
                    else
                    {
                        if (!partial.StartsWith(testWord))
                        {
                            break;
                        }
                    }
                }
                return(wc.subwords.Count != _numMaxSubWords); // continue
            });
            wc.subwords    = wc.subwords.OrderByDescending(w => w.Length).Select(p => p.ToUpper()).ToList();
            wc.InitialWord = wc.InitialWord.ToUpper();
            return(wc);
        }