From b5cf02a9332c3ec0e6e363496708e7efdba0a2d1 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 12 Jan 2019 10:54:38 -0800 Subject: [PATCH] Add more party related properties/methods --- PKHeX.Core/PKM/PKM.cs | 20 +++++++++++++++++++ .../Controls/PKM Editor/PKMEditor.cs | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 8cdf618b4..6fdf0bc7d 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -782,12 +782,32 @@ public void SetStats(ushort[] stats) Stat_SPD = stats[5]; } + /// + /// Indicates if Party Stats are present. False if not initialized (from stored format). + /// + public bool PartyStatsPresent => Stat_HPMax != 0; + + /// + /// Clears any status condition and refreshes the stats. + /// public void Heal() { SetStats(GetStats(PersonalInfo)); Status_Condition = 0; } + /// + /// Enforces that Party Stat values are present. + /// + /// True if stats were refreshed, false if stats were already present. + public bool ForcePartyData() + { + if (PartyStatsPresent) + return false; + Heal(); + return true; + } + /// /// Checks if the can hold its . /// diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index eb401d69b..cb9889c7a 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -253,7 +253,7 @@ private void LoadFieldsFromPKM(PKM pk, bool focus = true, bool skipConversionChe MT_Level.Text = (pk.Stat_HPMax != 0 ? pk.Stat_Level : Experience.GetLevel(pk.EXP, pk.Species, pk.AltForm)).ToString(); TB_EXP.Text = pk.EXP.ToString(); MT_Form.Text = pk.AltForm.ToString(); - if (pk.Stat_HPMax != 0) // stats present + if (pk.PartyStatsPresent) // stats present Stats.LoadPartyStats(pk); } FieldsLoaded = true;