diff --git a/PKHeX.Core/Editing/BattleTemplate/Showdown/ShowdownSet.cs b/PKHeX.Core/Editing/BattleTemplate/Showdown/ShowdownSet.cs index 505a318c9..c4273affc 100644 --- a/PKHeX.Core/Editing/BattleTemplate/Showdown/ShowdownSet.cs +++ b/PKHeX.Core/Editing/BattleTemplate/Showdown/ShowdownSet.cs @@ -299,35 +299,35 @@ private void ParseLineAbilityBracket(ReadOnlySpan line, GameStrings locali Ability = abilityIndex; } - private bool ParseEntry(BattleTemplateToken token, ReadOnlySpan value, BattleTemplateLocalization localization) => token switch + private bool ParseEntry(BattleTemplateToken token, ReadOnlySpan input, BattleTemplateLocalization localization) => token switch { - BattleTemplateToken.Ability => ParseLineAbility(value, localization.Strings.abilitylist), - BattleTemplateToken.Nature => ParseLineNature(value, localization.Strings.natures), + BattleTemplateToken.Ability => ParseLineAbility(input, localization.Strings.abilitylist), + BattleTemplateToken.Nature => ParseLineNature(input, localization.Strings.natures), BattleTemplateToken.Shiny => Shiny = true, BattleTemplateToken.Gigantamax => CanGigantamax = true, - BattleTemplateToken.HeldItem => ParseItemName(value, localization.Strings), - BattleTemplateToken.Nickname => ParseNickname(value), - BattleTemplateToken.Gender => ParseGender(value, localization.Config), - BattleTemplateToken.Friendship => ParseFriendship(value), - BattleTemplateToken.EVs => ParseLineEVs(value, localization), - BattleTemplateToken.IVs => ParseLineIVs(value, localization.Config), - BattleTemplateToken.Level => ParseLevel(value), - BattleTemplateToken.DynamaxLevel => ParseDynamax(value), - BattleTemplateToken.TeraType => ParseTeraType(value, localization.Strings.types), + BattleTemplateToken.HeldItem => ParseItemName(input, localization.Strings), + BattleTemplateToken.Nickname => ParseNickname(input), + BattleTemplateToken.Gender => ParseGender(input, localization.Config), + BattleTemplateToken.Friendship => ParseFriendship(input), + BattleTemplateToken.EVs => ParseLineEVs(input, localization), + BattleTemplateToken.IVs => ParseLineIVs(input, localization.Config), + BattleTemplateToken.Level => ParseLevel(input), + BattleTemplateToken.DynamaxLevel => ParseDynamax(input), + BattleTemplateToken.TeraType => ParseTeraType(input, localization.Strings.types), _ => false, }; - private bool ParseLineAbility(ReadOnlySpan value, ReadOnlySpan abilityNames) + private bool ParseLineAbility(ReadOnlySpan input, ReadOnlySpan abilityNames) { - var index = StringUtil.FindIndexIgnoreCase(abilityNames, value); + var index = StringUtil.FindIndexIgnoreCase(abilityNames, input); if (index < 0) { - LogError(AbilityUnrecognized, value); + LogError(AbilityUnrecognized, input); return false; } if (Ability != -1 && Ability != index) { - LogError(AbilityAlreadySpecified, value); + LogError(AbilityAlreadySpecified, input); return false; } @@ -335,21 +335,21 @@ private bool ParseLineAbility(ReadOnlySpan value, ReadOnlySpan abi return true; } - private bool ParseLineNature(ReadOnlySpan value, ReadOnlySpan natureNames) + private bool ParseLineNature(ReadOnlySpan input, ReadOnlySpan natureNames) { - var index = StringUtil.FindIndexIgnoreCase(natureNames, value); + var index = StringUtil.FindIndexIgnoreCase(natureNames, input); if (index < 0) return false; var nature = (Nature)index; if (!nature.IsFixed()) { - LogError(NatureUnrecognized, value); + LogError(NatureUnrecognized, input); return false; } if (Nature != Nature.Random && Nature != nature) { - LogError(NatureAlreadySpecified, value); + LogError(NatureAlreadySpecified, input); return false; } @@ -357,23 +357,23 @@ private bool ParseLineNature(ReadOnlySpan value, ReadOnlySpan natu return true; } - private bool ParseNickname(ReadOnlySpan value) + private bool ParseNickname(ReadOnlySpan input) { - if (value.Length == 0) + if (input.Length == 0) return false; // ignore length, but generally should be <= the Context's max length - Nickname = value.ToString(); + Nickname = input.ToString(); return true; } - private bool ParseGender(ReadOnlySpan value, BattleTemplateConfig cfg) + private bool ParseGender(ReadOnlySpan input, BattleTemplateConfig cfg) { - if (value.Equals(cfg.Male, StringComparison.OrdinalIgnoreCase)) + if (input.Equals(cfg.Male, StringComparison.OrdinalIgnoreCase)) { Gender = EntityGender.Male; return true; } - if (value.Equals(cfg.Female, StringComparison.OrdinalIgnoreCase)) + if (input.Equals(cfg.Female, StringComparison.OrdinalIgnoreCase)) { Gender = EntityGender.Female; return true; @@ -381,43 +381,43 @@ private bool ParseGender(ReadOnlySpan value, BattleTemplateConfig cfg) return false; } - private bool ParseLevel(ReadOnlySpan value) + private bool ParseLevel(ReadOnlySpan input) { - if (!byte.TryParse(value.Trim(), out var val)) + if (!byte.TryParse(input.Trim(), out var value)) return false; - if ((uint)val is 0 or > Experience.MaxLevel) + if ((uint)value is 0 or > Experience.MaxLevel) return false; - Level = val; + Level = value; return true; } - private bool ParseFriendship(ReadOnlySpan value) + private bool ParseFriendship(ReadOnlySpan input) { - if (!byte.TryParse(value.Trim(), out var val)) + if (!byte.TryParse(input.Trim(), out var value)) return false; - Friendship = val; + Friendship = value; return true; } - private bool ParseDynamax(ReadOnlySpan value) + private bool ParseDynamax(ReadOnlySpan input) { Context = EntityContext.Gen8; - var val = Util.ToInt32(value); - if ((uint)val > 10) + var value = Util.ToInt32(input); + if ((uint)value > 10) return false; - DynamaxLevel = (byte)val; + DynamaxLevel = (byte)value; return true; } - private bool ParseTeraType(ReadOnlySpan value, ReadOnlySpan types) + private bool ParseTeraType(ReadOnlySpan input, ReadOnlySpan types) { Context = EntityContext.Gen9; - var val = StringUtil.FindIndexIgnoreCase(types, value); - if (val < 0) + var value = StringUtil.FindIndexIgnoreCase(types, input); + if (value < 0) return false; - if (val == TeraTypeUtil.StellarTypeDisplayStringIndex) - val = TeraTypeUtil.Stellar; - TeraType = (MoveType)val; + if (value == TeraTypeUtil.StellarTypeDisplayStringIndex) + value = TeraTypeUtil.Stellar; + TeraType = (MoveType)value; return true; } diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/0138 - AMONITAS - 071B.pk2 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/0138 - AMONITAS - 071B.pk2 new file mode 100644 index 000000000..1022080f6 Binary files /dev/null and b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/0138 - AMONITAS - 071B.pk2 differ diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/138_-_OMANYTE_-_6050.pk2 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/138_-_OMANYTE_-_6050.pk2 deleted file mode 100644 index cf084937f..000000000 Binary files a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 2/138_-_OMANYTE_-_6050.pk2 and /dev/null differ