Skip to content

Commit

Permalink
Update to AutoCorrect Showdown
Browse files Browse the repository at this point in the history
- Shows what was corrected.
  • Loading branch information
bdawg1989 committed Jun 18, 2024
1 parent 030a9bb commit 7642af4
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 73 deletions.
42 changes: 39 additions & 3 deletions SysBot.Pokemon.Discord/Commands/Bots/TradeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,24 @@ public async Task HideTradeAsync([Summary("Trade Code")] int code, [Summary("Sho
// Perform auto correct if it's on and send that shit through again
if (SysCord<T>.Runner.Config.Trade.AutoCorrectConfig.EnableAutoCorrect && !la.Valid)
{
var correctedContent = await AutoCorrectShowdown<T>.PerformAutoCorrect(content, pkm, la);
var (correctedContent, correctionMessages) = await AutoCorrectShowdown<T>.PerformAutoCorrect(content, pkm, la);
set = new ShowdownSet(correctedContent);
template = AutoLegalityWrapper.GetTemplate(set);
pkm = sav.GetLegal(template, out result);
la = new LegalityAnalysis(pkm);
setEdited = true;

if (correctionMessages.Count > 0)
{
var userName = Context.User.Mention;
var changesEmbed = new EmbedBuilder()
.WithTitle("Showdown Set Corrections")
.WithColor(Color.Orange)
.WithDescription(string.Join("\n", correctionMessages))
.Build();

await ReplyAsync($"{userName}, here are the corrections made to your Showdown set:", embed: changesEmbed).ConfigureAwait(false);
}
}

if (pkm is not T correctedPk || !la.Valid)
Expand Down Expand Up @@ -579,12 +591,24 @@ public async Task TradeAsync([Summary("Trade Code")] int code, [Summary("Showdow
// Perform auto correct if it's on and send that shit through again
if (SysCord<T>.Runner.Config.Trade.AutoCorrectConfig.EnableAutoCorrect && !la.Valid)
{
var correctedContent = await AutoCorrectShowdown<T>.PerformAutoCorrect(content, pkm, la);
var (correctedContent, correctionMessages) = await AutoCorrectShowdown<T>.PerformAutoCorrect(content, pkm, la);
set = new ShowdownSet(correctedContent);
template = AutoLegalityWrapper.GetTemplate(set);
pkm = sav.GetLegal(template, out result);
la = new LegalityAnalysis(pkm);
setEdited = true;

if (correctionMessages.Count > 0)
{
var userName = Context.User.Mention;
var changesEmbed = new EmbedBuilder()
.WithTitle("Showdown Set Corrections")
.WithColor(Color.Orange)
.WithDescription(string.Join("\n", correctionMessages))
.Build();

await ReplyAsync($"{userName}, here are the corrections made to your Showdown set:", embed: changesEmbed).ConfigureAwait(false);
}
}

if (pkm is not T correctedPk || !la.Valid)
Expand Down Expand Up @@ -860,12 +884,24 @@ private async Task ProcessSingleTradeAsync(string tradeContent, int batchTradeCo
// Perform auto correct if it's on and send that shit through again
if (SysCord<T>.Runner.Config.Trade.AutoCorrectConfig.EnableAutoCorrect && !la.Valid)
{
var correctedContent = await AutoCorrectShowdown<T>.PerformAutoCorrect(tradeContent, pkm, la);
var (correctedContent, correctionMessages) = await AutoCorrectShowdown<T>.PerformAutoCorrect(tradeContent, pkm, la);
set = new ShowdownSet(correctedContent);
template = AutoLegalityWrapper.GetTemplate(set);
pkm = sav.GetLegal(template, out result);
la = new LegalityAnalysis(pkm);
setEdited = true;

if (correctionMessages.Count > 0)
{
var userName = Context.User.Mention;
var changesEmbed = new EmbedBuilder()
.WithTitle("Showdown Set Corrections")
.WithColor(Color.Orange)
.WithDescription(string.Join("\n", correctionMessages))
.Build();

await ReplyAsync($"{userName}, here are the corrections made to your Showdown set:", embed: changesEmbed).ConfigureAwait(false);
}
}

if (pkm is not T correctedPk || !la.Valid)
Expand Down
Loading

0 comments on commit 7642af4

Please sign in to comment.