Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

08/31/24 #6

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SysBot.Pokemon.Discord/Commands/Bots/CloneModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task CloneAsync(int code)
var lgcode = Info.GetRandomLGTradeCode();

// Add to queue asynchronously
_ = QueueHelper<T>.AddToQueueAsync(Context, code, Context.User.Username, sig, new T(), PokeRoutineType.Clone, PokeTradeType.Clone, Context.User, false, 1, 1, false, false, lgcode);
_ = QueueHelper<T>.AddToQueueAsync(Context, code, Context.User.Username, sig, new T(), PokeRoutineType.Clone, PokeTradeType.Clone, Context.User, false, 1, 1, false, false, false, lgcode);

// Immediately send a confirmation message without waiting
var confirmationMessage = await ReplyAsync("Processing your clone request...").ConfigureAwait(false);
Expand Down Expand Up @@ -63,7 +63,7 @@ public async Task CloneAsync([Summary("Trade Code")][Remainder] string code)
var lgcode = Info.GetRandomLGTradeCode();

// Add to queue asynchronously
_ = QueueHelper<T>.AddToQueueAsync(Context, tradeCode == 0 ? Info.GetRandomTradeCode(userID) : tradeCode, Context.User.Username, sig, new T(), PokeRoutineType.Clone, PokeTradeType.Clone, Context.User, false, 1, 1, false, false, lgcode);
_ = QueueHelper<T>.AddToQueueAsync(Context, tradeCode == 0 ? Info.GetRandomTradeCode(userID) : tradeCode, Context.User.Username, sig, new T(), PokeRoutineType.Clone, PokeTradeType.Clone, Context.User, false, 1, 1, false, false, false, lgcode);

// Immediately send a confirmation message without waiting
var confirmationMessage = await ReplyAsync("Processing your clone request...").ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion SysBot.Pokemon.Discord/Commands/Bots/MysteryEggModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@

if (!skipLegalityCheck)
{
la = new LegalityAnalysis(pk);

Check warning on line 176 in SysBot.Pokemon.Discord/Commands/Bots/MysteryEggModule.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'pk' in 'LegalityAnalysis.LegalityAnalysis(PKM pk, StorageSlotType source = StorageSlotType.None)'.

Check warning on line 176 in SysBot.Pokemon.Discord/Commands/Bots/MysteryEggModule.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'pk' in 'LegalityAnalysis.LegalityAnalysis(PKM pk, StorageSlotType source = StorageSlotType.None)'.
if (!la.Valid)
{
string responseMessage;
Expand All @@ -189,7 +189,7 @@
else
{
// If we're skipping the initial check, we still need to create a LegalityAnalysis object
la = new LegalityAnalysis(pk);

Check warning on line 192 in SysBot.Pokemon.Discord/Commands/Bots/MysteryEggModule.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'pk' in 'LegalityAnalysis.LegalityAnalysis(PKM pk, StorageSlotType source = StorageSlotType.None)'.

Check warning on line 192 in SysBot.Pokemon.Discord/Commands/Bots/MysteryEggModule.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'pk' in 'LegalityAnalysis.LegalityAnalysis(PKM pk, StorageSlotType source = StorageSlotType.None)'.
}

if (!la.Valid && la.Results.Any(m => m.Identifier is CheckIdentifier.Memory))
Expand All @@ -209,7 +209,7 @@
if (la.Valid) pk = clone;
}

await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, pk, PokeRoutineType.LinkTrade, tradeType, usr, isBatchTrade, batchTradeNumber, totalBatchTrades, isHiddenTrade, isMysteryEgg, lgcode, ignoreAutoOT).ConfigureAwait(false);
await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, pk, PokeRoutineType.LinkTrade, tradeType, usr, isBatchTrade, batchTradeNumber, totalBatchTrades, isHiddenTrade, false, isMysteryEgg, lgcode, ignoreAutoOT).ConfigureAwait(false);
}

private static List<Pictocodes> GenerateRandomPictocodes(int count)
Expand Down
6 changes: 3 additions & 3 deletions SysBot.Pokemon.Discord/Commands/Bots/MysteryMonModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
}

var sig = Context.User.GetFavor();
await AddTradeToQueueAsync(code, Context.User.Username, pk, sig, Context.User).ConfigureAwait(false);
await AddTradeToQueueAsync(code, Context.User.Username, pk, sig, Context.User, isMysteryMon: true).ConfigureAwait(false);

if (Context.Message is IUserMessage userMessage)
{
Expand Down Expand Up @@ -342,9 +342,9 @@
};
}

private async Task AddTradeToQueueAsync(int code, string trainerName, T? pk, RequestSignificance sig, SocketUser usr, bool isBatchTrade = false, int batchTradeNumber = 1, int totalBatchTrades = 1, bool isHiddenTrade = false)
private async Task AddTradeToQueueAsync(int code, string trainerName, T? pk, RequestSignificance sig, SocketUser usr, bool isBatchTrade = false, int batchTradeNumber = 1, int totalBatchTrades = 1, bool isHiddenTrade = false, bool isMysteryMon = false)
{
var la = new LegalityAnalysis(pk);

Check warning on line 347 in SysBot.Pokemon.Discord/Commands/Bots/MysteryMonModule.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'pk' in 'LegalityAnalysis.LegalityAnalysis(PKM pk, StorageSlotType source = StorageSlotType.None)'.

Check warning on line 347 in SysBot.Pokemon.Discord/Commands/Bots/MysteryMonModule.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'pk' in 'LegalityAnalysis.LegalityAnalysis(PKM pk, StorageSlotType source = StorageSlotType.None)'.
if (!la.Valid)
{
string responseMessage;
Expand All @@ -357,7 +357,7 @@
return;
}

await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, pk, PokeRoutineType.LinkTrade, PokeTradeType.Specific, usr, isBatchTrade, batchTradeNumber, totalBatchTrades, isHiddenTrade).ConfigureAwait(false);
await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, pk, PokeRoutineType.LinkTrade, PokeTradeType.Specific, usr, isBatchTrade, batchTradeNumber, totalBatchTrades, isHiddenTrade, isMysteryMon).ConfigureAwait(false);
}
}
}
4 changes: 2 additions & 2 deletions SysBot.Pokemon.Discord/Commands/Bots/SpecialRequestModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ private static DateOnly GenerateRandomDateInRange(DateOnly startDate, DateOnly e
return startDate.AddDays(randomDays);
}

private async Task AddTradeToQueueAsync(int code, string trainerName, T? pk, RequestSignificance sig, SocketUser usr, bool isBatchTrade = false, int batchTradeNumber = 1, int totalBatchTrades = 1, bool isMysteryEgg = false, List<Pictocodes>? lgcode = null, PokeTradeType tradeType = PokeTradeType.Specific, bool ignoreAutoOT = false, bool isHiddenTrade = false)
private async Task AddTradeToQueueAsync(int code, string trainerName, T? pk, RequestSignificance sig, SocketUser usr, bool isBatchTrade = false, int batchTradeNumber = 1, int totalBatchTrades = 1, bool isMysteryMon = false, bool isMysteryEgg = false, List<Pictocodes>? lgcode = null, PokeTradeType tradeType = PokeTradeType.Specific, bool ignoreAutoOT = false, bool isHiddenTrade = false)
{
lgcode ??= TradeModule<T>.GenerateRandomPictocodes(3);
#pragma warning disable CS8604 // Possible null reference argument.
Expand Down Expand Up @@ -353,7 +353,7 @@ private async Task AddTradeToQueueAsync(int code, string trainerName, T? pk, Req
if (la.Valid) pk = clone;
}

await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, pk, PokeRoutineType.LinkTrade, tradeType, usr, isBatchTrade, batchTradeNumber, totalBatchTrades, isHiddenTrade, isMysteryEgg, lgcode, ignoreAutoOT).ConfigureAwait(false);
await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, pk, PokeRoutineType.LinkTrade, tradeType, usr, isBatchTrade, batchTradeNumber, totalBatchTrades, isHiddenTrade, isMysteryMon, isMysteryEgg, lgcode, ignoreAutoOT).ConfigureAwait(false);
}
}
}
8 changes: 4 additions & 4 deletions SysBot.Pokemon.Discord/Commands/Bots/TradeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task FixAdOT()
var lgcode = Info.GetRandomLGTradeCode();
var sig = Context.User.GetFavor();

await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, new T(), PokeRoutineType.FixOT, PokeTradeType.FixOT, Context.User, false, 1, 1, false, false, lgcode).ConfigureAwait(false);
await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, new T(), PokeRoutineType.FixOT, PokeTradeType.FixOT, Context.User, false, 1, 1, false, false, false, lgcode).ConfigureAwait(false);
if (Context.Message is IUserMessage userMessage)
{
_ = DeleteMessagesAfterDelayAsync(userMessage, null, 2);
Expand All @@ -74,7 +74,7 @@ public async Task FixAdOT([Summary("Trade Code")] int code)
var sig = Context.User.GetFavor();
var lgcode = Info.GetRandomLGTradeCode();

await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, new T(), PokeRoutineType.FixOT, PokeTradeType.FixOT, Context.User, false, 1, 1, false, false, lgcode).ConfigureAwait(false);
await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, new T(), PokeRoutineType.FixOT, PokeTradeType.FixOT, Context.User, false, 1, 1, false, false, false, lgcode).ConfigureAwait(false);
if (Context.Message is IUserMessage userMessage)
{
_ = DeleteMessagesAfterDelayAsync(userMessage, null, 2);
Expand Down Expand Up @@ -1508,7 +1508,7 @@ private static string ConvertMasterBall(string content)
return string.Join('\n', lines);
}

private async Task AddTradeToQueueAsync(int code, string trainerName, T? pk, RequestSignificance sig, SocketUser usr, bool isBatchTrade = false, int batchTradeNumber = 1, int totalBatchTrades = 1, bool isHiddenTrade = false, bool isMysteryEgg = false, List<Pictocodes>? lgcode = null, PokeTradeType tradeType = PokeTradeType.Specific, bool ignoreAutoOT = false, bool setEdited = false)
private async Task AddTradeToQueueAsync(int code, string trainerName, T? pk, RequestSignificance sig, SocketUser usr, bool isBatchTrade = false, int batchTradeNumber = 1, int totalBatchTrades = 1, bool isHiddenTrade = false, bool isMysteryMon = false, bool isMysteryEgg = false, List<Pictocodes>? lgcode = null, PokeTradeType tradeType = PokeTradeType.Specific, bool ignoreAutoOT = false, bool setEdited = false)
{
lgcode ??= TradeModule<T>.GenerateRandomPictocodes(3);
if (pk is not null && !pk.CanBeTraded())
Expand Down Expand Up @@ -1569,7 +1569,7 @@ private async Task AddTradeToQueueAsync(int code, string trainerName, T? pk, Req
la = new LegalityAnalysis(clone);
if (la.Valid) pk = clone;
}
await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, pk!, PokeRoutineType.LinkTrade, tradeType, usr, isBatchTrade, batchTradeNumber, totalBatchTrades, isHiddenTrade, isMysteryEgg, lgcode, ignoreAutoOT: ignoreAutoOT, setEdited: setEdited, isNonNative: isNonNative).ConfigureAwait(false);
await QueueHelper<T>.AddToQueueAsync(Context, code, trainerName, sig, pk!, PokeRoutineType.LinkTrade, tradeType, usr, isBatchTrade, batchTradeNumber, totalBatchTrades, isHiddenTrade, isMysteryMon, isMysteryEgg, lgcode, ignoreAutoOT: ignoreAutoOT, setEdited: setEdited, isNonNative: isNonNative).ConfigureAwait(false);
}

public static List<Pictocodes> GenerateRandomPictocodes(int count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async void Logger(PokeRoutineExecutorBase bot, PokeTradeDetail<T> detail)
ballImgUrl = $"https://raw.githubusercontent.com/bdawg1989/sprites/main/AltBallImg/28x28/{ballName}.png";
}

string tradeTitle = detail.IsMysteryEgg ? "✨ Mystery Egg" : detail.Type switch
string tradeTitle = detail.IsMysteryMon ? "✨ Mystery Pokémon" : detail.IsMysteryEgg ? "✨ Mystery Egg" : detail.Type switch
{
PokeTradeType.Clone => "Cloned Pokémon",
PokeTradeType.Dump => "Pokémon Dump",
Expand All @@ -103,7 +103,7 @@ async void Logger(PokeRoutineExecutorBase bot, PokeTradeDetail<T> detail)
_ => speciesName
};

string embedImageUrl = detail.IsMysteryEgg ? "https://raw.githubusercontent.com/bdawg1989/sprites/main/mysteryegg3.png" : detail.Type switch
string embedImageUrl = detail.IsMysteryMon ? "https://i.imgur.com/FdESYAv.png" : detail.IsMysteryEgg ? "https://raw.githubusercontent.com/bdawg1989/sprites/main/mysteryegg3.png" : detail.Type switch
{
PokeTradeType.Clone => "https://raw.githubusercontent.com/bdawg1989/sprites/main/clonepod.png",
PokeTradeType.Dump => "https://raw.githubusercontent.com/bdawg1989/sprites/main/AltBallImg/128x128/dumpball.png",
Expand All @@ -116,7 +116,7 @@ async void Logger(PokeRoutineExecutorBase bot, PokeTradeDetail<T> detail)

string footerText = detail.Type == PokeTradeType.Clone || detail.Type == PokeTradeType.Dump || detail.Type == PokeTradeType.Seed || detail.Type == PokeTradeType.FixOT
? "Initializing trade now."
: $"Initializing trade now. Enjoy your {(detail.IsMysteryEgg ? "✨ Mystery Egg" : speciesName)}!";
: $"Initializing trade now. Enjoy your {(detail.IsMysteryMon ? "✨ Mystery Pokémon" : detail.IsMysteryEgg ? "✨ Mystery Egg" : speciesName)}!";

var embed = new EmbedBuilder()
.WithColor(new DiscordColor(r, g, b))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using PKHeX.Core;
using PKHeX.Core.AutoMod;
using SysBot.Base;
using SysBot.Pokemon.Helpers;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down Expand Up @@ -40,6 +41,9 @@ public static async Task ReplyWithLegalizedSetAsync(this ISocketMessageChannel c
await channel.SendMessageAsync(imsg).ConfigureAwait(false);
return;
}
// Specie Img
bool canGmax = pkm is PK8 pk8 && pk8.CanGigantamax;
var speciesImage = TradeExtensions<PK9>.PokeImg(pkm, canGmax, false);

// Create RegenTemplate from the legalized PKM
var regenTemplate = new RegenTemplate(pkm);
Expand All @@ -58,6 +62,7 @@ public static async Task ReplyWithLegalizedSetAsync(this ISocketMessageChannel c

// Create embed
var embed = new EmbedBuilder()
.WithThumbnailUrl(speciesImage)
.WithTitle($"Legalized RegenTemplate for {speciesForm}")
.WithDescription($"Result: {result}\nEncounter: {la.EncounterOriginal.Name}")
.AddField("RegenTemplate", $"```{regenText}```")
Expand Down
19 changes: 10 additions & 9 deletions SysBot.Pokemon.Discord/Helpers/DetailsExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public static void AddNormalTradeFields(EmbedBuilder embedBuilder, EmbedData emb
embedBuilder.AddField("**Moves:**", embedData.MovesDisplay, inline: true);
}

public static void AddSpecialTradeFields(EmbedBuilder embedBuilder, bool isMysteryEgg, bool isSpecialRequest, bool isCloneRequest, bool isFixOTRequest, string trainerMention)
public static void AddSpecialTradeFields(EmbedBuilder embedBuilder, bool isMysteryMon, bool isMysteryEgg, bool isSpecialRequest, bool isCloneRequest, bool isFixOTRequest, string trainerMention)
{
string specialDescription = $"**Trainer:** {trainerMention}\n" +
(isMysteryEgg ? "Mystery Egg" : isSpecialRequest ? "Special Request" : isCloneRequest ? "Clone Request" : isFixOTRequest ? "FixOT Request" : "Dump Request");
(isMysteryMon ? "Mystery Pokémon" : isMysteryEgg ? "Mystery Egg" : isSpecialRequest ? "Special Request" : isCloneRequest ? "Clone Request" : isFixOTRequest ? "FixOT Request" : "Dump Request");
embedBuilder.AddField("\u200B", specialDescription, inline: false);
}

Expand All @@ -57,7 +57,7 @@ public static void AddThumbnails(EmbedBuilder embedBuilder, bool isCloneRequest,
}
}

public static EmbedData ExtractPokemonDetails(T pk, SocketUser user, bool isMysteryEgg, bool isCloneRequest, bool isDumpRequest, bool isFixOTRequest, bool isSpecialRequest, bool isBatchTrade, int batchTradeNumber, int totalBatchTrades)
public static EmbedData ExtractPokemonDetails(T pk, SocketUser user, bool isMysteryMon, bool isMysteryEgg, bool isCloneRequest, bool isDumpRequest, bool isFixOTRequest, bool isSpecialRequest, bool isBatchTrade, int batchTradeNumber, int totalBatchTrades)
{
var strings = GameInfo.GetStrings(1);
var embedData = new EmbedData
Expand Down Expand Up @@ -117,10 +117,10 @@ public static EmbedData ExtractPokemonDetails(T pk, SocketUser user, bool isMyst
embedData.PokemonDisplayName = pk.IsNicknamed ? pk.Nickname : embedData.SpeciesName;

// Trade title
embedData.TradeTitle = GetTradeTitle(isMysteryEgg, isCloneRequest, isDumpRequest, isFixOTRequest, isSpecialRequest, isBatchTrade, batchTradeNumber, embedData.PokemonDisplayName, pk.IsShiny);
embedData.TradeTitle = GetTradeTitle(isMysteryMon, isMysteryEgg, isCloneRequest, isDumpRequest, isFixOTRequest, isSpecialRequest, isBatchTrade, batchTradeNumber, embedData.PokemonDisplayName, pk.IsShiny);

// Author name
embedData.AuthorName = GetAuthorName(user.Username, embedData.TradeTitle, isMysteryEgg, isFixOTRequest, isCloneRequest, isDumpRequest, isSpecialRequest, isBatchTrade, embedData.PokemonDisplayName, pk.IsShiny);
embedData.AuthorName = GetAuthorName(user.Username, embedData.TradeTitle, isMysteryMon, isMysteryEgg, isFixOTRequest, isCloneRequest, isDumpRequest, isSpecialRequest, isBatchTrade, embedData.PokemonDisplayName, pk.IsShiny);

return embedData;
}
Expand Down Expand Up @@ -155,10 +155,10 @@ private static string GetAbilityName(T pk)
return GameInfo.AbilityDataSource.FirstOrDefault(a => a.Value == pk.Ability)?.Text ?? "";
}

private static string GetAuthorName(string username, string tradeTitle, bool isMysteryEgg, bool isFixOTRequest, bool isCloneRequest, bool isDumpRequest, bool isSpecialRequest, bool isBatchTrade, string pokemonDisplayName, bool isShiny)
private static string GetAuthorName(string username, string tradeTitle, bool isMysteryMon, bool isMysteryEgg, bool isFixOTRequest, bool isCloneRequest, bool isDumpRequest, bool isSpecialRequest, bool isBatchTrade, string pokemonDisplayName, bool isShiny)
{
string isPkmShiny = isShiny ? "Shiny " : "";
return isMysteryEgg || isFixOTRequest || isCloneRequest || isDumpRequest || isSpecialRequest || isBatchTrade ?
return isMysteryMon || isMysteryEgg || isFixOTRequest || isCloneRequest || isDumpRequest || isSpecialRequest || isBatchTrade ?
$"{username}'s {tradeTitle}" :
$"{username}'s {isPkmShiny}{pokemonDisplayName}";
}
Expand Down Expand Up @@ -257,10 +257,11 @@ private static string GetTeraTypeString(PK9 pk9)
return teraType.ToString();
}

private static string GetTradeTitle(bool isMysteryEgg, bool isCloneRequest, bool isDumpRequest, bool isFixOTRequest, bool isSpecialRequest, bool isBatchTrade, int batchTradeNumber, string pokemonDisplayName, bool isShiny)
private static string GetTradeTitle(bool isMysteryMon, bool isMysteryEgg, bool isCloneRequest, bool isDumpRequest, bool isFixOTRequest, bool isSpecialRequest, bool isBatchTrade, int batchTradeNumber, string pokemonDisplayName, bool isShiny)
{
string shinyEmoji = isShiny ? "✨ " : "";
return isMysteryEgg ? "✨ Shiny Mystery Egg ✨" :
return isMysteryMon ? "✨ Mystery Pokémon ✨" :
isMysteryEgg ? "✨ Shiny Mystery Egg ✨" :
isBatchTrade ? $"Batch Trade #{batchTradeNumber} - {shinyEmoji}{pokemonDisplayName}" :
isFixOTRequest ? "FixOT Request" :
isSpecialRequest ? "Special Request" :
Expand Down
Loading
Loading