[Activity] Add interstellar exploration formatter
This commit is contained in:
@@ -10,9 +10,11 @@ namespace Cocotte.Modules.Activities;
|
|||||||
public class ActivityFormatter
|
public class ActivityFormatter
|
||||||
{
|
{
|
||||||
private readonly ActivityOptions _options;
|
private readonly ActivityOptions _options;
|
||||||
|
private readonly InterstellarFormatter _interstellarFormatter;
|
||||||
|
|
||||||
public ActivityFormatter(IOptions<ActivityOptions> options)
|
public ActivityFormatter(IOptions<ActivityOptions> options, InterstellarFormatter interstellarFormatter)
|
||||||
{
|
{
|
||||||
|
_interstellarFormatter = interstellarFormatter;
|
||||||
_options = options.Value;
|
_options = options.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ public class ActivityFormatter
|
|||||||
ActivityName.VoidRift => "Failles du néant",
|
ActivityName.VoidRift => "Failles du néant",
|
||||||
ActivityName.OriginsOfWar => "Origine de la guerre",
|
ActivityName.OriginsOfWar => "Origine de la guerre",
|
||||||
ActivityName.JointOperation => "Opération conjointe",
|
ActivityName.JointOperation => "Opération conjointe",
|
||||||
ActivityName.InterstellarExploration => "Portes interstellaires",
|
ActivityName.InterstellarExploration => "Porte interstellaire",
|
||||||
ActivityName.BreakFromDestiny => "Échapper au destin (3v3)",
|
ActivityName.BreakFromDestiny => "Échapper au destin (3v3)",
|
||||||
ActivityName.CriticalAbyss => "Abîme critique (8v8)",
|
ActivityName.CriticalAbyss => "Abîme critique (8v8)",
|
||||||
ActivityName.Event => "Event",
|
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<ActivityPlayer> players)
|
public EmbedBuilder ActivityEmbed(Activity activity, IReadOnlyCollection<ActivityPlayer> players)
|
||||||
{
|
{
|
||||||
// Activity full
|
// Activity full
|
||||||
@@ -53,23 +60,34 @@ public class ActivityFormatter
|
|||||||
{
|
{
|
||||||
StagedActivity stagedActivity =>
|
StagedActivity stagedActivity =>
|
||||||
$"{FormatActivityName(activity.Name)} ({players.Count}/{activity.MaxPlayers}) - Étage {stagedActivity.Stage}",
|
$"{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)
|
string description = string.IsNullOrWhiteSpace(activity.Description)
|
||||||
? $"Rejoignez l'activité de {MentionUtils.MentionUser(activity.CreatorDiscordId)}"
|
? $"Rejoignez l'activité de {MentionUtils.MentionUser(activity.CreatorDiscordId)}"
|
||||||
: activity.Description;
|
: 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;
|
var color = activityFull ? Colors.CocotteOrange : Colors.CocotteBlue;
|
||||||
|
|
||||||
return new EmbedBuilder()
|
var builder = new EmbedBuilder()
|
||||||
.WithColor(color)
|
.WithColor(color)
|
||||||
.WithTitle(title)
|
.WithTitle(title)
|
||||||
.WithDescription(description)
|
.WithDescription(description)
|
||||||
.WithImageUrl(bannerUrl)
|
.WithImageUrl(bannerUrl)
|
||||||
.WithFields(playersField);
|
.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
|
private static string GetActivityCode(ActivityName activityName) => activityName switch
|
||||||
|
|||||||
30
Cocotte/Modules/Activities/InterstellarFormatter.cs
Normal file
30
Cocotte/Modules/Activities/InterstellarFormatter.cs
Normal file
@@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,9 +48,10 @@ IHost host = Host.CreateDefaultBuilder(args)
|
|||||||
services.AddSingleton<IPlayerInfosRepository, MemoryPlayerInfosRepository>();
|
services.AddSingleton<IPlayerInfosRepository, MemoryPlayerInfosRepository>();
|
||||||
services.AddSingleton<RolesOptions>();
|
services.AddSingleton<RolesOptions>();
|
||||||
|
|
||||||
// Groups
|
// Activities
|
||||||
services.AddTransient<ActivityFormatter>();
|
services.AddTransient<ActivityFormatter>();
|
||||||
services.AddSingleton<ActivityHelper>();
|
services.AddTransient<InterstellarFormatter>();
|
||||||
|
services.AddTransient<ActivityHelper>();
|
||||||
|
|
||||||
// Raids
|
// Raids
|
||||||
services.AddTransient<RaidFormatter>();
|
services.AddTransient<RaidFormatter>();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public class CocotteDbContext : DbContext
|
|||||||
{
|
{
|
||||||
public DbSet<Activity> Activities => Set<Activity>();
|
public DbSet<Activity> Activities => Set<Activity>();
|
||||||
public DbSet<StagedActivity> StagedActivities => Set<StagedActivity>();
|
public DbSet<StagedActivity> StagedActivities => Set<StagedActivity>();
|
||||||
|
public DbSet<InterstellarActivity> InterstellarActivities => Set<InterstellarActivity>();
|
||||||
|
|
||||||
public DbSet<ActivityPlayer> ActivityPlayers => Set<ActivityPlayer>();
|
public DbSet<ActivityPlayer> ActivityPlayers => Set<ActivityPlayer>();
|
||||||
public DbSet<ActivityRolePlayer> ActivityRolePlayers => Set<ActivityRolePlayer>();
|
public DbSet<ActivityRolePlayer> ActivityRolePlayers => Set<ActivityRolePlayer>();
|
||||||
|
|||||||
Reference in New Issue
Block a user