2018-11-17 01:42:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2018-07-02 02:17:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies miscellaneous data including <see cref="PKM.FatefulEncounter"/> and minor values.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class MiscVerifier : Verifier
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Misc;
|
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;
|
|
|
|
|
if (pkm.IsEgg)
|
|
|
|
|
{
|
|
|
|
|
VerifyMiscEggCommon(data);
|
|
|
|
|
|
|
|
|
|
if (pkm is IContestStats s && s.HasContestStats())
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEggContest, CheckIdentifier.Egg));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
|
|
|
|
switch (pkm)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2019-01-01 05:01:54 +00:00
|
|
|
|
case PK5 pk5 when pk5.PokeStarFame != 0 && pk5.IsEgg:
|
|
|
|
|
data.AddLine(GetInvalid(LEggShinyPokeStar, CheckIdentifier.Egg));
|
|
|
|
|
break;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
case PK4 pk4 when pk4.ShinyLeaf != 0:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEggShinyLeaf, CheckIdentifier.Egg));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
break;
|
|
|
|
|
case PK4 pk4 when pk4.PokéathlonStat != 0:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEggPokeathlon, CheckIdentifier.Egg));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
break;
|
|
|
|
|
case PK3 _ when pkm.Language != 1: // All Eggs are Japanese and flagged specially for localized string
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LOTLanguage, LanguageID.Japanese, (LanguageID)pkm.Language), CheckIdentifier.Egg));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
break;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-28 03:44:26 +00:00
|
|
|
|
if (pkm is PK7 pk7 && pk7.ResortEventStatus >= 20)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LTransferBad));
|
2018-11-17 01:42:50 +00:00
|
|
|
|
if (pkm is PB7 pb7)
|
|
|
|
|
VerifyBelugaStats(data, pb7);
|
2018-08-28 03:44:26 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
VerifyMiscFatefulEncounter(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void VerifyMiscG1(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (pkm.IsEgg)
|
|
|
|
|
{
|
|
|
|
|
VerifyMiscEggCommon(data);
|
|
|
|
|
if (pkm.PKRS_Cured || pkm.PKRS_Infected)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEggPokerus, CheckIdentifier.Egg));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(pkm is PK1 pk1))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
VerifyMiscG1Types(data, pk1);
|
|
|
|
|
VerifyMiscG1CatchRate(data, pk1);
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
private void VerifyMiscG1Types(LegalityAnalysis data, PK1 pk1)
|
|
|
|
|
{
|
|
|
|
|
var Type_A = pk1.Type_A;
|
|
|
|
|
var Type_B = pk1.Type_B;
|
2018-07-01 17:49:11 +00:00
|
|
|
|
if (pk1.Species == 137) // Porygon
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:49:11 +00:00
|
|
|
|
// Can have any type combination of any species by using Conversion.
|
2018-10-10 23:32:02 +00:00
|
|
|
|
if (!GBRestrictions.Types_Gen1.Contains(Type_A))
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LG1TypePorygonFail1));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2018-10-10 23:32:02 +00:00
|
|
|
|
else if (!GBRestrictions.Types_Gen1.Contains(Type_B))
|
2018-07-27 02:34:27 +00:00
|
|
|
|
{
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LG1TypePorygonFail2));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
}
|
2018-07-01 17:49:11 +00:00
|
|
|
|
else // Both match a type, ensure a gen1 species has this combo
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var TypesAB_Match = PersonalTable.RB.IsValidTypeCombination(Type_A, Type_B);
|
2018-09-01 21:11:12 +00:00
|
|
|
|
var result = TypesAB_Match ? GetValid(LG1TypeMatchPorygon) : GetInvalid(LG1TypePorygonFail);
|
2018-07-01 17:49:11 +00:00
|
|
|
|
data.AddLine(result);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Types must match species types
|
|
|
|
|
{
|
|
|
|
|
var Type_A_Match = Type_A == PersonalTable.RB[pk1.Species].Type1;
|
|
|
|
|
var Type_B_Match = Type_B == PersonalTable.RB[pk1.Species].Type2;
|
|
|
|
|
|
2018-09-01 21:11:12 +00:00
|
|
|
|
var first = Type_A_Match ? GetValid(LG1TypeMatch1) : GetInvalid(LG1Type1Fail);
|
|
|
|
|
var second = Type_B_Match ? GetValid(LG1TypeMatch2) : GetInvalid(LG1Type2Fail);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
data.AddLine(first);
|
|
|
|
|
data.AddLine(second);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
private void VerifyMiscG1CatchRate(LegalityAnalysis data, PK1 pk1)
|
|
|
|
|
{
|
2018-07-17 23:54:23 +00:00
|
|
|
|
var e = data.EncounterMatch;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
var catch_rate = pk1.Catch_Rate;
|
2018-08-28 03:44:26 +00:00
|
|
|
|
var result = pk1.TradebackStatus == TradebackType.Gen1_NotTradeback
|
|
|
|
|
? GetWasNotTradeback()
|
|
|
|
|
: GetWasTradeback();
|
|
|
|
|
data.AddLine(result);
|
|
|
|
|
|
|
|
|
|
CheckResult GetWasTradeback()
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-08-28 03:44:26 +00:00
|
|
|
|
if (catch_rate == 0 || Legal.HeldItems_GSC.Contains((ushort)catch_rate))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LG1CatchRateMatchTradeback);
|
2018-08-28 03:44:26 +00:00
|
|
|
|
if (pk1.TradebackStatus == TradebackType.WasTradeback)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LG1CatchRateItem);
|
2018-08-28 03:44:26 +00:00
|
|
|
|
|
|
|
|
|
return GetWasNotTradeback();
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-08-28 03:44:26 +00:00
|
|
|
|
CheckResult GetWasNotTradeback()
|
|
|
|
|
{
|
|
|
|
|
if ((e as EncounterStatic)?.Version == GameVersion.Stadium || e is EncounterTradeCatchRate)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LG1CatchRateMatchPrevious); // Encounters detected by the catch rate, cant be invalid if match this encounters
|
2018-10-10 23:32:02 +00:00
|
|
|
|
if ((pk1.Species == 149 && catch_rate == PersonalTable.Y[149].CatchRate) || (GBRestrictions.Species_NotAvailable_CatchRate.Contains(pk1.Species) && catch_rate == PersonalTable.RB[pk1.Species].CatchRate))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LG1CatchRateEvo);
|
2018-08-28 03:44:26 +00:00
|
|
|
|
if (!data.Info.EvoChainsAllGens[1].Any(c => RateMatchesEncounter(c.Species)))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(pk1.Gen1_NotTradeback ? LG1CatchRateChain : LG1CatchRateNone);
|
|
|
|
|
return GetValid(LG1CatchRateMatchPrevious);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-17 23:54:23 +00:00
|
|
|
|
|
|
|
|
|
bool RateMatchesEncounter(int species)
|
|
|
|
|
{
|
|
|
|
|
if (catch_rate == PersonalTable.RB[species].CatchRate)
|
|
|
|
|
return true;
|
|
|
|
|
if (catch_rate == PersonalTable.Y[species].CatchRate)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-07-01 17:49:11 +00:00
|
|
|
|
private static void VerifyMiscFatefulEncounter(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
var EncounterMatch = data.EncounterMatch;
|
|
|
|
|
switch (EncounterMatch)
|
|
|
|
|
{
|
|
|
|
|
case WC3 w when w.Fateful:
|
|
|
|
|
if (w.IsEgg)
|
|
|
|
|
{
|
|
|
|
|
// Eggs hatched in RS clear the obedience flag!
|
|
|
|
|
if (pkm.Format != 3)
|
|
|
|
|
return; // possible hatched in either game, don't bother checking
|
|
|
|
|
if (pkm.Met_Location <= 087) // hatched in RS
|
|
|
|
|
break; // ensure fateful is not active
|
|
|
|
|
// else, ensure fateful is active (via below)
|
|
|
|
|
}
|
|
|
|
|
VerifyFatefulIngameActive(data);
|
|
|
|
|
VerifyWC3Shiny(data, w);
|
|
|
|
|
return;
|
|
|
|
|
case WC3 w:
|
|
|
|
|
if (w.Version == GameVersion.XD)
|
|
|
|
|
return; // Can have either state
|
|
|
|
|
VerifyWC3Shiny(data, w);
|
|
|
|
|
break;
|
|
|
|
|
case MysteryGift g when g.Format != 3: // WC3
|
2018-07-28 05:26:27 +00:00
|
|
|
|
VerifyReceivability(data, g);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
VerifyFatefulMysteryGift(data, g);
|
|
|
|
|
return;
|
|
|
|
|
case EncounterStatic s when s.Fateful: // ingame fateful
|
|
|
|
|
case EncounterSlot _ when pkm.Version == 15: // ingame pokespot
|
|
|
|
|
case EncounterTrade t when t.Fateful:
|
|
|
|
|
VerifyFatefulIngameActive(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (pkm.FatefulEncounter)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LFatefulInvalid, CheckIdentifier.Fateful));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-07-01 17:49:11 +00:00
|
|
|
|
private static void VerifyMiscEggCommon(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (pkm.Move1_PPUps > 0 || pkm.Move2_PPUps > 0 || pkm.Move3_PPUps > 0 || pkm.Move4_PPUps > 0)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEggPPUp, CheckIdentifier.Egg));
|
2018-07-27 02:34:27 +00:00
|
|
|
|
if (pkm.Move1_PP != pkm.GetMovePP(pkm.Move1, 0) || pkm.Move2_PP != pkm.GetMovePP(pkm.Move2, 0) || pkm.Move3_PP != pkm.GetMovePP(pkm.Move3, 0) || pkm.Move4_PP != pkm.GetMovePP(pkm.Move4, 0))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEggPP, CheckIdentifier.Egg));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-08-02 03:39:20 +00:00
|
|
|
|
var EncounterMatch = data.EncounterOriginal;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
var HatchCycles = (EncounterMatch as EncounterStatic)?.EggCycles;
|
|
|
|
|
if (HatchCycles == 0 || HatchCycles == null)
|
|
|
|
|
HatchCycles = pkm.PersonalInfo.HatchCycles;
|
|
|
|
|
if (pkm.CurrentFriendship > HatchCycles)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEggHatchCycles, CheckIdentifier.Egg));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Format >= 6 && EncounterMatch is EncounterEgg && !pkm.Moves.SequenceEqual(pkm.RelearnMoves))
|
|
|
|
|
{
|
|
|
|
|
var moves = string.Join(", ", LegalityAnalysis.GetMoveNames(pkm.Moves));
|
2018-09-01 21:11:12 +00:00
|
|
|
|
var msg = string.Format(LMoveFExpect_0, moves);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
data.AddLine(GetInvalid(msg, CheckIdentifier.Egg));
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-07-01 17:49:11 +00:00
|
|
|
|
private static void VerifyFatefulMysteryGift(LegalityAnalysis data, MysteryGift g)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (g is PGF p && p.IsShiny)
|
|
|
|
|
{
|
|
|
|
|
var Info = data.Info;
|
|
|
|
|
Info.PIDIV = MethodFinder.Analyze(pkm);
|
2019-05-11 03:46:49 +00:00
|
|
|
|
if (Info.PIDIV.Type != PIDType.G5MGShiny && pkm.Egg_Location != Locations.LinkTrade5)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LPIDTypeMismatch, CheckIdentifier.PID));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-13 07:50:31 +00:00
|
|
|
|
var result = pkm.FatefulEncounter != pkm.WasLink
|
2018-09-01 21:11:12 +00:00
|
|
|
|
? GetValid(LFatefulMystery, CheckIdentifier.Fateful)
|
|
|
|
|
: GetInvalid(LFatefulMysteryMissing, CheckIdentifier.Fateful);
|
2018-07-01 17:49:11 +00:00
|
|
|
|
data.AddLine(result);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-07-28 05:26:27 +00:00
|
|
|
|
private static void VerifyReceivability(LegalityAnalysis data, MysteryGift g)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
switch (g)
|
|
|
|
|
{
|
2018-10-27 16:44:47 +00:00
|
|
|
|
case WC6 wc6 when !wc6.CanBeReceivedByVersion(pkm.Version) && !pkm.WasTradedEgg:
|
|
|
|
|
case WC7 wc7 when !wc7.CanBeReceivedByVersion(pkm.Version) && !pkm.WasTradedEgg:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEncGiftVersionNotDistributed, CheckIdentifier.GameOrigin));
|
2018-07-28 05:26:27 +00:00
|
|
|
|
return;
|
|
|
|
|
case WC6 wc6 when wc6.RestrictLanguage != 0 && wc6.Language != wc6.RestrictLanguage:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LOTLanguage, wc6.RestrictLanguage, pkm.Language), CheckIdentifier.Language));
|
2018-07-28 05:26:27 +00:00
|
|
|
|
return;
|
|
|
|
|
case WC7 wc7 when wc7.RestrictLanguage != 0 && wc7.Language != wc7.RestrictLanguage:
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(string.Format(LOTLanguage, wc7.RestrictLanguage, pkm.Language), CheckIdentifier.Language));
|
2018-07-28 05:26:27 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-01 17:49:11 +00:00
|
|
|
|
private static void VerifyWC3Shiny(LegalityAnalysis data, WC3 g3)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
// check for shiny locked gifts
|
|
|
|
|
if (!g3.Shiny.IsValid(data.pkm))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEncGiftShinyMismatch, CheckIdentifier.Fateful));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-07-01 17:49:11 +00:00
|
|
|
|
private static void VerifyFatefulIngameActive(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (pkm.Version == 15 && pkm is XK3 xk3 && data.Info.WasXD)
|
|
|
|
|
{
|
|
|
|
|
// can't have fateful until traded away, which clears ShadowID
|
|
|
|
|
if (xk3.FatefulEncounter && xk3.ShadowID != 0 && data.EncounterMatch is EncounterStaticShadow)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LFatefulInvalid, CheckIdentifier.Fateful));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
return; // fateful is set when transferred away
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-01 17:49:11 +00:00
|
|
|
|
var result = pkm.FatefulEncounter
|
2018-09-01 21:11:12 +00:00
|
|
|
|
? GetValid(LFateful, CheckIdentifier.Fateful)
|
|
|
|
|
: GetInvalid(LFatefulMissing, CheckIdentifier.Fateful);
|
2018-07-01 17:49:11 +00:00
|
|
|
|
data.AddLine(result);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void VerifyVersionEvolution(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (pkm.Format < 7 || data.EncounterMatch.Species == pkm.Species)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// No point using the evolution tree. Just handle certain species.
|
|
|
|
|
switch (pkm.Species)
|
|
|
|
|
{
|
|
|
|
|
case 745 when (pkm.AltForm == 0 && Moon()) || (pkm.AltForm == 1 && Sun()): // Lycanroc
|
|
|
|
|
case 791 when Moon(): // Solgaleo
|
|
|
|
|
case 792 when Sun(): // Lunala
|
|
|
|
|
bool Sun() => pkm.Version == (int)GameVersion.SN || pkm.Version == (int)GameVersion.US;
|
|
|
|
|
bool Moon() => pkm.Version == (int)GameVersion.MN || pkm.Version == (int)GameVersion.UM;
|
|
|
|
|
if (pkm.IsUntraded)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
data.AddLine(GetInvalid(LEvoTradeRequired, CheckIdentifier.Evolution));
|
2018-06-24 05:00:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-17 01:42:50 +00:00
|
|
|
|
|
|
|
|
|
private static void VerifyBelugaStats(LegalityAnalysis data, PB7 pb7)
|
|
|
|
|
{
|
2019-01-23 05:08:48 +00:00
|
|
|
|
// ReSharper disable once CompareOfFloatsByEqualityOperator -- THESE MUST MATCH EXACTLY
|
|
|
|
|
if (!IsCloseEnough(pb7.HeightAbsolute, pb7.CalcHeightAbsolute))
|
2018-11-17 01:42:50 +00:00
|
|
|
|
data.AddLine(GetInvalid(LStatIncorrectHeight, CheckIdentifier.Encounter));
|
2019-01-23 05:08:48 +00:00
|
|
|
|
// ReSharper disable once CompareOfFloatsByEqualityOperator -- THESE MUST MATCH EXACTLY
|
|
|
|
|
if (!IsCloseEnough(pb7.WeightAbsolute, pb7.CalcWeightAbsolute))
|
2018-11-17 01:42:50 +00:00
|
|
|
|
data.AddLine(GetInvalid(LStatIncorrectWeight, CheckIdentifier.Encounter));
|
2018-11-17 02:17:01 +00:00
|
|
|
|
if (pb7.Stat_CP != pb7.CalcCP && !IsStarter(pb7))
|
2018-11-17 01:42:50 +00:00
|
|
|
|
data.AddLine(GetInvalid(LStatIncorrectCP, CheckIdentifier.Encounter));
|
2018-12-06 02:38:05 +00:00
|
|
|
|
|
|
|
|
|
if (IsTradeEvoRequired7b(data.EncounterOriginal, pb7))
|
|
|
|
|
{
|
|
|
|
|
var unevolved = LegalityAnalysis.SpeciesStrings[pb7.Species];
|
|
|
|
|
var evolved = LegalityAnalysis.SpeciesStrings[pb7.Species + 1];
|
|
|
|
|
data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved), CheckIdentifier.Evolution));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 05:08:48 +00:00
|
|
|
|
private static bool IsCloseEnough(float a, float b)
|
|
|
|
|
{
|
|
|
|
|
var ia = BitConverter.ToInt32(BitConverter.GetBytes(a), 0);
|
|
|
|
|
var ib = BitConverter.ToInt32(BitConverter.GetBytes(b), 0);
|
2019-02-08 00:57:17 +00:00
|
|
|
|
return Math.Abs(ia - ib) <= 7;
|
2019-01-23 05:08:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-06 02:38:05 +00:00
|
|
|
|
private static bool IsTradeEvoRequired7b(IEncounterable enc, PKM pb7)
|
|
|
|
|
{
|
|
|
|
|
// There's no everstone! All Trade evolutions must evolve.
|
|
|
|
|
// Anything with current level == met level, having a HT, and being a trade-evolvable species must be evolved.
|
|
|
|
|
// Kadabra → Alakazam
|
|
|
|
|
// Machoke → Machamp
|
|
|
|
|
// Graveler → Golem
|
|
|
|
|
// Haunter → Gengar
|
|
|
|
|
if (pb7.Species != enc.Species)
|
|
|
|
|
return false;
|
|
|
|
|
if (!tradeEvo7b.Contains(enc.Species))
|
|
|
|
|
return false;
|
2018-12-06 04:55:57 +00:00
|
|
|
|
if (pb7.Met_Level != pb7.CurrentLevel)
|
|
|
|
|
return false;
|
2018-12-06 02:38:05 +00:00
|
|
|
|
return !pb7.IsUntraded;
|
2018-11-17 01:42:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-06 02:38:05 +00:00
|
|
|
|
private static readonly int[] tradeEvo7b = { 064, 067, 075, 093 };
|
2018-11-17 01:42:50 +00:00
|
|
|
|
private static bool IsStarter(PKM pb7) => (pb7.Species == 25 && pb7.AltForm == 8) || (pb7.Species == 133 && pb7.AltForm == 1);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|