mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-14 15:17:23 -05:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user