示例#1
0
        private static async void OnSearch(object sender, EventArgs e)
        {
            mainLabel.Text = "Cargando...";
            PokemonSpecies p = await DataFetcher.GetNamedApiObject <PokemonSpecies>(pkmnText.Text.ToLower());

            Pokemon pk = await DataFetcher.GetNamedApiObject <Pokemon>(pkmnText.Text.ToLower());

            if (p == null || pk == null)
            {
                throw new Exception("Eso no es un Pokemon o llegaste al límite de llamadas al API.");
            }
            else
            {
                try
                {
                    pkmnId         = p.ID;
                    mainLabel.Text = "Ingresa el nombre de un Pokémon:";
                    GetMainInfo(pkmnId, p, pk);
                    GetBaseStats(pk);
                }
                catch (Exception ex)
                {
                    throw new Exception("Ajale jaleo!");
                }
            }
        }
示例#2
0
            public async Task Purge([Remainder()] string name)
            {
                IUserMessage msg = await Context.Channel.SendMessageAsync("Fetching Data...");

                try
                {
                    PokeAPI.Pokemon p = await DataFetcher.GetNamedApiObject <PokeAPI.Pokemon>(name.ToLower());

                    EmbedBuilder builder = new EmbedBuilder()
                    {
                        Title = "Pokemon Request by Name", Color = Color.DarkGreen, ThumbnailUrl = p.Sprites.FrontMale
                    };

                    builder.Description = $"{FormatHelper.Capatalize(p.Name)} the {FormatHelper.Capatalize((await DataFetcher.GetNamedApiObject<PokemonSpecies>(name)).Genera[2].Name)}";

                    EmbedFieldBuilder field = new EmbedFieldBuilder()
                    {
                        Name     = "Base Stats",
                        IsInline = true
                    };

                    foreach (PokemonStats stat in p.Stats)
                    {
                        field.Value += $"{FormatHelper.Capatalize(stat.Stat.Name)}: {stat.BaseValue.ToString()}\n";
                    }

                    builder.AddField(field);

                    await msg.ModifyAsync(x => { x.Content = ""; x.Embed = builder.Build(); });
                }
                catch
                {
                    await msg.ModifyAsync(x => x.Content = "Could find pokemon with name: " + name);
                }
            }
        public async Task TestPokemonApi()
        {
            PokemonSpecies p = await DataFetcher.GetNamedApiObject <PokemonSpecies>(pokemonName);

            Assert.IsNotNull(p);
            Assert.AreEqual(p.Name, pokemonName);
        }
示例#4
0
        [HttpGet] // https://localhost:44392/api/pokemon?name=charizard
        public async Task <PokemonModel> GetPokemon([FromQuery] string name)
        {
            var obj = await DataFetcher.GetNamedApiObject <Pokemon>(name.ToLower()); // wrapper can't handle any uppercase letters, wah wah

            // create PokemonModel from PokeApi.Pokemon
            var pokemon = new PokemonModel()
            {
                Id            = obj.ID,
                Name          = obj.Name,
                BackImageUri  = obj.Sprites.BackMale,
                FrontImageUri = obj.Sprites.FrontMale,

                BaseHP         = obj.Stats.Where(s => s.Stat.Name.ToLower().Equals("hp")).Select(s => s.BaseValue).FirstOrDefault() * 10,
                ActingHP       = obj.Stats.Where(s => s.Stat.Name.ToLower().Equals("hp")).Select(s => s.BaseValue).FirstOrDefault() * 10,
                Attack         = obj.Stats.Where(s => s.Stat.Name.ToLower().Equals("attack")).Select(s => s.BaseValue).FirstOrDefault(),
                Defense        = obj.Stats.Where(s => s.Stat.Name.ToLower().Equals("defense")).Select(s => s.BaseValue).FirstOrDefault(),
                SpecialAttack  = obj.Stats.Where(s => s.Stat.Name.ToLower().Equals("special-attack")).Select(s => s.BaseValue).FirstOrDefault(),
                SpecialDefense = obj.Stats.Where(s => s.Stat.Name.ToLower().Equals("special-defense")).Select(s => s.BaseValue).FirstOrDefault(),
                Speed          = obj.Stats.Where(s => s.Stat.Name.ToLower().Equals("speed")).Select(s => s.BaseValue).FirstOrDefault()
            };

            // add list of available moves to pokemon
            obj.Moves.Select(m => m.Move).ToList().ForEach(m =>
            {
                pokemon.Moves.Add(
                    new MoveModel()
                {
                    Name        = m.Name,
                    ResourceUri = m.Url.AbsoluteUri.ToString()
                });
            });

            foreach (var m in pokemon.Moves)
            {
                var info = await GetAdditionInfo(m.ResourceUri);

                if (info != null && info.Count > 0)
                {
                    m.Id     = info.ContainsKey("id") ? int.Parse(info?["id"].ToString()) : 0;
                    m.Damage = info.ContainsKey("power") && info?["power"] != null?int.Parse(info?["power"].ToString()) : 0;

                    m.Category = info.ContainsKey("damage_class") && info?["damage_class"] != null ? ((ExpandoObject)info?["damage_class"]).First().Value.ToString() : string.Empty;
                    m.Type     = info.ContainsKey("type") ? ((ExpandoObject)info?["type"]).First().Value.ToString() : string.Empty;
                }
            }

            pokemon.Moves.RemoveAll(m => m.Damage == 0); // get rid of moves without damage

            // add any types to the pokemon
            obj.Types.ToList().ForEach(t =>
            {
                pokemon.Types.Add(new Shared.Models.PokemonType
                {
                    Name        = t.Type.Name,
                    ResourceUri = t.Type.Url.AbsoluteUri.ToString()
                });
            });

            return(pokemon);
        }
示例#5
0
        /// <summary>
        /// This method uses the text of the activity to decide which type
        /// of card to respond with and reply with that card to the user.
        /// </summary>
        /// <param name="step">A <see cref="WaterfallStepContext"/> provides context for the current waterfall step.</param>
        /// <param name="cancellationToken" >(Optional) A <see cref="CancellationToken"/> that can be used by other objects
        /// or threads to receive notice of cancellation.</param>
        /// <returns>A <see cref="DialogTurnResult"/> indicating the turn has ended.</returns>
        /// <remarks>Related types <see cref="Attachment"/> and <see cref="AttachmentLayoutTypes"/>.</remarks>
        private static async Task <DialogTurnResult> ShowCardStepAsync(WaterfallStepContext step, CancellationToken cancellationToken)
        {
            // Get the pokemon name from the activity
            var pokemonName = step.Context.Activity.Text.ToLowerInvariant().Split(' ')[0];

            // Reply to the activity we received with an activity.
            var reply = step.Context.Activity.CreateReply();

            // Cards are sent as Attachments in the Bot Framework.
            // So we need to create a list of attachments on the activity.
            reply.Attachments = new List <Attachment>();

            Pokemon pokemon = await DataFetcher.GetNamedApiObject <Pokemon>(pokemonName);

            PokemonSpecies pokemonSpecies = await DataFetcher.GetNamedApiObject <PokemonSpecies>(pokemonName);

            reply.Attachments.Add(GetThumbnailCard(pokemon, pokemonSpecies).ToAttachment());

            // Send the card(s) to the user as an attachment to the activity
            await step.Context.SendActivityAsync(reply, cancellationToken);

            // Give the user instructions about what to do next
            await step.Context.SendActivityAsync("Type another Pokémon name to see information about it!", cancellationToken : cancellationToken);

            return(await step.EndDialogAsync(cancellationToken : cancellationToken));
        }
示例#6
0
        private async Task GetPkmnType(IDialogContext context, string PkmnName)
        {
            try
            {
                List <string> Types = new List <string>();
                Pokemon       p     = await DataFetcher.GetNamedApiObject <Pokemon>(PkmnName);

                if (p != null)
                {
                    string Tipos = "";
                    foreach (var tp in p.Types)
                    {
                        Types.Add(tp.Type.Name);
                        Tipos += tp.Type.Name;
                        Tipos += " ";
                    }
                    //string Tipos = "Flying Dragon "; // Para testes no Proxy
                    await context.PostAsync($"Tipo(s) de {PkmnName}: {Tipos.Trim()}");
                }
                context.Wait(MessageReceived);
            }
            catch (Exception e)
            {
                await context.PostAsync($"[GetPkmnType]Ocorreu um erro: {e.Message}");
            }
        }
        public async Task <PokemonApi> recuperarPokemonAPI(string nombrePokemon)
        {
            try
            {
                PokemonApi     pokemonApi    = new PokemonApi();
                PokemonSpecies pokemonSpecie = await DataFetcher.GetNamedApiObject <PokemonSpecies>(nombrePokemon.ToLower());

                if (pokemonSpecie != null)
                {
                    pokemonApi.Id     = pokemonSpecie.ID;
                    pokemonApi.Nombre = pokemonSpecie.Name;


                    PokeAPI.Pokemon pokemon = await DataFetcher.GetNamedApiObject <PokeAPI.Pokemon>(pokemonSpecie.ID.ToString());

                    if (pokemon.Types != null)
                    {
                        pokemonApi.Tipo = pokemon.Types[0].Type.Name;
                    }

                    return(pokemonApi);
                }
            }
            catch (Exception error) { }
            return(null);
        }
示例#8
0
        public async Task <List <string> > GetMoves(string name)
        {
            var obj = await DataFetcher.GetNamedApiObject <Pokemon>(name);

            var moves = obj.Moves.Select(m => m.Move.Name).ToList();

            return(moves);
        }
        public bool DisplayMoves()
        {
            try
            {
                Console.WriteLine("Displaying list of moves......");
                Task <PokeAPI.Pokemon> p             = DataFetcher.GetNamedApiObject <PokeAPI.Pokemon>(Name);
                PokemonMove[]          returnedmoves = p.Result.Moves;
                int linecountspace          = 0;
                Task <PokeAPI.Move>[] moves = new Task <PokeAPI.Move> [returnedmoves.Length];
                for (int i = 0; i < returnedmoves.Length; i++)
                {
                    moves[i] = (DataFetcher.GetNamedApiObject <PokeAPI.Move>(returnedmoves[i].Move.Name.ToString()));
                }
                Task.WaitAll(moves);
                foreach (Task <PokeAPI.Move> e in moves)
                {
                    if (e.Result.Power != null && !string.IsNullOrEmpty(e.Result.Power.ToString()))
                    {
                        string movestring = e.Result.Name.ToString();
                        Console.Write(movestring + ", ");
                        AvailbleMoves.Add(movestring);
                        linecountspace++;
                        if (linecountspace == 4)
                        {
                            Console.Write("\n");
                            linecountspace = 0;
                        }
                    }
                    e.Dispose();
                }
                //foreach (PokeAPI.PokemonMove element in returnedmoves)
                //{

                //    Task<PokeAPI.Move> m = DataFetcher.GetNamedApiObject<PokeAPI.Move>(element.Move.Name.ToString());

                //    if (m.Result.Power != 0 && m.Result.Power.ToString() != "" && m.Result.Power != null)
                //    {
                //        string movestring = element.Move.Name.ToString();
                //        Console.Write(movestring + ", ");
                //        AvailbleMoves.Add(movestring);
                //        linecountspace++;
                //        if (linecountspace == 4)
                //        {
                //            Console.Write("\n");
                //            linecountspace = 0;
                //        }
                //    }
                //}
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error most likely with pokemon name! \n" + e.Message);
                return(false);
            }
        }
        public static async Task <JsonResult> getTranslatedDescription(string pokemonName)
        {
            PokemonSpecies p;

            try
            {
                p = await DataFetcher.GetNamedApiObject <PokemonSpecies>(pokemonName);
            }
            catch (HttpRequestException)
            {
                return(new JsonResult(ErrorMessage.pokeMonNotFoundOrUnAvailable)
                {
                    StatusCode = StatusCodes.Status404NotFound
                });
            }
            catch (PokemonParseException ex)
            {
                return(new JsonResult(ex.Message)
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }

            try
            {
                string description = Array.Find(p.FlavorTexts, element => element.Language.Name == "en").FlavorText;

                JsonResult shakespeareResult = await ShakespeareClient.getShakespeareTranslated(description);

                if (shakespeareResult.StatusCode == StatusCodes.Status429TooManyRequests)
                {
                    return(new JsonResult(ErrorMessage.tooManyRequest)
                    {
                        StatusCode = StatusCodes.Status429TooManyRequests
                    });
                }

                PokemonDetails pDetails = new PokemonDetails()
                {
                    Name        = p.Name,
                    Description = shakespeareResult.Value.ToString()
                };

                return(new JsonResult(pDetails)
                {
                    StatusCode = StatusCodes.Status200OK // Status code here
                });
            }
            catch (Exception ex)
            {
                return(new JsonResult(ex.Message)
                {
                    StatusCode = StatusCodes.Status500InternalServerError // Status code here
                });
            }
        }
示例#11
0
        public async Task <ActionResult <Pokemon> > Get(string pokemonName)
        {
            try
            {
                PokemonSpecies pokemon = await DataFetcher.GetNamedApiObject <PokemonSpecies>(pokemonName);

                // For demo purposes, we assume the desired flavortext will always be provided by index 1
                // In a real scenario, this should change, by specifying what we should do with the foreign language
                // (e.g. always select en, translate the text, select specific value etc)
                string originalDescription = pokemon.FlavorTexts[1].FlavorText;

                var client = new HttpClient();

                // Create the HttpContent for the form to be posted.
                var requestContent = new FormUrlEncodedContent(new[] {
                    new KeyValuePair <string, string>("text", originalDescription),
                    new KeyValuePair <string, string>("api_key", "dWuL_uQCQj4GYAxQDaVTEweF"),
                });

                // Get the response.
                HttpResponseMessage response = await client.PostAsync(
                    "https://api.funtranslations.com/translate/shakespeare.json",
                    requestContent);

                // Get the response content.
                HttpContent responseContent = response.Content;

                // Get the stream of the content.
                using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
                {
                    // Write the output
                    JObject translatedPokemonDescriptionResult     = JObject.Parse(await reader.ReadToEndAsync());
                    string  translatedPokemonDescriptionResultText = (string)translatedPokemonDescriptionResult["contents"]["translated"];

                    //  Create an object for the requested Pokemon including Pokemon's name and Shakespeare's description
                    Pokemon requestedPokemon = new Pokemon();
                    requestedPokemon.Name        = pokemonName;
                    requestedPokemon.Description = translatedPokemonDescriptionResultText;
                    return(requestedPokemon);
                }
            }



            catch (Exception error)
            {
                // Log error
                // In caase of error, return a friendly message to the user.
                Pokemon unknownPokemon = new Pokemon();
                unknownPokemon.Name        = "MissingNO";
                unknownPokemon.Description = "Are you trying to catch MISSINGNO? (https://en.wikipedia.org/wiki/MissingNo.) " +
                                             "Why don't you try a different name of a friendlier Pokemon such as 'Charizard', or 'Bulbasaur'?";
                return(unknownPokemon);
            }
        }
示例#12
0
        /// </inheritdoc>
        public async Task <PokemonInformation> GetPokemonInformationAsync(string pokemonName)
        {
            _logger.LogDebug($"Fetching data using the Pokemon's name");

            // because both the api and smogon use lower case
            pokemonName = pokemonName.ToLower();

            // get information from the API
            PokemonSpecies pokemonSpecies = await DataFetcher.GetNamedApiObject <PokemonSpecies>(pokemonName);

            Pokemon pokemon = await DataFetcher.GetNamedApiObject <Pokemon>(pokemonName);

            return(await GetSmogonInformationAndMergeItAsync(pokemonName, pokemonSpecies, pokemon));
        }
        private async Task <string> CreateStarterPokemonXMLAsync(string starterName)
        {
            PRPGDiscordBot.Models.Team team = new Models.Team();

            PokeAPI.Pokemon p = await DataFetcher.GetNamedApiObject <PokeAPI.Pokemon>(starterName.ToLower());

            Models.Pokemon pokemon = new Models.Pokemon()
            {
                ID = p.ID, Level = 5, PokeBallType = Models.PokeBallType.PokeBall, Form = 0, Happiness = 70, Nickname = "", Shiny = false, Status = Models.Status.None
            };
            pokemon.Stats        = Models.Pokemon.GenerateStarterStats(p);
            pokemon.Moves        = Models.Pokemon.GenerateStarterMoves(p);
            pokemon.Ability.Name = p.Abilities[0].Ability.Name;

            team.Add(pokemon);

            return(team.Serialize());
        }
示例#14
0
        public async void UpdateData()
        {
            if (SelectedPokemon == null)
            {
                return;
            }
            if (!StaticPokemonNames.Contains(SelectedPokemon))
            {
                return;
            }

            Pokemon p = await DataFetcher.GetNamedApiObject <Pokemon>(SelectedPokemon);

            CalcMon.BasePokemon = p;
            Abilities           = p.Abilities.Select(a => a.Ability.Name).ToList();
            CalcMon.Ability     = Abilities[0];

            this.RaisePropertyChanged(x => x.CalcMon);
        }
示例#15
0
 public bool SearchPokemonAsync(string name)
 {
     try
     {
         Task <PokemonSpecies> p = DataFetcher.GetNamedApiObject <PokemonSpecies>(name.Trim().ToLower());
         if (p.Result.Name.ToString() == name)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
示例#16
0
        /// <summary>
        /// Compose the pokemon specs
        /// </summary>
        /// <param name="name">Pokemon's name used to search on API</param>
        public async void getPokemon(string name)
        {
            try
            {
                Pokemon p = await DataFetcher.GetNamedApiObject <Pokemon>(name);

                Image(p);
                Name(p);
                Height(p);
                Mass(p);
                Species(p);
                Moves(p);
                Ability(p);
                Types(p);
            }
            catch (Exception ex)
            {
                Response.Redirect("Error.html");
            }
        }
示例#17
0
        public async Task GetPokemon([Summary("pokemonName")] string pokemonName)
        {
            try
            {
                DataFetcher.ShouldCacheData = true;
                Pokemon pokemon;
                try
                {
                    pokemon = await DataFetcher.GetNamedApiObject <Pokemon>(pokemonName.ToLower());
                }
                catch
                {
                    await ReplyAsync("I couldn't find that pokemon :confused:");

                    return;
                }
                var embed = await pokemonEmbedBuilder(pokemon);
                await ReplyAsync("", false, embed.Build());
            }
            catch (Exception e)
            {
                _errorHandler.HandleCommandException(e, Context);
            }
        }
示例#18
0
 public async Task GetPokemon(string pokemon, string group = null)
 => await SendPokemonAsync(await DataFetcher.GetNamedApiObject <PokemonSpecies>(pokemon.ToLowerInvariant()).ConfigureAwait(false), group ?? "default").ConfigureAwait(false);
示例#19
0
 public async Task <PokeAPI.Move> FetchMove(String MoveName)
 {
     return(await DataFetcher.GetNamedApiObject <PokeAPI.Move>(MoveName));
 }
示例#20
0
 public async Task <Pokemon> GetPokemon()
 {
     return(await DataFetcher.GetNamedApiObject <Pokemon>("excadrill"));
 }
        /// <summary>
        /// Author: Samuel Gardner
        /// </summary>
        public void LoadData()
        {
            var tempLineUp      = new List <Pokemon>();
            var getPokemonQuery = (TrainerName == string.Empty ? "SELECT `Pokemon1`,`MovesCSV1`,`Pokemon2`,`MovesCSV2`,`Pokemon3`,`MovesCSV3`" +
                                   ",`Pokemon4`,`MovesCSV4`,`Pokemon5`,`MovesCSV5`,`Pokemon6`,`MovesCSV6`" +
                                   " FROM sql3346222.TrainerLineup WHERE(UserID = @ID);" :
                                   "SELECT `Pokemon1`,`MovesCSV1`,`Pokemon2`,`MovesCSV2`,`Pokemon3`,`MovesCSV3`" +
                                   ",`Pokemon4`,`MovesCSV4`,`Pokemon5`,`MovesCSV5`,`Pokemon6`,`MovesCSV6`" +
                                   " FROM sql3346222.EliteFour WHERE(TrainerName = @Username);");


            //Get pokemon from DB
            Con.Open();
            MySqlCommand cmd = new MySqlCommand(getPokemonQuery, Con);

            if (TrainerName == string.Empty)
            {
                cmd.Parameters.Add(@"@ID", MySqlDbType.Int32);
                cmd.Parameters[@"@ID"].Value = TrainerId;
            }
            else
            {
                cmd.Parameters.Add(@"@Username", MySqlDbType.VarChar);
                cmd.Parameters[@"@Username"].Value = TrainerName;
            }
            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                var tasks = new Queue <Tuple <Task <PokeAPI.Pokemon>, List <Task <PokeAPI.Move> > > >();
                Dictionary <string, Task <PokeAPI.Pokemon> > requestedPokemon = new Dictionary <string, Task <PokeAPI.Pokemon> >();
                Dictionary <string, Task <PokeAPI.Move> >    requestedMoves   = new Dictionary <string, Task <PokeAPI.Move> >();
                Task <PokeAPI.Pokemon>      tempGetPoke = null;
                List <Task <PokeAPI.Move> > tempGetMove = null;
                while (reader.Read())
                {
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        if (i % 2 == 0)
                        {
                            //this record is a pokemon.
                            string cleaned = reader.GetString(i).Trim().ToLower();
                            if (requestedPokemon.ContainsKey(cleaned))
                            {
                                Console.WriteLine($"Pokemon {cleaned} already requested, removing redundancy...");
                                tempGetPoke = requestedPokemon[cleaned];
                            }
                            else
                            {
                                Console.WriteLine($"Starting request for pokemon: {cleaned}...");
                                tempGetPoke = DataFetcher.GetNamedApiObject <PokeAPI.Pokemon>(cleaned);
                                requestedPokemon.Add(cleaned, tempGetPoke);
                            }
                            //tempGetPoke.Start();
                        }
                        else
                        {
                            //this record is a moves.
                            tempGetMove = reader.GetString(i).Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x =>
                            {
                                string cleaned = x.Trim().ToLower();
                                if (requestedMoves.ContainsKey(cleaned))
                                {
                                    Console.WriteLine($"Move {cleaned} already requested, removing redundancy...");
                                    return(requestedMoves[cleaned]);
                                }
                                else
                                {
                                    Console.WriteLine($"Starting request for move: {cleaned}...");
                                    requestedMoves.Add(cleaned, DataFetcher.GetNamedApiObject <PokeAPI.Move>(cleaned));
                                    return(requestedMoves[cleaned]);
                                }
                            }).ToList();
                            //tempGetMove = GetMovesAsync(reader.GetString(i).Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray());
                            //tempGetMove.ForEach(x =>
                            //{
                            //    x.Start();
                            //});
                        }
                        if (tempGetMove != null && tempGetPoke != null)
                        {
                            tasks.Enqueue(new Tuple <Task <PokeAPI.Pokemon>, List <Task <PokeAPI.Move> > >(tempGetPoke, tempGetMove));
                            tempGetMove = null;
                            tempGetPoke = null;
                        }
                    }
                }
                //Task.WaitAll(tasks.Select(x => new List<Task>(x.Item2).Add(x.Item1)).Aggregate((x, y) => x.Concat(y).ToArray()));
                foreach (Tuple <Task <PokeAPI.Pokemon>, List <Task <PokeAPI.Move> > > e in tasks)
                {
                    Task.WaitAll((e.Item2.Select(x => (Task)x).Append((Task)e.Item1)).ToArray());
                    int hp = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "hp").BaseValue;
                    tempLineUp.Add(new Pokemon()
                    {
                        BaseHP         = hp,
                        ActingHP       = hp,
                        Attack         = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "attack").BaseValue,
                        Defense        = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "defense").BaseValue,
                        SpecialAttack  = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "special-attack").BaseValue,
                        SpecialDefense = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "special-defense").BaseValue,
                        Speed          = e.Item1.Result.Stats.FirstOrDefault(x => x.Stat.Name == "speed").BaseValue,
                        BackImageUri   = e.Item1.Result.Sprites.BackFemale ?? e.Item1.Result.Sprites.BackMale,
                        FrontImageUri  = e.Item1.Result.Sprites.FrontFemale ?? e.Item1.Result.Sprites.FrontMale,
                        Id             = e.Item1.Result.ID,
                        Species        = e.Item1.Result.Species.Name,
                        ConsoleMoves   = e.Item2.Select(x => new Move()
                        {
                            Damage     = x.Result.Power ?? 0,
                            IsPhysical = x.Result.DamageClass.Name == "physical",
                            Name       = x.Result.Name,
                            Type       = x.Result.Type.Name
                        }).ToList(),
                        ConsoleTypes = e.Item1.Result.Types.Select(x => x.Type.Name).ToList(),
                        Moves        = e.Item2.Select(x => new Web.Shared.Models.MoveModel()
                        {
                            Category    = x.Result.DamageClass.Name,
                            Damage      = x.Result.Power ?? 0,
                            Id          = x.Result.ID,
                            Name        = x.Result.Name,
                            ResourceUri = null,    //Not sure what to do about this field.
                            Seleted     = default, //Not sure what to do about this either.
示例#22
0
        public void SearchPokemonAsync()
        {
            Task <PokemonSpecies> p = DataFetcher.GetNamedApiObject <PokemonSpecies>(SearchedName);

            ReturnedName = p.Result.Name.ToString();
        }
示例#23
0
        public async Task <Pokemon> GetPokemonAsync(string pokemonName)
        {
            var p = await DataFetcher.GetNamedApiObject <Pokemon>(pokemonName.ToLower());

            return(p);
        }
示例#24
0
 // Fetch Task by name
 public async Task <PokeAPI.Pokemon> FetchPokemonByName(string PokemonName)
 {
     return(await DataFetcher.GetNamedApiObject <PokeAPI.Pokemon>(PokemonName));
 }