Пример #1
0
 private void GetNewQuestion(object obj)
 {
     if (CheckForWinner())
     {
         return;
     }
     var options = GetPlayerOptions();
     Player user = null;
     IEnumerable<TwitterStatus> tweets = null;
     while (user == null)
     {
         user = options.OrderBy(x => _random.Next()).First();
         tweets = _service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions
         {
             ScreenName = user.Name,
             ExcludeReplies = true,
             IncludeRts = false,
             Count = 100
         });
         if (!tweets.Any())
             user = null;
     }
     var randomIndex = _random.Next(tweets.Count());
     var randomTweet = tweets.ElementAt(randomIndex);
     var question = new Question
         {
             Tweet = randomTweet.TextDecoded,
             RightAnswer = randomTweet.User.ScreenName,
             PlayerOptions = options.ToArray()
         };
     this.Game.SetQuestion(question);
     _hub.Clients.Group(Game.ID).NewQuestion(question);
     _hub.Clients.Client(Host).NewQuestion(question);
     //have 15 seconds to answer
     this._currentQuestionTimer = new Timer(QuestionTimeout, null, 20000, Timeout.Infinite);
 }
Пример #2
0
 public void SetQuestion(Question question)
 {
     this.Question = question;
     this.Guesses = new List<Guess>();
 }