From 0bb4534870d42daeb6f1878010b993cb4c29264a Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 8 Dec 2021 22:43:56 -0800 Subject: [PATCH] Reset contest stats to enc instead of zeroed Can't lower contest stats, but there's no cases of them giving a pkm with contest stats in a game that can't obtain contest stats -- let's just reset instead of zero for futureproofing. Make them extension methods too; add an overload if you want to purposefully maximize them. --- .../Verifiers/Misc/ContestStatInfo.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/PKHeX.Core/Legality/Verifiers/Misc/ContestStatInfo.cs b/PKHeX.Core/Legality/Verifiers/Misc/ContestStatInfo.cs index a70f97d0f..da911939b 100644 --- a/PKHeX.Core/Legality/Verifiers/Misc/ContestStatInfo.cs +++ b/PKHeX.Core/Legality/Verifiers/Misc/ContestStatInfo.cs @@ -9,18 +9,28 @@ public static class ContestStatInfo private const int WorstFeelPoffin = 17; private const int MaxContestStat = 255; - public static void SetSuggestedContestStats(PKM pk, IEncounterTemplate enc) + public static void SetSuggestedContestStats(this PKM pk, IEncounterTemplate enc) { if (pk is not IContestStatsMutable s) return; var restrict = GetContestStatRestriction(pk, pk.Generation); - if (restrict == None) - s.SetAllContestStatsTo(0, 0); // zero - if (pk.Species is not (int)Species.Milotic) - GetReferenceTemplate(enc).CopyContestStatsTo(s); // reset + var baseStat = GetReferenceTemplate(enc); + if (restrict == None || pk.Species is not (int)Species.Milotic) + baseStat.CopyContestStatsTo(s); // reset else - s.SetAllContestStatsTo(MaxContestStat, restrict == NoSheen ? (byte)0 : (byte)255); + s.SetAllContestStatsTo(MaxContestStat, restrict == NoSheen ? baseStat.CNT_Sheen : (byte)255); + } + + public static void SetMaxContestStats(this PKM pk, IEncounterTemplate enc) + { + if (pk is not IContestStatsMutable s) + return; + var restrict = GetContestStatRestriction(pk, pk.Generation); + var baseStat = GetReferenceTemplate(enc); + if (restrict == None) + return; + s.SetAllContestStatsTo(MaxContestStat, restrict == NoSheen ? baseStat.CNT_Sheen : (byte)255); } public static ContestStatGranting GetContestStatRestriction(PKM pk, int origin) => origin switch