Ejemplo n.º 1
0
        public static Common.PossibilitySet.Possibility[] GetEncounterPossibilities(PokemonTranslator pokemonTranslator, int level)
        {
            Dictionary <int, List <Common.PossibilitySet.Possibility.IV> > IVs = new Dictionary <int, List <Common.PossibilitySet.Possibility.IV> >();

            for (int attack = PokeConstants.MinRaidBossIV; attack <= PokeConstants.Evaluation.Attribute.Max; attack++)
            {
                for (int defense = PokeConstants.MinRaidBossIV; defense <= PokeConstants.Evaluation.Attribute.Max; defense++)
                {
                    for (int stamina = PokeConstants.MinRaidBossIV; stamina <= PokeConstants.Evaluation.Attribute.Max; stamina++)
                    {
                        Common.IVScore pokemonIV = new Common.IVScore(attack, defense, stamina);
                        Common.IVScore baseIV    = new Common.IVScore(pokemonTranslator.PokemonSettings.stats);

                        int cp = PokeFormulas.GetPokemonCP(baseIV, pokemonIV, level);
                        int hp = PokeFormulas.GetPokemonHP(baseIV.stamina, stamina, level);
                        if (!IVs.ContainsKey(cp))
                        {
                            IVs.Add(cp, new List <Common.PossibilitySet.Possibility.IV>());
                        }
                        IVs[cp].Add(new Common.PossibilitySet.Possibility.IV(pokemonIV, hp));
                    }
                }
            }

            List <Common.PossibilitySet.Possibility> possibilities = new List <Common.PossibilitySet.Possibility>();

            foreach (var ivs in IVs)
            {
                possibilities.Add(new Common.PossibilitySet.Possibility(ivs.Key, ivs.Value.ToArray()));
            }

            return(possibilities.ToArray());
        }
Ejemplo n.º 2
0
            public _Pokemon(PokemonTranslator pokemonTranslator, PokemonAvailability._Pokemon _availability, Traits traits, _Stats._MaxStats maxStats) :
                base(pokemonTranslator.Id, pokemonTranslator.Name, pokemonTranslator.Form)
            {
                family       = pokemonTranslator.CandyType;
                buddy_km     = (int)pokemonTranslator.PokemonSettings.km_buddy_distance;
                gender_ratio = pokemonTranslator.GenderRatio;
                rarity       = pokemonTranslator.Rarity;
                shiny        = _availability.shiny;
                ditto        = traits.CanBeDitto(pokemonTranslator);
                var egg = traits.GetEgg(pokemonTranslator);

                availability = (egg != null && string.Equals(_availability.availability, PokeConstants.Availability.HatchOnly)) ?
                               string.Format(PokeConstants.Availability.HatchOnlyFormat, egg.type) :
                               _availability.availability;

                Type = new PokeTypes(pokemonTranslator.Type1, pokemonTranslator.Type2);

                if (pokemonTranslator.EvolvesFromId > 0)
                {
                    EvolvesFrom = new EvolvesFrom(pokemonTranslator);
                }

                Stats = new _Stats(
                    new _Stats.IVScore(pokemonTranslator.PokemonSettings.stats.base_attack, pokemonTranslator.PokemonSettings.stats.base_defense, pokemonTranslator.PokemonSettings.stats.base_stamina),
                    new _Stats.Variation(pokemonTranslator.PokemonSettings.pokedex_height_m, pokemonTranslator.PokemonSettings.pokedex_height_m),
                    new _Stats.Variation(pokemonTranslator.PokemonSettings.pokedex_weight_kg, pokemonTranslator.PokemonSettings.pokedex_weight_kg),
                    new _Stats._Rates(Math.Min(pokemonTranslator.PokemonSettings.encounter.base_capture_rate, 1.0f), pokemonTranslator.PokemonSettings.encounter.base_flee_rate, pokemonTranslator.PokemonSettings.encounter.attack_probability, pokemonTranslator.PokemonSettings.encounter.dodge_probability),
                    maxStats);
            }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
        public bool CanBeDitto(PokemonTranslator pokemonTranslator)
        {
            foreach (var pokemon in Ditto.Pokemon)
            {
                if (pokemon.id == pokemonTranslator.Id && pokemon.FormId == pokemonTranslator.Form)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        public static double GetMoveSetDPS(PokemonTranslator pokemonTranslator, MoveTranslator fastMove, MoveTranslator chargedMove)
        {
            if (fastMove.Energy == 0)
            {
                return(0);
            }

            double fastMovesToCharge = Math.Ceiling((double)-chargedMove.Energy / (double)fastMove.Energy);
            double damage            = (fastMove.Power * fastMovesToCharge) + chargedMove.Power;
            double time = (fastMove.Duration * fastMovesToCharge) + chargedMove.Duration;

            return(damage / time);
        }
Ejemplo n.º 6
0
        public _Eggs._Egg GetEgg(PokemonTranslator pokemonTranslator)
        {
            foreach (var egg in Eggs.Egg)
            {
                foreach (var pokemon in egg.Pokemon)
                {
                    if (pokemon.id == pokemonTranslator.Id && pokemon.FormId == pokemonTranslator.Form)
                    {
                        return(egg);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 7
0
        private static List <_Pokemon._MoveSet> GetMoveSets(PokemonTranslator pokemonTranslator, Dictionary <PokemonMove, MoveTranslator> moves, bool fastMovesLegacy, bool chargedMovesLegacy)
        {
            List <_Pokemon._MoveSet> moveSets     = new List <_Pokemon._MoveSet>();
            List <PokemonMove>       fastMoves    = new List <PokemonMove>();
            List <PokemonMove>       chargedMoves = new List <PokemonMove>();

            // Avoid duplicates. (They do happen sometimes, such as charged moves in MEW.)
            foreach (var fastMove in fastMovesLegacy ? pokemonTranslator.LegacyFastMoves : pokemonTranslator.PokemonSettings.quick_moves)
            {
                if (!fastMoves.Contains(fastMove))
                {
                    fastMoves.Add(fastMove);
                }
                else
                {
                    ConsoleOutput.OutputWarning($"Duplicate FastMove found: {pokemonTranslator.Id} - {pokemonTranslator.Name} \"{fastMove.ToString()}\"");
                }
            }
            foreach (var chargedMove in chargedMovesLegacy ? pokemonTranslator.LegacyChargedMoves : pokemonTranslator.PokemonSettings.cinematic_moves)
            {
                if (!chargedMoves.Contains(chargedMove))
                {
                    chargedMoves.Add(chargedMove);
                }
                else
                {
                    ConsoleOutput.OutputWarning($"Duplicate ChargedMove found: {pokemonTranslator.Id} - {pokemonTranslator.Name} \"{chargedMove.ToString()}\"");
                }
            }

            foreach (var fastMove in fastMoves)
            {
                foreach (var chargedMove in chargedMoves)
                {
                    if (fastMove == PokemonMove.HIDDEN_POWER_FAST)
                    {
                        moveSets.Add(new _Pokemon._MoveSet(pokemonTranslator, moves[fastMove], fastMovesLegacy, true, moves[chargedMove], chargedMovesLegacy));
                        moveSets.Add(new _Pokemon._MoveSet(pokemonTranslator, moves[fastMove], fastMovesLegacy, false, moves[chargedMove], chargedMovesLegacy));
                    }
                    else
                    {
                        moveSets.Add(new _Pokemon._MoveSet(pokemonTranslator, moves[fastMove], fastMovesLegacy, moves[chargedMove], chargedMovesLegacy));
                    }
                }
            }

            return(moveSets);
        }
Ejemplo n.º 8
0
        public static double GetTrueDPS(PokemonTranslator pokemonTranslator, MoveTranslator fastMove, bool fastMoveStab, MoveTranslator chargedMove, bool chargedMoveStab)
        {
            if (fastMove.Energy == 0)
            {
                return(0);
            }

            double fastSTAB          = fastMoveStab ? STAB_BONUS : 1;
            double chargedSTAB       = chargedMoveStab ? STAB_BONUS : 1;
            double fastMovesToCharge = Math.Ceiling((double)-chargedMove.Energy / (double)fastMove.Energy);
            double fastPower         = (Math.Floor((pokemonTranslator.PokemonSettings.stats.base_attack + PokeConstants.Evaluation.Attribute.Max) * fastMove.Power * fastSTAB / 200) + 1) * fastMovesToCharge;
            double chargedPower      = (Math.Floor((pokemonTranslator.PokemonSettings.stats.base_attack + PokeConstants.Evaluation.Attribute.Max) * chargedMove.Power * chargedSTAB / 200) + 1);
            double time = (fastMove.Duration * fastMovesToCharge) + chargedMove.Duration;

            return((fastPower + chargedPower) / time);
        }
Ejemplo n.º 9
0
 public static double GetTrueDPS(PokemonTranslator pokemonTranslator, MoveTranslator fastMove, MoveTranslator chargedMove)
 {
     return(GetTrueDPS(pokemonTranslator, fastMove, HasStab(pokemonTranslator, fastMove), chargedMove, HasStab(pokemonTranslator, chargedMove)));
 }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
0
 public static bool HasStab(PokemonTranslator pokemonTranslator, MoveTranslator move)
 {
     return(string.Equals(pokemonTranslator.Type1, move.Type, StringComparison.OrdinalIgnoreCase) ||
            string.Equals(pokemonTranslator.Type2, move.Type, StringComparison.OrdinalIgnoreCase));
 }
Ejemplo n.º 12
0
 public static int GetMaxHP(PokemonTranslator pokemonTranslator)
 {
     return(GetPokemonHP(pokemonTranslator.PokemonSettings.stats.base_stamina, PokeConstants.Evaluation.Attribute.Max, PokeConstants.MaxPokemonLevel));
 }
Ejemplo n.º 13
0
 public static int GetMaxCP(PokemonTranslator pokemonTranslator)
 {
     return(GetPokemonCP(new Common.IVScore(pokemonTranslator.PokemonSettings.stats), new Common.IVScore(PokeConstants.Evaluation.Attribute.Max, PokeConstants.Evaluation.Attribute.Max, PokeConstants.Evaluation.Attribute.Max), PokeConstants.MaxPokemonLevel));
 }
Ejemplo n.º 14
0
 public static int GetGeneration(PokemonTranslator pokemon)
 {
     return(GetGeneration(pokemon.Id));
 }
Ejemplo n.º 15
0
 private static PokeStats._Pokemon._Stats._MaxStats GetMaxStats(PokemonTranslator pokemonTranslator)
 {
     return(new PokeStats._Pokemon._Stats._MaxStats(PokeFormulas.GetMaxCP(pokemonTranslator), PokeFormulas.GetMaxHP(pokemonTranslator)));
 }
Ejemplo n.º 16
0
 private static bool IsMoveSetMatch(PokemonTranslator pokemonTranslator1, PokemonTranslator pokemonTranslator2)
 {
     return
         (IsMoveSetMatch(pokemonTranslator1.PokemonSettings.quick_moves, pokemonTranslator2.PokemonSettings.quick_moves) &&
          IsMoveSetMatch(pokemonTranslator1.PokemonSettings.cinematic_moves, pokemonTranslator2.PokemonSettings.cinematic_moves));
 }
Ejemplo n.º 17
0
 public _Pokemon(PokemonTranslator pokemonTranslator, _MoveSet[] moveSet) :
     base(pokemonTranslator.Id, pokemonTranslator.Name, pokemonTranslator.Form)
 {
     MoveSet = moveSet;
 }
Ejemplo n.º 18
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)
 {
 }