From d58278d170bc001dba0dc9dbb7444ef6c29eec52 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 22 Mar 2018 22:43:56 -0700 Subject: [PATCH] Pull out stat modification logic --- PKHeX.Core/PKM/PKM.cs | 5 +---- PKHeX.Core/PKM/PKX.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 4801128b3..351bca0c9 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -730,10 +730,7 @@ public virtual ushort[] GetStats(PersonalInfo p) Stats[3] = (ushort)(((HT_SPE ? 31 : IV_SPE) + 2 * p.SPE + EV_SPE / 4) * level / 100 + 5); // Account for nature - if (PKX.GetNatureModification(Nature, out int incr, out int decr)) - return Stats; - Stats[incr] *= 11; Stats[incr] /= 10; - Stats[decr] *= 9; Stats[decr] /= 10; + PKX.ModifyStatsForNature(Stats, Nature); return Stats; } /// diff --git a/PKHeX.Core/PKM/PKX.cs b/PKHeX.Core/PKM/PKX.cs index 16df332e1..851cb7d5d 100644 --- a/PKHeX.Core/PKM/PKX.cs +++ b/PKHeX.Core/PKM/PKX.cs @@ -367,6 +367,19 @@ public static bool GetNatureModification(int nature, out int incr, out int decr) decr = nature % 5 + 1; return incr == decr || nature >= 25; // invalid } + + /// + /// Updates stats according to the specified nature. + /// + /// Current stats to amplify if appropriate + /// Nature + public static void ModifyStatsForNature(ushort[] Stats, int nature) + { + if (GetNatureModification(nature, out int incr, out int decr)) + return; + Stats[incr] *= 11; Stats[incr] /= 10; + Stats[decr] *= 9; Stats[decr] /= 10; + } /// /// Positions for shuffling.