// Adds the calling player's answer to the game stats
        public void AddAnswer(M_PlayerAnswer newAnswer, string gameKey)
        {
            M_GameState curGameState = GetGame(gameKey);

            M_AnswerStats curAnswerStats = curGameState.GetAnswerStats();

            if (curAnswerStats.FocusedPlayerAnswer.PlayerAnswer == 0)
            {
                curAnswerStats.FocusedPlayerAnswer = newAnswer;
            }
            else
            {
                curAnswerStats.OtherPlayerAnswers.Add(newAnswer);
            }

            curGameState.UpdateAnswerStats(curAnswerStats);
            UpdateGameState(curGameState);
        }
Esempio n. 2
0
        //Client sends answer
        public void SubmitAnswer(M_PlayerAnswer myAnswer, string gameKey)
        {
            try
            {
                gameController.AddAnswer(myAnswer, gameKey);
            }
            catch (Exception e)
            {
                Clients.Caller.DisplayError("Oops! Something went wrong :( Try that again!", e);
            }

            if (gameController.IsFirstAnswer(gameKey))
            {
                Clients.Others.EnableAnswerSubmission();
            }
            else if (gameController.IsLastAnswer(gameKey))
            {
                Clients.All.DisplayQuestionStats(gameController.GetHandAnswerStats(gameKey));
            }
        }