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.
This commit is contained in:
Kurt
2021-12-08 22:43:56 -08:00
parent 88822b4e68
commit 0bb4534870

View File

@@ -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