Beispiel #1
0
        public GameResponse CreateGame()
        {
            var game = new Game
            {
                Id = KeyUtils.RandomString(6)
            };

            _currentGames.Add(game.Id, game);
            _gameContext.Games.Add(game);
            _gameContext.SaveChanges();
            return(GameResponse.FromGame(game));
        }
Beispiel #2
0
        public Player AddPlayer(string name)
        {
            _log.LogInformation($"Adding new player {name}");

            var player = _gameContext.Players.Add(
                new Player
            {
                Id      = KeyUtils.RandomString(12),
                Name    = name,
                AuthKey = KeyUtils.RandomString(18)
            });

            _gameContext.SaveChanges();

            return(player.Entity);
        }