Misc tweaks

Rename args for better clarity
Fix invalid pokerus on gen2 unit test case (apparently pkrs in gen2 was unchecked until recent miscverifier fix)
This commit is contained in:
Kurt 2026-02-18 07:46:39 -06:00
parent a9f449ff01
commit aab826ef13
3 changed files with 43 additions and 43 deletions

View File

@ -299,35 +299,35 @@ private void ParseLineAbilityBracket(ReadOnlySpan<char> line, GameStrings locali
Ability = abilityIndex; Ability = abilityIndex;
} }
private bool ParseEntry(BattleTemplateToken token, ReadOnlySpan<char> value, BattleTemplateLocalization localization) => token switch private bool ParseEntry(BattleTemplateToken token, ReadOnlySpan<char> input, BattleTemplateLocalization localization) => token switch
{ {
BattleTemplateToken.Ability => ParseLineAbility(value, localization.Strings.abilitylist), BattleTemplateToken.Ability => ParseLineAbility(input, localization.Strings.abilitylist),
BattleTemplateToken.Nature => ParseLineNature(value, localization.Strings.natures), BattleTemplateToken.Nature => ParseLineNature(input, localization.Strings.natures),
BattleTemplateToken.Shiny => Shiny = true, BattleTemplateToken.Shiny => Shiny = true,
BattleTemplateToken.Gigantamax => CanGigantamax = true, BattleTemplateToken.Gigantamax => CanGigantamax = true,
BattleTemplateToken.HeldItem => ParseItemName(value, localization.Strings), BattleTemplateToken.HeldItem => ParseItemName(input, localization.Strings),
BattleTemplateToken.Nickname => ParseNickname(value), BattleTemplateToken.Nickname => ParseNickname(input),
BattleTemplateToken.Gender => ParseGender(value, localization.Config), BattleTemplateToken.Gender => ParseGender(input, localization.Config),
BattleTemplateToken.Friendship => ParseFriendship(value), BattleTemplateToken.Friendship => ParseFriendship(input),
BattleTemplateToken.EVs => ParseLineEVs(value, localization), BattleTemplateToken.EVs => ParseLineEVs(input, localization),
BattleTemplateToken.IVs => ParseLineIVs(value, localization.Config), BattleTemplateToken.IVs => ParseLineIVs(input, localization.Config),
BattleTemplateToken.Level => ParseLevel(value), BattleTemplateToken.Level => ParseLevel(input),
BattleTemplateToken.DynamaxLevel => ParseDynamax(value), BattleTemplateToken.DynamaxLevel => ParseDynamax(input),
BattleTemplateToken.TeraType => ParseTeraType(value, localization.Strings.types), BattleTemplateToken.TeraType => ParseTeraType(input, localization.Strings.types),
_ => false, _ => false,
}; };
private bool ParseLineAbility(ReadOnlySpan<char> value, ReadOnlySpan<string> abilityNames) private bool ParseLineAbility(ReadOnlySpan<char> input, ReadOnlySpan<string> abilityNames)
{ {
var index = StringUtil.FindIndexIgnoreCase(abilityNames, value); var index = StringUtil.FindIndexIgnoreCase(abilityNames, input);
if (index < 0) if (index < 0)
{ {
LogError(AbilityUnrecognized, value); LogError(AbilityUnrecognized, input);
return false; return false;
} }
if (Ability != -1 && Ability != index) if (Ability != -1 && Ability != index)
{ {
LogError(AbilityAlreadySpecified, value); LogError(AbilityAlreadySpecified, input);
return false; return false;
} }
@ -335,21 +335,21 @@ private bool ParseLineAbility(ReadOnlySpan<char> value, ReadOnlySpan<string> abi
return true; return true;
} }
private bool ParseLineNature(ReadOnlySpan<char> value, ReadOnlySpan<string> natureNames) private bool ParseLineNature(ReadOnlySpan<char> input, ReadOnlySpan<string> natureNames)
{ {
var index = StringUtil.FindIndexIgnoreCase(natureNames, value); var index = StringUtil.FindIndexIgnoreCase(natureNames, input);
if (index < 0) if (index < 0)
return false; return false;
var nature = (Nature)index; var nature = (Nature)index;
if (!nature.IsFixed()) if (!nature.IsFixed())
{ {
LogError(NatureUnrecognized, value); LogError(NatureUnrecognized, input);
return false; return false;
} }
if (Nature != Nature.Random && Nature != nature) if (Nature != Nature.Random && Nature != nature)
{ {
LogError(NatureAlreadySpecified, value); LogError(NatureAlreadySpecified, input);
return false; return false;
} }
@ -357,23 +357,23 @@ private bool ParseLineNature(ReadOnlySpan<char> value, ReadOnlySpan<string> natu
return true; return true;
} }
private bool ParseNickname(ReadOnlySpan<char> value) private bool ParseNickname(ReadOnlySpan<char> input)
{ {
if (value.Length == 0) if (input.Length == 0)
return false; return false;
// ignore length, but generally should be <= the Context's max length // ignore length, but generally should be <= the Context's max length
Nickname = value.ToString(); Nickname = input.ToString();
return true; return true;
} }
private bool ParseGender(ReadOnlySpan<char> value, BattleTemplateConfig cfg) private bool ParseGender(ReadOnlySpan<char> input, BattleTemplateConfig cfg)
{ {
if (value.Equals(cfg.Male, StringComparison.OrdinalIgnoreCase)) if (input.Equals(cfg.Male, StringComparison.OrdinalIgnoreCase))
{ {
Gender = EntityGender.Male; Gender = EntityGender.Male;
return true; return true;
} }
if (value.Equals(cfg.Female, StringComparison.OrdinalIgnoreCase)) if (input.Equals(cfg.Female, StringComparison.OrdinalIgnoreCase))
{ {
Gender = EntityGender.Female; Gender = EntityGender.Female;
return true; return true;
@ -381,43 +381,43 @@ private bool ParseGender(ReadOnlySpan<char> value, BattleTemplateConfig cfg)
return false; return false;
} }
private bool ParseLevel(ReadOnlySpan<char> value) private bool ParseLevel(ReadOnlySpan<char> input)
{ {
if (!byte.TryParse(value.Trim(), out var val)) if (!byte.TryParse(input.Trim(), out var value))
return false; return false;
if ((uint)val is 0 or > Experience.MaxLevel) if ((uint)value is 0 or > Experience.MaxLevel)
return false; return false;
Level = val; Level = value;
return true; return true;
} }
private bool ParseFriendship(ReadOnlySpan<char> value) private bool ParseFriendship(ReadOnlySpan<char> input)
{ {
if (!byte.TryParse(value.Trim(), out var val)) if (!byte.TryParse(input.Trim(), out var value))
return false; return false;
Friendship = val; Friendship = value;
return true; return true;
} }
private bool ParseDynamax(ReadOnlySpan<char> value) private bool ParseDynamax(ReadOnlySpan<char> input)
{ {
Context = EntityContext.Gen8; Context = EntityContext.Gen8;
var val = Util.ToInt32(value); var value = Util.ToInt32(input);
if ((uint)val > 10) if ((uint)value > 10)
return false; return false;
DynamaxLevel = (byte)val; DynamaxLevel = (byte)value;
return true; return true;
} }
private bool ParseTeraType(ReadOnlySpan<char> value, ReadOnlySpan<string> types) private bool ParseTeraType(ReadOnlySpan<char> input, ReadOnlySpan<string> types)
{ {
Context = EntityContext.Gen9; Context = EntityContext.Gen9;
var val = StringUtil.FindIndexIgnoreCase(types, value); var value = StringUtil.FindIndexIgnoreCase(types, input);
if (val < 0) if (value < 0)
return false; return false;
if (val == TeraTypeUtil.StellarTypeDisplayStringIndex) if (value == TeraTypeUtil.StellarTypeDisplayStringIndex)
val = TeraTypeUtil.Stellar; value = TeraTypeUtil.Stellar;
TeraType = (MoveType)val; TeraType = (MoveType)value;
return true; return true;
} }