示例#1
0
        public async Task Run()
        {
            while (GameState != GameState.Running)
            {
                await Task.Delay(1000);
            }

            SetUpGame();

            while (Players.Any() && QuestionPile.Any() && AnswerPile.Any())
            {
                SetUpRound();
                await DealCards();
                await ShowQuestion();

                // Wait for users to pick their answers
                await Sleep(60, CheckIfMaxAnswersHaveBeenSubmitted);
                await ShowAnswers();

                // Wait for users to cast their votes
                await Sleep(60, CheckIfMaxVotesHaveBeenCast);
                await CalculateAndDisplayWinningCard();
                await Sleep(8, () => false);
                await UpdateLeaderboard();
            }

            await ChangeGameState(GameState.Ended);
        }
示例#2
0
        private void SetUpGame()
        {
            CardGenerator generator = new CardGenerator();

            foreach (var card in generator.GenerateQuestions())
            {
                QuestionPile.Enqueue(card);
            }

            foreach (var card in generator.GenerateAnswers())
            {
                AnswerPile.Enqueue(card);
            }
        }
示例#3
0
        private async Task DealCards()
        {
            foreach (var player in Players)
            {
                while (player.Hand.Count < maxCardsInHand && AnswerPile.Any())
                {
                    var card = AnswerPile.Dequeue();

                    player.Hand.Add(card);
                }

                await gameHub.Clients.Client(player.ConnectionId).ShowHand(player.Hand);
            }
        }