2020-05-10 03:47:32 +00:00
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies the Contest stat details.
|
|
|
|
|
/// </summary>
|
2020-09-07 20:51:13 +00:00
|
|
|
|
public sealed class ContestStatVerifier : Verifier
|
2020-05-10 03:47:32 +00:00
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Memory;
|
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (pkm.Format <= 4)
|
|
|
|
|
return; // legal || not present
|
|
|
|
|
|
2021-02-28 04:02:18 +00:00
|
|
|
|
if (pkm is IContestStats s && s.HasContestStats() && !CanHaveContestStats(pkm, s, data.Info.Generation))
|
2020-05-10 03:47:32 +00:00
|
|
|
|
data.AddLine(GetInvalid(LegalityCheckStrings.LContestZero));
|
2020-05-11 23:51:10 +00:00
|
|
|
|
|
2020-05-10 03:47:32 +00:00
|
|
|
|
// some encounters have contest stats built in. they're already checked by the initial encounter match.
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-28 04:02:18 +00:00
|
|
|
|
private static bool CanHaveContestStats(PKM pkm, IContestStats s, int generation) => generation switch
|
2020-05-10 03:47:32 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
1 => false,
|
|
|
|
|
2 => false,
|
|
|
|
|
3 => true,
|
|
|
|
|
4 => true,
|
2021-02-28 04:02:18 +00:00
|
|
|
|
5 => s.CNT_Sheen == 0 && pkm.Format >= 6, // ORAS Contests
|
|
|
|
|
6 => s.CNT_Sheen == 0 && (!pkm.IsUntraded || pkm.AO),
|
2021-01-02 01:08:49 +00:00
|
|
|
|
_ => false,
|
|
|
|
|
};
|
2020-05-10 03:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|