Beispiel #1
0
        private ObservableCollection <Dragon> GetDragons()
        {
            var dragonsProvider = new MobgameDragonsProvider();

            dragonsProvider.Init();
            return(dragonsProvider.GetDragonsList());
        }
Beispiel #2
0
        public ObservableCollection <BreedingResult> Breed(Dragon parent1, Dragon parent2)
        {
            Init(parent1, parent2);

            var childs = _source.DocumentNode.SelectNodes(".//*[@id='hatchery']/ul/li");

            if (childs == null)
            {
                return(null);
            }
            var breedingResults = new ObservableCollection <BreedingResult>();
            var dragonsProvider = new MobgameDragonsProvider();
            var nfi             = new NumberFormatInfo {
                NumberDecimalSeparator = "."
            };

            foreach (var child in childs)
            {
                var name                  = child.SelectSingleNode(".//div/span[1]").InnerText;
                var oddsUnformatted       = double.Parse(child.SelectSingleNode(".//div/span[2]").InnerText, nfi);
                var odds                  = $"{Math.Round(oddsUnformatted, 2)}%";
                var breedingTimeInSeconds = int.Parse(child.SelectSingleNode(".//div/span[3]").InnerText.Split('.')[0]);
                var breedingTime          = PrepareTimeAsString(breedingTimeInSeconds);
                var expectedTimeInSeconds = int.Parse(child.SelectSingleNode(".//div/span[4]").InnerText.Split('.')[0]);
                var expectedTime          = PrepareTimeAsString(expectedTimeInSeconds);
                Application.Current.Dispatcher.Invoke(
                    () => breedingResults.Add(new BreedingResult(dragonsProvider.GetDragonByName(name), breedingTime, odds, expectedTime)));
            }
            return(breedingResults);
        }
Beispiel #3
0
        public ObservableCollection <DragonRecipe> GetFormula(Dragon selectedDragon)
        {
            Init(selectedDragon);

            var dragonsRecipeList   = new ObservableCollection <DragonRecipe>();
            var dragonsProvider     = new MobgameDragonsProvider();
            var dragonFormulasNodes =
                _source.DocumentNode.SelectNodes(
                    ".//*[@id='page']/div/div/div/section/div[2]/div[div[contains(@class, 'info')]]");

            if (dragonFormulasNodes == null)
            {
                return(null); //Dragon not breedable
            }
            foreach (var recipe in dragonFormulasNodes)
            {
                var firstParent  = recipe.SelectSingleNode(".//div[2]/div[1]/strong/a[1]").InnerText;
                var secondParent = recipe.SelectSingleNode(".//div[2]/div[1]/strong/a[2]").InnerText;
                var probability  = recipe.SelectSingleNode(".//div[2]/div[2]/span[2]").InnerText;
                var expectedTime = recipe.SelectSingleNode(".//div[2]/div[3]/span[2]").InnerText;

                Application.Current.Dispatcher.Invoke(() =>
                {
                    var firstDragon  = dragonsProvider.GetDragonByName(firstParent);
                    var secondDragon = dragonsProvider.GetDragonByName(secondParent);

                    dragonsRecipeList.Add(new DragonRecipe(firstDragon, secondDragon, probability, expectedTime));
                });
            }
            return(dragonsRecipeList);
        }