コード例 #1
0
ファイル: WordManager.cs プロジェクト: IcyWillow/iet-120
 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;
 }
コード例 #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);
        }