Ejemplo n.º 1
0
 public GamesController(IBullsAndCowsData data, IUserIdentityProvider userIdentityProvider,
                        IRandomChanceProvider randomChanceProvider, IGameLogicProvider gameLogicProvider)
     : base(data, userIdentityProvider)
 {
     this.randomChanceProvider = randomChanceProvider;
     this.gameLogicProvider    = gameLogicProvider;
 }
 public GamesController(
     IBullsAndCowsData data,
     IGameDataValidator gameValidator,
     IUserIdProvider userIdProvider)
     : base(data)
 {
     this.gameValidator = gameValidator;
     this.userIdProvider = userIdProvider;
 }
 public GamesController(
     IBullsAndCowsData data,
     IGameDataValidator gameValidator,
     IUserIdProvider userIdProvider)
     : base(data)
 {
     this.gameValidator  = gameValidator;
     this.userIdProvider = userIdProvider;
 }
        public InMemoryHttpServer(string baseUrl, IBullsAndCowsData unitOfWork)
        {
            this.baseUrl = baseUrl;
            var config = new HttpConfiguration();
            this.AddHttpRoutes(config.Routes);
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            var resolver = new BullsAndCowsDependencyResolver();
            resolver.UnitOfWork = unitOfWork;
            config.DependencyResolver = resolver;

            var server = new HttpServer(config);
            this.client = new HttpClient(server);
        }
        public IGuessResult GetResult(IGuess guess, IBullsAndCowsData data)
        {
            var guessingPlayer = data.Players.All()
                                 .FirstOrDefault(x => x.Id == guess.GuessingUserId);

            if (guessingPlayer == null)
            {
                throw new ArgumentException("Player cant be found. Make sure the given user id is correct.");
            }

            var currentGame = data.Games.All()
                              .FirstOrDefault(x => (x.FirstPlayerId == guessingPlayer.Id || x.SecondPlayerId == guessingPlayer.Id) &&
                                              x.State == GameState.FirstPlayerTurn || x.State == GameState.SecondPlayerTurn);

            if (currentGame == null)
            {
                throw new Exception("The current player game is invalid");
            }

            int?secretNumber;

            if (currentGame.FirstPlayerId == guess.GuessingUserId)
            {
                secretNumber = currentGame.SecondPlayerSecretNumber;
            }
            else
            {
                secretNumber = currentGame.FirstPlayerSecretNumber;
            }

            var result = this.CompareToSecret(secretNumber.ToString(), guess.GuessNumber.ToString());

            if (result.HasWon)
            {
                if (currentGame.FirstPlayerId == guess.GuessingUserId)
                {
                    result.GameResult = GameResult.WonByFirstPlayer;
                }
                else
                {
                    result.GameResult = GameResult.WonBySecondPlayer;
                }
            }

            return(result);
        }
        public IGuessResult GetResult(IGuess guess, IBullsAndCowsData data)
        {
            var guessingPlayer = data.Players.All()
                .FirstOrDefault(x => x.Id == guess.GuessingUserId);

            if (guessingPlayer == null)
            {
                throw new ArgumentException("Player cant be found. Make sure the given user id is correct.");
            }

            var currentGame = data.Games.All()
                .FirstOrDefault(x => (x.FirstPlayerId == guessingPlayer.Id || x.SecondPlayerId == guessingPlayer.Id) &&
                x.State == GameState.FirstPlayerTurn || x.State == GameState.SecondPlayerTurn);

            if (currentGame == null)
            {
                throw new Exception("The current player game is invalid");
            }

            int? secretNumber;
            if (currentGame.FirstPlayerId == guess.GuessingUserId)
            {
                secretNumber = currentGame.SecondPlayerSecretNumber;
            }
            else
            {
                secretNumber = currentGame.FirstPlayerSecretNumber;
            }

            var result = this.CompareToSecret(secretNumber.ToString(), guess.GuessNumber.ToString());

            if (result.HasWon)
            {
                if (currentGame.FirstPlayerId == guess.GuessingUserId)
                {
                    result.GameResult = GameResult.WonByFirstPlayer;
                }
                else
                {
                    result.GameResult = GameResult.WonBySecondPlayer;
                }
            }

            return result;
        }
Ejemplo n.º 7
0
 public GamesController(IBullsAndCowsData data, IGameResultValidator resultValidator, IUserIdProvider userIdProvider, Random randomGenerator) : base(data)
 {
     this.resultValidator = resultValidator;
     this.userIdProvider = userIdProvider;
     this.randomGenerator = randomGenerator;
 }
Ejemplo n.º 8
0
 public GamesController(IBullsAndCowsData data)
     : base(data)
 {
     this.random = new Random();
 }
 public BaseService(IBullsAndCowsData data)
 {
     this.Data = data;
 }
Ejemplo n.º 10
0
 public GamesController(IBullsAndCowsData data, IUserIdProvider userIdProvider, IGameResultValidator resultValidator)
     : base(data)
 {
     this.resultValidator = resultValidator;
     this.userIdProvider  = userIdProvider;
 }
 public UsersService(IBullsAndCowsData data)
     : base(data)
 {
 }
 public NotificationsController(IBullsAndCowsData data)
     : base(data)
 {
     this.data = data;
 }
Ejemplo n.º 13
0
 protected BaseApiController(IBullsAndCowsData data, IUserIdentityProvider userIdentityProvider)
 {
     this.data = data;
     this.userIdentityProvider = userIdentityProvider;
 }
Ejemplo n.º 14
0
 public BaseApiController(IBullsAndCowsData data)
 {
     this.data = data;
 }
 public NotificationsController(IBullsAndCowsData data, IUserIdProvider userIdProvider)
     : base(data)
 {
     this.userIdProvider = userIdProvider;
 }
Ejemplo n.º 16
0
 public GuessController(IBullsAndCowsData data)
     : base(data)
 {
 }
Ejemplo n.º 17
0
 public BaseApiController(IBullsAndCowsData data)
 {
     this.data = data;
 }
Ejemplo n.º 18
0
 public GamesController(IBullsAndCowsData data)
     : base(data)
 {
     this.rnd = new Random();
 }
Ejemplo n.º 19
0
 public GameController(IBullsAndCowsData data)
 // :base(data)
 {
     this.data = data;
 }
 public BaseController(IBullsAndCowsData bullsAndCowsData)
 {
     this.BullsAndCowsData = bullsAndCowsData;
 }
Ejemplo n.º 21
0
 public UsersService(IBullsAndCowsData data)
 {
     this.data = data;
 }
Ejemplo n.º 22
0
 public ScoresController(IBullsAndCowsData data, IUserIdentityProvider userIdentityProvider)
     : base(data, userIdentityProvider)
 {
 }
 public ScoresController(IBullsAndCowsData data)
     : base(data)
 {
 }
 public GuessController(IBullsAndCowsData bullsAndCowsData)
     : base(bullsAndCowsData)
 {
 }
        public ScoresService(IBullsAndCowsData data)
            : base(data)
        {

        }
Ejemplo n.º 26
0
 public ScoreController(IBullsAndCowsData data)
     : base(data)
 {
     this.data = data;
 }
 public NotificationsController(IBullsAndCowsData bullsAndCowsData)
     : base(bullsAndCowsData)
 {
 }
Ejemplo n.º 28
0
 public BaseService(IBullsAndCowsData data)
 {
     this.Data = data;
 }
Ejemplo n.º 29
0
 protected BaseApiController(IBullsAndCowsData data)
 {
     this.Data = data;
 }
Ejemplo n.º 30
0
 public GuessesController(IBullsAndCowsData data, IUserIdentityProvider userIdentityProvider,
                          IGameLogicProvider gameLogicProvider)
     : base(data, userIdentityProvider)
 {
     this.gameLogicProvider = gameLogicProvider;
 }
Ejemplo n.º 31
0
 public NotificationsController(IBullsAndCowsData data, IUserIdentityProvider userIdentityProvider)
     : base(data, userIdentityProvider)
 {
 }
Ejemplo n.º 32
0
 public GuessController(IBullsAndCowsData data)
     : base(data)
 {
     this.data = data;
 }
Ejemplo n.º 33
0
 public GameController(IBullsAndCowsData data)
    // :base(data)
 {
     this.data = data;
 }
 public ScoresService(IBullsAndCowsData data)
     : base(data)
 {
 }
Ejemplo n.º 35
0
 public ScoresController(IBullsAndCowsData data)
     : base(data)
 {
 }
Ejemplo n.º 36
0
 public UsersService(IBullsAndCowsData data)
     : base(data)
 {
 }
Ejemplo n.º 37
0
 protected BaseApiController(IBullsAndCowsData data)
 {
     this.Data = data;
 }
Ejemplo n.º 38
0
 public ScoresController(IBullsAndCowsData data, IUserIdProvider userIdProvider)
     : base(data)
 {
     this.userIdProvider = userIdProvider;
 }
Ejemplo n.º 39
0
 public NotificationsController(IBullsAndCowsData data)
     : base(data)
 {
 }
Ejemplo n.º 40
0
 public Services(IBullsAndCowsData data)
 {
     this.data = data;
 }