mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-11 21:22:41 +00:00
8912f76726
Futureproof with transfer considerations This is just a guess; gen7 didn't update the medal count and if we assume pk8 overhauls the structure for a new console, they'll drop old data. With c#8 later next week, will move SuperTrainingMedalCount() to a default interface method ez.
76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using System;
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Verifies the <see cref="ISuperTrain.SuperTrainingMedalCount"/> and associated values.
|
|
/// </summary>
|
|
public sealed class MedalVerifier : Verifier
|
|
{
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Training;
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
{
|
|
VerifyMedalsRegular(data);
|
|
VerifyMedalsEvent(data);
|
|
}
|
|
|
|
private void VerifyMedalsRegular(LegalityAnalysis data)
|
|
{
|
|
var pkm = data.pkm;
|
|
var train = (ISuperTrain)pkm;
|
|
var Info = data.Info;
|
|
uint value = BitConverter.ToUInt32(data.pkm.Data, 0x2C);
|
|
if ((value & 3) != 0) // 2 unused flags
|
|
data.AddLine(GetInvalid(LSuperUnused));
|
|
int TrainCount = train.SuperTrainingMedalCount();
|
|
|
|
if (pkm.IsEgg)
|
|
{
|
|
// Can't have any super training data as an egg.
|
|
if (TrainCount > 0)
|
|
data.AddLine(GetInvalid(LSuperEgg));
|
|
if (train.SecretSuperTrainingUnlocked)
|
|
data.AddLine(GetInvalid(LSuperNoUnlocked));
|
|
if (train.SecretSuperTrainingComplete)
|
|
data.AddLine(GetInvalid(LSuperNoComplete));
|
|
return;
|
|
}
|
|
|
|
if (Info.Generation >= 7 || Info.Generation <= 2)
|
|
{
|
|
// Can't have any super training data if it never visited Gen6.
|
|
if (TrainCount > 0)
|
|
data.AddLine(GetInvalid(LSuperUnavailable));
|
|
if (train.SecretSuperTrainingUnlocked)
|
|
data.AddLine(GetInvalid(LSuperNoUnlocked));
|
|
if (train.SecretSuperTrainingComplete)
|
|
data.AddLine(GetInvalid(LSuperNoComplete));
|
|
return;
|
|
}
|
|
|
|
if (pkm.Format >= 7)
|
|
{
|
|
// Gen6->Gen7 transfer wipes the two Secret flags.
|
|
if (train.SecretSuperTrainingUnlocked)
|
|
data.AddLine(GetInvalid(LSuperNoUnlocked));
|
|
if (train.SecretSuperTrainingComplete)
|
|
data.AddLine(GetInvalid(LSuperNoComplete));
|
|
return;
|
|
}
|
|
|
|
// Only reach here if Format==6.
|
|
if (TrainCount == 30 ^ train.SecretSuperTrainingComplete)
|
|
data.AddLine(GetInvalid(LSuperComplete));
|
|
}
|
|
|
|
private void VerifyMedalsEvent(LegalityAnalysis data)
|
|
{
|
|
var pkm = data.pkm;
|
|
byte value = pkm.Data[0x3A];
|
|
if (value != 0)
|
|
data.AddLine(GetInvalid(LSuperDistro));
|
|
}
|
|
}
|
|
}
|