Check catchrate tradeback separately

Closes #3510
Thanks @CodeWithMa !
This commit is contained in:
Kurt 2022-06-02 18:32:22 -07:00
parent 48ace3ca49
commit e571a0b95f
4 changed files with 12 additions and 6 deletions

View file

@ -62,7 +62,7 @@
{
if (pkm is not PK1 pk1)
return false;
if (PK1.IsCatchRateHeldItem(pk1.Catch_Rate))
if (ParseSettings.AllowGen1Tradeback && PK1.IsCatchRateHeldItem(pk1.Catch_Rate))
return false;
if (IsCatchRateValid(pk1))
return false;

View file

@ -126,10 +126,16 @@ namespace PKHeX.Core
return false;
}
}
else if (pkm is PK1 pk1 && !ParseSettings.AllowGen1Tradeback)
else if (pkm is PK1 pk1)
{
if (!Array.TrueForAll(info.Moves, z => z.Generation is 1) && !PK1.IsCatchRateHeldItem(pk1.Catch_Rate))
return false;
var hasGen2 = Array.Exists(info.Moves, z => z.Generation is not 1);
if (hasGen2)
{
if (!ParseSettings.AllowGen1Tradeback)
return false;
if (!PK1.IsCatchRateHeldItem(pk1.Catch_Rate))
return false;
}
}
info.Parse.Add(evo);

View file

@ -80,7 +80,7 @@ namespace PKHeX.Core
public override int Stat_SPD { get => Stat_SPC; set { } }
#endregion
public static bool IsCatchRateHeldItem(int rate) => ParseSettings.AllowGen1Tradeback && Array.IndexOf(Legal.HeldItems_GSC, (ushort)rate) >= 0;
public static bool IsCatchRateHeldItem(int rate) => rate == 0 || Array.IndexOf(Legal.HeldItems_GSC, (ushort)rate) >= 0;
private static bool IsCatchRatePreEvolutionRate(int baseSpecies, int finalSpecies, int rate)
{
@ -113,7 +113,7 @@ namespace PKHeX.Core
private static bool IsValidCatchRateAnyPreEvo(int species, int rate)
{
if (rate is 0 || IsCatchRateHeldItem(rate))
if (IsCatchRateHeldItem(rate))
return true;
if (species == (int)Core.Species.Pikachu && rate == 0xA3) // Light Ball (starter)
return true;