Tighten up memory 71 permissions

This commit is contained in:
Kurt 2021-06-30 15:55:32 -07:00
parent 600f4a550a
commit f2183f985f
2 changed files with 43 additions and 1 deletions

View file

@ -163,5 +163,47 @@ namespace PKHeX.Core
return true;
return false;
}
public static bool GetCanDynamaxTrainer(int species, int gen, GameVersion version)
{
if (gen != 8)
return false;
return version switch
{
GameVersion.SW => DynamaxTrainer_SWSH.Contains(species) || IsDynamaxSW(species),
GameVersion.SH => DynamaxTrainer_SWSH.Contains(species) || IsDynamaxSH(species),
_ => DynamaxTrainer_SWSH.Contains(species) || IsDynamaxSW(species) || IsDynamaxSH(species)
};
}
// exclusive to version
private static bool IsDynamaxSW(int species) => species is (int) Machamp or (int) Coalossal or (int) Flapple;
private static bool IsDynamaxSH(int species) => species is (int) Gengar or (int) Lapras or (int) Appletun;
// common to SW & SH
private static readonly HashSet<int> DynamaxTrainer_SWSH = new()
{
(int)Venusaur,
(int)Blastoise,
(int)Charizard,
(int)Slowbro,
(int)Snorlax,
(int)Slowking,
(int)Garbodor,
(int)Rillaboom,
(int)Inteleon,
(int)Cinderace,
(int)Corviknight,
(int)Eldegoss,
(int)Drednaw,
(int)Centiskorch,
(int)Hatterene,
(int)Grimmsnarl,
(int)Alcremie,
(int)Copperajah,
(int)Duraludon,
(int)Urshifu,
};
}
}

View file

@ -45,7 +45,7 @@ namespace PKHeX.Core
// Dynamaxing
// {0} battled at {1}s side against {2} that Dynamaxed. {4} that {3}.
case 71 when !GetCanBeCaptured(memory.Variable, 8, handler == 0 ? (GameVersion)pkm.Version : GameVersion.Any) && memory.Variable is not (int)Species.Urshifu:
case 71 when !GetCanDynamaxTrainer(memory.Variable, 8, handler == 0 ? (GameVersion)pkm.Version : GameVersion.Any):
// {0} battled {2} and Dynamaxed upon {1}s instruction. {4} that {3}.
case 72 when !((PersonalInfoSWSH)PersonalTable.SWSH[memory.Variable]).IsPresentInGame:
return GetInvalid(string.Format(LMemoryArgBadSpecies, handler == 0 ? L_XOT : L_XHT));