private async void LoadPokemonEvoInfos() { Pokemon pokemonInfo; EvolutionChain evoChain = await pokeClient.GetResourceAsync <EvolutionChain>(evoId); EvoOneList.Clear(); PokeImageBasis = null; PokeImageEvoOne = null; PokeImageEvoTwo = null; try { BasisHeader = EvolutionLanguage.GetBasisHeader(_language); PokemonSpecies pokemonBasis = await pokeClient.GetResourceAsync <PokemonSpecies>(evoChain.Chain.Species.Name); var tempBasis = _pokeList.First(x => x.PokeNameOriginal == pokemonBasis.Name).PokeName; PokemonBasisName = tempBasis; pokemonInfo = await pokeClient.GetResourceAsync <Pokemon>(pokemonBasis.Id); PokeImageBasis = await LoadPokemonEvoPic(pokemonInfo); } catch { PokemonBasisName = ""; } try { // Some Pokemons have more then one first evolution! // So we load allways in a List for (int i = 0; i < evoChain.Chain.EvolvesTo.Count; i++) { PokemonSpecies pokemonEvoOne = await pokeClient.GetResourceAsync <PokemonSpecies>(evoChain.Chain.EvolvesTo[i].Species.Name); var tempEvoOne = _pokeList.First(x => x.PokeNameOriginal == pokemonEvoOne.Name).PokeName; PokemonEvoOneName = tempEvoOne; pokemonInfo = await pokeClient.GetResourceAsync <Pokemon>(pokemonEvoOne.Id); PokeImageEvoOne = await LoadPokemonEvoPic(pokemonInfo); EvoOneList.Add(new EvolutionModel { Name = PokemonEvoOneName, EvoImage = PokeImageEvoOne } ); } if (EvoOneList.Count > 0) { EvoOneHeader = EvolutionLanguage.GetEvoOneHeader(_language); } } catch { PokemonEvoOneName = ""; } try { PokemonSpecies pokemonEvoTwo = await pokeClient.GetResourceAsync <PokemonSpecies>(evoChain.Chain.EvolvesTo[0].EvolvesTo[0].Species.Name); var tempEvoTwo = _pokeList.First(x => x.PokeNameOriginal == pokemonEvoTwo.Name).PokeName; EvoTwoHeader = EvolutionLanguage.GetEvoTwoHeader(_language); PokemonEvoTwoName = tempEvoTwo; pokemonInfo = await pokeClient.GetResourceAsync <Pokemon>(pokemonEvoTwo.Id); PokeImageEvoTwo = await LoadPokemonEvoPic(pokemonInfo); } catch { PokemonEvoTwoName = ""; } NotifyOfPropertyChange(() => BasisHeader); NotifyOfPropertyChange(() => PokemonBasisName); NotifyOfPropertyChange(() => PokeImageBasis); NotifyOfPropertyChange(() => EvoOneHeader); NotifyOfPropertyChange(() => EvoTwoHeader); NotifyOfPropertyChange(() => PokemonEvoTwoName); NotifyOfPropertyChange(() => PokeImageEvoTwo); ShowEvoOne(); CompareSelectedPokemon(); }
public MegaEvolution(PokemonSpecies Species, MegaStone MegaStone) { this.Species = Species; this.MegaStone = MegaStone; }
public static string GetDescription(PokemonSpecies species) { return(species.FlavorTexts.First(text => text.Language.Name == "en").FlavorText.Replace("\n", " ")); }
private string GetEventDescription(SerializedProperty currentSEvent) { SetEventProps(currentSEvent); //add more details according to which type of event it is CustomEventDetails.CustomEventType ty = (CustomEventDetails.CustomEventType)eventType_Prop.enumValueIndex; //set the event description to be the enum name string eventDescription = ty.ToString(); switch (ty) { case CustomEventDetails.CustomEventType.Walk: eventDescription = (bool0_Prop.boolValue) ? "Move " : "Walk "; eventDescription += (object0_Prop.objectReferenceValue != null) ? "\"" + object0_Prop.objectReferenceValue.name + "\" " : "\"null\" "; eventDescription += dir_Prop.enumDisplayNames[dir_Prop.enumValueIndex].ToLowerInvariant() + " " + int0_Prop.intValue + " spaces."; break; case CustomEventDetails.CustomEventType.TurnTo: int turns = int0_Prop.intValue; while (turns > 3) { turns -= 4; } while (turns < 0) { turns += 4; } eventDescription = (object0_Prop.objectReferenceValue != null) ? "Turn \"" + object0_Prop.objectReferenceValue.name + "\"" : "Turn \"null\""; if (object1_Prop.objectReferenceValue != null) { eventDescription += " towards \"" + object1_Prop.objectReferenceValue.name + "\""; if (turns != 0) { eventDescription += ", then"; } } switch (turns) { case 1: eventDescription += " clockwise."; break; case 2: eventDescription += " around."; break; case 3: eventDescription += " counter clockwise."; break; } break; case CustomEventDetails.CustomEventType.Wait: eventDescription = "Wait " + float0_Prop.floatValue + " seconds."; break; case CustomEventDetails.CustomEventType.Dialog: if (strings_Prop.arraySize > 0) { //check for invalid values before attempting to use any. if (strings_Prop.GetArrayElementAtIndex(0).stringValue != null) { if (strings_Prop.GetArrayElementAtIndex(0).stringValue.Length <= 32) { eventDescription = "\"" + strings_Prop.GetArrayElementAtIndex(0).stringValue + "\""; } else { eventDescription = "\"" + strings_Prop.GetArrayElementAtIndex(0).stringValue.Substring(0, 32) + "... \""; } } } break; case CustomEventDetails.CustomEventType.Choice: eventDescription = "Choices: "; int i = 0; while (eventDescription.Length < 32 && i < strings_Prop.arraySize) { if (strings_Prop.GetArrayElementAtIndex(i).stringValue != null) { eventDescription += strings_Prop.GetArrayElementAtIndex(i).stringValue; if (i + 1 < strings_Prop.arraySize) { eventDescription += ", "; } } i += 1; } if (eventDescription.Length > 32) { eventDescription = eventDescription.Substring(0, 32) + "..."; } break; case CustomEventDetails.CustomEventType.ReceivePokemon: eventDescription = "Receive a Lv. " + ints_Prop.GetArrayElementAtIndex(1).intValue + " \""; // ToDo: change this ints_Prop for string_Prop ? PokemonSpecies pkmn = GameController.Instance.PokemonDb.GetPokemonSpeciesByGameId(ints_Prop.GetArrayElementAtIndex(0).intValue.ToString()); eventDescription += (pkmn != null) ? pkmn.Name : "null"; eventDescription += "\" or Jump to " + int0_Prop.intValue + "."; break; case CustomEventDetails.CustomEventType.LogicCheck: CustomEventDetails.Logic lo = (CustomEventDetails.Logic)logic_Prop.enumValueIndex; if (lo == CustomEventDetails.Logic.CVariableEquals) { eventDescription = "If \"" + string0_Prop.stringValue + "\" == " + float0_Prop.floatValue + ", Jump to " + int0_Prop.intValue + "."; } else if (lo == CustomEventDetails.Logic.CVariableGreaterThan) { eventDescription = "If \"" + string0_Prop.stringValue + "\" > " + float0_Prop.floatValue + ", Jump to " + int0_Prop.intValue + "."; } else if (lo == CustomEventDetails.Logic.CVariableLessThan) { eventDescription = "If \"" + string0_Prop.stringValue + "\" < " + float0_Prop.floatValue + ", Jump to " + int0_Prop.intValue + "."; } //Boolean Logic Checks else if (lo == CustomEventDetails.Logic.SpaceInParty) { eventDescription = (bool0_Prop.boolValue) ? "If NOT " : "If "; eventDescription += logic_Prop.enumDisplayNames[logic_Prop.enumValueIndex] + ", Jump to " + int0_Prop.intValue + "."; } else { eventDescription = "If " + float0_Prop.floatValue + " " + logic_Prop.enumDisplayNames[logic_Prop.enumValueIndex] + ", Jump to " + int0_Prop.intValue + "."; } break; case CustomEventDetails.CustomEventType.SetCVariable: eventDescription = "Set C Variable \"" + string0_Prop.stringValue + "\" to " + float0_Prop.floatValue + "."; break; case CustomEventDetails.CustomEventType.SetActive: eventDescription = (bool0_Prop.boolValue) ? "Activate \"" : "Deactivate \""; eventDescription += (object0_Prop.objectReferenceValue != null) ? object0_Prop.objectReferenceValue.name + "\"" : "null\""; break; case CustomEventDetails.CustomEventType.Sound: eventDescription = "Play sound: \""; eventDescription += (sound_Prop.objectReferenceValue != null) ? sound_Prop.objectReferenceValue.name + "\"" : "null\""; break; case CustomEventDetails.CustomEventType.ReceiveItem: eventDescription = "Receive " + int0_Prop.intValue + " x \"" + string0_Prop.stringValue + "\""; break; case CustomEventDetails.CustomEventType.TrainerBattle: eventDescription = "Battle with "; eventDescription += (object0_Prop.objectReferenceValue != null) ? object0_Prop.objectReferenceValue.name + "\"" : "null\""; if (bool0_Prop.boolValue) { eventDescription += ", Jump To " + int0_Prop.intValue + " on Loss"; } break; } return(eventDescription); }
private IEnumerator AnimationCoroutine() { evolutionCanBeCancelled = true; evolutionHasBeenCancelled = false; EvolutionAnimationComplete = null; float musicInitialVolume = MusicSourceController.singleton.GetVolume(); MusicSourceController.singleton.SetVolume(musicVolume); Sprite startSprite = entranceArguments.PokemonSprite; PokemonSpecies endSpecies = PokemonSpecies.GetPokemonSpeciesById(entranceArguments.evolution.targetId); Sprite endSprite = endSpecies.LoadSprite(PokemonSpecies.SpriteType.Front1, entranceArguments.pokemon.gender, entranceArguments.pokemon.IsShiny); pokemonSpriteController.SetSprite(startSprite); yield return(new WaitForSeconds(initialPauseTime)); SoundFXController.singleton.PlayPokemonCry(entranceArguments.pokemon.speciesId); for (byte i = 0; i < bounceCount; i++) { yield return(StartCoroutine(Animation_Bounce(pokemonSpriteController.pokemonSpriteObject, bounceHeight, bounceSingleTime))); } yield return(new WaitForSeconds(bounceToShrinkDelayTime)); yield return(StartCoroutine(GradualEffect((t) => { pokemonSpriteController.SetScale(1 - t); pokemonSpriteController.SetWhiteness(t); }, shrinkTime))); if (!evolutionHasBeenCancelled) { pokemonSpriteController.SetSprite(endSprite); } evolutionCanBeCancelled = false; //Once sprite has been changed, evolution can't be cancelled yield return(StartCoroutine(GradualEffect((t) => { pokemonSpriteController.SetScale(t); pokemonSpriteController.SetWhiteness(1 - t); }, unshrinkTime))); if (!evolutionHasBeenCancelled) { //Evolution is allowed to be completed SoundFXController.singleton.PlaySound("evolution_end"); SoundFXController.singleton.PlayPokemonCry(endSpecies.id); yield return(StartCoroutine( textBoxController.RevealText(entranceArguments.pokemon.GetDisplayName() + " evolved into a " + endSpecies.name + '!', true) )); //Once animation is completed, evolve the pokemon entranceArguments.pokemon.Evolve(entranceArguments.evolution); } else { //Evolution is cancelled yield return(StartCoroutine( textBoxController.RevealText("Oh, " + entranceArguments.pokemon.GetDisplayName() + " stopped evolving", true) )); } yield return(new WaitForSeconds(endDelayTime)); MusicSourceController.singleton.SetVolume(musicInitialVolume); EvolutionAnimationComplete?.Invoke(); yield break; }
public async Task <ActionResult <DetailedPokemonData> > GetPokemonData(string pokemonName) { DetailedPokemonData cacheValue; //LOOK FOR CACHE KEY. if (!_cache.TryGetValue <DetailedPokemonData>(pokemonName, out cacheValue)) { // Key not in cache, so get data. if (pokemonName == null) { return(BadRequest()); } DetailedPokemonData pokeData = new DetailedPokemonData { EvolutionsNames = new List <string>() }; try { var pokemonData = await pokeClient.GetResourceAsync <Pokemon>(pokemonName); if (pokemonData == null) { return(NotFound()); } PokemonSpecies PokemonSpecies = await pokeClient.GetResourceAsync(pokemonData.Species); if (PokemonSpecies == null) { return(NotFound()); } var queryEngDescription = PokemonSpecies.FlavorTextEntries.First(result => result.Language.Name == "en"); pokeData.Description = queryEngDescription.FlavorText.Replace('\n', ' '); var evolutionChainUrl = PokemonSpecies.EvolutionChain.Url; var evolutionChainID = Int32.Parse(evolutionChainUrl.Split("/")[6]); EvolutionChain evolutionChain = await pokeClient.GetResourceAsync <EvolutionChain>(evolutionChainID); if (evolutionChain == null) { return(NotFound()); } var basePokemon = evolutionChain.Chain.Species.Name; pokeData.EvolutionsNames.Add(basePokemon); try { var FirstLevelEvolution = evolutionChain.Chain.EvolvesTo.Select(x => x.Species.Name); pokeData.EvolutionsNames.AddRange(FirstLevelEvolution); var secondLevelEvolution = evolutionChain.Chain.EvolvesTo[0].EvolvesTo.Select(x => x.Species.Name); pokeData.EvolutionsNames.AddRange(secondLevelEvolution); } catch { System.Diagnostics.Debug.Write("No evolutions for this pokemon"); } cacheValue = pokeData; } catch (Exception) { return(BadRequest()); } //Cache expiration in 3 minutes var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromMinutes(3)); // Save values in cache for a given key. _cache.Set <DetailedPokemonData>(pokemonName, cacheValue, cacheEntryOptions); } return(Ok(cacheValue)); }
public static float CalculateMultiplier(Type attackerType, PokemonSpecies defenderSpecies) { return(defenderSpecies.type2 == null ? CalculateMultiplier(attackerType, defenderSpecies.type1) : CalculateMultiplier(attackerType, defenderSpecies.type1, (Type)defenderSpecies.type2)); }
public async Task <IActionResult> SpecyById(int id) { PokemonSpecies s = await _pokeClient.GetResourceAsync <PokemonSpecies>(id); return(Ok(s)); }
public override void OnInspectorGUI() { PokemonSpecies ps = (PokemonSpecies)target; GUILayout.Label("Pokemon Info", EditorStyles.boldLabel); GUILayout.Space(5); ps.pokemonName = EditorGUILayout.TextField("Pokemon Name: ", ps.pokemonName); ps.index = EditorGUILayout.IntField("Index: ", ps.index); ps.dexnum = EditorGUILayout.IntField("Dex Number: ", ps.dexnum); ps.height = EditorGUILayout.FloatField("Height: ", ps.height); ps.weight = EditorGUILayout.FloatField("Weight: ", ps.weight); GUILayout.Space(15); GUILayout.Label("Types", EditorStyles.boldLabel); GUILayout.Space(5); ps.type1 = (Type)EditorGUILayout.ObjectField("Type 1", ps.type1, typeof(Type), false); ps.type2 = (Type)EditorGUILayout.ObjectField("Type 2", ps.type2, typeof(Type), false); GUILayout.BeginHorizontal(); if (GUILayout.Button("Find Type 1")) { EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GetAssetPath(ps.type1))); } if (ps.type2 != null) { if (GUILayout.Button("Find Type 2")) { EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GetAssetPath(ps.type2))); } } GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.Label("Stats", EditorStyles.boldLabel); GUILayout.Space(5); ps.statsBase[0] = EditorGUILayout.IntField("HP: ", ps.statsBase[0]); ps.statsBase[1] = EditorGUILayout.IntField("Attack: ", ps.statsBase[1]); ps.statsBase[2] = EditorGUILayout.IntField("Defense: ", ps.statsBase[2]); ps.statsBase[3] = EditorGUILayout.IntField("Sp. Attack: ", ps.statsBase[3]); ps.statsBase[4] = EditorGUILayout.IntField("Sp. Defense: ", ps.statsBase[4]); ps.statsBase[5] = EditorGUILayout.IntField("Speed: ", ps.statsBase[5]); GUILayout.Space(15); GUILayout.Label("Sprites", EditorStyles.boldLabel); GUILayout.Space(5); ps.frontSprite = (Texture2D)EditorGUILayout.ObjectField("Front: ", ps.frontSprite, typeof(Texture2D), false); ps.backSprite = (Texture2D)EditorGUILayout.ObjectField("Back: ", ps.backSprite, typeof(Texture2D), false); ps.miniSprite = (Texture2D)EditorGUILayout.ObjectField("Mini: ", ps.miniSprite, typeof(Texture2D), false); EditorUtility.SetDirty(ps); }
// mapper that uses Pokemon, Pokemon species and Smogon data to get relevant data private async Task <PokemonInformation> PokemonInformationMapperAsync(Pokemon pokemon, PokemonSpecies pokemonSpecies, List <SmogonAnalyse> analysis) { return(new PokemonInformation { Name = pokemon.Name, AllAbilities = pokemon.Abilities, BaseExperience = pokemon.BaseExperience, BaseStats = pokemon.Stats.ConvertToBaseStats(), PrimaryType = await pokemon.Types.First().Type.GetObject(), SecondaryType = await pokemon.Types.LastOrDefault().Type.GetObject(), EvolutionChain = await pokemonSpecies.EvolutionChain.GetObject(), Generation = await pokemonSpecies.Generation.GetObject(), HatchCounter = pokemonSpecies.HatchCounter, FemaleToMaleRate = pokemonSpecies.FemaleToMaleRate, EggGroup = await Task.WhenAll(pokemonSpecies.EggGroups.Select(group => group.GetObject())), PokemonColours = await pokemonSpecies.Colours.GetObject(), SmogonAnalysisList = analysis }); }
private async Task <PokemonInformation> GetSmogonInformationAndMergeItAsync(string pokemonName, PokemonSpecies pokemonSpecies, Pokemon pokemon) { _logger.LogInformation($"Gethering data for {pokemonName}"); // make an URL for smogon Sword and Shield data string url = $"{_smogonSwordAndShieldPath}+{pokemonName}"; _logger.LogDebug($"Getting smogon competitive sugestion from:\n{url}"); // get the essencial of HTML string headlineText = await ExtractAndParseSmogonData(url); // transform the string containing the JSON into a JObject JObject jsonFromHtml = JObject.Parse(headlineText); // get the strategies part of the json recursively List <JToken> resultList = new List <JToken>(); FindPropertyInJToken(jsonFromHtml, "strategies", resultList); // get contents and transform them into custom c# objects var strategiesContent = resultList.FirstOrDefault()?.Children <JObject>() ?? throw new NoSmogonDataException($"No smogon data for Sword and Shield for pokemon {pokemonName}"); if (strategiesContent.Count() == 0) { throw new NoSmogonDataException($"No smogon data for Sword and Shield for pokemon {pokemonName}"); } List <SmogonAnalyse> result = strategiesContent.Select(p => JsonConvert.DeserializeObject <SmogonAnalyse>(p.ToString())).ToList(); // merge the information return(await PokemonInformationMapperAsync(pokemon, pokemonSpecies, result)); }
public void Map_Null_ThrowsArgumentNullException() { PokemonSpecies pokemonSpecies = null; Assert.ThrowsException <ArgumentNullException>(() => _mapper.Map(pokemonSpecies)); }
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()); }