Exemplo n.º 1
0
        public async Task PostRaid(IMessageChannel channel, EpgpRaid raidObject)
        {
            if (!(channel is IGuildChannel guildChannel))
            {
                throw new ArgumentException("Raids can only be posted to server text channels");
            }

            var leader = await guildChannel.GetUserAsync(raidObject.RaidLeader);

            IMessageChannel leaderChannel;

            if (leader == null)
            {
                leaderChannel = channel;
            }
            else
            {
                leaderChannel = await leader.GetOrCreateDMChannelAsync();
            }
            var domainRaid = new Raid()
            {
                Id = Guid.NewGuid(), StartTime = raidObject.StartTime, EndTime = raidObject.StartTime + raidObject.Duration, Name = raidObject.Name
            };

            _dbContext.Raids.Add(domainRaid);
            _dbContext.SaveChanges();
            raidObject.RaidId = domainRaid.Id;
            var guildId = guildChannel.GuildId;
            var message = await channel.SendMessageAsync("", false, CreateEmbed(raidObject, guildChannel.GuildId), null);

            var raidData = new RaidData(message, raidObject, guildChannel.GuildId);

            raidData.LeaderChannel   = leaderChannel;
            _client.ReactionAdded   += ReactionAdded;
            _client.ReactionRemoved += ReactionRemoved;
            _aliasEventAlerter.ActiveAliasChanged += ActiveAliasChanged;
            await message.AddReactionAsync(Emote.Parse(_emoteService.GetFullyQualifiedName(guildId, EmbedConstants.CasterEmoteName)));

            await message.AddReactionAsync(Emote.Parse(_emoteService.GetFullyQualifiedName(guildId, EmbedConstants.MeleeEmoteName)));

            await message.AddReactionAsync(Emote.Parse(_emoteService.GetFullyQualifiedName(guildId, EmbedConstants.RangedEmoteName)));

            await message.AddReactionAsync(Emote.Parse(_emoteService.GetFullyQualifiedName(guildId, EmbedConstants.TankEmoteName)));

            await message.AddReactionAsync(Emote.Parse(_emoteService.GetFullyQualifiedName(guildId, EmbedConstants.HealerEmoteName)));

            await message.AddReactionAsync(new Emoji("❌"));

            using (var raidMonitor = await AddRaid(raidData))
            {
                await raidMonitor.Run();
            }
            await RemoveRaid(raidData);
        }
Exemplo n.º 2
0
        private string BuildUserList(EpgpRaid raid, Role userRole, ulong guildId)
        {
            var participants = raid.Participants.Values;

            if (participants.All(p => p.Role != userRole))
            {
                return("None");
            }
            var returnSb = new StringBuilder();

            foreach (var participant in participants.Where(p => p.Role == userRole))
            {
                foreach (var epgpAlias in participant.Aliases)
                {
                    var fullyQualifiedEmoteName =
                        _emoteService.GetFullyQualifiedName(guildId, epgpAlias.Class.GetEmoteName());
                    returnSb.AppendLine($"{fullyQualifiedEmoteName} {AliasString(epgpAlias)}");
                }
            }

            return(returnSb.ToString());
        }
Exemplo n.º 3
0
        private Embed CreateEmbed(EpgpRaid raidData, ulong guildId)
        {
            if (guildId == 0)
            {
                throw new InvalidOperationException("Raid embed must be within a server channel");
            }
            var casterEmote        = _emoteService.GetFullyQualifiedName(guildId, EmbedConstants.CasterEmoteName);
            var meleeEmote         = _emoteService.GetFullyQualifiedName(guildId, EmbedConstants.MeleeEmoteName);
            var rangedEmote        = _emoteService.GetFullyQualifiedName(guildId, EmbedConstants.RangedEmoteName);
            var tankEmote          = _emoteService.GetFullyQualifiedName(guildId, EmbedConstants.TankEmoteName);
            var healerEmote        = _emoteService.GetFullyQualifiedName(guildId, EmbedConstants.HealerEmoteName);
            var nexusCrystalString = raidData.NexusCrystalValue.ToGoldString();
            var embed = new EmbedBuilder();

            embed
            .WithTitle("__Raid Event__")
            .AddField(":busts_in_silhouette: Joined", $"{raidData.Joined}/{raidData.Capacity}", true)
            .AddField(":crown: Raid Leader", $"<@{raidData.RaidLeader}>", true)
            .AddField(":hourglass: Duration", $"{raidData.Duration.Hours} hrs {raidData.Duration.Minutes} mins", true)
            .AddField(":coffee: Start bonus", $"{raidData.StartBonus} EP", true)
            .AddField(":clock1: Time bonus", $"{raidData.TimeBonus} EP per {raidData.TimeBonusDuration.Minutes} mins", true)
            .AddField(":beers: End bonus", $"{raidData.EndBonus} EP", true)

            .AddField("__Roster__", EmbedConstants.EmptySpace)

            .AddField($"{casterEmote} Casters ({GetParticipantCount(raidData.Participants.Values, Role.Caster)})", BuildUserList(raidData, Role.Caster, guildId), true)
            .AddField($"{meleeEmote} Melee ({GetParticipantCount(raidData.Participants.Values, Role.Melee)})", BuildUserList(raidData, Role.Melee, guildId), true)
            .AddField($"{rangedEmote} Ranged ({GetParticipantCount(raidData.Participants.Values, Role.Ranged)})", BuildUserList(raidData, Role.Ranged, guildId), true)
            .AddField($"{tankEmote} Tanks ({GetParticipantCount(raidData.Participants.Values, Role.Tank)})", BuildUserList(raidData, Role.Tank, guildId), true)
            .AddField($"{healerEmote} Healers ({GetParticipantCount(raidData.Participants.Values, Role.Healer)})", BuildUserList(raidData, Role.Healer, guildId), true)
            .AddField(EmbedConstants.EmptySpace, EmbedConstants.EmptySpace, true)

            .AddField("__Notes__",
                      $"💎 Nexus Crystal Price: {nexusCrystalString}\n" +
                      $"🎲 Rolled Item GP Cost: {_epgpCalculator.ConvertGpFromGold(raidData.NexusCrystalValue) * 2} GP")
            .WithFooter((ftr) => ftr.WithText("\u200b\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tStarts"))
            .WithTimestamp(raidData.StartTime);
            return(embed.Build());
        }
Exemplo n.º 4
0
 public RaidData(IUserMessage message, EpgpRaid raidObject, ulong serverId)
 {
     Message    = message;
     RaidObject = raidObject;
     ServerId   = serverId;
 }