mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Verify Contest stats on gen5 origin
extract to separate logic class; only gen3+ call this (was originally called by gen6+); only really needs to include gen5
This commit is contained in:
parent
8650b5ceb2
commit
4decaa73f7
4 changed files with 40 additions and 19 deletions
|
@ -318,6 +318,8 @@ namespace PKHeX.Core
|
|||
if (pkm.Format <= 6 && pkm.Format >= 4)
|
||||
EncounterType.Verify(this); // Gen 6->7 transfer deletes encounter type data
|
||||
|
||||
Contest.Verify(this);
|
||||
|
||||
if (pkm.Format < 6)
|
||||
return;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace PKHeX.Core
|
|||
private static readonly Verifier CXD = new CXDVerifier();
|
||||
private static readonly Verifier Memory = new MemoryVerifier();
|
||||
private static readonly Verifier History = new HistoryVerifier();
|
||||
private static readonly Verifier Contest = new ContestStatVerifier();
|
||||
|
||||
private static readonly TrainerNameVerifier Trainer = new TrainerNameVerifier();
|
||||
private static readonly LevelVerifier Level = new LevelVerifier();
|
||||
|
|
36
PKHeX.Core/Legality/Verifiers/ContestStatVerifier.cs
Normal file
36
PKHeX.Core/Legality/Verifiers/ContestStatVerifier.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies the Contest stat details.
|
||||
/// </summary>
|
||||
public 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, 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, int origin)
|
||||
{
|
||||
return origin switch
|
||||
{
|
||||
1 => false,
|
||||
2 => false,
|
||||
3 => true,
|
||||
4 => true,
|
||||
5 => (pkm.Format >= 6), // ORAS Contests
|
||||
6 => (!pkm.IsUntraded || pkm.AO),
|
||||
7 => false,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,15 +22,12 @@ namespace PKHeX.Core
|
|||
private void VerifyTradeState(LegalityAnalysis data)
|
||||
{
|
||||
var pkm = data.pkm;
|
||||
var Info = data.Info;
|
||||
|
||||
if (data.pkm is IGeoTrack t)
|
||||
VerifyGeoLocationData(data, t, data.pkm);
|
||||
|
||||
if (pkm.VC && pkm is PK7 g && g.Geo1_Country == 0) // VC transfers set Geo1 Country
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LGeoMemoryMissing));
|
||||
if (pkm is IContestStats s && s.HasContestStats() && !CanHaveContestStats(pkm, Info.Generation))
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LContestZero));
|
||||
|
||||
if (!pkm.IsUntraded)
|
||||
{
|
||||
|
@ -203,20 +200,5 @@ namespace PKHeX.Core
|
|||
_ => throw new IndexOutOfRangeException(),
|
||||
};
|
||||
}
|
||||
|
||||
private static bool CanHaveContestStats(PKM pkm, int origin)
|
||||
{
|
||||
return origin switch
|
||||
{
|
||||
1 => false,
|
||||
2 => false,
|
||||
3 => true,
|
||||
4 => true,
|
||||
5 => (pkm.Format >= 6), // ORAS Contests
|
||||
6 => (!pkm.IsUntraded || pkm.AO),
|
||||
7 => false,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue