public async Task <ObservableCollection <PokemonForm> > LoadFormsAsync(SpeciesName species, GameVersion version, int displayLanguage, CancellationToken token) { try { string query = "SELECT pf.id, pfn.name FROM pokemon_v2_pokemonform pf\n" + "LEFT JOIN pokemon_v2_pokemon p ON pf.pokemon_id = p.id\n" + "LEFT JOIN\n(SELECT e.pokemon_form_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_pokemonformname e\n" + "LEFT OUTER JOIN pokemon_v2_pokemonformname o ON e.pokemon_form_id = o.pokemon_form_id and o.language_id = ?\n" + "WHERE e.language_id = 9\nGROUP BY e.pokemon_form_id)\nAS pfn ON pf.id = pfn.id\n" + "WHERE p.pokemon_species_id = ? AND pf.version_group_id <= ?"; IEnumerable <DbPokemonForm> forms = await _connection.QueryAsync <DbPokemonForm>(token, query, new object[] { displayLanguage, species.Id, version.VersionGroup }); return(new ObservableCollection <PokemonForm>(forms.Select((s) => { var f = new PokemonForm { Id = s.Id }; if (String.IsNullOrWhiteSpace(s.Name)) { f.Name = species.Name; } else { f.Name = s.Name; } return f; }))); } catch (Exception) { return(new ObservableCollection <PokemonForm>()); } }
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); Event.ConfigureForDatabase(builder); Region.ConfigureForDatabase(builder); LocationGroup.ConfigureForDatabase(builder); Location.ConfigureForDatabase(builder); BagCategory.ConfigureForDatabase(builder); Item.ConfigureForDatabase(builder); PlacedItem.ConfigureForDatabase(builder); Currency.ConfigureForDatabase(builder); CurrencyAmount.ConfigureForDatabase(builder); ElementalType.ConfigureForDatabase(builder); ElementalTypeRelation.ConfigureForDatabase(builder); Ability.ConfigureForDatabase(builder); PvpTier.ConfigureForDatabase(builder); PokemonAvailability.ConfigureForDatabase(builder); PokemonVarietyUrl.ConfigureForDatabase(builder); Entities.PokemonSpecies.ConfigureForDatabase(builder); PokemonVariety.ConfigureForDatabase(builder); PokemonForm.ConfigureForDatabase(builder); Evolution.ConfigureForDatabase(builder); MoveDamageClass.ConfigureForDatabase(builder); Move.ConfigureForDatabase(builder); MoveTutor.ConfigureForDatabase(builder); MoveTutorMove.ConfigureForDatabase(builder); MoveTutorMovePrice.ConfigureForDatabase(builder); MoveLearnMethod.ConfigureForDatabase(builder); MoveLearnMethodLocation.ConfigureForDatabase(builder); MoveLearnMethodLocationPrice.ConfigureForDatabase(builder); LearnableMove.ConfigureForDatabase(builder); LearnableMoveLearnMethod.ConfigureForDatabase(builder); TimeOfDay.ConfigureForDatabase(builder); Season.ConfigureForDatabase(builder); SeasonTimeOfDay.ConfigureForDatabase(builder); SpawnType.ConfigureForDatabase(builder); Spawn.ConfigureForDatabase(builder); SpawnOpportunity.ConfigureForDatabase(builder); Nature.ConfigureForDatabase(builder); HuntingConfiguration.ConfigureForDatabase(builder); Build.ConfigureForDatabase(builder); ItemOption.ConfigureForDatabase(builder); MoveOption.ConfigureForDatabase(builder); NatureOption.ConfigureForDatabase(builder); ItemStatBoost.ConfigureForDatabase(builder); Entities.ItemStatBoostPokemon.ConfigureForDatabase(builder); ImportSheet.ConfigureForDatabase(builder); }
public async Task GetPokemonFormResourceAsyncIntegrationTest() { // assemble PokeApiClient client = new PokeApiClient(); // act PokemonForm pokemonForm = await client.GetResourceAsync <PokemonForm>(1); // assert Assert.True(pokemonForm.Id != default(int)); }
public void Transform(OnboardPokemon op) { //形态(包括种族值)、能力值、能力等级、属性、特性、技能等变为与对方怪兽一样。 Form = op.Form; FiveD.Set5D(op.FiveD); lv5D.Set5D(op.lv5D); Gender = op.Gender; _accuracyLv = op._accuracyLv; _evasionLv = op._evasionLv; Type1 = op.Type1;//无视羽休 Type2 = op.Type2; Ability = op.Ability; _weight = op.Weight; }
// Gets a mon's id, name and sprite URL public static async Task <(int, string, string)> GetMonInfo(string nameOrId) { PokeApiClient pokeClient = new PokeApiClient(); int id; string name; string spriteUrl = null; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; Pokemon mon; if (int.TryParse(nameOrId, out id)) { mon = await pokeClient.GetResourceAsync <Pokemon>(id); } else { name = nameOrId.ToLower(); if (GetEggs().ContainsKey(name)) { (id, spriteUrl) = GetEggs()[name]; return(id, textInfo.ToTitleCase(name), spriteUrl); } else { name = GetCorrectName(name); mon = await pokeClient.GetResourceAsync <Pokemon>(name); } } try { string url = mon.Forms[0].Url; string[] urlSplit = url.Split('/'); int formNumber = int.Parse(urlSplit[urlSplit.Length - 2]); PokemonForm form = await pokeClient.GetResourceAsync <PokemonForm>(formNumber); spriteUrl = form.Sprites.FrontDefault; } catch (Exception e) { // Do not error on missing sprite } return(mon.Id, textInfo.ToTitleCase(mon.Name), spriteUrl); }
public static BitmapImage GetPokemonIcon(PokemonForm form, PokemonGender gender) { int n = form.Species.Number, f = form.Index; BitmapImage r; if (gender == PokemonGender.Female && (n == 521 || n == 592 || n == 593 || n == 668)) { r = GetImage("icon", n.ToString("000") + ".99"); } else if (f == 0 || n == 493 || n == 649 || n == 710 || n == 711 || n == 773) //arceus/genesect/pumpkaboo/gourgeist { if (icons[n] == null) { icons[n] = GetImage("icon", n.ToString("000") + ".00"); } r = icons[n]; } else { r = GetImage("icon", string.Format("{0:000}.{1:00}", n, f)); } return(r); }
public void ChangeForm(PokemonForm form) { Form = form; _weight = form.Data.Weight; SetTypes(form.Type1, form.Type2); Ability = form.Data.GetAbility(Pokemon.AbilityIndex); FiveD.Atk = Get5D(StatType.Atk); FiveD.SpAtk = Get5D(StatType.SpAtk); FiveD.Speed = Get5D(StatType.Speed); var d = Get5D(StatType.Def); var sd = Get5D(StatType.SpDef); if (HasCondition(Cs.WonderRoom)) { FiveD.Def = sd; FiveD.SpDef = d; } else { FiveD.Def = d; FiveD.SpDef = sd; } }
public async Task <PokemonForm> LoadPokemonFormByIdAsync(int id, GameVersion version, int language, CancellationToken token) { try { string query = Queries.PokemonFormByIdQuery(id, version.Id, version.VersionGroup, version.Generation, language); IEnumerable <DbForm> forms = await _connection.QueryAsync <DbForm>(token, query, new object[0]).ConfigureAwait(false); DbForm form = forms.Single(); var result = new PokemonForm { BaseExperience = form.BaseExperience, BaseHappiness = form.BaseHappiness, CaptureRate = form.CaptureRate, Color = new PokemonColor { Id = form.ColorId, Name = form.ColorName }, Genus = form.Genus, GrowthRate = new ModelNameBase { Id = form.GrowthRateId, Name = form.GrowthRateName }, Habitat = new ModelNameBase { Id = form.Habitat, Name = form.HabitatName }, HatchCounter = form.HatchCounter, Height = form.Height, Id = form.Id, IsBaby = form.IsBaby, ItemRarity = form.ItemRarity, Name = form.Name, Shape = new ModelUriBase { Id = form.ShapeId, Name = form.ShapeName }, Species = new ModelNameBase { Id = form.SpeciesId }, Weight = form.Weight }; result.Type1 = await GetTypeById(form.Type1Id, version.Generation); if (form.Type2Id != null) { result.Type2 = await GetTypeById((int)form.Type2Id, version.Generation); } if (form.PokedexId != null) { result.DexEntry = new PokedexEntry { DexNumber = form.PokedexNumber, Id = (int)form.PokedexId, Name = form.PokedexName } } ; if (version.Generation >= 2 && form.ItemId != null) { result.HeldItem = new ModelNameBase { Id = (int)form.ItemId, Name = form.ItemName } } ; if (version.Generation >= 3) { result.Ability1 = new ModelNameBase { Id = form.Ability1Id, Name = form.Ability1Name }; if (form.Ability2Id != null && !String.IsNullOrWhiteSpace(form.Ability2Name)) { result.Ability2 = new ModelNameBase { Id = (int)form.Ability2Id, Name = form.Ability2Name } } ; } if (version.Generation >= 5) { if (form.HiddenAbility != null && !String.IsNullOrWhiteSpace(form.HiddenAbilityName)) { result.HiddenAbility = new ModelNameBase { Id = (int)form.HiddenAbility, Name = form.HiddenAbilityName } } ; } return(result); } catch (Exception) { return(null); } }
public static BitmapImage GetPokemonBack(PokemonForm form, PokemonGender gender, bool shiny) { return(GetPokemonImage("back", form, gender, shiny)); }
public static BitmapImage GetPokemonFront(PokemonForm form, PokemonGender gender, bool shiny) { return(GetPokemonImage("front", form, gender, shiny)); }
private static BitmapImage GetPokemonImage(string category, PokemonForm form, PokemonGender gender, bool shiny) { var path = /*shiny ? "shiny/" : */ "normal/" + category; return(GetImage(path, form.Species.Number, form.Index, gender == PokemonGender.Female)); }
public async Task <PokemonForm> LoadFormAsync(int formId, GameVersion version, int displayLanguage, CancellationToken token) { try { string query = "SELECT pf.id, pf.pokemon_id, p.pokemon_species_id, pfn.name, p.height, p.weight, p.base_experience, pt1.type_id AS type1, pt2.type_id AS type2, " + "pa1.ability_id AS ability1, pa2.ability_id AS ability2, pa3.ability_id AS hidden_ability, pi.rarity, pi.item_id FROM pokemon_v2_pokemonform pf\n" + "LEFT JOIN\n(SELECT e.pokemon_form_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_pokemonformname e\n" + "LEFT OUTER JOIN pokemon_v2_pokemonformname o ON e.pokemon_form_id = o.pokemon_form_id and o.language_id = ?\n" + "WHERE e.language_id = 9\nGROUP BY e.pokemon_form_id)\nAS pfn ON pf.id = pfn.id\n" + "LEFT JOIN pokemon_v2_pokemon p ON pf.pokemon_id = p.id\n" + "LEFT JOIN pokemon_v2_pokemontype AS pt1 ON p.id = pt1.pokemon_id AND pt1.slot = 1\n" + "LEFT JOIN pokemon_v2_pokemontype AS pt2 ON p.id = pt2.pokemon_id AND pt2.slot = 2\n" + "LEFT JOIN pokemon_v2_pokemonability AS pa1 ON p.id = pa1.pokemon_id AND pa1.slot = 1\n" + "LEFT JOIN pokemon_v2_pokemonability AS pa2 ON p.id = pa2.pokemon_id AND pa2.slot = 2\n" + "LEFT JOIN pokemon_v2_pokemonability AS pa3 ON p.id = pa3.pokemon_id AND pa3.slot = 3\n" + "LEFT JOIN pokemon_v2_pokemonitem AS pi ON p.id = pi.pokemon_id AND pi.version_id = ?\n" + "WHERE pf.id = ?"; IEnumerable <DbPokemonForm> forms = await _connection.QueryAsync <DbPokemonForm>(token, query, new object[] { displayLanguage, version.Id, formId }); DbPokemonForm f = forms.First(); var form = new PokemonForm { BaseExperience = f.BaseExperience, Height = Math.Round((double)f.Height / 10, 2), HeldItemRarity = f.ItemRarity, Id = f.Id, Weight = Math.Round((double)f.Weight / 10, 2) }; form.Species = await LoadSpeciesAsync(f.PokemonSpeciesId, version, displayLanguage, token); if (String.IsNullOrWhiteSpace(f.Name)) { form.Name = form.Species.Name; } else { form.Name = f.Name; } // Handle Fairy before Gen 6 if (version.Generation < 6 && f.Type1 == 18) { f.Type1 = 1; } form.Type1 = await GetTypeAsync(f.Type1, version); if (f.Type2 != null) { form.Type2 = await GetTypeAsync((int)f.Type2, version); } if (version.Generation >= 3) { //form.Ability1 = await LoadAbilityAsync(f.Ability1, version, displayLanguage, token); //if (f.Ability2 != null) // form.Ability2 = await LoadAbilityAsync((int)f.Ability2, version, displayLanguage, token); //if (version.Generation >= 5 && f.HiddenAbility != null) // form.HiddenAbility = await LoadAbilityAsync((int)f.HiddenAbility, version, displayLanguage, token); } if (f.ItemId != null) { form.HeldItem = await LoadItemAsync((int)f.ItemId, displayLanguage, token); } //form.Stats = await LoadPokemonStatsAsync(f.PokemonId, version, displayLanguage, token); return(form); } catch (Exception) { return(null); } }
public async Task <PokemonForm> LoadFormByIdAsync(int id, GameVersion version, int language, CancellationToken token) { try { string query = String.Format(@" SELECT pf.id, pf.pokemon_id, p.species_id, pfn.name, p.height, p.weight, p.base_experience, pt1.type_id AS type1, pt2.type_id AS type2, pa1.ability_id AS ability1, pa2.ability_id AS ability2, pa3.ability_id AS hidden_ability, pi.rarity, pi.item_id FROM pokemon_forms pf LEFT JOIN (SELECT e.pokemon_form_id AS id, COALESCE(o.form_name, e.form_name) AS name FROM pokemon_form_names e LEFT OUTER JOIN pokemon_form_names o ON e.pokemon_form_id = o.pokemon_form_id and o.local_language_id = {0} WHERE e.local_language_id = 9 GROUP BY e.pokemon_form_id) AS pfn ON pf.id = pfn.id LEFT JOIN pokemon p ON pf.pokemon_id = p.id LEFT JOIN pokemon_types AS pt1 ON p.id = pt1.pokemon_id AND pt1.slot = 1 LEFT JOIN pokemon_types AS pt2 ON p.id = pt2.pokemon_id AND pt2.slot = 2 LEFT JOIN pokemon_abilities AS pa1 ON p.id = pa1.pokemon_id AND pa1.slot = 1 LEFT JOIN pokemon_abilities AS pa2 ON p.id = pa2.pokemon_id AND pa2.slot = 2 LEFT JOIN pokemon_abilities AS pa3 ON p.id = pa3.pokemon_id AND pa3.slot = 3 LEFT JOIN pokemon_items AS pi ON p.id = pi.pokemon_id AND pi.version_id = {1} WHERE pf.id = {2} ", language, version.Id, id); IEnumerable <DbPokemonForm> forms = await _connection.QueryAsync <DbPokemonForm>(token, query, new object[0]).ConfigureAwait(false); DbPokemonForm f = forms.Single(); // Handle Fairy Type before gen 6 if (version.Generation < 6 && f.Type1 == 18) { f.Type1 = 1; } Task <ElementType> type1Task = GetTypeAsync(f.Type1, version); Task <ElementType> type2Task = null; Task <Item> itemTask = null; Task <Ability> ability1Task = null; Task <Ability> ability2Task = null; Task <Ability> hiddenAbilityTask = null; var tasks = new List <Task> { type1Task, type2Task, itemTask, ability1Task, ability2Task, hiddenAbilityTask }; if (f.Type2 != null) { type2Task = GetTypeAsync((int)f.Type2, version); } if (version.Generation >= 2 && f.ItemId != null) { itemTask = LoadItemByIdAsync((int)f.ItemId, language, token); } if (version.Generation >= 3) { ability1Task = LoadAbilityByIdAsync(f.Ability1, version, language, token); if (f.Ability2 != null) { ability2Task = LoadAbilityByIdAsync((int)f.Ability2, version, language, token); } } if (version.Generation >= 5 && f.HiddenAbility != null) { hiddenAbilityTask = LoadAbilityByIdAsync((int)f.HiddenAbility, version, language, token); } var form = new PokemonForm { BaseExperience = f.BaseExperience, Height = Math.Round((double)f.Height / 10, 2), HeldItemRarity = f.ItemRarity, Id = f.Id, Weight = Math.Round((double)f.Weight / 10, 2) }; //form.Species = await LoadSpeciesAsync(f.PokemonSpeciesId, version, displayLanguage, token); //if (String.IsNullOrWhiteSpace(f.Name)) // form.Name = form.Species.Name; //else // form.Name = f.Name; await Task.WhenAll(tasks.Where(w => w != null)); form.Type1 = type1Task.Result; if (type2Task != null) { form.Type2 = type2Task.Result; } if (itemTask != null) { form.HeldItem = itemTask.Result; } if (ability1Task != null) { form.Ability1 = ability1Task.Result; } if (ability2Task != null) { form.Ability2 = ability2Task.Result; } if (hiddenAbilityTask != null) { form.HiddenAbility = hiddenAbilityTask.Result; } //form.Type1 = await GetTypeAsync(f.Type1, version); //if (f.Type2 != null) // form.Type2 = await GetTypeAsync((int)f.Type2, version); //if (f.ItemId != null) // form.HeldItem = await LoadItemByIdAsync((int)f.ItemId, language, token); //if (version.Generation >= 3) //{ // form.Ability1 = await LoadAbilityByIdAsync(f.Ability1, version, language, token); // if (f.Ability2 != null) // form.Ability2 = await LoadAbilityByIdAsync((int)f.Ability2, version, language, token); //} //if (version.Generation >= 5 && f.HiddenAbility != null) // form.HiddenAbility = await LoadAbilityByIdAsync((int)f.HiddenAbility, version, language, token); return(form); } catch (Exception) { return(null); } }