Beispiel #1
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 #2
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 #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>
 /// Adds a player to the raid group.
 /// If the user is already in the raid group, their party size is updated.
 /// Will update attend size or remote size, not both
 /// </summary>
 /// <param name="player">Player to add.</param>
 /// <param name="attendSize">Number of accounts attending in person.</param>
 /// <param name="remoteSize">Number of accounts attending via remote.</param>
 public void AddPlayer(SocketGuildUser player, int attendSize, int remoteSize)
 {
     if (!Invited.ContainsKey(player))
     {
         if (Attending.ContainsKey(player))
         {
             if (remoteSize == Global.NO_ADD_VALUE)
             {
                 Attending[player] = SetValue(attendSize, GetRemote(Attending[player]));
             }
             else if (attendSize == Global.NO_ADD_VALUE)
             {
                 Attending[player] = SetValue(GetAttending(Attending[player]), remoteSize);
             }
         }
         else if (Ready.ContainsKey(player))
         {
             if (remoteSize == Global.NO_ADD_VALUE)
             {
                 Ready[player] = SetValue(attendSize, GetRemote(Ready[player]));
             }
             else if (attendSize == Global.NO_ADD_VALUE)
             {
                 Ready[player] = SetValue(GetAttending(Ready[player]), remoteSize);
             }
         }
         else
         {
             int attend    = (attendSize == Global.NO_ADD_VALUE) ? 0 : attendSize;
             int remote    = (remoteSize == Global.NO_ADD_VALUE) ? 0 : remoteSize;
             int partySize = (remote << Global.REMOTE_SHIFT) | attend;
             if (partySize != 0)
             {
                 Attending.Add(player, partySize);
             }
         }
     }
 }
Beispiel #5
0
 /// <summary>
 /// Gets all invited players where the inviter is attending.
 /// </summary>
 /// <returns>Immutable dictionary of invited players.</returns>
 public ImmutableDictionary <SocketGuildUser, SocketGuildUser> GetReadonlyInvitedAttending()
 {
     return(Invited.Where(invite => Attending.ContainsKey(invite.Value)).ToImmutableDictionary(k => k.Key, v => v.Value));
 }
Beispiel #6
0
 /// <summary>
 /// Checks if the raid group has a desired user.
 /// </summary>
 /// <param name="player">Player to check.</param>
 /// <param name="checkInvite">If invited players should be checked.</param>
 /// <returns>True if the player is in the raid group, otherwise false.</returns>
 public bool HasPlayer(SocketGuildUser player, bool checkInvite = true)
 {
     return(Attending.ContainsKey(player) || Ready.ContainsKey(player) || (checkInvite && Invited.ContainsKey(player)));
 }