Ejemplo n.º 1
0
 public void ListWords(DataGrid dtg, string query = null)
 {
     Words.Clear();
     if (_user == null)
     {
         Words = string.IsNullOrEmpty(query) ? Word.AllActive() : Word.Like(query);
     }
     else
     {
         Words = string.IsNullOrEmpty(query) ? Word.ReadByCreatorId(_user.Id) : Word.LikeByCreator(query, _user.Id);
     }
     dtg.ItemsSource = Words;
 }
Ejemplo n.º 2
0
        public bool IsRandomWordValid()
        {
            Random      rnd         = new Random();
            List <Word> words       = Word.AllActive();
            bool        isWordValid = false;
            int         findCounter = 0;

            while (!isWordValid && findCounter < 100)
            {
                GameWord = words[rnd.Next(0, words.Count)].Name.ToLower();
                findCounter++;
                switch (_difficulty)
                {
                case Difficulty.Easy:
                    if (GameWord.Length <= 5)
                    {
                        isWordValid = true;
                    }
                    continue;

                case Difficulty.Medium:
                    if (GameWord.Length > 5 && GameWord.Length <= 9)
                    {
                        isWordValid = true;
                    }
                    continue;

                case Difficulty.Hard:
                    if (GameWord.Length > 9)
                    {
                        isWordValid = true;
                    }
                    continue;
                }
            }

            return(isWordValid);
        }