2018-06-24 05:00:01 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2018-07-02 02:17:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies the <see cref="PKM.EVs"/>.
|
|
|
|
|
/// </summary>
|
2018-06-24 05:00:01 +00:00
|
|
|
|
public sealed class EffortValueVerifier : Verifier
|
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.EVs;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
var EncounterMatch = data.EncounterMatch;
|
|
|
|
|
var evs = pkm.EVs;
|
|
|
|
|
int sum = pkm.EVTotal;
|
|
|
|
|
if (sum > 0 && pkm.IsEgg)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEffortEgg));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (pkm.Format >= 3 && sum > 510)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEffortAbove510));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (pkm.Format >= 6 && evs.Any(ev => ev > 252))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEffortAbove252));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (pkm.Format == 4 && pkm.Gen4 && EncounterMatch.LevelMin == 100)
|
|
|
|
|
{
|
|
|
|
|
// Cannot EV train at level 100 -- Certain events are distributed at level 100.
|
|
|
|
|
if (evs.Any(ev => ev > 100)) // EVs can only be increased by vitamins to a max of 100.
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEffortCap100));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
else if (pkm.Format < 5)
|
|
|
|
|
{
|
|
|
|
|
// In Generations I and II, when a Pokémon is taken out of the Day Care, its experience will lower to the minimum value for its current level.
|
|
|
|
|
if (pkm.Format < 3) // can abuse daycare for EV training without EXP gain
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const int maxEV = 100; // Vitamin Max
|
|
|
|
|
if (PKX.GetEXP(EncounterMatch.LevelMin, pkm.Species) == pkm.EXP && evs.Any(ev => ev > maxEV))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LEffortUntrainedCap, maxEV)));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only one of the following can be true: 0, 508, and x%6!=0
|
|
|
|
|
if (sum == 0 && !EncounterMatch.IsWithinRange(pkm))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(Get(LEffortEXPIncreased, Severity.Fishy));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
else if (sum == 508)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(Get(LEffort2Remaining, Severity.Fishy));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
else if (evs[0] != 0 && evs.All(ev => evs[0] == ev))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(Get(LEffortAllEqual, Severity.Fishy));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|