diff --git a/Cocotte/Modules/Activities/ActivityFormatter.cs b/Cocotte/Modules/Activities/ActivityFormatter.cs index d860535..a4c1290 100644 --- a/Cocotte/Modules/Activities/ActivityFormatter.cs +++ b/Cocotte/Modules/Activities/ActivityFormatter.cs @@ -10,9 +10,11 @@ namespace Cocotte.Modules.Activities; public class ActivityFormatter { private readonly ActivityOptions _options; + private readonly InterstellarFormatter _interstellarFormatter; - public ActivityFormatter(IOptions options) + public ActivityFormatter(IOptions options, InterstellarFormatter interstellarFormatter) { + _interstellarFormatter = interstellarFormatter; _options = options.Value; } @@ -26,7 +28,7 @@ public class ActivityFormatter ActivityName.VoidRift => "Failles du néant", ActivityName.OriginsOfWar => "Origine de la guerre", ActivityName.JointOperation => "Opération conjointe", - ActivityName.InterstellarExploration => "Portes interstellaires", + ActivityName.InterstellarExploration => "Porte interstellaire", ActivityName.BreakFromDestiny => "Échapper au destin (3v3)", ActivityName.CriticalAbyss => "Abîme critique (8v8)", ActivityName.Event => "Event", @@ -36,6 +38,11 @@ public class ActivityFormatter }; } + public static string GetActivityBanner(ActivityName activityName) + { + return $"https://sage.cdn.ilysix.fr/assets/Cocotte/banner/{GetActivityCode(activityName)}.webp"; + } + public EmbedBuilder ActivityEmbed(Activity activity, IReadOnlyCollection players) { // Activity full @@ -53,23 +60,34 @@ public class ActivityFormatter { StagedActivity stagedActivity => $"{FormatActivityName(activity.Name)} ({players.Count}/{activity.MaxPlayers}) - Étage {stagedActivity.Stage}", - _ => $"{FormatActivityName(activity.Name)} ({players.Count}/{activity.MaxPlayers})" + InterstellarActivity interstellar => + $"{FormatActivityName(activity.Name)} {_interstellarFormatter.FormatInterstellarColor(interstellar.Color)} ({players.Count}/{activity.MaxPlayers})", + _ => + $"{FormatActivityName(activity.Name)} ({players.Count}/{activity.MaxPlayers})" }; string description = string.IsNullOrWhiteSpace(activity.Description) ? $"Rejoignez l'activité de {MentionUtils.MentionUser(activity.CreatorDiscordId)}" : activity.Description; - string bannerUrl = $"https://sage.cdn.ilysix.fr/assets/Cocotte/banner/{GetActivityCode(activity.Name)}.webp"; + string bannerUrl = GetActivityBanner(activity.Name); var color = activityFull ? Colors.CocotteOrange : Colors.CocotteBlue; - return new EmbedBuilder() + var builder = new EmbedBuilder() .WithColor(color) .WithTitle(title) .WithDescription(description) .WithImageUrl(bannerUrl) .WithFields(playersField); + + // Add material for interstellar exploration + if (activity is InterstellarActivity interstellarActivity) + { + builder.WithThumbnailUrl(_interstellarFormatter.GetColorIcon(interstellarActivity.Color)); + } + + return builder; } private static string GetActivityCode(ActivityName activityName) => activityName switch diff --git a/Cocotte/Modules/Activities/InterstellarFormatter.cs b/Cocotte/Modules/Activities/InterstellarFormatter.cs new file mode 100644 index 0000000..f7ddadb --- /dev/null +++ b/Cocotte/Modules/Activities/InterstellarFormatter.cs @@ -0,0 +1,30 @@ +using Cocotte.Modules.Activities.Models; + +namespace Cocotte.Modules.Activities; + +public class InterstellarFormatter +{ + public string FormatInterstellarColor(InterstellarColor color) => color switch + { + InterstellarColor.Black => "noire", + InterstellarColor.Blue => "bleue", + InterstellarColor.Green => "verte", + InterstellarColor.Red => "rouge", + _ => "N/A" + }; + + public string InterstellarColorEmote(InterstellarColor color) => color switch + { + InterstellarColor.Black => "<:gate_black:1088385899022258248>", + InterstellarColor.Blue => "<:gate_blue:1088385901324935200>", + InterstellarColor.Green => "<:gate_green:1088385902792945664>", + InterstellarColor.Red => "<:gate_red:1088385905405984859>", + _ => "" + }; + + public string GetColorIcon(InterstellarColor color) + { + return + $"https://sage.cdn.ilysix.fr/assets/Cocotte/icons/tof/gate/gate_{color.ToString().ToLowerInvariant()}.webp"; + } +} \ No newline at end of file diff --git a/Cocotte/Program.cs b/Cocotte/Program.cs index fdc6613..00604b7 100644 --- a/Cocotte/Program.cs +++ b/Cocotte/Program.cs @@ -48,9 +48,10 @@ IHost host = Host.CreateDefaultBuilder(args) services.AddSingleton(); services.AddSingleton(); - // Groups + // Activities services.AddTransient(); - services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); // Raids services.AddTransient(); diff --git a/Cocotte/Services/CocotteDbContext.cs b/Cocotte/Services/CocotteDbContext.cs index 7f98625..e2d2124 100644 --- a/Cocotte/Services/CocotteDbContext.cs +++ b/Cocotte/Services/CocotteDbContext.cs @@ -7,6 +7,7 @@ public class CocotteDbContext : DbContext { public DbSet Activities => Set(); public DbSet StagedActivities => Set(); + public DbSet InterstellarActivities => Set(); public DbSet ActivityPlayers => Set(); public DbSet ActivityRolePlayers => Set();