public AttackStaticData(short id) { var move = DataFetcher.GetApiObject <Move>(id).Result; ID = id; Name = move.Names.Single(MonsterStaticData.GetLocalizedName).Name; Type = Cached <MonsterTypeStaticData> .Get((byte)move.Type.ID); Target = (Target)move.Target.ID; DamageClass = (DamageClass)move.DamageClass.ID; Power = (byte)(move.Power ?? 0); Accuracy = (byte)(move.Accuracy ?? 0); Priority = (byte)move.Priority; PP = (byte)(move.PP ?? 0); }
/// <summary> /// Gets a new pokemon species and sets the data to it's specifications /// </summary> /// <param name="pokedexNumber">Inputs the pokedex number of the desired pokemon</param> public async void GetPokemon(int pokedexNumber) { PokemonSpecies currentPokemon = await DataFetcher.GetApiObject <PokemonSpecies>(pokedexNumber); happiness = currentPokemon.BaseHappiness; captureRate = currentPokemon.CaptureRate; pokemonName = currentPokemon.Name; flavorText = currentPokemon.FlavorTexts[0].FlavorText; habitat = currentPokemon.Habitat.Name; growthRate = currentPokemon.GrowthRate.Name; eggGroup = currentPokemon.EggGroups[0].Name; pokemonName = Capitalize(pokemonName); habitat = Capitalize(habitat); eggGroup = Capitalize(eggGroup); growthRate = Capitalize(growthRate); }
public async Task <IActionResult> PostAsync(string Text, string Clave) { if (!string.IsNullOrEmpty(Text) && !string.IsNullOrEmpty(Clave)) { Random random = new Random(); int num = random.Next(1, 700); PokemonSpecies species = await DataFetcher.GetApiObject <PokemonSpecies>(num); StringBuilder Mensaje = new StringBuilder(Text); Clave = species.Name; EnC.CIFRARIn(ref Mensaje, Clave); return(Ok($"su texto{Mensaje} \n" + $"Pokemon asignado como clave es: {Clave} \n")); } else { return(NotFound()); } }
public static async Task <List <int> > GetEvolutionIDs(PokeAPI.Pokemon poke) { List <int> ids = new List <int>(); EvolutionChain evs; try { evs = await DataFetcher.GetApiObject <EvolutionChain>(poke.ID); } catch (Exception) { return(ids); } if (evs.Chain.Details.Count() > 0) { /* ids.Add(_pokemons.First(x => x.Name == evs.Chain.EvolvesTo[0].Species.Name).ID); * if(( l = evs.Chain.EvolvesTo[0].EvolvesTo).Count() > 0) * ids.AddRange(await GetEvolutionIDs(_pokemons.First(x => x.Name == l[0].Species.Name))); */ } return(ids); }
public static async Task LoadAPIMoves() { int max = 728; List <MoveModel> moves = new List <MoveModel>(); for (int i = 1; i <= max; i++) { var move = await DataFetcher.GetApiObject <Move>(i).ConfigureAwait(false); if (move.Power == null || move.Accuracy == null) { continue; } if (move.DamageClass.Name != "special" && move.DamageClass.Name != "physical") { continue; } _pokemontypes.TryGetValue(move.Type.Name, out var type); MoveModel model = new MoveModel() { Accuracy = move.Accuracy, DamageClass = (move.DamageClass.Name == "special") ? DamageType.SPECIAL : DamageType.PHYSICAL, ID = move.ID, Name = move.Name, ESPName = move.Names[4].Name, Power = move.Power, MovementType = type }; moves.Add(model); if (!_pokemontypes.TryGetValue(move.Type.Name, out var t) && move.Type.Name != "grass") { Console.WriteLine(move.Type.Name); Console.ReadKey(); } } var s = JsonConvert.SerializeObject(moves, Formatting.Indented); File.WriteAllText("moves.json", s); }
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)); }
public static async Task LoadPokemonAPI() { int max = MaxPokemonId; List <PokemonModel> models = new List <PokemonModel>(); for (int i = 800; i <= max; i++) { var pokemon = await DataFetcher.GetApiObject <PokeAPI.Pokemon>(i); List <int> idmoves = new List <int>(); foreach (var x in pokemon.Moves) { var m = MovesModel.FirstOrDefault(u => u.Name == x.Move.Name); if (m != null) { //Console.WriteLine(m.Name); idmoves.Add(m.ID); } else { continue; } } if (pokemon.Forms.Count() > 1) { Console.WriteLine(pokemon.Forms.Count() + " for " + pokemon.Name); } PokemonModel model = new PokemonModel(pokemon, idmoves); model.BuildIvsEvs(pokemon.Stats); models.Add(model); Console.WriteLine("[" + model.ID + "] " + model.Name); } var s = JsonConvert.SerializeObject(models, Formatting.Indented); File.WriteAllText("pokemon_model.json", s); }
public async Task <PokeAPI.Move> FetchMove(int MoveID) { return(await DataFetcher.GetApiObject <PokeAPI.Move>(MoveID)); }
public async Task GetsMove(int moveID) { var t = await DataFetcher.GetApiObject <Move>(moveID); Assert.NotNull(t); }
// Fetch Task by ID public async Task <PokeAPI.Pokemon> FetchPokemon(int PokemonID) { return(await DataFetcher.GetApiObject <PokeAPI.Pokemon>(PokemonID)); }
public async Task <Pokemon> GetPokemonAsync(int pokedexId) { var p = await DataFetcher.GetApiObject <Pokemon>(pokedexId); return(p); }
async Task GetPKM(int number, bool recalculate = true) { Pokemon pkm = await DataFetcher.GetApiObject <Pokemon>(number + 1); txtName.Text = pkm.Name; Random rng = new Random(); WebClient wc = new WebClient(); if (pkm.Sprites.FrontMale != null) { byte[] bytes = wc.DownloadData(pkm.Sprites.FrontMale); using (MemoryStream stream = new MemoryStream(bytes)) { pkm_img.Source = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); } } else if (pkm.Sprites.FrontFemale != null) { byte[] bytes = wc.DownloadData(pkm.Sprites.FrontFemale); using (MemoryStream stream = new MemoryStream(bytes)) { pkm_img.Source = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); } } if ((bool)gen12.IsChecked) { if (recalculate) { txtBox_level.Text = rng.Next(101).ToString(); txtAtk.Text = rng.Next(16).ToString(); txtDef.Text = rng.Next(16).ToString(); txtSpd.Text = rng.Next(16).ToString(); txtSpc.Text = rng.Next(16).ToString(); string str = ((int.Parse(txtAtk.Text) & 8) > 0 ? "1" : "0") + ((int.Parse(txtDef.Text) & 8) > 0 ? "1" : "0") + ((int.Parse(txtSpd.Text) & 8) > 0 ? "1" : "0") + ((int.Parse(txtSpc.Text) & 8) > 0 ? "1" : "0").ToString(); txtHp.Text = Convert.ToByte(str, 2).ToString(); txtAtk_ev.Text = rng.Next(65536).ToString(); txtDef_ev.Text = rng.Next(65536).ToString(); txtSpd_ev.Text = rng.Next(65536).ToString(); txtSpc_ev.Text = rng.Next(65536).ToString(); txtHp_ev.Text = rng.Next(65536).ToString(); } txtHp_stat.Text = Math.Floor((((((pkm.Stats[5].BaseValue + int.Parse(txtHp.Text)) * 2 + ((Math.Sqrt(double.Parse(txtHp_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + int.Parse(txtBox_level.Text) + 100)).ToString(); txtAtk_stat.Text = Math.Floor((((((pkm.Stats[4].BaseValue + int.Parse(txtAtk.Text)) * 2 + ((Math.Sqrt(double.Parse(txtAtk_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); txtDef_stat.Text = Math.Floor((((((pkm.Stats[3].BaseValue + int.Parse(txtDef.Text)) * 2 + ((Math.Sqrt(double.Parse(txtDef_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); txtSpd_stat.Text = Math.Floor((((((pkm.Stats[0].BaseValue + int.Parse(txtSpd.Text)) * 2 + ((Math.Sqrt(double.Parse(txtSpd_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); txtSpc_stat.Text = Math.Floor((((((pkm.Stats[2].BaseValue + int.Parse(txtSpc.Text)) * 2 + ((Math.Sqrt(double.Parse(txtSpc_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); } else { if (recalculate) { txtBox_level.Text = rng.Next(101).ToString(); txtAtk.Text = rng.Next(32).ToString(); txtDef.Text = rng.Next(32).ToString(); txtSpd.Text = rng.Next(32).ToString(); txtSpc.Text = rng.Next(32).ToString(); txtSpcDef.Text = rng.Next(32).ToString(); txtHp.Text = rng.Next(32).ToString(); int total_ev = 511; txtAtk_ev.Text = rng.Next(total_ev).ToString(); total_ev -= int.Parse(txtAtk_ev.Text); txtDef_ev.Text = rng.Next(total_ev).ToString(); total_ev -= int.Parse(txtDef_ev.Text); txtSpd_ev.Text = rng.Next(total_ev).ToString(); total_ev -= int.Parse(txtSpd_ev.Text); txtSpc_ev.Text = rng.Next(total_ev).ToString(); total_ev -= int.Parse(txtSpc_ev.Text); txtHp_ev.Text = rng.Next(total_ev).ToString(); total_ev -= int.Parse(txtHp_ev.Text); txtSpcDef_ev.Text = rng.Next(total_ev).ToString(); } txtHp_stat.Text = Math.Floor((((2 * pkm.Stats[5].BaseValue + int.Parse(txtHp.Text) + ((Math.Sqrt(double.Parse(txtHp_ev.Text))) / 4) * int.Parse(txtBox_level.Text)) / 100) + int.Parse(txtBox_level.Text) + 10)).ToString(); txtAtk_stat.Text = Math.Floor((((((pkm.Stats[4].BaseValue + int.Parse(txtAtk.Text)) * 2 + ((Math.Sqrt(double.Parse(txtAtk_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); txtDef_stat.Text = Math.Floor((((((pkm.Stats[3].BaseValue + int.Parse(txtDef.Text)) * 2 + ((Math.Sqrt(double.Parse(txtDef_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); txtSpd_stat.Text = Math.Floor((((((pkm.Stats[0].BaseValue + int.Parse(txtSpd.Text)) * 2 + ((Math.Sqrt(double.Parse(txtSpd_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); txtSpc_stat.Text = Math.Floor((((((pkm.Stats[2].BaseValue + int.Parse(txtSpc.Text)) * 2 + ((Math.Sqrt(double.Parse(txtSpc_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); txtSpcDef_stat.Text = Math.Floor((((((pkm.Stats[1].BaseValue + int.Parse(txtSpcDef.Text)) * 2 + ((Math.Sqrt(double.Parse(txtSpcDef_ev.Text))) / 4)) * int.Parse(txtBox_level.Text)) / 100) + 5)).ToString(); } //foreach (var attack in pkm.Moves) //{ // ComboBox1.Items.Add(attack.Move.Name); // moves.Add(attack.Move.Url); //} moves = new string[pkm.Moves.Length]; for (int i = 0; i < pkm.Moves.Length; i++) { ComboBox1.Items.Add(pkm.Moves[i].Move.Name); //moves.Add(); moves[i] = pkm.Moves[i].Move.Url.OriginalString.Substring(31); //moves.Add(Regex.Match(pkm.Moves[i].Move.Url.OriginalString, @"https://pokeapi.co/api/v2/move/([0-9]*)/").Groups[0].Captures[0].Value); } }
public async Task GetsAbility(int abilityID) { var t = DataFetcher.GetApiObject <Ability>(abilityID); Assert.NotNull(t); }
private IReadOnlyList <EvolvesTo> GetEvolutions() { var evolvesToList = new List <EvolvesTo>(); var evolutionChain = DataFetcher.GetApiObject <PokemonSpecies>(ID).Result.EvolutionChain.GetObject().Result; if (evolutionChain.Chain.EvolvesTo.Any()) { var chains = GetChains(evolutionChain.Chain); var chain = chains.FirstOrDefault(c => ID == c.Species.ID); foreach (var evolvesTo in chain.EvolvesTo) { var list = new List <EvolvesTo.IEvolutionCondition>(); foreach (var evolutionDetail in evolvesTo.Details) { var evolutionConditions = new List <EvolvesTo.ISubEvolutionCondition>(); if (evolutionDetail.MinLevel != null) { evolutionConditions.Add(new EvolvesTo.ByLevel((byte)evolutionDetail.MinLevel)); } if (evolutionDetail.MinHappiness != null) { evolutionConditions.Add(new EvolvesTo.ByHappiness((byte)evolutionDetail.MinHappiness.Value)); } if (evolutionDetail.MinAffection != null) { evolutionConditions.Add(new EvolvesTo.ByAffection((byte)evolutionDetail.MinAffection.Value)); } if (evolutionDetail.MinBeauty != null) { evolutionConditions.Add(new EvolvesTo.ByBeauty((byte)evolutionDetail.MinBeauty)); } if (evolutionDetail.KnownMove != null) { evolutionConditions.Add(new EvolvesTo.ByAttack(Cached <AttackStaticData> .Get((short)evolutionDetail.KnownMove.ID))); } if (evolutionDetail.KnownMoveType != null) { evolutionConditions.Add(new EvolvesTo.ByKnownAttackType(Cached <MonsterTypeStaticData> .Get((byte)evolutionDetail.KnownMoveType.ID))); } if (evolutionDetail.Item != null) { evolutionConditions.Add(new EvolvesTo.ByItem(Cached <ItemStaticData> .Get(evolutionDetail.Item.ID))); } if (evolutionDetail.HeldItem != null) { evolutionConditions.Add(new EvolvesTo.ByHeldItem(Cached <ItemStaticData> .Get(evolutionDetail.HeldItem.ID))); } if (evolutionDetail.Gender != null) { evolutionConditions.Add(new EvolvesTo.ByGender((BattleEngine.Monster.Enums.Gender)evolutionDetail.Gender)); } if (evolutionDetail.Location != null) { evolutionConditions.Add(new EvolvesTo.ByArea(null)); } if (evolutionDetail.NeedsOverworldRain) { evolutionConditions.Add(new EvolvesTo.ByWeather(Weather.Rain)); } if (evolutionDetail.PartySpecies != null) { evolutionConditions.Add(new EvolvesTo.ByMonsterInTeam((short)evolutionDetail.PartySpecies.ID)); } if (evolutionDetail.PartyType != null) { evolutionConditions.Add(new EvolvesTo.ByMonsterTypeInTeam(Cached <MonsterTypeStaticData> .Get((byte)evolutionDetail.PartySpecies.ID))); } if (evolutionDetail.TradeSpecies != null) { evolutionConditions.Add(new EvolvesTo.ByTradeMonster((short)evolutionDetail.TradeSpecies.ID)); } if (evolutionDetail.TurnUpsideDown) { evolutionConditions.Add(new ByTurnUpsideDown()); } if (!string.IsNullOrEmpty(evolutionDetail.TimeOfDay)) { if (Enum.TryParse(evolutionDetail.TimeOfDay, true, out EvolvesTo.ByTimeOfDay.TimeOfDay @enum)) { evolutionConditions.Add(new EvolvesTo.ByTimeOfDay(@enum)); } else { throw new Exception(); } } switch (evolutionDetail.Trigger.ID) { case 1: list.Add(new EvolvesTo.ByLevelUp(evolutionConditions)); break; case 2: list.Add(new EvolvesTo.ByTrade(evolutionConditions)); break; case 3: list.Add(new EvolvesTo.ByItemUse(evolutionConditions)); break; case 4: list.Add(new ByShed()); break; default: break; } } evolvesToList.Add(new EvolvesTo(Cached <MonsterStaticData> .Get((short)evolvesTo.Species.ID), list)); } } return(evolvesToList); }
public async Task GetsItem(int itemID) { var t = await DataFetcher.GetApiObject <Item>(itemID); Assert.NotNull(t); }
public async Task GetPokemon(int pokemonid, string group = null) => await SendPokemonAsync(await DataFetcher.GetApiObject <PokemonSpecies>(pokemonid).ConfigureAwait(false), group ?? "default").ConfigureAwait(false);
public async Task Purge(int ID) { IUserMessage msg = await Context.Channel.SendMessageAsync("Fetching Data..."); try { PokeAPI.Pokemon p = await DataFetcher.GetApiObject <PokeAPI.Pokemon>(ID); EmbedBuilder builder = new EmbedBuilder() { Title = "Pokemon Request by ID", Color = Color.DarkGreen, ThumbnailUrl = p.Sprites.FrontMale }; builder.Description = $"{FormatHelper.Capatalize(p.Name)} the {FormatHelper.Capatalize((await DataFetcher.GetApiObject<PokemonSpecies>(ID)).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 ID: " + ID); } }
public static async Task <Embed> GetEmbedAsync(this PokemonSpecies pokemon, PokemonDataGroup group) { if (pokemon == null) { return(null); } var poke = await DataFetcher.GetApiObject <Pokemon>(pokemon.ID).ConfigureAwait(false); var embed = new EmbedBuilder { Author = new EmbedAuthorBuilder { Name = $"{char.ToUpperInvariant(pokemon.Name[0])}{pokemon.Name.Substring(1)} - {pokemon.ID}" }, Color = Color.Blue }; var result = SkuldRandom.Next(0, 8193); string sprite = null; //if it equals 8 out of a random integer between 1 and 8192 then give shiny if (result == 8) { sprite = poke.Sprites.FrontShinyMale ?? poke.Sprites.FrontShinyFemale; } else { sprite = poke.Sprites.FrontMale ?? poke.Sprites.FrontFemale; } switch (group) { case PokemonDataGroup.Default: embed.AddInlineField("Height", poke.Height + "dm"); //embed.AddInlineField("Weight", poke.Weight + "hg"); embed.AddInlineField("Base Experience", $"{poke.BaseExperience}xp"); break; case PokemonDataGroup.Abilities: foreach (var ability in poke.Abilities) { embed.AddInlineField(ability.Ability.Name, "Slot: " + ability.Slot); } break; case PokemonDataGroup.Games: string games = null; foreach (var game in poke.GameIndices) { games += game.Version.Name + "\n"; if (game.GameIndex == poke.GameIndices.Last().GameIndex) { games += game.Version.Name; } } embed.AddInlineField("Game", games); break; case PokemonDataGroup.HeldItems: if (poke.HeldItems.Length > 0) { foreach (var hitem in poke.HeldItems) { foreach (var game in hitem.VersionDetails) { embed.AddInlineField("Item", hitem.Item.Name + "\n**Game**\n" + game.Version.Name + "\n**Rarity**\n" + game.Rarity); } } } else { embed.Description = "This pokemon doesn't hold any items in the wild"; } break; case PokemonDataGroup.Moves: var moves = poke.Moves.Take(4).Select(i => i).ToArray(); foreach (var move in moves) { string mve = move.Move.Name; mve += "\n**Learned at:**\n" + "Level " + move.VersionGroupDetails.FirstOrDefault().LearnedAt; mve += "\n**Method:**\n" + move.VersionGroupDetails.FirstOrDefault().LearnMethod.Name; embed.AddInlineField("Move", mve); } embed.Author.Url = "https://bulbapedia.bulbagarden.net/wiki/" + pokemon.Name + "_(Pokémon)"; embed.Footer = new EmbedFooterBuilder { Text = "Click the name to view more moves, I limited it to 4 to prevent a wall of text" }; break; case PokemonDataGroup.Stats: foreach (var stat in poke.Stats) { embed.AddInlineField(stat.Stat.Name, "Base Stat: " + stat.BaseValue); } break; } embed.ThumbnailUrl = sprite; return(embed.Build()); }