private async Task <TronGame> CreateNewGame(TronLobby tronLobby) { var game = _gameService.CreateNewGame(tronLobby); foreach (var player in game.Players) { await Groups.AddToGroupAsync(player.Key, game.GroupName); } return(game); }
public TronGame CreateNewGame(TronLobby tronLobby) { var groupName = Guid.NewGuid().ToString(); var game = new TronGame { GroupName = groupName, State = GameState.Playing, TimeCreated = DateTime.UtcNow, Players = tronLobby.Players, Board = tronLobby.Board }; lock (MapLock) { foreach (var player in game.Players) { Map.Add(player.Key, game); } } return(game); }