Compare commits
3 Commits
d000e6a299
...
224fe4cb25
| Author | SHA1 | Date | |
|---|---|---|---|
| 224fe4cb25 | |||
| ca3e951d9a | |||
| 37a4da26d7 |
@@ -9,7 +9,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AppAny.Quartz.EntityFrameworkCore.Migrations.SQLite" Version="0.4.0" />
|
||||
<PackageReference Include="Discord.Net" Version="3.9.0" />
|
||||
<PackageReference Include="Discord.Net" Version="3.10.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ActivityFormatter
|
||||
ActivityName.InterstellarExploration => "Porte interstellaire",
|
||||
ActivityName.BreakFromDestiny => "Échapper au destin (3v3)",
|
||||
ActivityName.CriticalAbyss => "Abîme critique (8v8)",
|
||||
ActivityName.Event => "Évènement",
|
||||
ActivityName.Minigame => "Évènement",
|
||||
ActivityName.Fishing => "Pêche",
|
||||
ActivityName.MirroriaRace => "Course Mirroria",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(activityName), activityName, null)
|
||||
@@ -77,16 +77,19 @@ public class ActivityFormatter
|
||||
|
||||
fields.Add(playersField);
|
||||
|
||||
string countTitlePart = activity.MaxPlayers == ActivityHelper.UnlimitedPlayers
|
||||
? ""
|
||||
: $"({participants.Length}/{activity.MaxPlayers})";
|
||||
var title = activity switch
|
||||
{
|
||||
StagedActivity stagedActivity =>
|
||||
$"{FormatActivityName(activity.Name)} ({participants.Length}/{activity.MaxPlayers}) - Étage {stagedActivity.Stage}",
|
||||
$"{FormatActivityName(activity.Name)} {countTitlePart} - Étage {stagedActivity.Stage}",
|
||||
InterstellarActivity interstellar =>
|
||||
$"{FormatActivityName(activity.Name)} {_interstellarFormatter.FormatInterstellarColor(interstellar.Color)} ({players.Count}/{activity.MaxPlayers})",
|
||||
$"{FormatActivityName(activity.Name)} {_interstellarFormatter.FormatInterstellarColor(interstellar.Color)} {countTitlePart}",
|
||||
OrganizedActivity =>
|
||||
$"{(ActivityHelper.IsEventActivity(activity.Type) ? "Organisation d'évènement" : $"Proposition d'aide - {FormatActivityName(activity.Name)}")} ({participants.Length}/{activity.MaxPlayers})",
|
||||
$"{(ActivityHelper.IsEventActivity(activity.Type) ? "Organisation d'évènement" : $"Proposition d'aide - {FormatActivityName(activity.Name)}")} {countTitlePart}",
|
||||
_ =>
|
||||
$"{FormatActivityName(activity.Name)} ({participants.Length}/{activity.MaxPlayers})"
|
||||
$"{FormatActivityName(activity.Name)} {countTitlePart}"
|
||||
};
|
||||
|
||||
// Build description
|
||||
@@ -156,7 +159,7 @@ public class ActivityFormatter
|
||||
ActivityName.BreakFromDestiny => "BR",
|
||||
ActivityName.CriticalAbyss => "CA",
|
||||
ActivityName.Fishing => "FI",
|
||||
ActivityName.Event => "EV",
|
||||
ActivityName.Minigame => "EV",
|
||||
ActivityName.MirroriaRace => "MR",
|
||||
_ => "NA"
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Cocotte.Modules.Activities;
|
||||
|
||||
public class ActivityHelper
|
||||
{
|
||||
private const uint UnlimitedPlayers = uint.MaxValue;
|
||||
public const uint UnlimitedPlayers = uint.MaxValue;
|
||||
|
||||
private readonly ActivityOptions _options;
|
||||
private readonly ActivitiesRepository _activitiesRepository;
|
||||
@@ -57,32 +57,31 @@ public class ActivityHelper
|
||||
|
||||
ActivityName.BreakFromDestiny => ActivityType.Pvp3Players,
|
||||
|
||||
ActivityName.Event or
|
||||
ActivityName.Fishing => ActivityType.Event8Players,
|
||||
ActivityName.Minigame => ActivityType.Other8Players,
|
||||
|
||||
ActivityName.MirroriaRace => ActivityType.Event4Players,
|
||||
ActivityName.MirroriaRace => ActivityType.Other4Players,
|
||||
|
||||
_ => ActivityType.Other
|
||||
_ => ActivityType.OtherUnlimitedPlayers
|
||||
};
|
||||
|
||||
public static uint ActivityTypeToMaxPlayers(ActivityType activityType) => activityType switch
|
||||
{
|
||||
ActivityType.Pve4Players or
|
||||
ActivityType.Event4Players => 4,
|
||||
ActivityType.Other4Players => 4,
|
||||
|
||||
ActivityType.Pve8Players or
|
||||
ActivityType.Pvp8Players or
|
||||
ActivityType.Event8Players => 8,
|
||||
ActivityType.Other8Players => 8,
|
||||
|
||||
ActivityType.Pvp3Players => 3,
|
||||
|
||||
ActivityType.Other => UnlimitedPlayers,
|
||||
ActivityType.OtherUnlimitedPlayers => UnlimitedPlayers,
|
||||
|
||||
_ => 0
|
||||
};
|
||||
|
||||
public static bool IsEventActivity(ActivityType activityType) =>
|
||||
activityType is ActivityType.Event8Players or ActivityType.Event4Players or ActivityType.Other;
|
||||
activityType is ActivityType.Other8Players or ActivityType.Other4Players or ActivityType.OtherUnlimitedPlayers;
|
||||
|
||||
public bool IsOrganizer(OrganizedActivity organizedActivity, SocketGuildUser user)
|
||||
{
|
||||
|
||||
@@ -142,12 +142,12 @@ public partial class ActivityModule : InteractionModuleBase<SocketInteractionCon
|
||||
|
||||
[SlashCommand("evenement", "Créer un groupe pour les évènements")]
|
||||
[Alias("event")]
|
||||
public async Task ActivityEvent(
|
||||
public async Task ActivityMinigame(
|
||||
[Summary("joueurs", "Nombre de joueurs maximum pour cette activité")] [MinValue(2), MaxValue(16)]
|
||||
uint maxPlayers = 8, [Summary("heure", "Heure à laquelle l'activité est prévue")] string? timeInput = null,
|
||||
[Summary("description", "Message accompagnant la demande de groupe")] string description = "")
|
||||
{
|
||||
await CreateActivity(ActivityName.Event, timeInput, description, areRolesEnabled: false,
|
||||
await CreateActivity(ActivityName.Minigame, timeInput, description, areRolesEnabled: false,
|
||||
maxPlayers: maxPlayers);
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ public partial class ActivityModule : InteractionModuleBase<SocketInteractionCon
|
||||
}
|
||||
|
||||
// Check if user has permission to delete this activity
|
||||
if (User.Id != activity.CreatorUserId && !User.GetPermissions((IGuildChannel) Context.Channel).ManageMessages)
|
||||
if (User.Id != activity.CreatorUserId && Context.User.Id != (await Context.Client.GetApplicationInfoAsync()).Owner.Id)
|
||||
{
|
||||
await RespondAsync(
|
||||
ephemeral: true,
|
||||
|
||||
@@ -189,6 +189,56 @@ public partial class ActivityModule
|
||||
await RespondWithModalAsync<ActivityDescriptionModal>("activity description_modal");
|
||||
}
|
||||
|
||||
[SlashCommand("etage", "Changer l'étage de l'activité pour l'abîme du néant et l'origine de la guerre")]
|
||||
public async Task ThreadChangeStage([Summary("étage", "Nouvel étage, de 1 à 6 en abîme du néant, et de 1 à 25 en origine de la guerre")] [MinValue(1), MaxValue(25)] uint stage)
|
||||
{
|
||||
// Get activity linked to this thread
|
||||
var activity = _activitiesRepository.FindActivityByThreadId(Context.Channel.Id);
|
||||
|
||||
if (!await CheckCommandInThread(activity, checkCreator: true) || activity is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activity is not StagedActivity stagedActivity)
|
||||
{
|
||||
await RespondAsync(
|
||||
ephemeral: true,
|
||||
embed: EmbedUtils.ErrorEmbed("Cette commande n'est utilisable que pour l'abîme du néant et l'origine de la guerre").Build()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if stage is valid
|
||||
var stageValid = (activity.Name, stage) switch
|
||||
{
|
||||
(ActivityName.Abyss, >= 1 and <= 6) => true,
|
||||
(ActivityName.OriginsOfWar, >= 1 and <= 25) => true,
|
||||
_ => false
|
||||
};
|
||||
|
||||
if (!stageValid)
|
||||
{
|
||||
await RespondAsync(
|
||||
ephemeral: true,
|
||||
embed: EmbedUtils.ErrorEmbed("Etage invalide").Build()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
stagedActivity.Stage = stage;
|
||||
await _activitiesRepository.SaveChanges();
|
||||
|
||||
await UpdateActivityEmbed(activity, ActivityUpdateReason.Update);
|
||||
|
||||
await RespondAsync(
|
||||
ephemeral: true,
|
||||
embed: EmbedUtils.InfoEmbed($"L'activité est maintenant bien définie à **l'étage {stage}**").Build()
|
||||
);
|
||||
}
|
||||
|
||||
[ModalInteraction("activity description_modal", ignoreGroupNames: true)]
|
||||
public async Task ActivityDescriptionSubmit(ActivityDescriptionModal descriptionModal)
|
||||
{
|
||||
@@ -246,4 +296,4 @@ public class ActivityDescriptionModal : IModal
|
||||
[InputLabel("Description")]
|
||||
[ModalTextInput("activity_description", TextInputStyle.Paragraph)]
|
||||
public required string Description { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public enum ActivityName
|
||||
BreakFromDestiny,
|
||||
CriticalAbyss,
|
||||
Fishing,
|
||||
Event,
|
||||
MirroriaRace
|
||||
Minigame,
|
||||
MirroriaRace,
|
||||
Event
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public enum ActivityType
|
||||
Pve8Players,
|
||||
Pvp8Players,
|
||||
Pvp3Players,
|
||||
Event8Players,
|
||||
Event4Players,
|
||||
Other
|
||||
Other8Players,
|
||||
Other4Players,
|
||||
OtherUnlimitedPlayers
|
||||
}
|
||||
Reference in New Issue
Block a user