Skip to content

Commit

Permalink
Integrate Milestone (awards) based on trading numbers. Idea from @Sec…
Browse files Browse the repository at this point in the history
…ludely
  • Loading branch information
bdawg1989 committed Nov 16, 2024
1 parent f85593f commit b3aaa0c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
42 changes: 29 additions & 13 deletions SysBot.Pokemon.Discord/Helpers/QueueHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ namespace SysBot.Pokemon.Discord;

private static readonly ConcurrentDictionary<ulong, int> ActiveBatchIds = new();

private static readonly Dictionary<int, string> MilestoneImages = new()
{
{ 1, "https://raw.githubusercontent.com/Secludedly/ZE-FusionBot-Sprite-Images/main/001.png" },
{ 50, "https://raw.githubusercontent.com/Secludedly/ZE-FusionBot-Sprite-Images/main/050.png" },
{ 100, "https://raw.githubusercontent.com/Secludedly/ZE-FusionBot-Sprite-Images/main/100.png" },
{ 200, "https://raw.githubusercontent.com/Secludedly/ZE-FusionBot-Sprite-Images/main/200.png" },
{ 300, "https://raw.githubusercontent.com/Secludedly/ZE-FusionBot-Sprite-Images/main/300.png" },
{ 400, "https://raw.githubusercontent.com/Secludedly/ZE-FusionBot-Sprite-Images/main/400.png" },
{ 500, "https://raw.githubusercontent.com/Secludedly/ZE-FusionBot-Sprite-Images/main/500.png" }
};

private static int GetOrCreateBatchId(ulong userId, int batchTradeNumber)
{
if (batchTradeNumber == 1)
Expand Down Expand Up @@ -252,6 +263,13 @@ private static async Task<TradeQueueResult> AddToTradeQueue(SocketCommandContext
return new TradeQueueResult(false);
}

if (SysCord<T>.Runner.Hub.Config.Trade.TradeConfiguration.StoreTradeCodes)
{
var tradeCodeStorage = new TradeCodeStorage();
int tradeCount = tradeCodeStorage.GetTradeCount(trader.Id);
_ = SendMilestoneEmbed(tradeCount, context.Channel, trader);
}

return new TradeQueueResult(true);
}

Expand Down Expand Up @@ -567,21 +585,19 @@ private static void DeleteBatchTradeFiles(int batchTradeId)
}
}

public enum AlcremieDecoration
private static async Task SendMilestoneEmbed(int tradeCount, ISocketMessageChannel channel, SocketUser user)
{
Strawberry = 0,

Berry = 1,

Love = 2,

Star = 3,

Clover = 4,

Flower = 5,
if (MilestoneImages.TryGetValue(tradeCount, out string? imageUrl))
{
var embed = new EmbedBuilder()
.WithTitle($"🎉 Congratulations, {user.Username}! 🎉")
.WithDescription($"You've completed {tradeCount} trades!\n*Keep up the great work!*")
.WithColor(new DiscordColor(255, 215, 0)) // Gold color
.WithImageUrl(imageUrl)
.Build();

Ribbon = 6,
await channel.SendMessageAsync(embed: embed).ConfigureAwait(false);
}
}

public static async Task<(int R, int G, int B)> GetDominantColorAsync(string imagePath)
Expand Down
2 changes: 1 addition & 1 deletion SysBot.Pokemon/Helpers/TradeBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public static class TradeBot

public const string ConfigPath = "config.json";

public const string Version = "v4.2";
public const string Version = "v4.3";
}
}

0 comments on commit b3aaa0c

Please sign in to comment.