From 36a97a6eda9b25587dd613fc5986556eae7a9367 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 20 Dec 2021 19:26:07 -0800 Subject: [PATCH] Add misc edit to defeat all trainers & rebattle all --- .../Gen8/BS/BattleTrainerStatus8b.cs | 4 +++ .../Save Editors/Gen8/SAV_Misc8b.Designer.cs | 26 +++++++++++++++++++ .../Subforms/Save Editors/Gen8/SAV_Misc8b.cs | 19 ++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/BattleTrainerStatus8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/BattleTrainerStatus8b.cs index 59f06d9b7..88d3a87d5 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/BattleTrainerStatus8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/BattleTrainerStatus8b.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace PKHeX.Core { @@ -15,6 +16,9 @@ public sealed class BattleTrainerStatus8b : SaveBlock private const int COUNT_TRAINER = 707; private const int SIZE_TRAINER = 8; // bool,bool + public bool AnyDefeated => Enumerable.Range(0, COUNT_TRAINER).Any(GetIsWin); + public bool AnyUndefeated => Enumerable.Range(0, COUNT_TRAINER).Any(z => !GetIsWin(z)); + /// /// Don't use this unless you've finished the post-game. /// diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Misc8b.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Misc8b.Designer.cs index 62ca8c99a..d2829399b 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Misc8b.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Misc8b.Designer.cs @@ -32,11 +32,13 @@ private void InitializeComponent() this.B_Save = new System.Windows.Forms.Button(); this.TC_Misc = new System.Windows.Forms.TabControl(); this.TAB_Main = new System.Windows.Forms.TabPage(); + this.B_DefeatEyecatch = new System.Windows.Forms.Button(); this.B_Roamer = new System.Windows.Forms.Button(); this.B_DialgaPalkia = new System.Windows.Forms.Button(); this.B_Darkrai = new System.Windows.Forms.Button(); this.B_Shaymin = new System.Windows.Forms.Button(); this.B_Spiritomb = new System.Windows.Forms.Button(); + this.B_RebattleEyecatch = new System.Windows.Forms.Button(); this.TC_Misc.SuspendLayout(); this.TAB_Main.SuspendLayout(); this.SuspendLayout(); @@ -78,6 +80,8 @@ private void InitializeComponent() // // TAB_Main // + this.TAB_Main.Controls.Add(this.B_RebattleEyecatch); + this.TAB_Main.Controls.Add(this.B_DefeatEyecatch); this.TAB_Main.Controls.Add(this.B_Roamer); this.TAB_Main.Controls.Add(this.B_DialgaPalkia); this.TAB_Main.Controls.Add(this.B_Darkrai); @@ -91,6 +95,16 @@ private void InitializeComponent() this.TAB_Main.Text = "Main"; this.TAB_Main.UseVisualStyleBackColor = true; // + // B_DefeatEyecatch + // + this.B_DefeatEyecatch.Location = new System.Drawing.Point(136, 134); + this.B_DefeatEyecatch.Name = "B_DefeatEyecatch"; + this.B_DefeatEyecatch.Size = new System.Drawing.Size(124, 58); + this.B_DefeatEyecatch.TabIndex = 5; + this.B_DefeatEyecatch.Text = "Defeat all Eyecatch Trainers"; + this.B_DefeatEyecatch.UseVisualStyleBackColor = true; + this.B_DefeatEyecatch.Click += new System.EventHandler(this.B_DefeatEyecatch_Click); + // // B_Roamer // this.B_Roamer.Location = new System.Drawing.Point(136, 70); @@ -141,6 +155,16 @@ private void InitializeComponent() this.B_Spiritomb.UseVisualStyleBackColor = true; this.B_Spiritomb.Click += new System.EventHandler(this.B_Spiritomb_Click); // + // B_RebattleEyecatch + // + this.B_RebattleEyecatch.Location = new System.Drawing.Point(6, 198); + this.B_RebattleEyecatch.Name = "B_RebattleEyecatch"; + this.B_RebattleEyecatch.Size = new System.Drawing.Size(124, 58); + this.B_RebattleEyecatch.TabIndex = 6; + this.B_RebattleEyecatch.Text = "Rebattle all Eyecatch Trainers"; + this.B_RebattleEyecatch.UseVisualStyleBackColor = true; + this.B_RebattleEyecatch.Click += new System.EventHandler(this.B_RebattleEyecatch_Click); + // // SAV_Misc8b // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -171,5 +195,7 @@ private void InitializeComponent() private System.Windows.Forms.Button B_Spiritomb; private System.Windows.Forms.Button B_DialgaPalkia; private System.Windows.Forms.Button B_Roamer; + private System.Windows.Forms.Button B_DefeatEyecatch; + private System.Windows.Forms.Button B_RebattleEyecatch; } } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Misc8b.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Misc8b.cs index 393c17995..5690ae7c8 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Misc8b.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen8/SAV_Misc8b.cs @@ -33,6 +33,9 @@ private void ReadMain() B_Shaymin.Enabled = SAV.Work.GetFlag(545) || !(SAV.Work.GetWork(276) == 1 && SAV.Zukan.HasNationalDex && SAV.Items.GetItemQuantity(452) == 1 && SAV.Work.GetSystemFlag(5)); // HAIHUEVENT_ID_D30, Oak's Letter B_DialgaPalkia.Enabled = SAV.Work.GetFlag(308) && SAV.Work.GetWork(84) != 5; // FE_D05R0114_SPPOKE_GET, WK_SCENE_D05R0114 (1-3 story related, 4 = captured, 5 = can retry) B_Roamer.Enabled = SAV.Encounter.Roamer1Encount != 1 || SAV.Encounter.Roamer2Encount != 1; // 0 = inactive, 1 = roaming, 2 = KOed, 3 = captured + + B_RebattleEyecatch.Enabled = SAV.BattleTrainer.AnyDefeated; + B_DefeatEyecatch.Enabled = SAV.BattleTrainer.AnyUndefeated; } private void SaveMain() @@ -97,5 +100,21 @@ private void B_Roamer_Click(object sender, EventArgs e) System.Media.SystemSounds.Asterisk.Play(); B_Roamer.Enabled = false; } + + private void B_DefeatEyecatch_Click(object sender, EventArgs e) + { + SAV.BattleTrainer.DefeatAll(); + System.Media.SystemSounds.Asterisk.Play(); + B_DefeatEyecatch.Enabled = false; + B_RebattleEyecatch.Enabled = true; + } + + private void B_RebattleEyecatch_Click(object sender, EventArgs e) + { + SAV.BattleTrainer.RebattleAll(); + System.Media.SystemSounds.Asterisk.Play(); + B_RebattleEyecatch.Enabled = false; + B_DefeatEyecatch.Enabled = true; + } } }