示例#1
0
        public static PokemonInstance GenerateFromBasicSpecification(PokemonInstance.BasicSpecification spec)
        {
            int          speciesId, experience;
            int          natureId;
            Stats <byte> effortValues;
            Stats <byte> individualValues;

            int[]  moves;
            byte[] movePPs;
            bool?  gender;

            speciesId        = spec.speciesId;
            experience       = spec.GetExperienceFromLevel();
            natureId         = Nature.GetRandomNatureId();
            effortValues     = spec.EVs;
            individualValues = spec.useRandomIVs ? GenerateRandomIVs() : spec.IVs;
            if (spec.useAutomaticMoves)
            {
                moves = ChooseMovesFromSpeciesAndLevel(speciesId, spec.level, out movePPs);
            }
            else
            {
                moves   = spec.moveIds;
                movePPs = moves
                          .Select(x => Moves.PokemonMove.MoveIdIsUnset(x)
                    ? (byte)0
                    : Moves.PokemonMove.GetPokemonMoveById(x).maxPP)
                          .ToArray();
            }
            gender = spec.GetGender();

            return(GenerateFull(
                       speciesId: speciesId,
                       natureId: natureId,
                       effortValues: effortValues,
                       individualValues: individualValues,

                       _moves: moves,
                       movePPs: movePPs,
                       experience: experience,
                       nonVolatileStatusCondition: PokemonInstance.NonVolatileStatusCondition.None,
                       battleProperties: null,
                       gender: gender,

                       pokeBallId: spec.pokeBallId > 0 ? spec.pokeBallId : PokemonInstance.defaultPokeBallId,
                       nickname: spec.nickname
                       ));
        }
示例#2
0
        /// <summary>
        /// Generate a PokemonInstance as if for in the wild
        /// </summary>
        /// <param name="possibleSpeciesIds">Array of species ids that the pokemon could be</param>
        /// <param name="minLevel">The minimum level for the PokemonInstance (inclusive)</param>
        /// <param name="maxLevel">The maximum level for the PokemonInstance (inclusive)</param>
        /// <returns>The PokemonInstance created</returns>
        public static PokemonInstance GenerateWild(
            int speciesId,
            byte minLevel,
            byte maxLevel,
            string originalTrainerName = "",
            Guid?originalTrainerGuid   = null,
            long catchTime             = 0,
            bool shinyPokemon          = false
            )
        {
            int          experience;
            byte         level;
            int          natureId;
            Stats <byte> effortValues;
            Stats <byte> individualValues;

            int[]  moves;
            byte[] movePPs;
            bool?  gender;

            PokemonSpecies species = PokemonSpecies.GetPokemonSpeciesById(speciesId);

            #region Stats

            level      = ChooseLevelInRange(minLevel, maxLevel);
            experience = GrowthTypeData.GetMinimumExperienceForLevel(level, species.growthType);

            natureId = Nature.GetRandomNatureId();

            effortValues = new Stats <byte>()
            {
                attack         = 0,
                defense        = 0,
                specialAttack  = 0,
                specialDefense = 0,
                speed          = 0,
                health         = 0
            };

            individualValues = GenerateRandomIVs();

            #endregion

            moves = ChooseMovesFromSpeciesAndLevel(speciesId, level, out movePPs);

            gender = ChooseRandomGender(speciesId);

            return(GenerateFull(
                       speciesId: speciesId,
                       natureId: natureId,
                       effortValues: effortValues,
                       individualValues: individualValues,

                       _moves: moves,
                       movePPs: movePPs,
                       experience: experience,
                       nonVolatileStatusCondition: PokemonInstance.NonVolatileStatusCondition.None,
                       battleProperties: null,
                       gender: gender,

                       originalTrainerName: originalTrainerName,
                       _originalTrainerGuid: originalTrainerGuid,
                       catchTime: catchTime,

                       shinyPokemon: shinyPokemon
                       ));
        }