Пример #1
0
        public GameResultDto SolveBattle(int gameId, DragonDto dragon)
        {
            if (dragon != null)
            {
                _logger.Write("Claw sharpness = " + dragon.ClawSharpness);
                _logger.Write("Firebreath = " + dragon.FireBreath);
                _logger.Write("Scale thickness = " + dragon.ScaleThickness);
                _logger.Write("Wing strength = " + dragon.WingStrength);
            }

            var partOfPath = "/{gameid}/solution/";
            var path       = partOfPath.Replace("{gameid}", gameId.ToString());
            var fullPath   = String.Format("{0}{1}", _uri, path);

            var dragonWrapper = new DragonDtoWrapper {
                Dragon = dragon
            };

            var response = _httpClient.DoPut(dragonWrapper, fullPath);

            var gameResult = response.Result.Content.ReadAsStringAsync().Result;

            var result = JsonConvert.DeserializeObject <GameResultDto>(gameResult);

            _logger.Write("Game Status: " + result.Status);
            _logger.Write("Message: " + result.Message);

            return(result);
        }
Пример #2
0
        public DragonDto CreateDragon(DragonDto dragon, KnightDto knight)
        {
            var abilitiesOrderedList = DetermineStrongestKnightAbility(knight);

            var dragonAbilities = DefineDragonAbilities(abilitiesOrderedList);

            dragon = dragonAbilities;

            return(dragon);
        }
Пример #3
0
 public FogyWeatherStrategyTests()
 {
     _fogyStrategy = new FogyWeatherStrategy();
     _dragon       = new DragonDto
     {
         ClawSharpness  = 10,
         FireBreath     = 3,
         ScaleThickness = 2,
         WingStrength   = 5
     };
 }
 public LongDryWeatherStrategyTests()
 {
     _longDryStrategy = new LongDryWeatherStrategy();
     _dragonModel     = new DragonDto
     {
         ClawSharpness  = 10,
         FireBreath     = 3,
         ScaleThickness = 2,
         WingStrength   = 5
     };
 }
Пример #5
0
 public HeavyRainWeatherStrategyTests()
 {
     _heavyRainStrategy = new HeavyRainWeatherStrategy();
     _dragon            = new DragonDto
     {
         ClawSharpness  = 10,
         FireBreath     = 3,
         ScaleThickness = 2,
         WingStrength   = 5
     };
 }
Пример #6
0
 public StormWeatherStrategyTests()
 {
     _stormStrategy = new StormWeatherStrategy();
     _dragonModel   = new DragonDto
     {
         ClawSharpness  = 10,
         FireBreath     = 3,
         ScaleThickness = 2,
         WingStrength   = 5
     };
 }
 public NormalWeatherStrategyTests()
 {
     _normalStrategy = new NormalWeatherStrategy();
     _dragon         = new DragonDto();
     _knight         = new KnightDto
     {
         Agility   = 8,
         Armor     = 4,
         Attack    = 0,
         Endurance = 8
     };
 }
Пример #8
0
        public DragonDto CreateDragon(DragonDto dragon, KnightDto knight)
        {
            dragon = new DragonDto
            {
                ClawSharpness  = 5,
                FireBreath     = 5,
                ScaleThickness = 5,
                WingStrength   = 5
            };

            return(dragon);
        }
Пример #9
0
        public DragonDto CreateDragon(DragonDto dragon, KnightDto knight)
        {
            var fire = dragon.FireBreath;

            dragon.ClawSharpness = dragon.ClawSharpness + fire;

            if (dragon.ClawSharpness > 10)
            {
                var attributes = dragon.ClawSharpness - 10;
                dragon.ScaleThickness = dragon.ScaleThickness + attributes;
                dragon.ClawSharpness  = 10;
            }
            dragon.FireBreath = 0;

            return(dragon);
        }
Пример #10
0
        public void CreateDragon_ShouldReturnDragon()
        {
            var expectedDragon = new DragonDto
            {
                ClawSharpness  = 10,
                FireBreath     = 3,
                ScaleThickness = 2,
                WingStrength   = 5
            };

            var result = _fogyStrategy.CreateDragon(_dragon, null);

            Assert.NotNull(result);
            Assert.Equal(expectedDragon.FireBreath, result.FireBreath);
            Assert.Equal(expectedDragon.ClawSharpness, result.ClawSharpness);
            Assert.Equal(expectedDragon.ScaleThickness, result.ScaleThickness);
            Assert.Equal(expectedDragon.WingStrength, result.WingStrength);
        }
Пример #11
0
 public GameClientTests()
 {
     _httpClient = new Mock <IHttpClient>();
     _logger     = new Mock <ILogger>();
     _gameResult = new HttpResponseMessage {
         Content = new StringContent(_gameResultText)
     };
     _httpClient.Setup(x => x.DoGet(It.IsAny <string>())).Returns(Task.FromResult(_gameInfo));
     _httpClient.Setup(x => x.DoPut(It.IsAny <object>(), It.IsAny <string>())).ReturnsAsync(_gameResult);
     _gameClient = new GameClient(_httpClient.Object, _logger.Object, "uri");
     _dragonDto  = new DragonDto
     {
         ClawSharpness  = 10,
         FireBreath     = 3,
         ScaleThickness = 2,
         WingStrength   = 5
     };
 }
Пример #12
0
        public void CreateDragon_ShouldReturnDragon()
        {
            var expectedDragon = new DragonDto
            {
                ClawSharpness  = 3,
                FireBreath     = 7,
                ScaleThickness = 0,
                WingStrength   = 10
            };

            var result = _normalStrategy.CreateDragon(_dragon, _knight);

            Assert.NotNull(result);
            Assert.Equal(expectedDragon.FireBreath, result.FireBreath);
            Assert.Equal(expectedDragon.ClawSharpness, result.ClawSharpness);
            Assert.Equal(expectedDragon.ScaleThickness, result.ScaleThickness);
            Assert.Equal(expectedDragon.WingStrength, result.WingStrength);
        }
Пример #13
0
        private DragonDto DefineDragonAbilities(List <KeyValuePair <KnightsAttributes, int> > abilitiesList)
        {
            var dragon = new DragonDto();

            var dragonAttributes = new Dictionary <DragonsAttributes, int>
            {
                { (DragonsAttributes)abilitiesList[0].Key, abilitiesList[0].Value + 2 },
                { (DragonsAttributes)abilitiesList[1].Key, abilitiesList[1].Value - 1 },
                { (DragonsAttributes)abilitiesList[2].Key, abilitiesList[2].Value - 1 },
                { (DragonsAttributes)abilitiesList[3].Key, abilitiesList[3].Value }
            };

            dragonAttributes.OrderBy(x => x.Key).ToList();

            dragon.WingStrength   = dragonAttributes.FirstOrDefault(x => x.Key == DragonsAttributes.WingStrength).Value;
            dragon.ClawSharpness  = dragonAttributes.FirstOrDefault(x => x.Key == DragonsAttributes.ClawSharpness).Value;
            dragon.ScaleThickness = dragonAttributes.FirstOrDefault(x => x.Key == DragonsAttributes.ScaleThickness).Value;
            dragon.FireBreath     = dragonAttributes.FirstOrDefault(x => x.Key == DragonsAttributes.Firebreath).Value;

            return(dragon);
        }
Пример #14
0
 public DragonDto CreateDragon(DragonDto dragon, KnightDto knight)
 {
     return(dragon);
 }
Пример #15
0
        public static DragonDto CreateDragon(string code, DragonDto dragon, KnightDto knight)
        {
            var result = _strategies[code].CreateDragon(dragon, knight);

            return(result);
        }