2018-06-24 05:00:01 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
2018-08-26 18:15:32 +00:00
|
|
|
|
using static PKHeX.Core.Ball;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2018-07-02 02:17:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies the <see cref="PKM.Ball"/> value.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class BallVerifier : Verifier
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
protected override CheckIdentifier Identifier => CheckIdentifier.Ball;
|
2018-09-01 21:11:12 +00:00
|
|
|
|
private CheckResult NONE => GetInvalid(LBallNone);
|
2018-06-30 17:34:09 +00:00
|
|
|
|
|
2018-06-24 05:00:01 +00:00
|
|
|
|
public override void Verify(LegalityAnalysis data)
|
|
|
|
|
{
|
2018-06-30 17:34:09 +00:00
|
|
|
|
if (data.pkm.Format <= 2)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
return; // no ball info saved
|
2018-06-30 17:34:09 +00:00
|
|
|
|
var result = VerifyBall(data);
|
|
|
|
|
data.AddLine(result);
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBall(LegalityAnalysis data)
|
|
|
|
|
{
|
2018-06-24 05:00:01 +00:00
|
|
|
|
var EncounterMatch = data.EncounterMatch;
|
|
|
|
|
var Info = data.Info;
|
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
// Fixed ball cases -- can be only one ball ever
|
2018-08-26 18:15:32 +00:00
|
|
|
|
switch (EncounterMatch)
|
|
|
|
|
{
|
|
|
|
|
case MysteryGift g:
|
|
|
|
|
return VerifyBallMysteryGift(data, g);
|
|
|
|
|
case EncounterTrade t:
|
|
|
|
|
return VerifyBallEquals(data, t.Ball);
|
|
|
|
|
case EncounterStatic s when s.Gift:
|
|
|
|
|
return VerifyBallEquals(data, s.Ball);
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
// Capture / Inherit cases -- can be one of many balls
|
|
|
|
|
var pkm = data.pkm;
|
2020-04-12 18:28:03 +00:00
|
|
|
|
if (pkm.Species == (int)Species.Shedinja && data.EncounterMatch.Species != (int)Species.Shedinja) // Shedinja. For gen3, copy the ball from Nincada
|
|
|
|
|
{
|
|
|
|
|
// Only Gen3 origin Shedinja can copy the wild ball.
|
|
|
|
|
// Evolution chains will indicate if it could have existed as Shedinja in Gen3.
|
|
|
|
|
// The special move verifier has a similar check!
|
|
|
|
|
if (Info.Generation != 3 || Info.EvoChainsAllGens[3].Count != 2)
|
|
|
|
|
return VerifyBallEquals(data, (int)Poke); // Pokeball Only
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (pkm.Ball == (int)Heavy && Legal.AlolanCaptureNoHeavyBall.Contains(EncounterMatch.Species) && !EncounterMatch.EggEncounter && pkm.SM)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallHeavy); // Heavy Ball, can inherit if from egg (USUM fixed catch rate calc)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2019-10-05 03:10:50 +00:00
|
|
|
|
return EncounterMatch switch
|
2018-08-26 18:15:32 +00:00
|
|
|
|
{
|
2019-10-05 03:10:50 +00:00
|
|
|
|
EncounterStatic e => VerifyBallStatic(data, e),
|
|
|
|
|
EncounterSlot w => VerifyBallWild(data, w),
|
|
|
|
|
EncounterEgg _ => VerifyBallEgg(data),
|
|
|
|
|
EncounterInvalid _ => VerifyBallEquals(data, pkm.Ball), // ignore ball, pass whatever
|
|
|
|
|
_ => VerifyBallEquals(data, (int)Poke)
|
|
|
|
|
};
|
2018-06-30 17:34:09 +00:00
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBallMysteryGift(LegalityAnalysis data, MysteryGift g)
|
|
|
|
|
{
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (g.Generation == 4 && g.Species == (int)Species.Manaphy && g.Ball == 0) // there is no ball data in Manaphy Mystery Gift from Gen4
|
2018-08-26 18:29:47 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Poke); // Pokeball
|
2018-06-30 17:34:09 +00:00
|
|
|
|
return VerifyBallEquals(data, g.Ball);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBallStatic(LegalityAnalysis data, EncounterStatic s)
|
|
|
|
|
{
|
|
|
|
|
if (s.Location == 75 && s.Generation == 5) // Entree Forest (Dream World)
|
|
|
|
|
return VerifyBallEquals(data, Legal.DreamWorldBalls);
|
|
|
|
|
return VerifyBallEquals(data, Legal.GetWildBalls(data.pkm));
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBallWild(LegalityAnalysis data, EncounterSlot w)
|
|
|
|
|
{
|
|
|
|
|
if (w.Location == 30016 && w.Generation == 7) // Poké Pelago
|
2018-08-26 18:29:47 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Poke); // Pokeball
|
2018-06-30 17:34:09 +00:00
|
|
|
|
|
|
|
|
|
var Info = data.Info;
|
|
|
|
|
|
|
|
|
|
// For gen3/4 Safari Zones and BCC getValidWildEncounters already filter to not return
|
|
|
|
|
// mixed possible encounters between safari, BCC and other encounters
|
|
|
|
|
// That means is the first encounter is not safari then there is no safari encounter in the array
|
|
|
|
|
if (3 <= Info.Generation && Info.Generation <= 4 && w.Type.IsSafariType())
|
2018-08-26 18:15:32 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Safari); // Safari Ball
|
2018-06-30 17:34:09 +00:00
|
|
|
|
if (Info.Generation == 4 && w.Type == SlotType.BugContest)
|
2018-08-26 18:15:32 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Sport); // Sport Ball
|
2018-06-30 17:34:09 +00:00
|
|
|
|
return VerifyBallEquals(data, Legal.GetWildBalls(data.pkm));
|
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBallEgg(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
if (data.Info.Generation < 6) // No inheriting Balls
|
2018-08-26 18:29:47 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Poke); // Must be Pokéball -- no ball inheritance.
|
2018-06-30 17:34:09 +00:00
|
|
|
|
|
2019-10-05 03:10:50 +00:00
|
|
|
|
return pkm.Ball switch
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2019-10-05 03:10:50 +00:00
|
|
|
|
(int)Poke => GetValid(LBallEnc), // Poké Ball
|
|
|
|
|
(int)Master => GetInvalid(LBallEggMaster), // Master Ball
|
|
|
|
|
(int)Cherish => GetInvalid(LBallEggCherish), // Cherish Ball
|
|
|
|
|
_ => VerifyBallInherited(data)
|
|
|
|
|
};
|
2018-06-30 17:34:09 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBallInherited(LegalityAnalysis data)
|
|
|
|
|
{
|
2019-10-05 03:10:50 +00:00
|
|
|
|
return data.Info.Generation switch
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2019-10-05 03:10:50 +00:00
|
|
|
|
6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules
|
|
|
|
|
7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules
|
|
|
|
|
8 => VerifyBallEggGen8(data),
|
|
|
|
|
_ => NONE
|
|
|
|
|
};
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-06-30 17:34:09 +00:00
|
|
|
|
|
|
|
|
|
private CheckResult VerifyBallEggGen6(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2018-07-01 17:49:11 +00:00
|
|
|
|
int species = data.EncounterMatch.Species;
|
|
|
|
|
if (pkm.Gender == 2 || Legal.BreedMaleOnly.Contains(species)) // Genderless
|
2018-08-26 18:29:47 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Poke); // Must be Pokéball as ball can only pass via mother (not Ditto!)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-08-26 18:15:32 +00:00
|
|
|
|
Ball ball = (Ball)pkm.Ball;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball == Safari) // Safari Ball
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (!Legal.Inherit_Safari.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-30 17:34:09 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball.IsApricornBall()) // Apricorn Ball
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (!Legal.Inherit_Apricorn6.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball == Sport) // Sport Ball
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (!Legal.Inherit_Sport.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-30 17:34:09 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball == Dream) // Dream Ball
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:49:11 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4 && Legal.Ban_DreamHidden.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (Legal.Inherit_Dream.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (Dusk <= ball && ball <= Quick) // Dusk Heal Quick
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:49:11 +00:00
|
|
|
|
if (!Legal.Ban_Gen4Ball_6.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (Ultra <= ball && ball <= Premier) // Don't worry, Safari was already checked.
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:49:11 +00:00
|
|
|
|
if (Legal.Ban_Gen3Ball.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-30 17:34:09 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4 && Legal.Ban_Gen3BallHidden.Contains(pkm.SpecForm))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-01 17:49:11 +00:00
|
|
|
|
if (species > 650 && species != 700) // Sylveon
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:49:11 +00:00
|
|
|
|
if (Legal.WildPokeballs6.Contains(pkm.Ball))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball >= Dream)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallUnavailable);
|
2018-08-26 18:15:32 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
return NONE;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBallEggGen7(LegalityAnalysis data)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2018-07-01 17:49:11 +00:00
|
|
|
|
int species = data.EncounterMatch.Species;
|
|
|
|
|
if (722 <= species && species <= 730) // G7 Starters
|
2018-08-26 18:29:47 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Poke);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-08-26 18:15:32 +00:00
|
|
|
|
Ball ball = (Ball)pkm.Ball;
|
2018-07-01 17:13:26 +00:00
|
|
|
|
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball == Safari)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (!(Legal.Inherit_Safari.Contains(species) || Legal.Inherit_SafariMale.Contains(species)))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4 && Legal.Ban_SafariBallHidden_7.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball.IsApricornBall()) // Apricorn Ball
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (!Legal.Inherit_Apricorn7.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4 && Legal.Ban_NoHidden7Apricorn.Contains(species | pkm.AltForm << 11)) // lineage is 3->2->origin
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball == Sport) // Sport Ball
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (!Legal.Inherit_Sport.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4 && (species == (int)Species.Volbeat || species == (int)Species.Illumise)) // Volbeat/Illumise
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball == Dream) // Dream Ball
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (Legal.Inherit_Dream.Contains(species) || Legal.Inherit_DreamMale.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (Dusk <= ball && ball <= Quick) // Dusk Heal Quick
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (!Legal.Ban_Gen4Ball_7.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (Ultra <= ball && ball <= Premier) // Don't worry, Safari was already checked.
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (!Legal.Ban_Gen3Ball_7.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball == Beast)
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2020-02-09 04:24:02 +00:00
|
|
|
|
if (species == (int)Species.Flabébé && pkm.AltForm == 3 && pkm.AbilityNumber == 4)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility); // Can't obtain Flabébé-Blue with Hidden Ability in wild
|
2020-02-09 04:24:02 +00:00
|
|
|
|
if (species == (int)Species.Voltorb && pkm.AbilityNumber == 4)
|
|
|
|
|
return GetInvalid(LBallAbility); // Can't obtain with Hidden Ability in wild (can only breed with Ditto)
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (((int)Species.Pikipek <= species && species <= (int)Species.Kommoo) || (Legal.AlolanCaptureOffspring.Contains(species) && !Legal.PastGenAlolanNativesUncapturable.Contains(species)))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-07-01 17:13:26 +00:00
|
|
|
|
if (Legal.PastGenAlolanScans.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
// next statement catches all new alolans
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (species > (int)Species.Volcanion)
|
2018-07-01 17:49:11 +00:00
|
|
|
|
return VerifyBallEquals(data, Legal.WildPokeballs7);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-08-26 18:15:32 +00:00
|
|
|
|
if (ball > Beast)
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallUnavailable);
|
2018-06-30 17:34:09 +00:00
|
|
|
|
|
|
|
|
|
return NONE;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 23:56:47 +00:00
|
|
|
|
private CheckResult VerifyBallEggGen8(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
|
|
|
|
int species = data.EncounterMatch.Species;
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if ((int)Species.Grookey <= species && species <= (int)Species.Inteleon) // G8 Starters
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Poke);
|
|
|
|
|
|
2020-03-11 00:53:56 +00:00
|
|
|
|
if (IsGalarBreed(species))
|
2019-11-17 01:45:51 +00:00
|
|
|
|
{
|
2020-03-11 00:53:56 +00:00
|
|
|
|
if (Legal.WildPokeballs8.Contains(pkm.Ball))
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
if (species >= (int)Species.Grookey)
|
2019-11-17 01:45:51 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 05:59:46 +00:00
|
|
|
|
if (722 <= species && species <= 730) // G7 Starters
|
|
|
|
|
return VerifyBallEquals(data, (int)Poke);
|
|
|
|
|
|
2019-09-23 23:56:47 +00:00
|
|
|
|
Ball ball = (Ball)pkm.Ball;
|
|
|
|
|
|
|
|
|
|
if (ball == Safari)
|
|
|
|
|
{
|
|
|
|
|
if (!(Legal.Inherit_Safari.Contains(species) || Legal.Inherit_SafariMale.Contains(species)))
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
if (pkm.AbilityNumber == 4 && Legal.Ban_SafariBallHidden_7.Contains(species))
|
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
}
|
|
|
|
|
if (ball.IsApricornBall()) // Apricorn Ball
|
|
|
|
|
{
|
|
|
|
|
if (!Legal.Inherit_Apricorn7.Contains(species))
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
2020-02-13 02:40:41 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4 && Legal.Ban_NoHidden8Apricorn.Contains(species | pkm.AltForm << 11)) // lineage is 3->2->origin
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
}
|
|
|
|
|
if (ball == Sport) // Sport Ball
|
|
|
|
|
{
|
|
|
|
|
if (!Legal.Inherit_Sport.Contains(species))
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (pkm.AbilityNumber == 4 && (species == (int)Species.Volbeat || species == (int)Species.Illumise)) // Volbeat/Illumise
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
}
|
|
|
|
|
if (ball == Dream) // Dream Ball
|
|
|
|
|
{
|
|
|
|
|
if (Legal.Inherit_Dream.Contains(species) || Legal.Inherit_DreamMale.Contains(species))
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
|
|
|
|
if (Dusk <= ball && ball <= Quick) // Dusk Heal Quick
|
|
|
|
|
{
|
|
|
|
|
if (!Legal.Ban_Gen4Ball_7.Contains(species))
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
|
|
|
|
if (Ultra <= ball && ball <= Premier) // Don't worry, Safari was already checked.
|
|
|
|
|
{
|
|
|
|
|
if (!Legal.Ban_Gen3Ball_7.Contains(species))
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ball == Beast)
|
|
|
|
|
{
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (species == (int)Species.Flabébé && pkm.AltForm == 3 && pkm.AbilityNumber == 4)
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallAbility); // Can't obtain Flabébé-Blue with Hidden Ability in wild
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (((int)Species.Pikipek <= species && species <= (int)Species.Kommoo) || (Legal.AlolanCaptureOffspring.Contains(species) && !Legal.PastGenAlolanNativesUncapturable.Contains(species)))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
if (Legal.PastGenAlolanScans.Contains(species))
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
// next statement catches all new alolans
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (species > Legal.MaxSpeciesID_7_USUM)
|
|
|
|
|
return VerifyBallEquals(data, Legal.WildPokeballs8);
|
|
|
|
|
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (species > (int)Species.Volcanion)
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return VerifyBallEquals(data, Legal.WildPokeballs7);
|
|
|
|
|
|
|
|
|
|
if (ball > Beast)
|
|
|
|
|
return GetInvalid(LBallUnavailable);
|
|
|
|
|
|
|
|
|
|
return NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 00:53:56 +00:00
|
|
|
|
public static bool IsGalarBreed(int species)
|
2019-11-17 01:45:51 +00:00
|
|
|
|
{
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if ((int)Species.Grookey <= species && species <= (int)Species.Inteleon) // starter
|
2019-11-17 01:45:51 +00:00
|
|
|
|
return false;
|
|
|
|
|
var pt = PersonalTable.SWSH;
|
2020-02-15 22:29:23 +00:00
|
|
|
|
return ((PersonalInfoSWSH)pt.GetFormeEntry(species, 0)).PokeDexIndex != 0;
|
2019-11-17 01:45:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBallEquals(LegalityAnalysis data, int ball) => GetResult(ball == data.pkm.Ball);
|
2018-07-01 17:49:11 +00:00
|
|
|
|
private CheckResult VerifyBallEquals(LegalityAnalysis data, HashSet<int> balls) => GetResult(balls.Contains(data.pkm.Ball));
|
2018-06-30 17:34:09 +00:00
|
|
|
|
private CheckResult VerifyBallEquals(LegalityAnalysis data, ICollection<int> balls) => GetResult(balls.Contains(data.pkm.Ball));
|
2018-09-01 21:11:12 +00:00
|
|
|
|
private CheckResult GetResult(bool valid) => valid ? GetValid(LBallEnc) : GetInvalid(LBallEncMismatch);
|
2018-06-24 05:00:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|