Skip to content

Commit

Permalink
Revert Ball string changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bdawg1989 committed Oct 29, 2024
1 parent e259cd4 commit 7fc2146
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 64 deletions.
18 changes: 16 additions & 2 deletions SysBot.Pokemon.Discord/Commands/Bots/TradeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public async Task TradeEggAsync([Summary("Trade Code")] int code, [Summary("Show
return;
}
content = ReusableActions.StripCodeBlock(content);
content = TradeModule<T>.ConvertMasterBall(content); // Temp fix for Ball: Master being unrecognized by the bot
var set = new ShowdownSet(content);
var template = AutoLegalityWrapper.GetTemplate(set);
_ = Task.Run(async () =>
Expand Down Expand Up @@ -354,7 +355,7 @@ public async Task HideTradeAsync([Summary("Trade Code")] int code, [Summary("Sho
}
var ignoreAutoOT = content.Contains("OT:") || content.Contains("TID:") || content.Contains("SID:");
content = ReusableActions.StripCodeBlock(content);
content = TradeExtensions<T>.ConvertBalls(content);
content = TradeModule<T>.ConvertMasterBall(content); // Temp fix for Ball: Master being unrecognized by the bot

// Check if the showdown set contains "Egg"
bool isEgg = TradeExtensions<T>.IsEggCheck(content);
Expand Down Expand Up @@ -579,7 +580,7 @@ public async Task TradeAsync([Summary("Trade Code")] int code, [Summary("Showdow

var ignoreAutoOT = content.Contains("OT:") || content.Contains("TID:") || content.Contains("SID:");
content = ReusableActions.StripCodeBlock(content);
content = TradeExtensions<T>.ConvertBalls(content);
content = TradeModule<T>.ConvertMasterBall(content); // Temp fix for Ball: Master being unrecognized by the bot

// Check if the showdown set contains "Egg"
bool isEgg = TradeExtensions<T>.IsEggCheck(content);
Expand Down Expand Up @@ -1648,6 +1649,19 @@ private async Task ReplyAndDeleteAsync(string message, int delaySeconds, IMessag
}
}

private static string ConvertMasterBall(string content)
{
var lines = content.Split('\n');
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].StartsWith("Ball:") && lines[i].Contains("Master"))
{
lines[i] = ".Ball=1";
}
}
return string.Join('\n', lines);
}

private async Task DeleteMessagesAfterDelayAsync(IMessage? sentMessage, IMessage? messageToDelete, int delaySeconds)
{
try
Expand Down
62 changes: 0 additions & 62 deletions SysBot.Pokemon/Helpers/TradeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,67 +621,5 @@ private static void SetRandomDateFromRanges(PKM pk, List<(DateOnly Start, DateOn
int rangeDays = End.DayNumber - Start.DayNumber + 1;
pk.MetDate = Start.AddDays(Random.Shared.Next(rangeDays));
}

private static readonly Dictionary<string, int> BallIdMapping = new Dictionary<string, int>
{
{"Beast", 26},
{"Cherish", 16},
{"Dive", 7},
{"Dream", 25},
{"Dusk", 13},
{"Fast", 17},
{"Friend", 22},
{"Great", 3},
{"Heal", 14},
{"Heavy", 20},
{"Level", 18},
{"Love", 21},
{"Lure", 19},
{"Luxury", 11},
{"Master", 1},
{"Moon", 23},
{"Nest", 8},
{"Net", 6},
{"Poke", 4},
{"Premier", 12},
{"Quick", 15},
{"Repeat", 9},
{"Safari", 5},
{"Sport", 24},
{"Timer", 10},
{"Ultra", 2},
// LA Specific Balls
{"LAPoke", 28},
{"Strange", 27},
{"LAGreat", 29},
{"LAUltra", 30},
{"Feather", 31},
{"Wing", 32},
{"Jet", 33},
{"LAHeavy", 34},
{"Leaden", 35},
{"Gigaton", 36},
{"Origin", 37}
};

public static string ConvertBalls(string content)
{
var lines = content.Split('\n');
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].StartsWith("Ball:"))
{
foreach (var ballMapping in BallIdMapping)
{
if (lines[i].Contains(ballMapping.Key))
{
lines[i] = $".Ball={ballMapping.Value}";
break;
}
}
}
}
return string.Join('\n', lines);
}
}
}

0 comments on commit 7fc2146

Please sign in to comment.