コード例 #1
0
        public async Task <long> CreateGame(CreateGameStartView view)
        {
            var game = new Game();

            game.Id = await _gameRepository.Create(game);

            List <Player> players = await CreatePlayerList(view.UserName, view.AmountOfBots);

            var gamePlayers = new List <GamePlayer>();

            foreach (Player player in players)
            {
                GamePlayer gamePlayer = CustomMapper.MapGamePlayer(player, game.Id);
                gamePlayers.Add(gamePlayer);
            }

            await _gamePlayerRepository.CreateMany(gamePlayers);

            await _historyMessageManager.AddMessagesForCreateGame(gamePlayers);

            long gameId = game.Id;

            return(gameId);
        }