コード例 #1
0
        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            try
            {
                Pokemon.Clear();
                var pokemon = await DataStore.GetItemsAsync(true);

                foreach (var poke in pokemon)
                {
                    Pokemon temp = poke;
                    temp.name = UppercaseFirst(temp.name);
                    Pokemon.Add(temp);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #2
0
 // CREATE
 public Pokemon Create(Pokemon pokemon)
 {
     pokemon.Id = nextId();
     pokemon.Add(pokemon);
     SavePokemon();
     return(pokemon);
 }
コード例 #3
0
        public async Task <PokemonRaidPost> AddOrUpdatePost(PokemonRaidPost post)
        {
            var loc            = Uri.UnescapeDataString(post.FullLocation);
            var locationEntity = await Locations.SingleOrDefaultAsync(x => x.ServerId == post.GuildId && x.Name == loc);

            if (locationEntity == null)
            {
                var newLoc = _mapper.Map <RaidPostLocationEntity>(post);
                locationEntity = Locations.Add(newLoc).Entity;
                await SaveChangesAsync();
            }

            var bossEntity = await Pokemon.SingleOrDefaultAsync(x => x.Id == post.PokemonId);

            if (bossEntity == null)
            {
                var newBoss = _mapper.Map <PokemonEntity>(post);
                bossEntity = Pokemon.Add(newBoss).Entity;
            }

            var postEntity = new RaidPostEntity();

            if (post.DbId != default(ulong))
            {
                postEntity = await Posts.FirstOrDefaultAsync(x => x.Id == post.DbId);
            }

            _mapper.Map(post, postEntity);

            postEntity.Pokemon   = bossEntity;
            postEntity.PokemonId = bossEntity.Id;

            postEntity.Location   = locationEntity;
            postEntity.LocationId = locationEntity.Id;

            if (post.DbId == default(ulong))
            {
                Add(postEntity);
                await SaveChangesAsync();

                post.DbId = postEntity.Id;
            }

            foreach (var channelId in post.ChannelMessages.Keys.Where(x => ChannelPosts.Where(y => y.ChannelId == x && y.RaidPostId == post.DbId).Count() == 0))
            {
                var channelPost = new RaidPostChannelEntity()
                {
                    ChannelId = channelId, RaidPostId = post.DbId
                };
                Add(channelPost);
            }

            await SaveChangesAsync();

            post.DbLocationId = locationEntity.Id;
            return(post);
        }
コード例 #4
0
        public async void PopulatePokemon(IEnumerable <Pokemon> source = null)
        {
            IsLoading = true;

            if (source == null)
            {
                _pokemon = await _pokeApiService.GetPokemonAsync();
            }
            else
            {
                _pokemon = source;
            }

            Pokemon.Clear();

            foreach (var p in _pokemon)
            {
                Pokemon.Add(p);
            }

            IsLoading = false;
        }
コード例 #5
0
        public void UpdateInventory()
        {
            LogCaller(new LoggerEventArgs("Updating inventory.", LoggerTypes.Debug));

            try
            {
                var inventoryItems = _client?.ClientSession?.Player?.Inventory?.InventoryItems;
                if (inventoryItems == null)
                {
                    return;
                }
                Items.Clear();
                Pokemon.Clear();
                Pokedex.Clear();
                PokemonCandy.Clear();
                Incubators.Clear();
                Eggs.Clear();
                foreach (var inventoryItem in inventoryItems)
                {
                    if (inventoryItem.InventoryItemData?.PlayerStats != null)
                    {
                        Stats = inventoryItem.InventoryItemData.PlayerStats;
                    }
                    if (inventoryItem.InventoryItemData?.Item != null)
                    {
                        Items.Add(inventoryItem.InventoryItemData.Item);
                    }
                    if (inventoryItem.InventoryItemData?.PokedexEntry != null)
                    {
                        Pokedex.Add(inventoryItem.InventoryItemData.PokedexEntry);
                    }
                    if (inventoryItem.InventoryItemData?.Candy != null)
                    {
                        PokemonCandy.Add(inventoryItem.InventoryItemData.Candy);
                    }
                    if (inventoryItem.InventoryItemData?.EggIncubators != null)
                    {
                        foreach (var eggIncubator in inventoryItem.InventoryItemData.EggIncubators.EggIncubator)
                        {
                            if (eggIncubator != null)
                            {
                                Incubators.Add(eggIncubator);
                            }
                        }
                    }
                    if (inventoryItem.InventoryItemData?.PokemonData != null)
                    {
                        if (inventoryItem.InventoryItemData.PokemonData.IsEgg)
                        {
                            Eggs.Add(inventoryItem.InventoryItemData.PokemonData);
                        }
                        else
                        {
                            Pokemon.Add(inventoryItem.InventoryItemData.PokemonData);
                        }
                    }
                }
            }
            catch (Exception ex1)
            {
                AccountState = Enums.AccountState.TemporalBan;
                LogCaller(new LoggerEventArgs(String.Format("Failed updating inventory."), LoggerTypes.Debug, ex1));
                Stop();
            }
        }
コード例 #6
0
        /// <summary>
        /// Goes through the GAME_MASTERs and collects the data we want to leverage for the PokeRef site.
        /// </summary>
        /// <param name="gameMaster"></param>
        /// <param name="legacyGameMasters"></param>
        private void CollectData(GameMasterTemplate gameMasterTemplate, IEnumerable <GameMasterTemplate> legacyGameMasterTemplates)
        {
            // Get a list of all of the GAME_MASTER files.
            CurrentGameMaster = gameMasterTemplate;
            GameMasters.Add(gameMasterTemplate.FileName, gameMasterTemplate.HaveRawGameMaster);
            foreach (var legacyGameMasterTemplate in legacyGameMasterTemplates)
            {
                GameMasters.Add(legacyGameMasterTemplate.FileName, legacyGameMasterTemplate.HaveRawGameMaster);
            }

            // Process the current GameMaster
            foreach (var itemTemplate in gameMasterTemplate.GameMaster.item_templates)
            {
                try
                {
                    if (itemTemplate.pokemon_settings != null)
                    {
                        PokemonTranslator pokemon = new PokemonTranslator(itemTemplate);
                        Pokemon.Add(pokemon.Key, pokemon);
                    }
                    else if (itemTemplate.move_settings != null)
                    {
                        MoveTranslator move = new MoveTranslator(itemTemplate);
                        PokeMoves.Add(move.Key, move);
                    }
                    else if (itemTemplate.gender_settings != null)
                    {
                        GenderRatioTranslator genderRatio = new GenderRatioTranslator(itemTemplate);

                        // Some Pokemon are duplicated and should be ignored. (E.G. Castform for each of the weathers.)
                        if (GenderRatios.ContainsKey(genderRatio.Key))
                        {
                            continue;
                        }

                        GenderRatios.Add(genderRatio.Key, genderRatio);
                    }
                    else if (itemTemplate.player_level != null)
                    {
                        PlayerLevel = new PlayerLevelTranslator(itemTemplate);
                    }
                    else if (itemTemplate.form_settings != null)
                    {
                        if (itemTemplate.form_settings.forms != null)
                        {
                            FormSettingsTranslator formSettings = new FormSettingsTranslator(itemTemplate);
                            Forms.Add(formSettings.Key, formSettings);
                        }
                    }
                    else if (itemTemplate.friendship_milestone_settings != null)
                    {
                        Friendships.Add(new FriendshipTranslator(itemTemplate));
                    }

                    #region Data I am currently not using.

                    //else if (itemTemplate.avatarCustomization != null)
                    //{
                    //}
                    //else if (itemTemplate.badgeSettings != null)
                    //{
                    //}
                    //else if (itemTemplate.battleSettings != null)
                    //{
                    //}
                    //else if (itemTemplate.camera != null)
                    //{
                    //}
                    //else if (itemTemplate.encounterSettings != null)
                    //{
                    //}
                    //else if (itemTemplate.gymBadgeSettings != null)
                    //{
                    //}
                    //else if (itemTemplate.gymLevel != null)
                    //{
                    //}
                    //else if (itemTemplate.iapItemDisplay != null)
                    //{
                    //}
                    //else if (itemTemplate.iapSettings != null)
                    //{
                    //}
                    //else if (itemTemplate.itemSettings != null)
                    //{
                    //}
                    //else if (itemTemplate.moveSequenceSettings != null)
                    //{
                    //}
                    //else if (itemTemplate.pokemonUpgrades != null)
                    //{
                    //}
                    //else if (itemTemplate.questSettings != null)
                    //{
                    //}
                    //else if (itemTemplate.typeEffective != null)
                    //{
                    //}

                    #endregion Data I am currently not using.
                }
                catch (Exception ex)
                {
                    ConsoleOutput.OutputException(ex, $"Error processing {itemTemplate.template_id} ({gameMasterTemplate.FileName})");
                }
            }

            Legacy.Initialize(gameMasterTemplate, legacyGameMasterTemplates, ManualDataSettings.PokemonAvailability, ManualDataSettings.SpecialMoves);
            foreach (var pokemon in Pokemon.Values)
            {
                pokemon.AssignProperties(Pokemon,
                                         GenderRatios.ContainsKey(pokemon.PokemonSettings.pokemon_id) ? GenderRatios[pokemon.PokemonSettings.pokemon_id] : null,
                                         Legacy.FastMoves.ContainsKey(pokemon.TemplateId) ? Legacy.FastMoves[pokemon.TemplateId] : null,
                                         Legacy.ChargedMoves.ContainsKey(pokemon.TemplateId) ? Legacy.ChargedMoves[pokemon.TemplateId] : null);
            }
        }
コード例 #7
0
        public ActionResult Put(Pokemon pokemon)
        {
            pokemon.Add(pokemon);

            return(Ok(pokemons));
        }
コード例 #8
0
        private void Parse(string pokemonStatsText)
        {
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
            var pokemonStatsDictionary = javaScriptSerializer.Deserialize <dynamic>(pokemonStatsText);

            foreach (dynamic itemTemplate in pokemonStatsDictionary["itemTemplates"])
            {
                string templateIdRaw = itemTemplate["templateId"];

                // Filter out stuff we don't deal with.
                //  (This is for maintenance purposes. It lists things that are in the list, but we don't deal with right now.)
                if (templateIdRaw.StartsWith("AVATAR") ||
                    templateIdRaw.StartsWith("BADGE") ||
                    templateIdRaw.StartsWith("BATTLE") ||
                    templateIdRaw.StartsWith("ENCOUNTER") ||
                    templateIdRaw.StartsWith("FORMS") ||     // This is valuable for Unown ([A-Z],!,?)
                    templateIdRaw.StartsWith("GYM") ||
                    templateIdRaw.StartsWith("IAP") ||
                    templateIdRaw.StartsWith("ITEM") ||
                    templateIdRaw.StartsWith("POKEMON_TYPE") ||
                    templateIdRaw.StartsWith("POKEMON_UPGRADE") ||
                    templateIdRaw.StartsWith("QUEST") ||
                    templateIdRaw.StartsWith("SPAWN") ||
                    templateIdRaw.StartsWith("camera") ||
                    templateIdRaw.StartsWith("android.test") ||
                    templateIdRaw.StartsWith("incenseordinary") ||
                    templateIdRaw.StartsWith("incubatorbasic") ||
                    templateIdRaw.StartsWith("itemstorageupgrade") ||
                    templateIdRaw.StartsWith("luckyegg") ||
                    templateIdRaw.StartsWith("pokeball") ||
                    templateIdRaw.StartsWith("pokecoin") ||
                    templateIdRaw.StartsWith("pokemonstorageupgrade") ||
                    templateIdRaw.StartsWith("sequence"))
                {
                    continue;
                }

                // There are some exact matches we will deal with.
                if (string.Equals(templateIdRaw, "PLAYER_LEVEL_SETTINGS", StringComparison.OrdinalIgnoreCase))
                {
                    CPModifiers = ReadCPModifiers(itemTemplate);
                    continue;
                }


                // In other cases, it is a pattern game.
                string[] templateId = templateIdRaw.Split('_');
                if (templateId.Count() < 2)
                {
                    throw new Exception("Unexpected small templateId");
                }

                if (templateId[0].StartsWith("V") &&
                    string.Equals(templateId[1], "POKEMON", StringComparison.OrdinalIgnoreCase))
                {
                    Pokemon pokemon = ReadPokemon(itemTemplate);
                    Pokemon.Add(pokemon.Name, pokemon);
                }
                else if (templateId[0].StartsWith("V") &&
                         string.Equals(templateId[1], "MOVE", StringComparison.OrdinalIgnoreCase))
                {
                    Move move = ReadMove(itemTemplate);
                    if (move.MoveType == MoveType.Quick)
                    {
                        MovesQuick.Add(move.Name, move);
                    }
                    else if (move.MoveType == MoveType.Charge)
                    {
                        MovesCharge.Add(move.Name, move);
                    }
                    else
                    {
                        throw new Exception("Invalid Move Type!");
                    }
                }
                else
                {
                    throw new Exception("Code needs to be updated to deal with " + itemTemplate["templateId"]);
                }
            }
        }