Beispiel #1
0
        /// <summary>
        /// Removes a player from the raid group.
        /// </summary>
        /// <param name="player">Player to remove.</param>
        /// <returns>List of players invited by the player.</returns>
        public List <SocketGuildUser> RemovePlayer(SocketGuildUser player)
        {
            if (Attending.ContainsKey(player))
            {
                Attending.Remove(player);
            }
            else if (Ready.ContainsKey(player))
            {
                Ready.Remove(player);
            }
            else if (Invited.ContainsKey(player))
            {
                Invited.Remove(player);
                return(new List <SocketGuildUser>());
            }

            List <SocketGuildUser> playerInvited = new List <SocketGuildUser>();

            foreach (KeyValuePair <SocketGuildUser, SocketGuildUser> invite in Invited.Where(x => x.Value.Equals(player)))
            {
                playerInvited.Add(invite.Key);
            }

            foreach (SocketGuildUser invite in playerInvited)
            {
                Invited.Remove(invite);
            }

            return(playerInvited);
        }
Beispiel #2
0
        /// <summary>
        /// Removes all players with a party size of 0.
        /// </summary>
        /// <returns>Dictionary of all users invited by removed players.</returns>
        public Dictionary <SocketGuildUser, List <SocketGuildUser> > ClearEmptyPlayers()
        {
            Dictionary <SocketGuildUser, List <SocketGuildUser> > empty = new Dictionary <SocketGuildUser, List <SocketGuildUser> >();

            foreach (KeyValuePair <SocketGuildUser, int> user in Attending.Where(user => user.Value == 0))
            {
                empty.Add(user.Key, new List <SocketGuildUser>());
                empty[user.Key].AddRange(Invited.Where(x => x.Value.Equals(user.Key)).Select(invite => invite.Key));
            }
            foreach (KeyValuePair <SocketGuildUser, int> user in Ready.Where(user => user.Value == 0))
            {
                empty.Add(user.Key, new List <SocketGuildUser>());
                empty[user.Key].AddRange(Invited.Where(x => x.Value.Equals(user.Key)).Select(invite => invite.Key));
            }

            foreach (SocketGuildUser user in empty.Keys)
            {
                if (Attending.ContainsKey(user))
                {
                    Attending.Remove(user);
                }
                else if (Ready.ContainsKey(user))
                {
                    Ready.Remove(user);
                }
            }
            foreach (SocketGuildUser user in empty.SelectMany(group => group.Value))
            {
                Invited.Remove(user);
            }

            return(empty);
        }
Beispiel #3
0
 /// <summary>
 /// Marks a player as ready.
 /// </summary>
 /// <param name="player">Player to mark ready.</param>
 public bool MarkPlayerReady(SocketGuildUser player)
 {
     if (Attending.ContainsKey(player))
     {
         Ready.Add(player, Attending[player]);
         Attending.Remove(player);
         return(true);
     }
     return(false);
 }
Beispiel #4
0
        /// <summary>
        /// Attempts to split the raid group.
        /// </summary>
        /// <returns>A new raid group if the raid can be split, else null.</returns>
        public RaidGroup SplitGroup()
        {
            RaidGroup newGroup = new RaidGroup(PlayerLimit, InviteLimit);

            foreach (KeyValuePair <SocketGuildUser, int> player in Attending)
            {
                if ((newGroup.TotalPlayers() + player.Value) <= PlayerLimit / 2)
                {
                    newGroup.Attending.Add(player.Key, player.Value);

                    foreach (KeyValuePair <SocketGuildUser, SocketGuildUser> invite in Invited)
                    {
                        if (invite.Value.Equals(player.Key))
                        {
                            newGroup.InvitePlayer(invite.Key, invite.Value);
                        }
                    }
                }
            }

            if (newGroup.TotalPlayers() < PlayerLimit / 2)
            {
                foreach (KeyValuePair <SocketGuildUser, int> player in Ready)
                {
                    if (newGroup.TotalPlayers() < PlayerLimit / 2)
                    {
                        newGroup.Ready.Add(player.Key, player.Value);
                        foreach (KeyValuePair <SocketGuildUser, SocketGuildUser> invite in Invited)
                        {
                            if (invite.Value.Equals(player.Key))
                            {
                                newGroup.InvitePlayer(invite.Key, invite.Value);
                            }
                        }
                    }
                }
            }

            foreach (SocketGuildUser player in newGroup.Attending.Keys)
            {
                Attending.Remove(player);
            }
            foreach (SocketGuildUser player in newGroup.Ready.Keys)
            {
                Ready.Remove(player);
            }
            foreach (SocketGuildUser player in newGroup.Invited.Keys)
            {
                Invited.Remove(player);
            }
            return(newGroup);
        }
 public void SetAnglerAttendance(bool isAttending)
 {
     if (isAttending)
     {
         NotAttending.Remove(App.User);
         Attending.Add(App.User);
     }
     else
     {
         Attending.Remove(App.User);
         NotAttending.Add(App.User);
     }
 }