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 Info = data.Info;
|
2021-01-11 02:15:33 +00:00
|
|
|
|
var enc = Info.EncounterMatch;
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2018-06-30 17:34:09 +00:00
|
|
|
|
// Fixed ball cases -- can be only one ball ever
|
2021-01-11 02:15:33 +00:00
|
|
|
|
switch (enc)
|
2018-08-26 18:15:32 +00:00
|
|
|
|
{
|
|
|
|
|
case MysteryGift g:
|
|
|
|
|
return VerifyBallMysteryGift(data, g);
|
|
|
|
|
case EncounterTrade t:
|
|
|
|
|
return VerifyBallEquals(data, t.Ball);
|
2020-12-22 06:33:48 +00:00
|
|
|
|
case EncounterStatic {Gift: true} s:
|
2018-08-26 18:15:32 +00:00
|
|
|
|
return VerifyBallEquals(data, s.Ball);
|
2020-12-22 07:37:07 +00:00
|
|
|
|
case EncounterSlot8GO: // Already a strict match
|
2020-11-17 05:17:45 +00:00
|
|
|
|
return GetResult(true);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
case EncounterSlot8b {IsMarsh: true}:
|
|
|
|
|
return VerifyBallEquals(data, (int)Safari);
|
2018-08-26 18:15:32 +00:00
|
|
|
|
}
|
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;
|
2021-07-30 23:22:10 +00:00
|
|
|
|
if (pkm.Species == (int)Species.Shedinja && enc.Species != (int)Species.Shedinja) // Shedinja. For gen3, copy the ball from Nincada
|
2020-04-12 18:28:03 +00:00
|
|
|
|
{
|
|
|
|
|
// 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!
|
2021-12-27 04:13:36 +00:00
|
|
|
|
if (pkm.HGSS && pkm.Ball == (int)Sport) // Can evolve in DP to retain the HG/SS ball -- not able to be captured in any other ball
|
|
|
|
|
return VerifyBallEquals(data, (int)Sport);
|
2020-04-12 18:28:03 +00:00
|
|
|
|
if (Info.Generation != 3 || Info.EvoChainsAllGens[3].Count != 2)
|
|
|
|
|
return VerifyBallEquals(data, (int)Poke); // Pokeball Only
|
|
|
|
|
}
|
2018-06-24 05:00:01 +00:00
|
|
|
|
|
2021-01-11 02:15:33 +00:00
|
|
|
|
if (pkm.Ball == (int)Heavy && BallBreedLegality.AlolanCaptureNoHeavyBall.Contains(enc.Species) && !enc.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
|
|
|
|
|
2021-01-11 02:15:33 +00:00
|
|
|
|
return enc 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),
|
2020-12-22 07:37:07 +00:00
|
|
|
|
EncounterEgg => VerifyBallEgg(data),
|
|
|
|
|
EncounterInvalid => VerifyBallEquals(data, pkm.Ball), // ignore ball, pass whatever
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => VerifyBallEquals(data, (int)Poke),
|
2019-10-05 03:10:50 +00:00
|
|
|
|
};
|
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)
|
2021-01-02 08:46:09 +00:00
|
|
|
|
return VerifyBallEquals(data, BallUseLegality.DreamWorldBalls);
|
2021-10-09 06:30:03 +00:00
|
|
|
|
return VerifyBallEquals(data, BallUseLegality.GetWildBalls(data.Info.Generation, s.Version));
|
2018-06-30 17:34:09 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2020-08-30 17:23:22 +00:00
|
|
|
|
private CheckResult VerifyBallWild(LegalityAnalysis data, EncounterSlot w)
|
|
|
|
|
{
|
2021-07-30 21:05:23 +00:00
|
|
|
|
var req = w.GetRequiredBallValue();
|
2020-08-30 17:23:22 +00:00
|
|
|
|
if (req != None)
|
|
|
|
|
return VerifyBallEquals(data, (int) req);
|
2018-06-30 17:34:09 +00:00
|
|
|
|
|
2021-10-09 06:30:03 +00:00
|
|
|
|
return VerifyBallEquals(data, BallUseLegality.GetWildBalls(data.Info.Generation, w.Version));
|
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 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)Master => GetInvalid(LBallEggMaster), // Master Ball
|
|
|
|
|
(int)Cherish => GetInvalid(LBallEggCherish), // Cherish Ball
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => VerifyBallInherited(data),
|
2019-10-05 03:10:50 +00:00
|
|
|
|
};
|
2018-06-30 17:34:09 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2021-01-02 01:08:49 +00:00
|
|
|
|
private CheckResult VerifyBallInherited(LegalityAnalysis data) => data.Info.Generation switch
|
2018-06-30 17:34:09 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
6 => VerifyBallEggGen6(data), // Gen6 Inheritance Rules
|
|
|
|
|
7 => VerifyBallEggGen7(data), // Gen7 Inheritance Rules
|
2021-11-20 02:23:49 +00:00
|
|
|
|
8 => data.pkm.BDSP ? VerifyBallEggGen8BDSP(data) : VerifyBallEggGen8(data),
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => NONE,
|
2021-01-02 01:08:49 +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;
|
2021-12-04 18:52:57 +00:00
|
|
|
|
if (pkm.Ball == (int)Poke)
|
|
|
|
|
return GetValid(LBallEnc); // Poké Ball
|
|
|
|
|
|
2021-01-02 08:46:09 +00:00
|
|
|
|
var enc = data.EncounterMatch;
|
|
|
|
|
int species = enc.Species;
|
|
|
|
|
if (pkm.Gender == 2 || BallBreedLegality.BreedMaleOnly6.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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Inherit_Safari.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2020-10-10 19:30:57 +00:00
|
|
|
|
if (IsHiddenAndNotPossible(pkm))
|
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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Inherit_Apricorn6.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2020-10-10 19:30:57 +00:00
|
|
|
|
if (IsHiddenAndNotPossible(pkm))
|
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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Inherit_Sport.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2020-10-10 19:30:57 +00:00
|
|
|
|
if (IsHiddenAndNotPossible(pkm))
|
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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Ban_DreamHidden.Contains(species) && IsHiddenAndNotPossible(pkm))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.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
|
|
|
|
}
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (ball is >= Dusk and <= Quick) // Dusk Heal Quick
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.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
|
|
|
|
}
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (ball is >= Ultra and <= Premier) // Don't worry, Safari was already checked.
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Ban_Gen3Ball.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Ban_Gen3BallHidden.Contains(species | (enc.Form << 11)) && IsHiddenAndNotPossible(pkm))
|
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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallUseLegality.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;
|
2021-12-04 18:52:57 +00:00
|
|
|
|
if (pkm.Ball == (int)Poke)
|
|
|
|
|
return GetValid(LBallEnc); // Poké Ball
|
|
|
|
|
|
2018-07-01 17:49:11 +00:00
|
|
|
|
int species = data.EncounterMatch.Species;
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (species is >= 722 and <= 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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!(BallBreedLegality.Inherit_Safari.Contains(species) || BallBreedLegality.Inherit_SafariMale.Contains(species)))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Ban_SafariBallHidden_7.Contains(species) && IsHiddenAndNotPossible(pkm))
|
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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Inherit_Apricorn7.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Ban_NoHidden7Apricorn.Contains(species | pkm.Form << 11) && IsHiddenAndNotPossible(pkm))
|
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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Inherit_Sport.Contains(species))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2020-12-25 20:30:26 +00:00
|
|
|
|
if ((species is (int)Species.Volbeat or (int)Species.Illumise) && IsHiddenAndNotPossible(pkm)) // 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
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Inherit_Dream.Contains(species) || BallBreedLegality.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
|
|
|
|
}
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (ball is >= Dusk and <= Quick) // Dusk Heal Quick
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.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
|
|
|
|
}
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (ball is >= Ultra and <= Premier) // Don't worry, Safari was already checked.
|
2018-06-24 05:00:01 +00:00
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.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-12-11 04:42:30 +00:00
|
|
|
|
if (species == (int)Species.Flabébé && pkm.Form == 3 && IsHiddenAndNotPossible(pkm))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetInvalid(LBallAbility); // Can't obtain Flabébé-Blue with Hidden Ability in wild
|
2020-10-10 19:30:57 +00:00
|
|
|
|
if (species == (int)Species.Voltorb && IsHiddenAndNotPossible(pkm))
|
2020-02-09 04:24:02 +00:00
|
|
|
|
return GetInvalid(LBallAbility); // Can't obtain with Hidden Ability in wild (can only breed with Ditto)
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if ((species is >= (int)Species.Pikipek and <= (int)Species.Kommoo) || (BallBreedLegality.AlolanCaptureOffspring.Contains(species) && !BallBreedLegality.PastGenAlolanNativesUncapturable.Contains(species)))
|
2018-09-01 21:11:12 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.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)
|
2021-01-02 08:46:09 +00:00
|
|
|
|
return VerifyBallEquals(data, BallUseLegality.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
|
|
|
|
}
|
|
|
|
|
|
2021-11-20 02:23:49 +00:00
|
|
|
|
private CheckResult VerifyBallEggGen8BDSP(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
int species = data.EncounterMatch.Species;
|
2021-11-22 01:31:45 +00:00
|
|
|
|
if (BallBreedLegality.BanInheritedBall_BDSP.Contains(species))
|
2021-11-20 02:23:49 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Poke);
|
2021-11-30 23:41:47 +00:00
|
|
|
|
if (BallBreedLegality.BanInheritedExceptSafari_BDSP.Contains(species))
|
|
|
|
|
return VerifyBallEquals(data, (int)Safari);
|
2021-11-20 02:23:49 +00:00
|
|
|
|
|
|
|
|
|
if (data.pkm.Ball == (int)Safari)
|
|
|
|
|
{
|
|
|
|
|
if (BallBreedLegality.InheritSafari_BDSP.Contains(species))
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var balls = BallUseLegality.GetWildBalls(8, GameVersion.BDSP);
|
|
|
|
|
return VerifyBallEquals(data, balls);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 23:56:47 +00:00
|
|
|
|
private CheckResult VerifyBallEggGen8(LegalityAnalysis data)
|
|
|
|
|
{
|
|
|
|
|
var pkm = data.pkm;
|
2021-12-04 18:52:57 +00:00
|
|
|
|
if (pkm.Ball == (int)Poke)
|
|
|
|
|
return GetValid(LBallEnc); // Poké Ball
|
|
|
|
|
|
2019-09-23 23:56:47 +00:00
|
|
|
|
int species = data.EncounterMatch.Species;
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (species is >= (int)Species.Grookey and <= (int)Species.Inteleon) // G8 Starters
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return VerifyBallEquals(data, (int)Poke);
|
|
|
|
|
|
2020-06-19 23:51:15 +00:00
|
|
|
|
if (IsGalarCatchAndBreed(species))
|
2019-11-17 01:45:51 +00:00
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallUseLegality.WildPokeballs8.Contains(pkm.Ball))
|
2020-03-11 00:53:56 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
if (species >= (int)Species.Grookey)
|
2019-11-17 01:45:51 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 23:56:47 +00:00
|
|
|
|
Ball ball = (Ball)pkm.Ball;
|
|
|
|
|
|
|
|
|
|
if (ball == Safari)
|
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!(BallBreedLegality.Inherit_Safari.Contains(species) || BallBreedLegality.Inherit_SafariMale.Contains(species)))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Ban_SafariBallHidden_7.Contains(species) && IsHiddenAndNotPossible(pkm))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
}
|
|
|
|
|
if (ball.IsApricornBall()) // Apricorn Ball
|
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Inherit_Apricorn7.Contains(species))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Ban_NoHidden8Apricorn.Contains(species | pkm.Form << 11) && IsHiddenAndNotPossible(pkm)) // lineage is 3->2->origin
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
}
|
|
|
|
|
if (ball == Sport) // Sport Ball
|
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Inherit_Sport.Contains(species))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallSpecies);
|
2020-12-25 20:30:26 +00:00
|
|
|
|
if ((species is (int)Species.Volbeat or (int)Species.Illumise) && IsHiddenAndNotPossible(pkm)) // Volbeat/Illumise
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallAbility);
|
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
}
|
|
|
|
|
if (ball == Dream) // Dream Ball
|
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.Inherit_Dream.Contains(species) || BallBreedLegality.Inherit_DreamMale.Contains(species))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (ball is >= Dusk and <= Quick) // Dusk Heal Quick
|
2019-09-23 23:56:47 +00:00
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Ban_Gen4Ball_7.Contains(species))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (ball is >= Ultra and <= Premier) // Don't worry, Safari was already checked.
|
2019-09-23 23:56:47 +00:00
|
|
|
|
{
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (!BallBreedLegality.Ban_Gen3Ball_7.Contains(species))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
return GetInvalid(LBallSpecies);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ball == Beast)
|
|
|
|
|
{
|
2020-12-11 04:42:30 +00:00
|
|
|
|
if (species == (int)Species.Flabébé && pkm.Form == 3 && IsHiddenAndNotPossible(pkm))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetInvalid(LBallAbility); // Can't obtain Flabébé-Blue with Hidden Ability in wild
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if ((species is >= (int)Species.Pikipek and <= (int)Species.Kommoo) || (BallBreedLegality.AlolanCaptureOffspring.Contains(species) && !BallBreedLegality.PastGenAlolanNativesUncapturable.Contains(species)))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
2021-01-02 08:46:09 +00:00
|
|
|
|
if (BallBreedLegality.PastGenAlolanScans.Contains(species))
|
2019-09-23 23:56:47 +00:00
|
|
|
|
return GetValid(LBallSpeciesPass);
|
|
|
|
|
// next statement catches all new alolans
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (species > Legal.MaxSpeciesID_7_USUM)
|
2021-01-02 08:46:09 +00:00
|
|
|
|
return VerifyBallEquals(data, BallUseLegality.WildPokeballs8);
|
2019-09-23 23:56:47 +00:00
|
|
|
|
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (species > (int)Species.Volcanion)
|
2021-01-02 08:46:09 +00:00
|
|
|
|
return VerifyBallEquals(data, BallUseLegality.WildPokeballs7);
|
2019-09-23 23:56:47 +00:00
|
|
|
|
|
|
|
|
|
if (ball > Beast)
|
|
|
|
|
return GetInvalid(LBallUnavailable);
|
|
|
|
|
|
|
|
|
|
return NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-10 19:30:57 +00:00
|
|
|
|
private static bool IsHiddenAndNotPossible(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (pkm.AbilityNumber != 4)
|
|
|
|
|
return false;
|
2020-11-04 02:48:29 +00:00
|
|
|
|
return !AbilityVerifier.CanAbilityPatch(pkm.Format, pkm.PersonalInfo.Abilities, pkm.Species);
|
2020-10-10 19:30:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-25 17:02:52 +00:00
|
|
|
|
private static bool IsGalarCatchAndBreed(int species)
|
2019-11-17 01:45:51 +00:00
|
|
|
|
{
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (species is >= (int)Species.Grookey and <= (int)Species.Inteleon) // starter
|
2019-11-17 01:45:51 +00:00
|
|
|
|
return false;
|
2020-10-24 18:16:01 +00:00
|
|
|
|
|
2020-10-25 17:02:52 +00:00
|
|
|
|
// Everything breed-able that is in the Galar Dex can be captured in-game.
|
2019-11-17 01:45:51 +00:00
|
|
|
|
var pt = PersonalTable.SWSH;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
var pi = (PersonalInfoSWSH) pt.GetFormEntry(species, 0);
|
2020-10-26 01:07:13 +00:00
|
|
|
|
if (pi.IsInDex)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// Foreign Captures
|
2021-05-29 22:31:47 +00:00
|
|
|
|
if (species is >= (int)Species.Treecko and <= (int)Species.Swampert) // Dynamax Adventures
|
2020-10-26 01:07:13 +00:00
|
|
|
|
return true;
|
2021-10-01 00:12:54 +00:00
|
|
|
|
if (species is >= (int)Species.Rowlet and <= (int)Species.Primarina) // Distribution Raids
|
|
|
|
|
return true;
|
2020-10-26 01:07:13 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
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
|
|
|
|
}
|
|
|
|
|
}
|