private async Task StartGame(TronGame game) { var players = game.Players; var positions = _playerSpawnService.GetPosition(players.Count, game.Board); var positionDtos = positions.ToDtos(); var playerDtos = players.Zip(positionDtos, (player, position) => new PlayerDto { Name = player.Name, Position = position }); var dto = new GameStartedDto { Players = playerDtos }; await Clients.Group(game.GroupName).ReceiveGameStarted(dto); }
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); }