예제 #1
0
 public static bool?ChooseRandomGender(int speciesId)
 => PokemonSpecies.GetPokemonSpeciesById(speciesId).GetRandomWeightedGender();
예제 #2
0
        /// <summary>
        /// Generate a PokemonInstance specifying many property values
        /// </summary>
        /// <returns>The PokemonInstance created</returns>
        public static PokemonInstance GenerateFull(
            int speciesId,
            int natureId,
            Stats <byte> effortValues,
            Stats <byte> individualValues,
            int[] _moves,
            byte[] movePPs,
            int experience,
            PokemonInstance.NonVolatileStatusCondition nonVolatileStatusCondition,
            PokemonInstance.BattleProperties battleProperties,
            Guid?_guid                 = null,
            string nickname            = "",
            Item heldItem              = null,
            int _health                = -1,
            bool?gender                = true,
            Stats <int> currentStats   = new Stats <int>(),                 //If all of these values are 0, they won't be used
            int pokeBallId             = PokemonInstance.defaultPokeBallId, //The poke ball id
            string originalTrainerName = "",
            Guid?_originalTrainerGuid  = null,
            bool cheatPokemon          = false,
            bool shinyPokemon          = false,
            long catchTime             = 0,
            byte?_friendship           = null // If this is null, the species' base friendship is used
            )
        {
            Guid guid = _guid == null?Guid.NewGuid() : (Guid)_guid;

            int[] moves = new int[4];

            //By default, the moves will be unset
            for (int i = 0; i < moves.Length; i++)
            {
                moves[i] = -1;
            }

            if (_moves.Length > 4)
            {
                Debug.LogWarning("Length of moves passed to GenerateFull was greater than 4");
                Array.Copy(_moves, moves, 4);
            }

            Array.Copy(_moves, moves, _moves.Length);

            Guid originalTrainerGuid = _originalTrainerGuid == null ? Guid.Empty : (Guid)_originalTrainerGuid;

            byte friendship = _friendship == null?PokemonSpecies.GetPokemonSpeciesById(speciesId).baseFriendship : (byte)_friendship;

            PokemonInstance instance = new PokemonInstance(individualValues)
            {
                speciesId    = speciesId,
                natureId     = natureId,
                effortValues = effortValues,
                moveIds      = moves,
                movePPs      = movePPs,
                experience   = experience,
                nonVolatileStatusCondition = nonVolatileStatusCondition,
                battleProperties           = battleProperties,
                guid                = guid,
                nickname            = nickname,
                heldItem            = heldItem,
                health              = _health > 0 ? _health : 1,
                gender              = gender,
                pokeBallId          = pokeBallId,
                originalTrainerName = originalTrainerName,
                originalTrainerGuid = originalTrainerGuid,
                cheatPokemon        = cheatPokemon,
                catchTime           = catchTime,
                friendship          = friendship
            };

            // Shininess
            instance.SetIsShiny(shinyPokemon);

            #region Setting Current Stats

            bool needToSetCurrentStats = false;

            foreach (Stats <int> .Stat stat in (Stats <int> .Stat[])Enum.GetValues(typeof(Stats <int> .Stat)))
            {
                if (currentStats.GetStat(stat) != 0)
                {
                    needToSetCurrentStats = true;
                    break;
                }
            }

            if (needToSetCurrentStats)
            {
                instance.SetCurrentStats(currentStats);
            }

            #endregion

            if (_health <= 0)
            {
                instance.RestoreFully();
            }

            return(instance);
        }
예제 #3
0
        public static int[] ChooseMovesFromSpeciesAndLevel(int speciesId,
                                                           byte level,
                                                           out byte[] movePPs)
        {
            PokemonSpecies species = PokemonSpecies.GetPokemonSpeciesById(speciesId);

            //Set the moves learnt as the last 4 moves that it could have learnt
            Dictionary <byte, int[]> levelUpMoves = species.levelUpMoves;

            int[] moves = new int[4];
            //By default, the moves will be unset
            for (int moveIndex = 0; moveIndex < moves.Length; moveIndex++)
            {
                moves[moveIndex] = -1;
            }

            movePPs = new byte[4];
            int  movesIndex  = 0;
            bool allMovesSet = false;

            byte i = level;

            while (true)
            {
                if (levelUpMoves.ContainsKey(i))
                {
                    foreach (int moveId in levelUpMoves[i])
                    {
                        moves[movesIndex]   = moveId;
                        movePPs[movesIndex] = Moves.PokemonMove.GetPokemonMoveById(moveId).maxPP;
                        movesIndex++;

                        if (movesIndex == 4)
                        {
                            allMovesSet = true;
                            break;
                        }
                    }
                }

                if (allMovesSet)
                {
                    break;
                }

                if (i <= 0)
                {
                    break;
                }

                i--;
            }

            //Add base moves if moves array isn't full yet
            if (!allMovesSet)
            {
                foreach (int moveId in species.baseMoves)
                {
                    moves[movesIndex]   = moveId;
                    movePPs[movesIndex] = Moves.PokemonMove.GetPokemonMoveById(moveId).maxPP;
                    movesIndex++;

                    if (movesIndex == 4)
                    {
                        allMovesSet = true;
                        break;
                    }
                }
            }

            return(moves);
        }
예제 #4
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
                       ));
        }