Пример #1
0
 protected override void ChangeVersion(GameVersion newVersion)
 {
     SelectedAbility = null;
     base.ChangeVersion(newVersion);
     if (newVersion != null)
         Abilities = NotifyTaskCompletionCollection<Ability>.Create(LoadAbilitiesAsync(CurrentVersion.VersionGroup, CurrentLanguage), _cachedAbilityId);
     //SelectedAbilityChanged(this, new SelectedItemChangedEventArgs<Ability>(null, new Ability { Id = _cachedAbilityId }));
 }
Пример #2
0
 public Task<ObservableCollection<PokemonMove>> LoadMoveSetAsync(int pokemonId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<ObservableCollection<PokemonMove>>();
     tcs.SetResult(new ObservableCollection<PokemonMove>
     {
         new PokemonMove
         {
             LearnMethod = new MoveLearnMethod { Id = 1, Name = "Level" },
             Level = 12,
             Move = LoadMoveAsync(1, version, displayLanguage, token).Result
         }
     });
     return tcs.Task;
 }
Пример #3
0
 public Task<Move> LoadMoveAsync(int id, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<Move>();
     tcs.SetResult(new Move
     {
         Accuracy = 90,
         DamageClass = LoadDamageClassAsync(1, displayLanguage, token).Result,
         Id = 2,
         Name = "Flügelschlag",
         Power = 60,
         PowerPoints = 15,
         Priority = 0,
         Type = new ElementType { Id = 1, Name = "Flug" }
     });
     return tcs.Task;
 }
Пример #4
0
 async Task<ObservableCollection<PokemonEvolution>> LoadEvolutionsAsync(int speciesId, GameVersion version, int language)
 {
     return await _pokemonService.LoadEvolutionGroupAsync(speciesId, version, language, _tokenSource.Token);
 }
Пример #5
0
 public Task<ElementType> GetTypeAsync(int id, GameVersion version)
 {
     var tcs = new TaskCompletionSource<ElementType>();
     tcs.SetResult(new ElementType { Id = 12, Name = "Feuer" });
     return tcs.Task;
 }
Пример #6
0
 public Task<ObservableCollection<PokemonEvolution>> LoadPossibleEvolutionsAsync(int speciesId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<ObservableCollection<PokemonEvolution>>();
     tcs.SetResult(new ObservableCollection<PokemonEvolution>
     {
         new PokemonEvolution
         {
             EvolutionTrigger = "Gegenstand benutzen",
             EvolutionItem = new Item { Id = 12, Name = "Feuerstein" },
             EvolvesTo = new SpeciesName { Id = 122, Name = "Pumpdjinn" },
             MinLevel = 16
         }
     });
     return tcs.Task;
 }
Пример #7
0
 public Task<ObservableCollection<PokemonLocation>> LoadPokemonEncountersAsync(int pokemonId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<ObservableCollection<PokemonLocation>>();
     tcs.SetResult(new ObservableCollection<PokemonLocation>
     {
         new PokemonLocation
         {
             Conditions = new List<EncounterCondition> { new EncounterCondition { Id = 1, Name = "Durch Benutzung des Pokéradars" } },
             EncounterMethod = new EncounterMethod
             {
                 Id = 1,
                 Name = "Im hohen Gras oder in einer Höhle laufen"
             },
             Location = LoadLocationFromAreaAsync(1, version, displayLanguage, token).Result,
             MaxLevel = 5,
             MinLevel = 5,
             Rarity = 12
         },
         new PokemonLocation
         {
             EncounterMethod = new EncounterMethod
             {
                 Id = 1,
                 Name = "Mit einer normalen Angel angeln"
             },
             Location = new Location { Id = 1, Name = "Route 11" },
             MaxLevel = 30,
             MinLevel = 20,
             Rarity = 100
         },
         new PokemonLocation
         {
             Conditions = new List<EncounterCondition>
             {
                 new EncounterCondition { Id = 4, Name = "Am Tag" },
                 new EncounterCondition { Id = 13, Name = "Radio aus" }
             },
             EncounterMethod = new EncounterMethod
             {
                 Id = 1,
                 Name = "Im raschelndem Gras laufen"
             },
             Location = new Location
             {
                 AreaId = 112,
                 AreaName = "Unten rechts",
                 Id = 133,
                 Name = "Safari Zone"
             },
             MaxLevel = 8,
             MinLevel = 6,
             Rarity = 40
         }
     });
     return tcs.Task;
 }
Пример #8
0
 public Task<Location> LoadLocationFromIdAsync(int id, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<Location>();
     tcs.SetResult(new Location
     {
         Id = 12,
         Name = "Kraterberg"
     });
     return tcs.Task;
 }
Пример #9
0
 public Task<PokemonForm> LoadFormAsync(int formId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<PokemonForm>();
     tcs.SetResult(new PokemonForm
     {
         Ability1 = new Ability { Description = "blub", Effect = "blob", FlavorText = "blubber", Id = 12, Name = "Adlerauge" },
         Ability2 = LoadAbilityAsync(1, version.VersionGroup, displayLanguage, token).Result,
         BaseExperience = 255,
         Height = 12,
         HeldItem = new Item { Id = 15, Name = "Beere" },
         HeldItemRarity = 5,
         Id = 12,
         HiddenAbility = new Ability { Description = "Secret Ability", Effect = "Awesome effect", FlavorText = "You know nothing", Id = 24, Name = "versteckt"},
         Name = "Mega Glurak X",
         Stats = LoadPokemonStatsAsync(1, version, displayLanguage, token).Result,
         Species = LoadSpeciesAsync(12, version, displayLanguage, token).Result,
         Type1 = new ElementType { DamageClassId = 1, Id = 9, Name = "Unlicht" },
         Type2 = GetTypeAsync(1, version).Result,
         Weight = 100
     });
     return tcs.Task;
 }
Пример #10
0
        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;
            }
        }
Пример #11
0
 public async Task<ObservableCollection<Stat>> LoadPokemonStatsAsync(int formId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     try
     {
         string query = "SELECT ps.pokemon_id, ps.stat_id, sn.name, ps.base_stat, ps.effort FROM pokemon_v2_pokemonstat ps\n" +
             "LEFT JOIN pokemon_v2_stat s ON ps.stat_id = s.id\n" +
             "LEFT JOIN\n(SELECT e.stat_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_statname e\n" +
             "LEFT OUTER JOIN pokemon_v2_statname o ON e.stat_id = o.stat_id and o.language_id = ?\n" +
             "WHERE e.language_id = 9\nGROUP BY e.stat_id)\nAS sn ON s.id = sn.id\n" +
             "WHERE ps.pokemon_id = ?";
         IEnumerable<DbPokemonStat> stats = await _connection.QueryAsync<DbPokemonStat>(token, query, new object[] { displayLanguage, formId });
         query = "SELECT psc.pokemon_id, psc.stat_id, sn.name, psc.base_stat FROM pokemon_v2_pokemonstatchange psc\n" +
             "LEFT JOIN pokemon_v2_stat s ON psc.stat_id = s.id\n" +
             "LEFT JOIN\n(SELECT e.stat_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_statname e\n" +
             "LEFT OUTER JOIN pokemon_v2_statname o ON e.stat_id = o.stat_id and o.language_id = ?\n" +
             "WHERE e.language_id = 9\nGROUP BY e.stat_id)\nAS sn ON s.id = sn.id\n" +
             "WHERE psc.pokemon_id = ? AND psc.min_generation_id >= ? AND psc.max_generation_id <= ?";
         IEnumerable<DbPokemonStat> statChanges = await _connection.QueryAsync<DbPokemonStat>(token, query, new object[] { displayLanguage, formId, version.Generation, version.Generation });                
         List<Stat> statTemp = stats.Select(s => new Stat
         {
             EffortValue = s.Effort,
             Id = s.StatId,
             Name = s.Name,
             StatValue = s.BaseStat
         }).ToList();
         foreach (DbPokemonStat stat in statChanges)
         {
             Stat newStat = statTemp.FirstOrDefault(f => f.Id == stat.StatId);
             if (newStat == null)
                 statTemp.Add(new Stat { Id = stat.StatId, Name = stat.Name, StatValue = stat.BaseStat });
             else
                 newStat.StatValue = stat.BaseStat;
         }
         return new ObservableCollection<Stat>(statTemp.Where(w => w.StatValue > 0));
     }
     catch (Exception)
     {
         return new ObservableCollection<Stat>();
     }
 }
Пример #12
0
        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>();
            }
        }
Пример #13
0
        public async Task<Species> LoadSpeciesAsync(int id, GameVersion version, int displayLanguage, CancellationToken token)
        {
            try
            {
                string query = "SELECT ps.id, psn.name, psn.genus, ps.gender_rate, ps.capture_rate, ps.base_happiness, ps.hatch_counter, ps.growth_rate_id FROM pokemon_v2_pokemonspecies AS ps\n" +
                    "LEFT JOIN\n(SELECT def.pokemon_species_id AS id, IFNULL(curr.name, def.name) AS name, IFNULL(curr.genus, def.genus) AS genus FROM pokemon_v2_pokemonspeciesname def\n" +
                    "LEFT JOIN pokemon_v2_pokemonspeciesname curr ON def.pokemon_species_id = curr.pokemon_species_id AND def.language_id = 9 AND curr.language_id = ?\n" +
                    "GROUP BY def.pokemon_species_id)\nAS psn ON ps.id = psn.id\n" +                    
                    "WHERE ps.id = ?";
                IEnumerable<DbPokemonSpecies> list = await _connection.QueryAsync<DbPokemonSpecies>(token, query, new object[] { displayLanguage, id });
                query = "SELECT p.id, pn.name FROM pokemon_v2_pokedex p\n" +
                    "LEFT JOIN\n(SELECT e.pokedex_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_pokedexdescription e\n" +
                    "LEFT OUTER JOIN pokemon_v2_pokedexdescription o ON e.pokedex_id = o.pokedex_id and o.language_id = ?\n" +
                    "WHERE e.language_id = 9\nGROUP BY e.pokedex_id)\nAS pn ON p.id = pn.id\n" +
                    "LEFT JOIN pokemon_v2_pokedexversiongroup pvg ON p.id = pvg.pokedex_id\n" +
                    "WHERE pvg.version_group_id = ?";
                IEnumerable<DbPokedex> temp = await _connection.QueryAsync<DbPokedex>(token, query, new object[] { displayLanguage, version.VersionGroup });
                query = "SELECT egg_group_id FROM pokemon_v2_pokemonegggroup WHERE pokemon_species_id = ?";
                var eggGroups = new List<DbPokemonEggGroup>(await _connection.QueryAsync<DbPokemonEggGroup>(token, query, new object[] { id }));

                DbPokemonSpecies dbSpecies = list.First();
                DbPokedex dex = temp.First();

                var species = new Species
                {
                    BaseHappiness = dbSpecies.BaseHappiness,
                    CatchRate = dbSpecies.CaptureRate,
                    HatchCounter = dbSpecies.HatchCounter,
                    Id = dbSpecies.Id,
                    Name = dbSpecies.Name
                };
                species.GrowthRate = await GetGrowthRateAsync(dbSpecies.GrowthRateId);
                species.DexEntry = await LoadPokedexEntryAsync(dex.Id,  dbSpecies.Id, displayLanguage, token);
                species.DexEntry.Name = dex.Name;
                species.EggGroup1 = await LoadEggGroupAsync(eggGroups[0].EggGroupId, displayLanguage, token);
                if (eggGroups.Count > 1)
                    species.EggGroup2 = await LoadEggGroupAsync(eggGroups[1].EggGroupId, displayLanguage, token);
                //species.PossibleEvolutions = await LoadPossibleEvolutionsAsync(id, version, displayLanguage, token);
                species.GenderRate = CalculateGenderRate(dbSpecies.GenderRate);

                return species;
            }
            catch (Exception)
            {
                return null;
            }
        }
Пример #14
0
 public async Task<ObservableCollection<SpeciesName>> LoadAllSpeciesAsync(GameVersion version, int displayLanguage, CancellationToken token)
 {
     try
     {
         string query = "SELECT ps.id, psn.name, ps.generation_id FROM pokemon_v2_pokemonspecies AS ps\n" +
             "LEFT JOIN\n(SELECT def.pokemon_species_id AS id, IFNULL(curr.name, def.name) AS name FROM pokemon_v2_pokemonspeciesname def\n" +
             "LEFT JOIN pokemon_v2_pokemonspeciesname curr ON def.pokemon_species_id = curr.pokemon_species_id AND def.language_id = 9 AND curr.language_id = ?\n" +
             "GROUP BY def.pokemon_species_id)\nAS psn ON ps.id = psn.id\nWHERE ps.generation_id <= ?";
         IEnumerable<DbPokemonSpecies> list = await _connection.QueryAsync<DbPokemonSpecies>(token, query, new object[] { displayLanguage, version.Generation });
         return new ObservableCollection<SpeciesName>(list.Select(s => new SpeciesName { Generation = s.GenerationId, Id = s.Id, Name = s.Name }));
     }
     catch (Exception)
     {
         return new ObservableCollection<SpeciesName>();
     }
 }
Пример #15
0
 async Task<ObservableCollection<PokemonLocation>> LoadLocationsAsync(int pokemonId, GameVersion version, int language)
 {
     return await _pokemonService.LoadPokemonEncountersAsync(pokemonId, version, language, _tokenSource.Token);
 }
Пример #16
0
 async Task<PokemonForm> LoadFormOldAsync(int id, GameVersion version, int language)
 {
     return await _testService.LoadFormByIdOldAsync(id, version, language, _tokenSource.Token);
 }
Пример #17
0
        public async Task<Move> LoadMoveAsync(int id, GameVersion version, int displayLanguage, CancellationToken token)
        {
            try
            {
                string query = "SELECT m.id, mn.name, IFNULL(mc.power, m.power) as power, IFNULL(mc.pp, m.pp) AS pp, IFNULL(mc.accuracy, m.accuracy) as accuracy,\n" +
                    " m.priority, m.move_damage_class_id, IFNULL(mc.type_id, m.type_id) AS type_id FROM pokemon_v2_move m\n" +
                    "LEFT JOIN\n(SELECT e.move_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_movename e\n" +
                    "LEFT OUTER JOIN pokemon_v2_movename o ON e.move_id = o.move_id and o.language_id = ?\n" +
                    "WHERE e.language_id = 9\nGROUP BY e.move_id)\nAS mn ON m.id = mn.id\n" +
                    "LEFT JOIN pokemon_v2_movechange mc ON m.id = mc.move_id AND mc.version_group_id > ?\n" +
                    "WHERE m.id = ? AND m.generation_id <= ?";
                IEnumerable<DbMove> moves = await _connection.QueryAsync<DbMove>(token, query, new object[] { displayLanguage, version.VersionGroup, id, version.Generation });
                DbMove move = moves.First();
                var result = new Move
                {
                    Accuracy = move.Accuracy,
                    Id = move.Id,
                    Name = move.Name,
                    Power = move.Power,
                    PowerPoints = move.PowerPoints,
                    Priority = move.Priority
                };
                result.Type = await GetTypeAsync(move.Type, version);
                if (version.Generation > 3 || move.MoveDamageClass == 1)
                    result.DamageClass = await GetDamageClassAsync(move.MoveDamageClass);
                else
                    result.DamageClass = await GetDamageClassAsync(result.Type.DamageClassId);

                return result;
            }
            catch (Exception)
            {
                return null;
            }
        }
Пример #18
0
        public async Task<ObservableCollection<PokemonMove>> LoadMoveSetAsync(int pokemonId, GameVersion version, int displayLanguage, CancellationToken token)
        {
            try
            {
                List<DbPokemonMove> moveList = await _connection.Table<DbPokemonMove>().Where(w => w.PokemonId == pokemonId && w.VersionGroupId == version.VersionGroup).ToListAsync(token);

                var bag = new ConcurrentBag<PokemonMove>();
                var tasks = moveList.Select(async (m) =>
                {
                    var move = new PokemonMove
                    {
                        Id = m.Id,
                        Level = m.Level,
                        Order = m.Order
                    };
                    move.LearnMethod = await LoadMoveLearnMethodAsync(m.MoveLearnMethodId, displayLanguage, token);
                    move.Move = await LoadMoveAsync(m.MoveId, version, displayLanguage, token);
                    bag.Add(move);
                });
                await Task.WhenAll(tasks);
                return new ObservableCollection<PokemonMove>(bag.OrderBy(o => o.LearnMethod.Id).ThenBy(t => t.Level).ThenBy(t => t.Order));
            }
            catch (Exception)
            {
                return new ObservableCollection<PokemonMove>();
            }
        }
Пример #19
0
 public Task<ObservableCollection<PokemonEvolution>> LoadEvolutionGroupAsync(int speciesId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<ObservableCollection<PokemonEvolution>>();
     tcs.SetResult(new ObservableCollection<PokemonEvolution>
     {
         new PokemonEvolution
         {
             EvolutionItem = LoadItemAsync(1, displayLanguage, token).Result,
             EvolutionTrigger = "Platz im Team und ein Pokéball",
             EvolvesTo = new SpeciesName { Id = 45, Name = "Arkani" }
         },
         new PokemonEvolution
         {
             EvolvesTo = new SpeciesName { Id = 482, Name = "Dragoran" },
             MinLevel = 58
         },
         new PokemonEvolution
         {
             EvolutionLocation = LoadLocationFromIdAsync(1, version, displayLanguage, token).Result,
             EvolvesTo = new SpeciesName { Id = 245, Name = "Magneton" }
         }
     });
     return tcs.Task;
 }
Пример #20
0
        public async Task<ObservableCollection<PokemonEvolution>> LoadPossibleEvolutionsAsync(int speciesId, GameVersion version, int displayLanguage, CancellationToken token)
        {
            try
            {
                string query = "SELECT ps.id, psn.name, pe.min_level, etn.name AS evolution_trigger, pe.evolution_item_id FROM pokemon_v2_pokemonspecies ps\n" +
                    "LEFT JOIN\n(SELECT def.pokemon_species_id AS id, IFNULL(curr.name, def.name) AS name FROM pokemon_v2_pokemonspeciesname def\n" +
                    "LEFT JOIN pokemon_v2_pokemonspeciesname curr ON def.pokemon_species_id = curr.pokemon_species_id AND def.language_id = 9 AND curr.language_id = ?\n" +
                    "GROUP BY def.pokemon_species_id)\nAS psn ON ps.id = psn.id\n" +
                    "LEFT JOIN pokemon_v2_pokemonevolution pe ON pe.evolved_species_id = ps.id\n" +
                    "LEFT JOIN pokemon_v2_evolutiontrigger et ON pe.evolution_trigger_id = et.id\n" +
                    "LEFT JOIN\n(SELECT e.evolution_trigger_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_evolutiontriggername e\n" +
                    "LEFT OUTER JOIN pokemon_v2_evolutiontriggername o ON e.evolution_trigger_id = o.evolution_trigger_id and o.language_id = ?\n" +
                    "WHERE e.language_id = 9\nGROUP BY e.evolution_trigger_id)\nAS etn ON et.id = etn.id\n" +
                    "WHERE ps.evolves_from_species_id = ? AND ps.generation_id <= ?";
                IEnumerable<DbPokemonEvolution> evolutions = await _connection.QueryAsync<DbPokemonEvolution>(token, query, new object[] { displayLanguage, displayLanguage, speciesId, version.Generation });

                var result = new ObservableCollection<PokemonEvolution>();
                foreach (DbPokemonEvolution dbEvolution in evolutions)
                {
                    var evolution = new PokemonEvolution
                    {
                        EvolvesTo = new SpeciesName { Id = dbEvolution.Id, Name = dbEvolution.Name },
                        MinLevel = dbEvolution.MinLevel,                        
                        EvolutionTrigger = dbEvolution.EvolutionTrigger
                        
                    };
                    if (dbEvolution.EvolutionItemId != null)
                        evolution.EvolutionItem = await LoadItemAsync((int)dbEvolution.EvolutionItemId, displayLanguage, token);
                    result.Add(evolution);
                }
                return result;
            }
            catch (Exception)
            {
                return new ObservableCollection<PokemonEvolution>();
            }
        }
Пример #21
0
 public Task<ObservableCollection<PokemonForm>> LoadFormsAsync(SpeciesName species, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<ObservableCollection<PokemonForm>>();
     tcs.SetResult(new ObservableCollection<PokemonForm> {
         new PokemonForm
         {
             BaseExperience = 255,
             Height = 12,
             Id = 12,
             Name = "Mega Glurak X",
             Species = LoadSpeciesAsync(species.Id, version, displayLanguage, token).Result,
             Weight = 100
         }
     });
     return tcs.Task;
 }
Пример #22
0
        public async Task<ObservableCollection<PokemonEvolution>> LoadEvolutionGroupAsync(int speciesId, GameVersion version, int displayLanguage, CancellationToken token)
        {
            try
            {
                string query = "SELECT ps.id, psn.name, pe.min_level, etn.name AS evolution_trigger, pe.evolution_item_id, pe.location_id, ec.baby_trigger_item_id,\n" +
                    "pe.min_happiness, pe.time_of_day, pe.held_item_id, ps.is_baby FROM pokemon_v2_pokemonspecies ps\n" +
                    "LEFT JOIN\n(SELECT def.pokemon_species_id AS id, IFNULL(curr.name, def.name) AS name FROM pokemon_v2_pokemonspeciesname def\n" +
                    "LEFT JOIN pokemon_v2_pokemonspeciesname curr ON def.pokemon_species_id = curr.pokemon_species_id AND def.language_id = 9 AND curr.language_id = ?\n" +
                    "GROUP BY def.pokemon_species_id)\nAS psn ON ps.id = psn.id\n" +
                    "LEFT JOIN pokemon_v2_pokemonevolution pe ON pe.evolved_species_id = ps.id\n" +
                    "LEFT JOIN pokemon_v2_evolutiontrigger et ON pe.evolution_trigger_id = et.id\n" +
                    "LEFT JOIN\n(SELECT e.evolution_trigger_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_evolutiontriggername e\n" +
                    "LEFT OUTER JOIN pokemon_v2_evolutiontriggername o ON e.evolution_trigger_id = o.evolution_trigger_id and o.language_id = ?\n" +
                    "WHERE e.language_id = 9\n\nGROUP BY e.evolution_trigger_id)\nAS etn ON et.id = etn.id\n" +
                    "LEFT JOIN pokemon_v2_evolutionchain ec ON ec.id = ps.evolution_chain_id\n" +
                    "WHERE ps.evolution_chain_id = (SELECT evolution_chain_id FROM pokemon_v2_pokemonspecies WHERE id = ?) AND ps.generation_id <= ?\n" +
                    "ORDER BY ps.'order'";
                IEnumerable<DbPokemonEvolution> evolutions = await _connection.QueryAsync<DbPokemonEvolution>(token, query, new object[] 
                {
                    displayLanguage,
                    displayLanguage,
                    speciesId,
                    version.Generation
                });
                var result = new ObservableCollection<PokemonEvolution>();
                foreach (DbPokemonEvolution evolution in evolutions)
                {
                    var evo = new PokemonEvolution
                    {
                        DayTime = evolution.TimeOfDay,
                        EvolutionTrigger = evolution.EvolutionTrigger,
                        EvolvesTo = new SpeciesName { Id = evolution.Id, Name = evolution.Name },                        
                        MinLevel = evolution.MinLevel,
                        MinHappiness = evolution.MinHappiness
                    };

                    if (evolution.IsBaby)
                        evo.EvolutionTrigger = "Zucht";

                    if (evolution.LocationId != null)
                    {
                        Location loc = await LoadLocationFromIdAsync((int)evolution.LocationId, version, displayLanguage, token);
                        if (loc == null)
                            continue;
                        evo.EvolutionLocation = loc;
                    }
                    if (evolution.EvolutionItemId != null)
                        evo.EvolutionItem = await LoadItemAsync((int)evolution.EvolutionItemId, displayLanguage, token);
                    else if (evolution.HeldItemId != null)
                        evo.EvolutionItem = await LoadItemAsync((int)evolution.HeldItemId, displayLanguage, token);
                    else if (evolution.IsBaby && evolution.BabyTriggerItemId != null)
                        evo.EvolutionItem = await LoadItemAsync((int)evolution.BabyTriggerItemId, displayLanguage, token);
                    result.Add(evo);
                }
                return result;
            }
            catch (Exception)
            {
                return new ObservableCollection<PokemonEvolution>();
            }
        }
Пример #23
0
 public Task<ObservableCollection<PokemonMove>> LoadMoveSetAsync(int pokemonId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<ObservableCollection<PokemonMove>>();
     tcs.SetResult(new ObservableCollection<PokemonMove>
     {
         new PokemonMove
         {
             LearnMethod = new MoveLearnMethod { Id = 1, Name = "Level" },
             Level = 12,
             Move = LoadMoveAsync(1, version, displayLanguage, token).Result
         },
         new PokemonMove
         {
             LearnMethod = new MoveLearnMethod { Id = 1, Name = "Level" },
             Level = 24,
             Move = new Move
             {
                 Accuracy = 100,
                 DamageClass = new DamageClass { Id = 2, Name = "Speziell" },
                 Id = 156,
                 Name = "Flammenwurf",
                 Power = 120,
                 PowerPoints = 5,
                 Priority = -2,
                 Type = new ElementType { DamageClassId = 1, Generation = 1, Id = 7, Name = "Coleottero" }
             }
         },
         new PokemonMove
         {
             LearnMethod = new MoveLearnMethod { Id = 1, Name = "Level" },
             Level = 24,
             Move = new Move
             {
                 Accuracy = null,
                 DamageClass = new DamageClass { Id = 2, Name = "Status" },
                 Id = 156,
                 Name = "Giftpuder",
                 Power = null,
                 PowerPoints = 25,
                 Priority = 2,
                 Type = new ElementType { DamageClassId = 1, Generation = 1, Id = 7, Name = "Gift" }
             }
         }
     });
     return tcs.Task;
 }
Пример #24
0
 public async Task<Location> LoadLocationFromIdAsync(int id, GameVersion version, int displayLanguage, CancellationToken token)
 {
     try
     {
         string query = "SELECT loc.id, ln.name FROM pokemon_v2_location loc\n" +
             "LEFT JOIN\n(SELECT e.location_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_locationname e\n" +
             "LEFT OUTER JOIN pokemon_v2_locationname o ON e.location_id = o.location_id and o.language_id = ?\n" +
             "WHERE e.language_id = 9\nGROUP BY e.location_id)\nAS ln ON loc.id = ln.id\n" +
             "LEFT JOIN pokemon_v2_region r ON r.id = loc.region_id\n" +
             "LEFT JOIN pokemon_v2_versiongroupregion vgr ON r.id = vgr.region_id\n" +
             "WHERE loc.id = ? AND vgr.version_group_id = ?";
         IEnumerable<DbLocation> locations = await _connection.QueryAsync<DbLocation>(token, query, new object[] { displayLanguage, id, version.VersionGroup });                
         DbLocation location = locations.FirstOrDefault();
         if (location == null)
             return null;
         return new Location { Id = location.Id, Name = location.Name };
     }
     catch (Exception)
     {
         return null;
     }
 }
Пример #25
0
 public Task<ObservableCollection<Stat>> LoadPokemonStatsAsync(int formId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<ObservableCollection<Stat>>();
     tcs.SetResult(new ObservableCollection<Stat>
     {
         new Stat { EffortValue = 1, Id = 1, Name = "KP", StatValue = 110 },
         new Stat { EffortValue = 0, Id = 2, Name = "Angriff", StatValue = 60 },
         new Stat { EffortValue = 1, Id = 3, Name = "Verteidigung", StatValue = 75 },
         new Stat { EffortValue = 0, Id = 4, Name = "Spezialangriff", StatValue = 55 },
         new Stat { EffortValue = 1, Id = 5, Name = "Spezialverteidigung", StatValue = 70 },
         new Stat { EffortValue = 0, Id = 6, Name = "Initative", StatValue = 70 }
     });
     return tcs.Task;
 }
Пример #26
0
 public async Task<Location> LoadLocationFromAreaAsync(int areaId, GameVersion version, int displayLanguage, CancellationToken token)
 {
     try
     {
         string query = "SELECT la.id, lan.name, la.location_id FROM pokemon_v2_locationarea la\n" +
                 "LEFT JOIN\n(SELECT e.location_area_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_locationareaname e\n" +
                 "LEFT OUTER JOIN pokemon_v2_locationareaname o ON e.location_area_id = o.location_area_id and o.language_id = ?\n" +
                 "WHERE e.language_id = 9\nGROUP BY e.location_area_id)\nAS lan ON la.id = lan.id\n" +                        
                 "WHERE la.id = ?";
         IEnumerable<DbLocationArea> areas = await _connection.QueryAsync<DbLocationArea>(token, query, new object[] { displayLanguage, areaId });
         DbLocationArea area = areas.First();
         Location location = await LoadLocationFromIdAsync(area.LocationId, version, displayLanguage, token);
         location.AreaId = area.Id;
         location.AreaName = area.Name;
         return location;
     }
     catch (Exception)
     {
         return null;
     }
 }
Пример #27
0
 public Task<Species> LoadSpeciesAsync(int id, GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<Species>();
     tcs.SetResult(new Species
     {
         BaseHappiness = 70,
         CatchRate = 45,
         DexEntry = LoadPokedexEntryAsync(39, 6, 6, token).Result,
         EggGroup1 = LoadEggGroupAsync(1, 6, token).Result,
         EggGroup2 = new EggGroup { Id = 12, Name = "Humanotyp" },
         GenderRate   = new GenderRate { Female = 50, Male = 50},
         GrowthRate = GetGrowthRateAsync(1).Result,
         HatchCounter = 20,
         Id = 6,
         Name = "Glurak",
         PossibleEvolutions = LoadPossibleEvolutionsAsync(id, version, displayLanguage, token).Result
     });
     return tcs.Task;
 }
Пример #28
0
        public async Task<ObservableCollection<PokemonLocation>> LoadPokemonEncountersAsync(int pokemonId, GameVersion version, int displayLanguage, CancellationToken token)
        {
            try
            {
                string query = "SELECT enc.id, MIN(enc.min_level) AS min_level, MAX(enc.max_level) AS max_level, enc.location_area_id, SUM(es.rarity) AS rarity, ecvm.encounter_condition_value_id, ec.id AS condition_id, es.encounter_method_id FROM pokemon_v2_encounter enc\n" +
                    "LEFT JOIN pokemon_v2_encounterslot es ON es.id = enc.encounter_slot_id\n" +
                    "LEFT JOIN pokemon_v2_encountermethod em ON em.id = es.encounter_method_id\n" +
                    "LEFT JOIN pokemon_v2_encounterconditionvaluemap ecvm ON ecvm.encounter_id = enc.id\n" +
                    "LEFT JOIN pokemon_v2_encounterconditionvalue ecv ON ecv.id = ecvm.encounter_condition_value_id\n" +
                    "LEFT JOIN pokemon_v2_encountercondition ec ON ecv.encounter_condition_id = ec.id\n" +
                    "WHERE enc.pokemon_id = ? AND enc.version_id = ?\n" +
                    "GROUP BY enc.location_area_id, es.encounter_method_id, ecvm.encounter_condition_value_id\n" +
                    "ORDER BY enc.location_area_id, ec.id, ecvm.encounter_condition_value_id";
                IEnumerable<DbPokemonEncounter> encounters = await _connection.QueryAsync<DbPokemonEncounter>(token, query, new object[] { pokemonId, version.Id });
                var result = new ObservableCollection<PokemonLocation>();
                foreach (DbPokemonEncounter encounter in encounters)
                {
                    PokemonLocation location = null;
                    //Check if there is another encounter on the same area with the same condition or null condition but another slot
                    PokemonLocation location2 = result.FirstOrDefault(f => f.Location.AreaId == encounter.LocationAreaId
                        && encounter.EncounterMethodId == f.EncounterMethod.Id && (encounter.EncounterConditionValueId == null || f.Conditions.Any() == false ||
                        (f.Conditions.Any() && f.Conditions.FirstOrDefault(x => x.Id == (int)encounter.EncounterConditionValueId) != null)));
                    // Merge encounter with same area and condition
                    if (location2 != null)
                    {
                        location2.Rarity += encounter.Rarity;
                        location = location2;
                    }
                    else
                        location = result.FirstOrDefault(f => f.Id == encounter.Id);

                    if (location == null)
                    {
                        location = new PokemonLocation
                        {
                            Id = encounter.Id,
                            MaxLevel = encounter.MaxLevel,
                            MinLevel = encounter.MinLevel,
                            Rarity = encounter.Rarity
                        };

                        location.EncounterMethod = await GetEncounterMethodAsync(encounter.EncounterMethodId);
                        location.Location = await LoadLocationFromAreaAsync(encounter.LocationAreaId, version, displayLanguage, token);
                    }

                    // Filter out double encounter conditions                    
                    if (encounter.EncounterConditionValueId != null && location.Conditions.FirstOrDefault(f => f.Id == (int)encounter.EncounterConditionValueId) == null)
                        //if (encounter.EncounterConditionValueId != null)
                        location.Conditions.Add(await GetEncounterConditionAsync((int)encounter.EncounterConditionValueId));

                    if (location2 == null)
                        result.Add(location);
                }
                return result;
            }
            catch (Exception)
            {
                return new ObservableCollection<PokemonLocation>();
            }
        }
Пример #29
0
 public Task<ObservableCollection<SpeciesName>> LoadAllSpeciesAsync(GameVersion version, int displayLanguage, CancellationToken token)
 {
     var tcs = new TaskCompletionSource<ObservableCollection<SpeciesName>>();
     tcs.SetResult(new ObservableCollection<SpeciesName>
     {
         new SpeciesName { Id = 6, Name = "Glurak", Generation = 1 },
         new SpeciesName { Id = 7, Name = "Schiggy", Generation = 1 }
     });
     return tcs.Task;
 }
Пример #30
0
 async Task<ObservableCollection<Stat>> LoadStatsAsync(int formId, GameVersion version, int language)
 {
     return await _pokemonService.LoadPokemonStatsAsync(formId, version, language, _tokenSource.Token);
 }