Пример #1
0
        public void SavePersonal()
        {
            var pkm = cPersonal;

            pkm.HP  = Util.ToInt32(TB_BaseHP.Text);
            pkm.ATK = Util.ToInt32(TB_BaseATK.Text);
            pkm.DEF = Util.ToInt32(TB_BaseDEF.Text);
            pkm.SPE = Util.ToInt32(TB_BaseSPE.Text);
            pkm.SPA = Util.ToInt32(TB_BaseSPA.Text);
            pkm.SPD = Util.ToInt32(TB_BaseSPD.Text);

            pkm.EV_HP  = Util.ToInt32(TB_HPEVs.Text);
            pkm.EV_ATK = Util.ToInt32(TB_ATKEVs.Text);
            pkm.EV_DEF = Util.ToInt32(TB_DEFEVs.Text);
            pkm.EV_SPE = Util.ToInt32(TB_SPEEVs.Text);
            pkm.EV_SPA = Util.ToInt32(TB_SPAEVs.Text);
            pkm.EV_SPD = Util.ToInt32(TB_SPDEVs.Text);

            pkm.CatchRate = Util.ToInt32(TB_CatchRate.Text);
            pkm.EvoStage  = Util.ToInt32(TB_Stage.Text);

            pkm.Types = new[] { CB_Type1.SelectedIndex, CB_Type2.SelectedIndex };
            pkm.Items = new[] { CB_HeldItem1.SelectedIndex, CB_HeldItem2.SelectedIndex, CB_HeldItem3.SelectedIndex };

            pkm.Gender         = Util.ToInt32(TB_Gender.Text);
            pkm.HatchCycles    = Util.ToInt32(TB_HatchCycles.Text);
            pkm.BaseFriendship = Util.ToInt32(TB_Friendship.Text);
            pkm.EXPGrowth      = (byte)CB_EXPGroup.SelectedIndex;
            pkm.EggGroups      = new[] { CB_EggGroup1.SelectedIndex, CB_EggGroup2.SelectedIndex };
            pkm.Abilities      = new[] { CB_Ability1.SelectedIndex, CB_Ability2.SelectedIndex, CB_Ability3.SelectedIndex };

            pkm.FormeSprite = Convert.ToUInt16(TB_FormeSprite.Text);
            pkm.FormeCount  = Util.ToInt32(TB_FormeCount.Text);
            pkm.Color       = (byte)(CB_Color.SelectedIndex) | (Util.ToInt32(TB_RawColor.Text) & 0xF0);
            pkm.BaseEXP     = Convert.ToUInt16(TB_BaseExp.Text);

            if (decimal.TryParse(TB_Height.Text, out decimal h))
            {
                pkm.Height = (int)(h * 100);
            }

            if (decimal.TryParse(TB_Weight.Text, out decimal w))
            {
                pkm.Weight = (int)(w * 10);
            }

            if (pkm is PersonalInfoSM sm)
            {
                pkm.EscapeRate       = Util.ToInt32(TB_CallRate.Text);
                sm.SpecialZ_Item     = CB_ZItem.SelectedIndex;
                sm.SpecialZ_BaseMove = CB_ZBaseMove.SelectedIndex;
                sm.SpecialZ_ZMove    = CB_ZMove.SelectedIndex;
                sm.LocalVariant      = CHK_Variant.Checked;
            }
            if (pkm is PersonalInfoGG gg)
            {
                gg.GoSpecies = Convert.ToUInt16(MT_GoID.Text);
            }

            for (int i = 0; i < CLB_TM.Items.Count; i++)
            {
                pkm.TMHM[i] = CLB_TM.GetItemChecked(i);
            }
        }