Example #1
0
        public void UpdateStats()
        {
            if (UpdatingFields)
            {
                return;
            }

            UpdatingFields = true;
            for (int i = 0; i < 6; i++)
            {
                if (Util.ToInt32(tb_iv[i].Text) > 31)
                {
                    tb_iv[i].Text = "31";
                }
                if (Util.ToInt32(tb_ev[i].Text) > 255)
                {
                    tb_ev[i].Text = "255";
                }
                if (Util.ToInt32(tb_av[i].Text) > 200)
                {
                    tb_av[i].Text = "200";
                }
            }
            UpdatingFields = false;

            var pi    = Personal.GetFormeEntry(PKM.Species, PKM.Form);
            var stats = PKM.GetStats(pi);

            Stat_HP.Text  = stats[0].ToString();
            Stat_ATK.Text = stats[1].ToString();
            Stat_DEF.Text = stats[2].ToString();
            Stat_SPA.Text = stats[4].ToString();
            Stat_SPD.Text = stats[5].ToString();
            Stat_SPE.Text = stats[3].ToString();

            TB_IVTotal.Text = tb_iv.Select(z => Util.ToInt32(z.Text)).Sum().ToString();
            TB_EVTotal.Text = tb_ev.Select(z => Util.ToInt32(z.Text)).Sum().ToString();
            if (PKM is IAwakened s)
            {
                TB_AVTotal.Text = s.AwakeningSum().ToString();
            }

            // Recolor the Stat Labels based on boosted stats.
            RecolorStatLabels();
            UpdatingFields          = true;
            CB_HPType.SelectedIndex = PKM.HiddenPowerType;
            UpdatingFields          = false;
        }
Example #2
0
        private void UpdateAV(object sender, EventArgs e)
        {
            if (UpdatingFields || !(sender is MaskedTextBox t) || !(PKM is IAwakened a))
            {
                return;
            }
            var index = Array.IndexOf(tb_av, t);

            if (index < 0)
            {
                return;
            }
            int value = Math.Min(200, Util.ToInt32(t.Text));

            a.SetAV(index, value);
            UpdateStats();
        }
Example #3
0
        private void UpdateEV(object sender, EventArgs e)
        {
            if (UpdatingFields || !(sender is MaskedTextBox t))
            {
                return;
            }
            var index = Array.IndexOf(tb_ev, t);

            if (index < 0)
            {
                return;
            }
            int value = Math.Min(252, Util.ToInt32(t.Text));

            PKM.SetEV(index, value);
            UpdateStats();
        }
Example #4
0
        private void UpdateIV(object sender, EventArgs e)
        {
            if (UpdatingFields || !(sender is MaskedTextBox t))
            {
                return;
            }
            var index = Array.IndexOf(tb_iv, t);

            if (index < 0)
            {
                return;
            }
            int value = Math.Min(31, Util.ToInt32(t.Text));

            PKM.SetIV(index, value);
            UpdatingFields          = true;
            CB_HPType.SelectedIndex = PKM.HiddenPowerType;
            UpdatingFields          = false;
            UpdateStats();
        }
Example #5
0
        public void UpdateStats()
        {
            if (UpdatingFields)
            {
                return;
            }

            UpdatingFields = true;
            for (int i = 0; i < 6; i++)
            {
                if (Util.ToInt32(tb_iv[i].Text) > 31)
                {
                    tb_iv[i].Text = "31";
                }
                if (Util.ToInt32(tb_ev[i].Text) > 255)
                {
                    tb_ev[i].Text = "255";
                }
                if (Util.ToInt32(tb_av[i].Text) > 200)
                {
                    tb_av[i].Text = "200";
                }
            }
            UpdatingFields = false;

            var pt = Personal;

            if (pt == null)
            {
                throw new NullReferenceException("Personal table hasn't been initialized.");
            }

            var pi    = pt.GetFormeEntry(PKM.Species, PKM.Form);
            var stats = PKM.GetStats(pi);

            Stat_HP.Text  = stats[0].ToString();
            Stat_ATK.Text = stats[1].ToString();
            Stat_DEF.Text = stats[2].ToString();
            Stat_SPA.Text = stats[4].ToString();
            Stat_SPD.Text = stats[5].ToString();
            Stat_SPE.Text = stats[3].ToString();

            TB_IVTotal.Text = tb_iv.Select(z => Util.ToInt32(z.Text)).Sum().ToString();
            TB_EVTotal.Text = tb_ev.Select(z => Util.ToInt32(z.Text)).Sum().ToString();
            if (PKM is IAwakened s)
            {
                TB_AVTotal.Text = s.AwakeningSum().ToString();
            }

            var showAV = PKM is IAwakened;

            Label_AVs.Visible = TB_AVTotal.Visible = FLP_HPType.Visible = showAV;
            foreach (var mtb in tb_av)
            {
                mtb.Visible = showAV;
            }
            Label_EVs.Visible = TB_EVTotal.Visible = FLP_Dynamax.Visible = !showAV;
            foreach (var mtb in tb_ev)
            {
                mtb.Visible = !showAV;
            }

            // Recolor the Stat Labels based on boosted stats.
            RecolorStatLabels();
            UpdatingFields          = true;
            CB_HPType.SelectedIndex = PKM.HiddenPowerType;
            UpdatingFields          = false;
        }