Example #1
0
 public _Pokemon(_Pokemon pokemon, _Form form)
 {
     id           = pokemon.id;
     name         = pokemon.name;
     date         = form.date;
     availability = form.availability;
     shiny        = form.shiny;
 }
Example #2
0
        /// <summary>
        /// Write out the Move Sets for each generation of Pokemon.
        /// </summary>
        public static void Write(IEnumerable <PokemonTranslator> pokemonTranslators, Dictionary <PokemonId, FormSettingsTranslator> forms, Dictionary <PokemonMove, MoveTranslator> moves, ManualDataSettings manualDataSettings, GameMasterStatsCalculator gameMasterStatsCalculator)
        {
            DateTime updateDateTime = new DateTime(Math.Max(
                                                       gameMasterStatsCalculator.GameMasterStats.last_updated.Date.Ticks,
                                                       manualDataSettings.SpecialMoves.last_updated.Date.Ticks));

            bool update = false;

            for (int gen = 1; gen < PokeConstants.Regions.Length; gen++)
            {
                string   filePath    = Path.Combine(Utils.OutputDataFileFolder, "movesets.gen" + gen + ".xml");
                DateTime lastUpdated = Utils.GetLastUpdated(filePath);
                if (!File.Exists(filePath) || lastUpdated < updateDateTime)
                {
                    update = true;
                    break;
                }
            }

            if (update)
            {
                List <MoveSets._Pokemon>[] pokemonMoveSetList = new List <MoveSets._Pokemon> [PokeConstants.Regions.Length + 1];
                for (int gen = 1; gen < PokeConstants.Regions.Length; gen++)
                {
                    pokemonMoveSetList[gen] = new List <MoveSets._Pokemon>();
                }

                foreach (var pokemonTranslator in pokemonTranslators)
                {
                    // Need to deal with the following cases:
                    //  - Unown has multiple forms, but only a single record.
                    //  - Castform has multiple forms and multiple records, but each record has unique movesets.
                    //  - Deoxys has multiple forms and multiple records, but all records have the same movesets.
                    if (forms.ContainsKey(pokemonTranslator.PokemonSettings.pokemon_id) &&
                        forms[pokemonTranslator.PokemonSettings.pokemon_id].FormSettings.forms.Count > 0)
                    {
                        List <PokemonTranslator> records = new List <PokemonTranslator>();
                        foreach (var pokemon in pokemonTranslators)
                        {
                            if (pokemon.Id == pokemonTranslator.Id)
                            {
                                records.Add(pokemon);
                            }
                        }

                        // If there are more that 1 match, then we need to deal with pokemon with multiple forms. (E.G. Unown)
                        if (records.Count > 1)
                        {
                            // There are multiple records. We need to compare the movesets for the records.
                            int matches = 0;
                            foreach (var record in records)
                            {
                                if (IsMoveSetMatch(pokemonTranslator, record))
                                {
                                    matches++;
                                }
                            }

                            // If every record matches the moveset, skip all but the base form.
                            if (matches == records.Count)
                            {
                                if (pokemonTranslator.Form != Form.FORM_UNSET)
                                {
                                    continue;
                                }
                            }
                            // If only a sub-set of records match the moveset, skip the base form.
                            else if (pokemonTranslator.Form == Form.FORM_UNSET)
                            {
                                continue;
                            }
                        }
                    }

                    List <_Pokemon._MoveSet> moveSets = new List <_Pokemon._MoveSet>();

                    moveSets.AddRange(GetMoveSets(pokemonTranslator, moves, false, false));
                    moveSets.AddRange(GetMoveSets(pokemonTranslator, moves, true, false));
                    moveSets.AddRange(GetMoveSets(pokemonTranslator, moves, false, true));
                    moveSets.AddRange(GetMoveSets(pokemonTranslator, moves, true, true));

                    double maxDPS = 0;
                    foreach (var moveSet in moveSets)
                    {
                        if (!moveSet.FastAttack.legacy && !moveSet.ChargedAttack.legacy)
                        {
                            maxDPS = Math.Max(maxDPS, moveSet.true_dps);
                        }
                    }

                    foreach (var moveSet in moveSets)
                    {
                        moveSet.comparison = (int)Math.Ceiling(moveSet.true_dps / maxDPS * 100);
                    }

                    _Pokemon _pokemon = new _Pokemon(pokemonTranslator, moveSets.ToArray());
                    pokemonMoveSetList[PokeFormulas.GetGeneration(pokemonTranslator)].Add(_pokemon);
                    gameMasterStatsCalculator.Update(_pokemon);
                }

                for (int gen = 1; gen < PokeConstants.Regions.Length; gen++)
                {
                    if (pokemonMoveSetList[gen].Count > 1)
                    {
                        Utils.WriteXML(new MoveSets(gen, pokemonMoveSetList[gen].ToArray(), updateDateTime), Path.Combine(Utils.OutputDataFileFolder, "movesets.gen" + gen + ".xml"));
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Write out the stats for each generation of Pokemon
        /// </summary>
        public static void Write(IEnumerable <PokemonTranslator> pokemonTranslators, ManualDataSettings manualDataSettings, GameMasterStatsCalculator gameMasterStatsCalculator)
        {
            DateTime updateDateTime = new DateTime(Math.Max(Math.Max(
                                                                gameMasterStatsCalculator.GameMasterStats.last_updated.Date.Ticks,
                                                                manualDataSettings.PokemonAvailability.last_updated.Date.Ticks),
                                                            manualDataSettings.PokemonAvailability.last_updated.Date.Ticks));

            // Create an array of lists to hold each generation.
            List <PokeStats._Pokemon>[] pokemonList = new List <PokeStats._Pokemon> [PokeConstants.Regions.Length + 1];
            for (int i = 1; i < PokeConstants.Regions.Length; i++)
            {
                pokemonList[i] = new List <PokeStats._Pokemon>();
            }

            // Need to provide basic info for Unreleased Pokemon.
            foreach (var pokemon in manualDataSettings.PokemonUnreleased.Pokemon)
            {
                if (pokemonList[PokeFormulas.GetGeneration(pokemon)] != null)
                {
                    pokemonList[PokeFormulas.GetGeneration(pokemon)].Add(
                        new _Pokemon(pokemon, manualDataSettings.PokemonAvailability.GetPokemon(pokemon.name, pokemon.form), manualDataSettings.PokemonAvailability.Pokemon[pokemon.id].rarity));
                }

                gameMasterStatsCalculator.Update(pokemon);
            }

            // Now gather the data for the Pokemon in the GAME_MASTER.
            foreach (var pokemonTranslator in pokemonTranslators)
            {
                int gen = PokeFormulas.GetGeneration(pokemonTranslator.Id);

                _Pokemon pokemon = new _Pokemon(pokemonTranslator,
                                                manualDataSettings.PokemonAvailability.GetPokemon(pokemonTranslator.Name, pokemonTranslator.FormName),
                                                manualDataSettings.Traits,
                                                GetMaxStats(pokemonTranslator));
                gameMasterStatsCalculator.Update(pokemon);

                if (pokemonList[gen] != null)
                {
                    pokemonList[gen].Add(pokemon);

                    // Handle cases where there are multiple forms, but only one record in the GAME_MASTER
                    if (string.Equals(pokemonTranslator.Name, "Unown", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(pokemonTranslator.Name, "Spinda", StringComparison.OrdinalIgnoreCase))
                    {
                        foreach (var form in manualDataSettings.PokemonAvailability.Pokemon[pokemonTranslator.Id].Form)
                        {
                            POGOProtos.Enums.Form formId;
                            Enum.TryParse(pokemonTranslator.Name.ToUpper() + "_" + form.name.ToUpper().Replace(' ', '_'), out formId);
                            pokemonTranslator.PokemonSettings.form = formId;
                            pokemonList[gen].Add(new _Pokemon(pokemonTranslator,
                                                              manualDataSettings.PokemonAvailability.GetPokemon(pokemonTranslator.Name, pokemonTranslator.FormName),
                                                              manualDataSettings.Traits,
                                                              GetMaxStats(pokemonTranslator)));
                        }
                    }
                }
            }

            for (int i = 1; i < PokeConstants.Regions.Length; i++)
            {
                string   filePath    = Path.Combine(Utils.OutputDataFileFolder, "pokestats.gen" + i + ".xml");
                DateTime lastUpdated = Utils.GetLastUpdated(filePath);
                if (!File.Exists(filePath) || lastUpdated < updateDateTime)
                {
                    Utils.WriteXML(new PokeStats(i, pokemonList[i].ToArray(), updateDateTime), Path.Combine(Utils.OutputDataFileFolder, "pokestats.gen" + i + ".xml"));
                }
            }
        }