예제 #1
0
파일: PKM.cs 프로젝트: Arch9SK7/PKHeX
        public PKM convertToPK3()
        {
            if (Format != 3)
            {
                return(null);
            }
            if (GetType() == typeof(PK3))
            {
                return(this);
            }
            var pk = new PK3();

            TransferPropertiesWithReflection(this, pk);
            pk.RefreshChecksum();
            return(pk);
        }
예제 #2
0
        private PKM preparePK3()
        {
            PK3 pk3 = pkm as PK3;

            if (pk3 == null)
            {
                return(null);
            }

            pk3.Species       = Util.getIndex(CB_Species);
            pk3.HeldItem      = Util.getIndex(CB_HeldItem);
            pk3.TID           = Util.ToInt32(TB_TID.Text);
            pk3.SID           = Util.ToInt32(TB_SID.Text);
            pk3.EXP           = Util.ToUInt32(TB_EXP.Text);
            pk3.PID           = Util.getHEXval(TB_PID.Text);
            pk3.AbilityNumber = CB_Ability.SelectedIndex; // 0/1 (stored in IVbits)

            pk3.FatefulEncounter = CHK_Fateful.Checked;
            pk3.Gender           = PKX.getGender(Label_Gender.Text);
            pk3.EV_HP            = Util.ToInt32(TB_HPEV.Text);
            pk3.EV_ATK           = Util.ToInt32(TB_ATKEV.Text);
            pk3.EV_DEF           = Util.ToInt32(TB_DEFEV.Text);
            pk3.EV_SPE           = Util.ToInt32(TB_SPEEV.Text);
            pk3.EV_SPA           = Util.ToInt32(TB_SPAEV.Text);
            pk3.EV_SPD           = Util.ToInt32(TB_SPDEV.Text);

            pk3.CNT_Cool   = Util.ToInt32(TB_Cool.Text);
            pk3.CNT_Beauty = Util.ToInt32(TB_Beauty.Text);
            pk3.CNT_Cute   = Util.ToInt32(TB_Cute.Text);
            pk3.CNT_Smart  = Util.ToInt32(TB_Smart.Text);
            pk3.CNT_Tough  = Util.ToInt32(TB_Tough.Text);
            pk3.CNT_Sheen  = Util.ToInt32(TB_Sheen.Text);

            pk3.PKRS_Days   = CB_PKRSDays.SelectedIndex;
            pk3.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
            pk3.Nickname    = TB_Nickname.Text;
            pk3.Move1       = Util.getIndex(CB_Move1);
            pk3.Move2       = Util.getIndex(CB_Move2);
            pk3.Move3       = Util.getIndex(CB_Move3);
            pk3.Move4       = Util.getIndex(CB_Move4);
            pk3.Move1_PP    = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk3.Move2_PP    = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk3.Move3_PP    = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk3.Move4_PP    = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk3.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk3.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk3.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk3.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;

            pk3.IV_HP       = Util.ToInt32(TB_HPIV.Text);
            pk3.IV_ATK      = Util.ToInt32(TB_ATKIV.Text);
            pk3.IV_DEF      = Util.ToInt32(TB_DEFIV.Text);
            pk3.IV_SPE      = Util.ToInt32(TB_SPEIV.Text);
            pk3.IV_SPA      = Util.ToInt32(TB_SPAIV.Text);
            pk3.IV_SPD      = Util.ToInt32(TB_SPDIV.Text);
            pk3.IsEgg       = CHK_IsEgg.Checked;
            pk3.IsNicknamed = CHK_Nicknamed.Checked;

            pk3.OT_Name           = TB_OT.Text;
            pk3.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);

            pk3.Ball      = Util.getIndex(CB_Ball);
            pk3.Met_Level = Util.ToInt32(TB_MetLevel.Text);
            pk3.OT_Gender = PKX.getGender(Label_OTGender.Text);
            pk3.Version   = Util.getIndex(CB_GameOrigin);
            pk3.Language  = Util.getIndex(CB_Language);

            pk3.Met_Location = Util.getIndex(CB_MetLocation);

            // Toss in Party Stats
            Array.Resize(ref pk3.Data, pk3.SIZE_PARTY);
            pk3.Stat_Level     = Util.ToInt32(TB_Level.Text);
            pk3.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
            pk3.Stat_HPMax     = Util.ToInt32(Stat_HP.Text);
            pk3.Stat_ATK       = Util.ToInt32(Stat_ATK.Text);
            pk3.Stat_DEF       = Util.ToInt32(Stat_DEF.Text);
            pk3.Stat_SPE       = Util.ToInt32(Stat_SPE.Text);
            pk3.Stat_SPA       = Util.ToInt32(Stat_SPA.Text);
            pk3.Stat_SPD       = Util.ToInt32(Stat_SPD.Text);

            if (HaX)
            {
                pk3.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
            }

            // Fix Moves if a slot is empty
            pk3.FixMoves();

            pk3.RefreshChecksum();
            return(pk3);
        }