From 724da7ff0fac381f1724125e6492a9cfba107fea Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Mon, 8 Aug 2016 18:42:42 -0700 Subject: [PATCH] Improve PID/EC rerolling automation --- MainWindow/Main.cs | 11 ++++++----- PKM/PKM.cs | 11 +++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/MainWindow/Main.cs b/MainWindow/Main.cs index 0a5a91864..cdd1fdf45 100644 --- a/MainWindow/Main.cs +++ b/MainWindow/Main.cs @@ -1628,13 +1628,13 @@ namespace PKHeX pkm.setPIDGender(pkm.Gender); TB_PID.Text = pkm.PID.ToString("X8"); getQuickFiller(dragout); - if (pkm.Format >= 6) - TB_EC.Text = pkm.EncryptionConstant.ToString("X8"); + if (pkm.GenNumber < 6 && TB_EC.Visible) + TB_EC.Text = TB_PID.Text; } private void updateRandomEC(object sender, EventArgs e) { - int origin = Util.getIndex(CB_GameOrigin); - if (origin < 24) + pkm.Version = Util.getIndex(CB_GameOrigin); + if (pkm.GenNumber < 6) { TB_EC.Text = TB_PID.Text; Util.Alert("EC should match PID."); @@ -2101,11 +2101,12 @@ namespace PKHeX pkm.Nature = Util.getIndex(CB_Nature); pkm.Gender = PKX.getGender(Label_Gender.Text); pkm.AltForm = CB_Form.SelectedIndex; + pkm.Version = Util.getIndex(CB_GameOrigin); pkm.setShinyPID(); TB_PID.Text = pkm.PID.ToString("X8"); - if (pkm.Format < 6) + if (pkm.GenNumber < 6 && TB_EC.Visible) TB_EC.Text = TB_PID.Text; getQuickFiller(dragout); diff --git a/PKM/PKM.cs b/PKM/PKM.cs index 2b5f121bf..1d3134d82 100644 --- a/PKM/PKM.cs +++ b/PKM/PKM.cs @@ -153,6 +153,17 @@ namespace PKHeX public bool Gen4 => Version >= 10 && Version < 12 || Version >= 7 && Version <= 8; public bool Gen3 => Version >= 1 && Version <= 5 || Version == 15; public bool GenU => !(Gen6 || Gen5 || Gen4 || Gen3); + public int GenNumber + { + get + { + if (Gen6) return 6; + if (Gen5) return 5; + if (Gen4) return 4; + if (Gen3) return 3; + return -1; + } + } public bool PKRS_Infected => PKRS_Strain > 0; public bool PKRS_Cured => PKRS_Days == 0 && PKRS_Strain > 0; public bool ChecksumValid => Checksum == CalculateChecksum();