mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-13 06:02:36 +00:00
723514e89c
Big thanks to @SciresM @sora10pls @Lusamine @architdate @ReignOfComputer for testing and contributing code / test cases. Can't add co-authors from the PR menu :( Builds will fail because azure pipelines not yet updated with net6.
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Verifies the Contest stat details.
|
|
/// </summary>
|
|
public sealed class ContestStatVerifier : Verifier
|
|
{
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Memory;
|
|
public override void Verify(LegalityAnalysis data)
|
|
{
|
|
var pkm = data.pkm;
|
|
if (pkm.Format <= 4)
|
|
return; // legal || not present
|
|
|
|
if (pkm is IContestStats s && s.HasContestStats() && !CanHaveContestStats(pkm, s, data.Info.Generation))
|
|
data.AddLine(GetInvalid(LegalityCheckStrings.LContestZero));
|
|
|
|
// some encounters have contest stats built in. they're already checked by the initial encounter match.
|
|
}
|
|
|
|
private static bool CanHaveContestStats(PKM pkm, IContestStats s, int generation) => generation switch
|
|
{
|
|
1 => false,
|
|
2 => false,
|
|
3 => true,
|
|
4 => true,
|
|
5 => s.CNT_Sheen == 0 && pkm.Format >= 6, // ORAS Contests
|
|
6 => s.CNT_Sheen == 0 && (!pkm.IsUntraded || pkm.AO),
|
|
8 => pkm.BDSP, // BDSP Contests
|
|
_ => false,
|
|
};
|
|
}
|
|
}
|