public async Task AddPlayerToListWaitingToSeeResults(string room, DrawPlayer drawPlayer, string chosenAnswer) { room = room.ToUpper(); _drawService.GetDrawGame(room).AddPlayerToWaiting(drawPlayer, chosenAnswer); List <DrawPlayer> playersWaiting = _drawService.GetDrawGame(room).GetPlayersWaiting(); await Clients.Group(room).SendAsync("FetchPlayersWaitingToSeeResults", playersWaiting); }
public async Task NewLobbyArrival(string room, DrawPlayer drawPlayer) { room = room.ToUpper(); drawPlayer.StillDrawing = false; _drawService.GetDrawGame(room).FirstRoundLobby.Add(drawPlayer); List <DrawPlayer> players = _drawService.GetDrawGame(room).FirstRoundLobby; await Clients.Group(room).SendAsync("FetchedNewLobbyArrivals", players); }
private DrawGame InstantiateNewDrawGameRoom(string roomCode, DrawPlayer drawPlayer) { DrawGame newDrawGame = new DrawGame(); newDrawGame.RoomName = roomCode; Tuple <string, string> colorPair = newDrawGame.GetColorPair(); drawPlayer.Color1 = colorPair.Item1; drawPlayer.Color2 = colorPair.Item2; newDrawGame.DrawPlayers.Add(drawPlayer); return(newDrawGame); }
public async Task AddUserGuessForPrompt(string room, DrawPlayer drawPlayer, string playersGuess) { room = room.ToUpper(); List <DrawPlayer> playersWhoAnswered = _drawService.GetDrawGame(room).AddAnswerAndReturnPlayers(drawPlayer, playersGuess); var guessResultsDTO = new { playersWhoAnswered = playersWhoAnswered, numberPlayersTotal = _drawService.GetDrawGame(room).GetTotalNumberPlayers() }; Console.WriteLine("guessResultsDTO"); Console.WriteLine(guessResultsDTO); await Clients.Group(room).SendAsync("FetchedNewPlayerGuesses", guessResultsDTO); }
public void JoinOrCreateNewGameRoom(string roomCode, string connectionString) { roomCode = roomCode.ToUpper(); DrawGame drawGameRoom = _drawGameRoomService.GetDrawGameRooms() .FirstOrDefault(rm => rm.RoomName == roomCode); DrawPlayer drawPlayer = new DrawPlayer(); drawPlayer.ConnectionString = connectionString; drawPlayer.Score = 0; if (drawGameRoom == null) { drawPlayer.IsAdmin = true; DrawGame newDrawGame = InstantiateNewDrawGameRoom(roomCode, drawPlayer); drawPlayer.ImageUrl = newDrawGame.PopRandomPlaceholderImage(); _drawGameRoomService.AddNewDrawGameRoom(newDrawGame); Console.WriteLine($"New drawgame room added with name {roomCode}"); } else { Tuple <string, string> colorPair = _drawGameRoomService.GetDrawGameRooms() .FirstOrDefault(rm => rm.RoomName == roomCode).GetColorPair(); drawPlayer.Color1 = colorPair.Item1; drawPlayer.Color2 = colorPair.Item2; drawPlayer.ImageUrl = drawGameRoom.PopRandomPlaceholderImage(); _drawGameRoomService.GetDrawGameRooms() .FirstOrDefault(rm => rm.RoomName == roomCode).DrawPlayers.Add(drawPlayer); } }