public async Task FetchRandomPromptRound(string room) { room = room.ToUpper(); DrawGameRound dgr = _drawService.GetDrawGame(room).FetchRandomGameRound(); var gameRoundDTO = new { url = dgr.ImageUrl }; await Clients.Group(room).SendAsync("FetchedRandomPromptRound", gameRoundDTO); }
public async Task GetNextRound(string room, List <DrawPlayer> drawPlayers) { room = room.ToUpper(); _drawService.GetDrawGame(room).UpdatePlayersScores(drawPlayers); DrawGameRound dgr = _drawService.GetDrawGame(room).FetchRandomGameRound(); var gameRoundDTO = new { url = dgr.ImageUrl }; await Clients.Group(room).SendAsync("GotNextRound", gameRoundDTO); }
public async Task CalculateAndFetchRoundResults(string room) { room = room.ToUpper(); DrawGameRound dgr = _drawService.GetDrawGame(room).FetchGameRoundResults(); PlayerAnswerHashMap hashMap = new PlayerAnswerHashMap(); foreach (Tuple <DrawPlayer, string> tpl in dgr.ListPlayerAnswerTuples) { if (hashMap.Associations.ContainsKey(tpl.Item2)) { hashMap.Associations[tpl.Item2].Add(tpl.Item1); } else { hashMap.Associations.Add(tpl.Item2, new List <DrawPlayer> { tpl.Item1 }); } } if (!hashMap.Associations.ContainsKey(dgr.Answer)) { hashMap.Associations.Add(dgr.Answer, new List <DrawPlayer> { }); } var roundResultsDTO = new { url = dgr.ImageUrl, players = dgr.Players, playerAnswerHashMap = hashMap, // this tracks who voted for which answer guessAndItsSubmitter = dgr.ListPlayerAnswerSubmissions, // this associates guesses with their submitters to assign points answer = dgr.Answer, lastRound = dgr.LastRound }; await Clients.Group(room).SendAsync("ReturningCalculatedAndFetchedRoundResults", roundResultsDTO); }