public GameService(TicTacToeContext dbContext, IGameBot gameBot)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException("dbContext");
            }
            if (gameBot == null)
            {
                throw new ArgumentNullException("gameBot");
            }
            _dbContext = dbContext;
            _gameBot   = gameBot;

            _mapConfig = new MapperConfiguration(mc => {
                mc.CreateMap <Game, GameDTO>().ReverseMap();
                mc.CreateMap <Player, PlayerDTO>().ReverseMap();
                mc.CreateMap <Movement, MovementDTO>().ReverseMap();
                mc.CreateMap <GamePlayer, GamePlayerDTO>().ForMember(gp => gp.Piece, opt => opt.MapFrom(gp => gp.Piece == "X" ? Pieces.X : Pieces.O));
                mc.CreateMap <GamePlayerDTO, GamePlayer>().ForMember(gp => gp.Piece, opt => opt.MapFrom(gp => gp.Piece.ToString()));
            });
            _mapper = _mapConfig.CreateMapper();
        }
Beispiel #2
0
 public BotGameController(IGameBot bot, GameParameters parameters)
 {
     this.bot        = bot;
     controller      = new GameController(parameters);
     this.parameters = parameters;
 }