コード例 #1
0
 public _MoveSet(PokemonTranslator pokemonTranslator, MoveTranslator fastMove, bool fastMoveLegacy, bool fastMoveStab, MoveTranslator chargedMove, bool chargedMoveLegacy, bool chargedMoveStab)
 {
     base_dps      = PokeFormulas.GetMoveSetDPS(pokemonTranslator, fastMove, chargedMove);
     true_dps      = PokeFormulas.GetTrueDPS(pokemonTranslator, fastMove, fastMoveStab, chargedMove, chargedMoveStab);
     FastAttack    = new Attack(fastMove.Name, fastMoveStab, fastMoveLegacy);
     ChargedAttack = new Attack(chargedMove.Name, chargedMoveStab, chargedMoveLegacy);
 }
コード例 #2
0
            public _CPMultipliers()
            {
                List <_CPM> cpms = new List <_CPM>();

                for (int level = 1; level <= 40; level++)
                {
                    cpms.Add(new _CPM(level, PokeFormulas.GetCMP(level)));
                }

                for (int level = 1; level < 40; level++)
                {
                    cpms.Add(new _CPM(level + 0.5, PokeFormulas.GetCMPHalfStep(level)));
                }

                CPM = cpms.ToArray();
            }
コード例 #3
0
        /// <summary>
        /// Write out a single RaidBoss XML file if necessary, then return the text that should be included in the .proj file.
        /// </summary>
        /// <param name="raidboss"></param>
        /// <returns>The text that should be included in the .proj file</returns>
        private static bool WriteEncounter(FieldResearch.RewardEncounter pokemon, DateTime updateDateTime)
        {
            bool     upToDate          = true;
            string   encounterFileName = GetFileNameBase(pokemon);
            string   filePath          = Path.Combine(OutputXmlFolder, encounterFileName + ".xml");
            DateTime lastUpdated       = Utils.GetLastUpdated(filePath);

            if (!File.Exists(filePath) || lastUpdated < updateDateTime)
            {
                Utils.WriteXML(new Encounter(pokemon, Utils.GetEncounterPossibilities(pokemon.PokemonTranslator, 15), updateDateTime), filePath);
                upToDate = false;
            }

            string htmlFilePath = Path.Combine(HtmlFileFolder, encounterFileName + ".html.xml");

            if (!File.Exists(htmlFilePath))
            {
                using (TextWriter htmlWriter = new StreamWriter(htmlFilePath))
                {
                    htmlWriter.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    htmlWriter.WriteLine("<!DOCTYPE Root [");
                    htmlWriter.WriteLine("  <!ENTITY Constants SYSTEM \"/_datafiles/constants.xml\">");
                    htmlWriter.WriteLine("  <!ENTITY Settings SYSTEM \"/_datafiles/settings.xml\">");
                    htmlWriter.WriteLine("  <!ENTITY PokeSprites SYSTEM \"/_datafiles.manual/infrequent/pokemon.sprites.xml\">");
                    htmlWriter.WriteLine("  <!ENTITY Images SYSTEM \"/_datafiles.manual/infrequent/images.xml\">");
                    htmlWriter.WriteLine("  <!ENTITY PokeStats SYSTEM \"/_datafiles/pokestats.gen" + PokeFormulas.GetGeneration(pokemon.id) + ".xml\">");
                    htmlWriter.WriteLine("  <!ENTITY Encounter SYSTEM \"/_datafiles/encounter/" + encounterFileName + ".xml\">");
                    htmlWriter.WriteLine("]>");
                    htmlWriter.WriteLine("<?xml-stylesheet type=\"text/xsl\" href=\"encounter.xsl\" output=\"" + encounterFileName + ".html\"?>");
                    htmlWriter.WriteLine("<Root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
                    htmlWriter.WriteLine("  &Constants; ");
                    htmlWriter.WriteLine("  &Settings;");
                    htmlWriter.WriteLine("  &PokeSprites;");
                    htmlWriter.WriteLine("  &Images;");
                    htmlWriter.WriteLine("  &PokeStats;");
                    htmlWriter.WriteLine("  &Encounter;");
                    htmlWriter.WriteLine("</Root> ");
                }

                upToDate = false;
            }

            return(upToDate);
        }
コード例 #4
0
        /// <summary>
        /// Write out a single RaidBoss XML file if necessary, then return the text that should be included in the .proj file.
        /// </summary>
        /// <param name="raidboss"></param>
        /// <returns>The text that should be included in the .proj file</returns>
        private static bool WriteRaidBoss(RaidBosses._RaidBoss raidboss, DateTime updateDateTime)
        {
            bool     upToDate         = true;
            string   raidbossFileName = GetFileNameBase(raidboss);
            string   filePath         = Path.Combine(OutputXmlFolder, raidbossFileName + ".xml");
            DateTime lastUpdated      = Utils.GetLastUpdated(filePath);

            if (!File.Exists(filePath) || lastUpdated < updateDateTime)
            {
                Common.IVScore baseIV = new Common.IVScore(
                    raidboss.PokemonTranslator.PokemonSettings.stats.base_attack,
                    raidboss.PokemonTranslator.PokemonSettings.stats.base_defense,
                    raidboss.PokemonTranslator.PokemonSettings.stats.base_stamina
                    );
                Utils.WriteXML(
                    new RaidBoss(raidboss, baseIV,
                                 Utils.GetEncounterPossibilities(raidboss.PokemonTranslator, 20),
                                 Utils.GetEncounterPossibilities(raidboss.PokemonTranslator, 25),
                                 updateDateTime),
                    filePath);
                upToDate = false;
            }

            string htmlFilePath = Path.Combine(HtmlFileFolder, raidbossFileName + ".html.xml");

            if (!File.Exists(htmlFilePath))
            {
                using (TextWriter htmlWriter = new StreamWriter(htmlFilePath))
                {
                    htmlWriter.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    htmlWriter.WriteLine("<!DOCTYPE Root [");
                    htmlWriter.WriteLine("  <!ENTITY Constants SYSTEM \"/_datafiles/constants.xml\">");
                    htmlWriter.WriteLine("  <!ENTITY Settings SYSTEM \"/_datafiles/settings.xml\">");
                    htmlWriter.WriteLine("  <!ENTITY PokeSprites SYSTEM \"/_datafiles.manual/infrequent/pokemon.sprites.xml\">");
                    htmlWriter.WriteLine("  <!ENTITY Images SYSTEM \"/_datafiles.manual/infrequent/images.xml\">");
                    htmlWriter.WriteLine("  <!ENTITY PokeStats SYSTEM \"/_datafiles/pokestats.gen" + PokeFormulas.GetGeneration(raidboss.id) + ".xml\">");
                    htmlWriter.WriteLine("  <!ENTITY RaidBoss SYSTEM \"/_datafiles/raidboss/" + raidbossFileName + ".xml\">");
                    htmlWriter.WriteLine("]>");
                    htmlWriter.WriteLine("<?xml-stylesheet type=\"text/xsl\" href=\"raidboss.xsl\" output=\"" + raidbossFileName + ".html\"?>");
                    htmlWriter.WriteLine("<Root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
                    htmlWriter.WriteLine("  &Constants; ");
                    htmlWriter.WriteLine("  &Settings;");
                    htmlWriter.WriteLine("  &PokeSprites;");
                    htmlWriter.WriteLine("  &Images;");
                    htmlWriter.WriteLine("  &PokeStats;");
                    htmlWriter.WriteLine("  &RaidBoss;");
                    htmlWriter.WriteLine("</Root> ");
                }

                upToDate = false;
            }

            return(upToDate);
        }
コード例 #5
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"));
                    }
                }
            }
        }
コード例 #6
0
 public _MoveSet(PokemonTranslator pokemonTranslator, MoveTranslator fastMove, bool fastMoveLegacy, MoveTranslator chargedMove, bool chargedMoveLegacy, bool chargedMoveStab) :
     this(pokemonTranslator, fastMove, fastMoveLegacy, PokeFormulas.HasStab(pokemonTranslator, fastMove), chargedMove, chargedMoveLegacy, chargedMoveStab)
 {
 }
コード例 #7
0
 private static PokeStats._Pokemon._Stats._MaxStats GetMaxStats(PokemonTranslator pokemonTranslator)
 {
     return(new PokeStats._Pokemon._Stats._MaxStats(PokeFormulas.GetMaxCP(pokemonTranslator), PokeFormulas.GetMaxHP(pokemonTranslator)));
 }
コード例 #8
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"));
                }
            }
        }