// Answer Question public async Task AnswerQuestion(AnswerModel answer) { bool isCorrect = false;; // Check if response is correct if (_IMathProblem.IsCorrect() && answer.isCorrect || !_IMathProblem.IsCorrect() && !answer.isCorrect) { // If the challenge was not answered yet, add +1 to player score if (!_IMathProblem.GetMathProblem().isAnswered) { _IMathProblem.setAnswered(); _IScore.AddPoint(answer.playerName); _IMathProblem.setAnswered(); } isCorrect = true; } // If response is incorrect, remove -1 point of score of the player else { _IScore.RemovePoint(answer.playerName); isCorrect = false; } // Remove the player from the match _IMathProblem.removePlayerInMatch(answer.playerName); // If there is no more players in match, wait 5 seconds then create a new challenge and send it to playerss if (_IMathProblem.GetPlayersInMatch().Count == 0) { await ReceiveScore(); await Clients.Caller.SendAsync("RiseAnswer", isCorrect == true? "Correct" : "Wrong answer"); await Clients.All.SendAsync("ChallengeFinished"); } else { await ReceiveScore(); await Clients.Caller.SendAsync("RiseAnswer", isCorrect == true? "Correct" : "Wrong answer"); } }