Example #1
0
        public async Task <PokedexViewModel> GetAdditionalPokemonInfo(int id)
        {
            var apiPokemonInfo = await _pokemonApi.GetMorePokemonInfo(id);

            var pokemon = new PokedexViewModel
            {
                PokemonWeight   = apiPokemonInfo.weight,
                PokemonName     = apiPokemonInfo.name,
                PokemonId       = apiPokemonInfo.id,
                PokemonImageUrl = apiPokemonInfo.sprites.front_default,
                PokemonHeight   = apiPokemonInfo.height
            };

            //var apiModel =  await _pokemonApi.DetermineIfPokemonHasEvolutionChain(id);
            //pokemon.HaveEvolutionChain = apiModel.evolution_chain.url;
            //if (pokemon.HaveEvolutionChain != null)
            //{
            //    var apiChain = await _pokemonApi.GetEvolutionChain(pokemon.HaveEvolutionChain);

            //    var pokemonEvolutionBaby = new PokemonResponse();
            //    pokemonEvolutionBaby.PokemonName = apiChain.chain.species.name;
            //    var apiImageUrlCall = await _pokemonApi.GetMorePokemonInfo(pokemonEvolutionBaby.PokemonName);
            //    pokemonEvolutionBaby.PokemonImageUrl = apiImageUrlCall.sprites.front_default;


            //    var pokemonEvolution2 = new PokemonResponse();
            //    pokemonEvolution2.PokemonName = apiChain.chain.evolves_to[0].species.name;
            //    var apiImageUrlCall2 = await _pokemonApi.GetMorePokemonInfo(pokemonEvolution2.PokemonName);
            //    pokemonEvolution2.PokemonImageUrl = apiImageUrlCall2.sprites.front_default;
            //    pokemon.EvolutionChain.Add(pokemonEvolutionBaby);
            //    pokemon.EvolutionChain.Add(pokemonEvolution2);

            //    if (apiChain.chain.evolves_to[0].evolves_to.Length != 0)
            //    {
            //        var pokemonEvolution3 = new PokemonResponse();
            //        //pokemonEvolution3.PokemonName = apiChain.chain.evolves_to[0].evolves_to[0].species.name;
            //        var apiImageUrlCall3 = await _pokemonApi.GetMorePokemonInfo(pokemonEvolution3.PokemonName);
            //        pokemonEvolution3.PokemonImageUrl = apiImageUrlCall3.sprites.front_default;
            //        pokemon.EvolutionChain.Add(pokemonEvolution3);
            //    }

            //}

            foreach (var stat in apiPokemonInfo.stats)
            {
                var pokemonStat = new PokemonStat
                {
                    StatName     = stat.stat.name,
                    PointsInStat = stat.base_stat
                };
                pokemon.PokemonStats.Add(pokemonStat);
            }

            foreach (var type in apiPokemonInfo.types)
            {
                pokemon.PokemonTypes.Add(type.type.name);
            }
            return(pokemon);
        }
Example #2
0
 public PokedexPage()
 {
     this.InitializeComponent();
     DataContextChanged += (a, b) =>
     {
         vm = b.NewValue as PokedexViewModel;
     };
 }
        public void CorrectResponceToValidType()
        {
            var pokedexViewModel = new PokedexViewModel(mockPokeRegistry.Object,
                                                        pokeTypeConstants, mockPdfService.Object, mockExcelService.Object);
            var validPokeType = new PokeType("fire");

            mockExcelService.Setup(e => e.getStoredFilter()).Returns((string.Empty, validPokeType));
            pokedexViewModel.LoadFilter.Execute();
            pokedexViewModel.PokeTypeErrorVisibility.Should().Be(Visibility.Visible);
        }
        public void CanFilterPokemonByType()
        {
            var pokedexViewModel = new PokedexViewModel(mockPokeRegistry.Object, pokeTypeConstants, mockPdfService.Object);

            pokedexViewModel.LoadPokemonTask.Wait();

            pokedexViewModel.SelectedPokeType = pokeTypeConstants.Dragon;


            pokedexViewModel.PokemonFilteredCollection.Count.Should().Be(1);
            pokedexViewModel.PokemonFilteredCollection.First().Name.Should().Be("ccc");
        }
        public void filterPokemonByName()
        {
            var pokedexViewModel = new PokedexViewModel(mockPokeRegistry.Object, pokeTypeConstants, mockPdfService.Object);

            pokedexViewModel.LoadPokemonTask.Wait();


            pokedexViewModel.PokemonNameFilter = "b";

            pokedexViewModel.PokemonFilteredCollection.Count.Should().Be(1);
            pokedexViewModel.PokemonFilteredCollection.First().Name.Should().Be("bbb");
        }
        public void CanFilterByTypeAndName()
        {
            var pokedexViewModel = new PokedexViewModel(mockPokeRegistry.Object, pokeTypeConstants, mockPdfService.Object);

            pokedexViewModel.LoadPokemonTask.Wait();
            pokedexViewModel.PokemonNameFilter = "d";
            pokedexViewModel.SelectedPokeType  = pokeTypeConstants.Electric;

            pokedexViewModel.PokemonFilteredCollection.Count.Should().Be(3);
            pokedexViewModel.PokemonFilteredCollection.Should().Contain(p => p.Name == "ddd");
            pokedexViewModel.PokemonFilteredCollection.Should().Contain(p => p.Name == "dab");
            pokedexViewModel.PokemonFilteredCollection.Should().Contain(p => p.Name == "dac");
        }
Example #7
0
 public PokedexPage()
 {
     InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);
     BindingContext = viewModel = new PokedexViewModel();
     this.PokemonsListView.ItemAppearing += (s, e) =>
     {
         //var item = (Pokemon)e.Item;
         //if (item.name == viewModel?.Items?.Last().name)
         //if (viewModel.Items.Count > 0)
         //viewModel.LoadItemsCommand.Execute(null);
     };
 }
Example #8
0
        public PokedexPage()
        {
            this.InitializeComponent();
            AllPokemonsByDexNumberList.ItemClick += PokemonsList_ItemClick;
            AllPokemonsByCpList.ItemClick        += PokemonsList_ItemClick;
            AllPokemonsByNameList.ItemClick      += PokemonsList_ItemClick;
            AllPokemonsByTypeList.ItemClick      += PokemonsList_ItemClick;

            DataContextChanged += (a, b) =>
            {
                vm = b.NewValue as PokedexViewModel;
            };
        }
        public async Task <IActionResult> GetPokemonDetails(int id, SelectPokemonViewModel userPokemon)
        {
            _quizFlow.ResetSession(); //user may have left quiz screen so reset session
            if (userPokemon.PokemonSelected != null)
            {
                var pokedexViewModelString = await _pokemonService.GetAdditionalPokemonInfo(userPokemon.PokemonSelected);

                return(View(pokedexViewModelString));
            }

            var pokedexViewModel = new PokedexViewModel();

            pokedexViewModel = await _pokemonService.GetAdditionalPokemonInfo(id);

            return(View(pokedexViewModel));
        }
        public async Task <ActionResult> Index()
        {
            List <PokedexModel> pokedex;

            pokedex = conn.Query <PokedexModel>("pkmn.Pokedex_List", commandType: CommandType.StoredProcedure).ToList();
            PokedexViewModel viewModel = new PokedexViewModel(pokedex);

            foreach (var pokemon in viewModel.pokedex)
            {
                PokemonSpecies p = await DataFetcher.GetApiObject <PokemonSpecies>(pokemon.Pokedex_ID.Value);

                pokemon.Name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(p.Name);
            }

            foreach (var pokemon in viewModel.pokedex)
            {
                if (pokemon.Percentage == "0")
                {
                    pokemon.BackgroundColor = "#FFFFFF";
                }
                else if (pokemon.Percentage == "25")
                {
                    pokemon.BackgroundColor = "#C1C7F9";
                }
                else if (pokemon.Percentage == "50")
                {
                    pokemon.BackgroundColor = "#979EEE";
                }
                else if (pokemon.Percentage == "75")
                {
                    pokemon.BackgroundColor = "#6871D5";
                }
                else if (pokemon.Percentage == "100")
                {
                    pokemon.BackgroundColor = "#384498";
                }
            }

            return(View(viewModel));
        }
Example #11
0
 public MainWindow()
 {
     InitializeComponent();
     _viewModel  = new PokedexViewModel();
     DataContext = _viewModel;
 }