Skip to content

Commit

Permalink
Remove Level adjustment from AutoCorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
bdawg1989 committed Aug 1, 2024
1 parent 5d75106 commit 6058c1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
27 changes: 5 additions & 22 deletions SysBot.Pokemon/Helpers/AutoCorrectShowdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace SysBot.Pokemon;
}
}

(string abilityName, string natureName, string ballName, string levelValue) = ParseLines(lines);
(string abilityName, string natureName, string ballName) = ParseLines(lines);

string correctedAbilityName = string.Empty;
if (!string.IsNullOrEmpty(abilityName) && autoCorrectConfig.AutoCorrectAbility)
Expand Down Expand Up @@ -114,16 +114,6 @@ namespace SysBot.Pokemon;
}
}

if (autoCorrectConfig.AutoCorrectLevel && !string.IsNullOrWhiteSpace(levelValue))
{
var levelVerifier = new LevelVerifier();
levelVerifier.Verify(la);
if (!la.Valid)
{
correctionMessages.Add($"Level was incorrect. Adjusted to **Level 100**.");
}
}

if (autoCorrectConfig.AutoCorrectMovesLearnset && lines.Any(line => line.StartsWith("- ")))
{
await MoveHelper<T>.ValidateMovesAsync(lines, pk, la, gameStrings, speciesName, correctedFormName ?? formName, correctionMessages);
Expand Down Expand Up @@ -178,7 +168,7 @@ namespace SysBot.Pokemon;
}
}

string[] correctedLines = lines.Select((line, i) => CorrectLine(line, i, speciesName, correctedSpeciesName, correctedFormName ?? formName, formName, correctedGender, gender, correctedHeldItem, heldItem, correctedAbilityName, correctedNatureName, correctedBallName, levelValue, la, nickname)).ToArray();
string[] correctedLines = lines.Select((line, i) => CorrectLine(line, i, speciesName, correctedSpeciesName, correctedFormName ?? formName, formName, correctedGender, gender, correctedHeldItem, heldItem, correctedAbilityName, correctedNatureName, correctedBallName, la, nickname)).ToArray();

// TODO: Validate Scale Line and remove if necessary.

Expand Down Expand Up @@ -277,12 +267,11 @@ private static (string speciesName, string formName, string gender, string heldI
return (speciesName, formName, gender, heldItem, nickname);
}

private static (string abilityName, string natureName, string ballName, string levelValue) ParseLines(string[] lines)
private static (string abilityName, string natureName, string ballName) ParseLines(string[] lines)
{
string abilityName = string.Empty;
string natureName = string.Empty;
string ballName = string.Empty;
string levelValue = string.Empty;

foreach (string line in lines)
{
Expand All @@ -294,14 +283,12 @@ private static (string abilityName, string natureName, string ballName, string l
natureName = trimmedLine[..^" Nature".Length].Trim();
else if (trimmedLine.StartsWith("Ball:"))
ballName = trimmedLine["Ball:".Length..].Trim();
else if (trimmedLine.StartsWith("Level:"))
levelValue = trimmedLine["Level:".Length..].Trim();
}

return (abilityName, natureName, ballName, levelValue);
return (abilityName, natureName, ballName);
}

private static string CorrectLine(string line, int index, string speciesName, string correctedSpeciesName, string correctedFormName, string formName, string correctedGender, string gender, string correctedHeldItem, string heldItem, string correctedAbilityName, string correctedNatureName, string correctedBallName, string levelValue, LegalityAnalysis la, string nickname)
private static string CorrectLine(string line, int index, string speciesName, string correctedSpeciesName, string correctedFormName, string formName, string correctedGender, string gender, string correctedHeldItem, string heldItem, string correctedAbilityName, string correctedNatureName, string correctedBallName, LegalityAnalysis la, string nickname)
{
if (index == 0) // Species line
{
Expand Down Expand Up @@ -349,10 +336,6 @@ private static string CorrectLine(string line, int index, string speciesName, st
{
return $"Ball: {correctedBallName}";
}
else if (line.StartsWith("Level:"))
{
return !la.Valid ? "Level: 100" : $"Level: {levelValue}";
}
else if (line.StartsWith("Shiny:", StringComparison.OrdinalIgnoreCase))
{
return la.EncounterMatch.Shiny.IsValid(la.Entity) ? "Shiny: Yes" : "Shiny: No";
Expand Down
9 changes: 0 additions & 9 deletions SysBot.Pokemon/Settings/TradeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,6 @@ public bool AutoCorrectBall
set => _autoCorrectBall = value;
}

private bool _autoCorrectLevel = true;

[Category(nameof(AutoCorrectShowdownCategory)), Description("If set to True, auto correction will correct wrong level."), DisplayName("Auto Correct Level")]
public bool AutoCorrectLevel
{
get => EnableAutoCorrect && _autoCorrectLevel;
set => _autoCorrectLevel = value;
}

private bool _autoCorrectGender = true;

[Category(nameof(AutoCorrectShowdownCategory)), Description("If set to True, auto correction will correct wrong gender."), DisplayName("Auto Correct Gender")]
Expand Down

0 comments on commit 6058c1c

Please sign in to comment.