コード例 #1
0
        public SharedSecretBase(byte[] data, SecretBaseManager secretBaseManager)
        {
            if (data.Length != 160)
            {
                throw new Exception("Shared Secret Base must be 160 bytes in length");
            }
            this.secretBaseManager = secretBaseManager;
            this.raw = data;
            this.placedDecorations = new List <PlacedDecoration>();
            this.pokemonTeam       = new List <GBAPokemon>();

            for (int i = 0; i < 16; i++)
            {
                byte id = raw[0x12 + i];
                if (id != 0)
                {
                    byte x = ByteHelper.BitsToByte(raw, 0x22 + i, 4, 4);
                    byte y = ByteHelper.BitsToByte(raw, 0x22 + i, 0, 4);
                    placedDecorations.Add(new PlacedDecoration(id, x, y));
                }
            }

            for (int i = 0; i < 6; i++)
            {
                ushort species = LittleEndian.ToUInt16(raw, 0x7C + i * 2);

                if (species != 0 && PokemonDatabase.GetPokemonFromID(species) != null)
                {
                    uint     personality = LittleEndian.ToUInt32(raw, 0x34 + i * 4);
                    ushort[] moves       = new ushort[4];
                    for (int j = 0; j < 4; j++)
                    {
                        moves[j] = LittleEndian.ToUInt16(raw, 0x4C + j * 2 + i * 8);
                    }
                    ushort heldItem = LittleEndian.ToUInt16(raw, 0x88 + i * 2);
                    byte   level    = raw[0x94 + i];
                    byte   unknown  = raw[0x9A + i];

                    GBAPokemon pokemon = new GBAPokemon();
                    pokemon.SpeciesID   = species;
                    pokemon.Personality = personality;
                    pokemon.TrainerID   = TrainerID;
                    pokemon.SecretID    = SecretID;
                    pokemon.Nickname    = pokemon.PokemonData.Name.ToUpper();
                    for (int j = 0; j < 4; j++)
                    {
                        pokemon.SetMoveAt(j, new Move(moves[j]));
                    }
                    pokemon.HeldItemID = heldItem;
                    pokemon.Language   = Languages.English;
                    pokemon.Experience = PokemonDatabase.GetExperienceFromLevel(pokemon.PokemonData.ExperienceGroup, level);
                    pokemon.Level      = level;
                    pokemon.RecalculateStats();
                    pokemonTeam.Add(pokemon);
                }
            }
        }
コード例 #2
0
        public void LoadPokemon(IPokemon pokemon)
        {
            this.gameIndex            = PokeManager.GetIndexOfGame(pokemon.GameSave);
            this.currentMoveIndex     = -1;
            this.pokemon              = pokemon;
            this.imagePokemon.Source  = pokemon.Sprite;
            this.imagePokemon2.Source = pokemon.Sprite;
            if (pokemon.IsShadowPokemon)
            {
                this.rectShadowMask.OpacityMask  = new ImageBrush(this.imagePokemon.Source);
                this.rectShadowMask2.OpacityMask = new ImageBrush(this.imagePokemon.Source);
                this.rectShadowMask.Visibility   = Visibility.Visible;
                this.rectShadowMask2.Visibility  = Visibility.Visible;
                this.imageShadowAura.Visibility  = Visibility.Visible;
                this.imageShadowAura2.Visibility = Visibility.Visible;
            }
            else
            {
                this.rectShadowMask.Visibility   = Visibility.Hidden;
                this.rectShadowMask2.Visibility  = Visibility.Hidden;
                this.imageShadowAura.Visibility  = Visibility.Hidden;
                this.imageShadowAura2.Visibility = Visibility.Hidden;
            }
            this.imageShinyStar.Visibility  = (pokemon.IsShiny ? Visibility.Visible : Visibility.Hidden);
            this.imageShinyStar2.Visibility = (pokemon.IsShiny ? Visibility.Visible : Visibility.Hidden);
            this.imageBallCaught.Source     = PokemonDatabase.GetBallCaughtImageFromID(pokemon.BallCaughtID);
            this.imageBallCaught2.Source    = PokemonDatabase.GetBallCaughtImageFromID(pokemon.BallCaughtID);


            if (pokemon.IsEgg)
            {
                this.labelNickname.Content = "EGG";
            }
            else
            {
                this.labelNickname.Content = pokemon.Nickname;
            }
            this.labelLevel.Content = "Lv " + pokemon.Level.ToString();
            if (pokemon.Gender == Genders.Male)
            {
                this.labelGender.Content    = "♂";
                this.labelGender.Foreground = new SolidColorBrush(Color.FromRgb(0, 136, 184));
            }
            else if (pokemon.Gender == Genders.Female)
            {
                this.labelGender.Content    = "♀";
                this.labelGender.Foreground = new SolidColorBrush(Color.FromRgb(184, 88, 80));
            }
            else
            {
                this.labelGender.Content = "";
            }

            if (pokemon.IsEgg)
            {
                this.labelOTName.Content    = "?????";
                this.labelOTName.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
                this.labelOTID.Content      = "?????";
                this.labelSecretID.Content  = "?????";
            }
            else
            {
                this.labelOTName.Content = pokemon.TrainerName;
                if (pokemon.TrainerGender == Genders.Male)
                {
                    this.labelOTName.Foreground = new SolidColorBrush(Color.FromRgb(0, 136, 184));
                }
                else if (pokemon.TrainerGender == Genders.Female)
                {
                    this.labelOTName.Foreground = new SolidColorBrush(Color.FromRgb(184, 88, 80));
                }
                this.labelOTID.Content     = pokemon.TrainerID.ToString("00000");
                this.labelSecretID.Content = pokemon.SecretID.ToString("00000");
            }

            if (pokemon.HasForm)
            {
                this.labelSpeciesName.Content = pokemon.PokemonFormData.Name;
            }
            else
            {
                this.labelSpeciesName.Content = pokemon.PokemonData.Name;
            }
            this.labelSpeciesNumber.Content = "No. " + pokemon.DexID.ToString("000");

            this.labelHPIV.Content        = pokemon.HPIV.ToString();
            this.labelAttackIV.Content    = pokemon.AttackIV.ToString();
            this.labelDefenseIV.Content   = pokemon.DefenseIV.ToString();
            this.labelSpAttackIV.Content  = pokemon.SpAttackIV.ToString();
            this.labelSpDefenseIV.Content = pokemon.SpDefenseIV.ToString();
            this.labelSpeedIV.Content     = pokemon.SpeedIV.ToString();

            this.labelHPEV.Content        = pokemon.HPEV.ToString();
            this.labelAttackEV.Content    = pokemon.AttackEV.ToString();
            this.labelDefenseEV.Content   = pokemon.DefenseEV.ToString();
            this.labelSpAttackEV.Content  = pokemon.SpAttackEV.ToString();
            this.labelSpDefenseEV.Content = pokemon.SpDefenseEV.ToString();
            this.labelSpeedEV.Content     = pokemon.SpeedEV.ToString();

            this.labelHPStat.Content        = pokemon.HP.ToString();
            this.labelAttackStat.Content    = pokemon.Attack.ToString();
            this.labelDefenseStat.Content   = pokemon.Defense.ToString();
            this.labelSpAttackStat.Content  = pokemon.SpAttack.ToString();
            this.labelSpDefenseStat.Content = pokemon.SpDefense.ToString();
            this.labelSpeedStat.Content     = pokemon.Speed.ToString();

            this.labelCool.Content   = pokemon.Coolness.ToString();
            this.labelBeauty.Content = pokemon.Beauty.ToString();
            this.labelCute.Content   = pokemon.Cuteness.ToString();
            this.labelSmart.Content  = pokemon.Smartness.ToString();
            this.labelTough.Content  = pokemon.Toughness.ToString();
            this.labelFeel.Content   = pokemon.Feel.ToString();

            if (pokemon.Move1ID != 0)
            {
                this.labelMove1Name.Content        = PokemonDatabase.GetMoveFromID(pokemon.Move1ID).Name;
                this.labelMove1PP.Content          = pokemon.Move1TotalPP.ToString();
                this.typeMove1.Type                = PokemonDatabase.GetMoveFromID(pokemon.Move1ID).Type;
                this.typeMove1.Visibility          = Visibility.Visible;
                this.labelContestMove1Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move1ID).Name;
                this.labelContestMove1PP.Content   = (pokemon.Move1Data.PP == 0 ? "--" : pokemon.Move1TotalPP.ToString());
                this.conditionMove1.Type           = PokemonDatabase.GetMoveFromID(pokemon.Move1ID).ConditionType;
                this.conditionMove1.Visibility     = Visibility.Visible;
            }
            else
            {
                this.labelMove1Name.Content        = "-";
                this.labelMove1PP.Content          = "--";
                this.typeMove1.Visibility          = Visibility.Hidden;
                this.labelContestMove1Name.Content = "-";
                this.labelContestMove1PP.Content   = "--";
                this.conditionMove1.Visibility     = Visibility.Hidden;
            }
            if (pokemon.Move2ID != 0)
            {
                this.labelMove2Name.Content        = PokemonDatabase.GetMoveFromID(pokemon.Move2ID).Name;
                this.labelMove2PP.Content          = pokemon.Move2TotalPP.ToString();
                this.typeMove2.Type                = PokemonDatabase.GetMoveFromID(pokemon.Move2ID).Type;
                this.typeMove2.Visibility          = Visibility.Visible;
                this.labelContestMove2Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move2ID).Name;
                this.labelContestMove2PP.Content   = (pokemon.Move2Data.PP == 0 ? "--" : pokemon.Move2TotalPP.ToString());
                this.conditionMove2.Type           = PokemonDatabase.GetMoveFromID(pokemon.Move2ID).ConditionType;
                this.conditionMove2.Visibility     = Visibility.Visible;
            }
            else
            {
                this.labelMove2Name.Content        = "-";
                this.labelMove2PP.Content          = "--";
                this.typeMove2.Visibility          = Visibility.Hidden;
                this.labelContestMove2Name.Content = "-";
                this.labelContestMove2PP.Content   = "--";
                this.conditionMove2.Visibility     = Visibility.Hidden;
            }
            if (pokemon.Move3ID != 0)
            {
                this.labelMove3Name.Content        = PokemonDatabase.GetMoveFromID(pokemon.Move3ID).Name;
                this.labelMove3PP.Content          = pokemon.Move3TotalPP.ToString();
                this.typeMove3.Type                = PokemonDatabase.GetMoveFromID(pokemon.Move3ID).Type;
                this.typeMove3.Visibility          = Visibility.Visible;
                this.labelContestMove3Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move3ID).Name;
                this.labelContestMove3PP.Content   = (pokemon.Move3Data.PP == 0 ? "--" : pokemon.Move3TotalPP.ToString());
                this.conditionMove3.Type           = PokemonDatabase.GetMoveFromID(pokemon.Move3ID).ConditionType;
                this.conditionMove3.Visibility     = Visibility.Visible;
            }
            else
            {
                this.labelMove3Name.Content        = "-";
                this.labelMove3PP.Content          = "--";
                this.typeMove3.Visibility          = Visibility.Hidden;
                this.labelContestMove3Name.Content = "-";
                this.labelContestMove3PP.Content   = "--";
                this.conditionMove3.Visibility     = Visibility.Hidden;
            }
            if (pokemon.Move4ID != 0)
            {
                this.labelMove4Name.Content        = PokemonDatabase.GetMoveFromID(pokemon.Move4ID).Name;
                this.labelMove4PP.Content          = pokemon.Move4TotalPP.ToString();
                this.typeMove4.Type                = PokemonDatabase.GetMoveFromID(pokemon.Move4ID).Type;
                this.typeMove4.Visibility          = Visibility.Visible;
                this.labelContestMove4Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move4ID).Name;
                this.labelContestMove4PP.Content   = (pokemon.Move4Data.PP == 0 ? "--" : pokemon.Move4TotalPP.ToString());
                this.conditionMove4.Type           = PokemonDatabase.GetMoveFromID(pokemon.Move4ID).ConditionType;
                this.conditionMove4.Visibility     = Visibility.Visible;
            }
            else
            {
                this.labelMove4Name.Content        = "-";
                this.labelMove4PP.Content          = "--";
                this.typeMove4.Visibility          = Visibility.Hidden;
                this.labelContestMove4Name.Content = "-";
                this.labelContestMove4PP.Content   = "--";
                this.conditionMove4.Visibility     = Visibility.Hidden;
            }

            if (pokemon.IsHoldingItem)
            {
                this.imageHeldItem.Source  = ItemDatabase.GetItemImageFromID(pokemon.HeldItemID);
                this.labelHeldItem.Content = ItemDatabase.GetItemFromID(pokemon.HeldItemID).Name;
            }
            else
            {
                this.imageHeldItem.Source  = null;
                this.labelHeldItem.Content = "None";
            }
            if (pokemon.IsEgg)
            {
                this.labelFriendshipText.Content = "Hatch Counter";
                this.labelFriendship.Content     = pokemon.Friendship.ToString() + " Cycles";
            }
            else
            {
                this.labelFriendshipText.Content = "Friendship";
                this.labelFriendship.Content     = pokemon.Friendship.ToString();
            }


            this.labelNature.Content        = pokemon.NatureData.Name;
            this.labelNatureRaised.Content  = "+" + pokemon.NatureData.RaisedStat.ToString();
            this.labelNatureLowered.Content = "-" + pokemon.NatureData.LoweredStat.ToString();

            this.labelAbility.Content             = pokemon.AbilityData.Name;
            this.textBlockAbilityDescription.Text = pokemon.AbilityData.Description;

            if (pokemon.IsShadowPokemon)
            {
                uint totalPurification = pokemon.HeartGauge;
                uint levelStartExp     = PokemonDatabase.GetExperienceFromLevel(pokemon.PokemonData.ExperienceGroup, pokemon.Level);
                this.labelNextLevelText.Content    = "Exp Stored";
                this.labelNextLevel.Content        = pokemon.ExperienceStored.ToString() + " (+" + (PokemonDatabase.GetLevelFromExperience(pokemon.PokemonData.ExperienceGroup, pokemon.Experience + pokemon.ExperienceStored) - pokemon.Level).ToString() + ")";
                this.labelTotalExperience.Content  = pokemon.Experience.ToString();
                this.labelExperienceText2.Content  = "Heart Gauge";
                this.labelTotalExperience2.Content = pokemon.Purification.ToString();

                double ratio = (double)Math.Max(0, pokemon.Purification) / (double)totalPurification;
                LinearGradientBrush purBrush = new LinearGradientBrush();
                purBrush.GradientStops.Add(new GradientStop(Color.FromRgb(160, 72, 220), 0));
                purBrush.GradientStops.Add(new GradientStop(Color.FromRgb(160, 72, 220), ratio));
                purBrush.GradientStops.Add(new GradientStop(Color.FromRgb(225, 235, 250), ratio));
                purBrush.GradientStops.Add(new GradientStop(Color.FromRgb(225, 235, 250), 1));
                this.rectExperienceBar.Fill = purBrush;

                this.rectPurificationBorder1.Visibility = Visibility.Visible;
                this.rectPurificationBorder2.Visibility = Visibility.Visible;
            }
            else
            {
                this.labelExperienceText.Content   = "Experience";
                this.labelNextLevelText.Content    = "Next Level";
                this.labelExperienceText2.Content  = "";
                this.labelTotalExperience2.Content = "";
                uint levelStartExp = PokemonDatabase.GetExperienceFromLevel(pokemon.PokemonData.ExperienceGroup, pokemon.Level);
                uint levelNextExp  = PokemonDatabase.GetExperienceFromLevel(pokemon.PokemonData.ExperienceGroup, (byte)Math.Min(100, (int)pokemon.Level + 1));
                this.labelTotalExperience.Content = pokemon.Experience.ToString();
                this.labelNextLevel.Content       = (levelNextExp - levelStartExp).ToString();

                double ratio = (double)(pokemon.Experience - levelStartExp) / (double)(levelNextExp - levelStartExp);
                LinearGradientBrush expBrush = new LinearGradientBrush();
                expBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 160, 220), 0));
                expBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 160, 220), ratio));
                expBrush.GradientStops.Add(new GradientStop(Color.FromRgb(100, 100, 100), ratio));
                expBrush.GradientStops.Add(new GradientStop(Color.FromRgb(100, 100, 100), 1));
                this.rectExperienceBar.Fill = expBrush;

                this.rectPurificationBorder1.Visibility = Visibility.Hidden;
                this.rectPurificationBorder2.Visibility = Visibility.Hidden;
            }

            this.labelPokerus.Content = pokemon.PokerusStatus.ToString();

            if (pokemon.IsEgg)
            {
                this.labelMetAtText.Content     = "Waiting to Hatch";
                this.labelMetAtLevel.Content    = "";
                this.labelMetAtLocation.Content = "";
                this.labelGame.Content          = "";
            }
            else
            {
                if (pokemon.LevelMet == 0)
                {
                    this.labelMetAtText.Content  = "Hatched At";
                    this.labelMetAtLevel.Content = "Lv 5";
                }
                else
                {
                    this.labelMetAtText.Content  = (pokemon.IsFatefulEncounter ? "Fateful Encounter At" : "Met At");
                    this.labelMetAtLevel.Content = "Lv " + pokemon.LevelMet.ToString();
                }
                this.labelMetAtLocation.Content = (pokemon.GameOrigin == GameOrigins.ColosseumXD ? "Orre Region" : PokemonDatabase.GetMetLocationFromID(pokemon.MetLocationID));
                this.labelGame.Content          = pokemon.GameOrigin.ToString() + " (" + pokemon.Language.ToString() + ")";
            }

            this.type1Pokemon.Type = pokemon.PokemonData.Type1;
            if (pokemon.PokemonData.HasTwoTypes)
            {
                this.type2Pokemon.Type       = pokemon.PokemonData.Type2;
                this.type2Pokemon.Visibility = Visibility.Visible;
            }
            else
            {
                this.type2Pokemon.Visibility = Visibility.Hidden;
            }

            Brush unmarkedBrush = new SolidColorBrush(Color.FromRgb(200, 200, 200));
            Brush markedBrush   = new SolidColorBrush(Color.FromRgb(0, 0, 0));

            markCircle.Foreground   = (pokemon.IsCircleMarked ? markedBrush : unmarkedBrush);
            markSquare.Foreground   = (pokemon.IsSquareMarked ? markedBrush : unmarkedBrush);
            markTriangle.Foreground = (pokemon.IsTriangleMarked ? markedBrush : unmarkedBrush);
            markHeart.Foreground    = (pokemon.IsHeartMarked ? markedBrush : unmarkedBrush);

            stackPanelRibbons.Children.Clear();
            for (int i = 0; i < pokemon.CoolRibbonCount; i++)
            {
                AddRibbon("COOL-" + (i + 1).ToString());
            }
            for (int i = 0; i < pokemon.BeautyRibbonCount; i++)
            {
                AddRibbon("BEAUTY-" + (i + 1).ToString());
            }
            for (int i = 0; i < pokemon.CuteRibbonCount; i++)
            {
                AddRibbon("CUTE-" + (i + 1).ToString());
            }
            for (int i = 0; i < pokemon.SmartRibbonCount; i++)
            {
                AddRibbon("SMART-" + (i + 1).ToString());
            }
            for (int i = 0; i < pokemon.ToughRibbonCount; i++)
            {
                AddRibbon("TOUGH-" + (i + 1).ToString());
            }

            /*for (int i = 0; i < 4; i++)
             *      AddRibbon("COOL-" + (i + 1).ToString());
             * for (int i = 0; i < 4; i++)
             *      AddRibbon("BEAUTY-" + (i + 1).ToString());
             * for (int i = 0; i < 4; i++)
             *      AddRibbon("CUTE-" + (i + 1).ToString());
             * for (int i = 0; i < 4; i++)
             *      AddRibbon("SMART-" + (i + 1).ToString());
             * for (int i = 0; i < 4; i++)
             *      AddRibbon("TOUGH-" + (i + 1).ToString());*/
            /*AddRibbon("CHAMPION");
             * AddRibbon("WINNING");
             * AddRibbon("VICTORY");
             * AddRibbon("ARTIST");
             * AddRibbon("EFFORT");
             * AddRibbon("MARINE");
             * AddRibbon("LAND");
             * AddRibbon("SKY");
             * AddRibbon("COUNTRY");
             * AddRibbon("NATIONAL");
             * AddRibbon("EARTH");
             * AddRibbon("WORLD");*/
            if (pokemon.HasChampionRibbon)
            {
                AddRibbon("CHAMPION");
            }
            if (pokemon.HasWinningRibbon)
            {
                AddRibbon("WINNING");
            }
            if (pokemon.HasVictoryRibbon)
            {
                AddRibbon("VICTORY");
            }
            if (pokemon.HasArtistRibbon)
            {
                AddRibbon("ARTIST");
            }
            if (pokemon.HasEffortRibbon)
            {
                AddRibbon("EFFORT");
            }
            if (pokemon.HasMarineRibbon)
            {
                AddRibbon("MARINE");
            }
            if (pokemon.HasLandRibbon)
            {
                AddRibbon("LAND");
            }
            if (pokemon.HasSkyRibbon)
            {
                AddRibbon("SKY");
            }
            if (pokemon.HasCountryRibbon)
            {
                AddRibbon("COUNTRY");
            }
            if (pokemon.HasNationalRibbon)
            {
                AddRibbon("NATIONAL");
            }
            if (pokemon.HasEarthRibbon)
            {
                AddRibbon("EARTH");
            }
            if (pokemon.HasWorldRibbon)
            {
                AddRibbon("WORLD");
            }

            buttonBall.IsEnabled     = !pokemon.IsEgg;
            buttonNickname.IsEnabled = !pokemon.IsEgg && !pokemon.IsShadowPokemon;
            buttonDeoxys.IsEnabled   = pokemon.DexID == 386;
            ButtonEVs.IsEnabled      = !pokemon.IsEgg && !pokemon.IsShadowPokemon;

            buttonMarkings.IsEnabled = true;
            buttonMoves.IsEnabled    = !pokemon.IsEgg && !pokemon.IsShadowPokemon;
            buttonGive.IsEnabled     = !pokemon.IsEgg;
            buttonTake.IsEnabled     = pokemon.IsHoldingItem;

            SetCurrentMove(-1);
        }
コード例 #3
0
        public override void GenerateReward(IGameSave gameSave)
        {
            Random      random      = new Random((int)DateTime.Now.Ticks);
            PokemonData pokemonData = PokemonDatabase.GetPokemonFromDexID(DexID);
            GBAPokemon  pkm         = new GBAPokemon();

            pkm.DexID            = DexID;
            pkm.Personality      = (Personality.HasValue ? Personality.Value : (uint)random.Next());
            pkm.Experience       = PokemonDatabase.GetExperienceFromLevel(pokemonData.ExperienceGroup, (IsEgg ? (byte)5 : Level));
            pkm.IsSecondAbility2 = (IsSecondAbility.HasValue ? IsSecondAbility.Value : (!pokemonData.CanOnlyHaveFirstAbility && random.Next(2) == 1));
            pkm.Nickname         = (Nickname != null ? Nickname : pokemonData.Name.ToUpper());
            pkm.BallCaughtID     = 4;
            pkm.MetLocationID    = 255;
            if (DexID == 151 || DexID == 386)
            {
                pkm.IsFatefulEncounter = true;
            }
            pkm.LevelMet   = (IsEgg ? (byte)0 : Level);
            pkm.Language   = Languages.English;
            pkm.Friendship = (byte)(IsEgg ? 10 : 70);

            // Ownership
            pkm.TrainerName   = (TrainerName != null ? TrainerName : PokeManager.ManagerGameSave.TrainerName);
            pkm.TrainerGender = (TrainerGender.HasValue ? TrainerGender.Value : PokeManager.ManagerGameSave.TrainerGender);
            pkm.TrainerID     = (TrainerID.HasValue ? TrainerID.Value : PokeManager.ManagerGameSave.TrainerID);
            pkm.SecretID      = (SecretID.HasValue ? SecretID.Value : PokeManager.ManagerGameSave.SecretID);
            if (TrainerGender.HasValue && TrainerGender.Value == Genders.Genderless)
            {
                pkm.TrainerGender = (random.Next(2) == 1 ? Genders.Female : Genders.Male);
            }

            if (!Personality.HasValue)
            {
                GeneratePID(pkm, random);
            }

            if (HeldItem != null)
            {
                pkm.HeldItemID = HeldItem[random.Next(HeldItem.Length)];
            }

            if (Conditions != null)
            {
                pkm.Coolness  = Conditions[0];
                pkm.Beauty    = Conditions[1];
                pkm.Cuteness  = Conditions[2];
                pkm.Smartness = Conditions[3];
                pkm.Toughness = Conditions[4];
                pkm.Feel      = Conditions[5];
            }

            pkm.HPIV        = (IVs != null ? IVs[0] : (byte)random.Next(32));
            pkm.AttackIV    = (IVs != null ? IVs[1] : (byte)random.Next(32));
            pkm.DefenseIV   = (IVs != null ? IVs[2] : (byte)random.Next(32));
            pkm.SpAttackIV  = (IVs != null ? IVs[3] : (byte)random.Next(32));
            pkm.SpDefenseIV = (IVs != null ? IVs[4] : (byte)random.Next(32));
            pkm.SpeedIV     = (IVs != null ? IVs[5] : (byte)random.Next(32));

            if (HiddenPowerDamage.HasValue)
            {
                pkm.SetHiddenPowerDamage(HiddenPowerDamage.Value);
            }
            if (HiddenPowerType.HasValue)
            {
                pkm.SetHiddenPowerType(HiddenPowerType.Value);
            }

            // Teach the Pokemon all of it's default moves
            ushort[] moves = PokemonDatabase.GetMovesLearnedAtLevelRange(pkm, 1, (IsEgg ? (byte)5 : Level));
            foreach (ushort moveID in moves)
            {
                if (!PokemonDatabase.PokemonHasMove(pkm, moveID))
                {
                    if (pkm.NumMoves < 4)
                    {
                        pkm.SetMoveAt(pkm.NumMoves, new Move(moveID));
                    }
                    else
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            pkm.SetMoveAt(i, pkm.GetMoveAt(i + 1));
                        }
                        pkm.SetMoveAt(3, new Move(moveID));
                    }
                }
            }
            if (Move1ID.HasValue)
            {
                pkm.SetMoveAt(0, new Move(Move1ID.Value));
            }
            if (Move2ID.HasValue)
            {
                pkm.SetMoveAt(1, new Move(Move2ID.Value));
            }
            if (Move3ID.HasValue)
            {
                pkm.SetMoveAt(2, new Move(Move3ID.Value));
            }
            if (Move4ID.HasValue)
            {
                pkm.SetMoveAt(3, new Move(Move4ID.Value));
            }

            GameTypes gameType = gameSave.GameType;

            if (gameType == GameTypes.Ruby)
            {
                pkm.GameOrigin = GameOrigins.Ruby;
            }
            else if (gameType == GameTypes.Sapphire)
            {
                pkm.GameOrigin = GameOrigins.Sapphire;
            }
            else if (gameType == GameTypes.Emerald)
            {
                pkm.GameOrigin = GameOrigins.Emerald;
            }
            else if (gameType == GameTypes.FireRed)
            {
                pkm.GameOrigin = GameOrigins.FireRed;
            }
            else if (gameType == GameTypes.LeafGreen)
            {
                pkm.GameOrigin = GameOrigins.LeafGreen;
            }
            else if (gameType == GameTypes.Colosseum ||
                     gameType == GameTypes.XD)
            {
                pkm.GameOrigin = GameOrigins.ColosseumXD;
            }
            else
            {
                pkm.GameOrigin = GameOrigins.Emerald;
            }

            pkm.GameType = gameType;
            pkm.Checksum = pkm.CalculateChecksum();
            pkm.RecalculateStats();
            reward = pkm;
        }