コード例 #1
0
ファイル: RaidGroup.cs プロジェクト: otooleam/Nona
        /// <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);
        }
コード例 #2
0
ファイル: RaidGroup.cs プロジェクト: otooleam/Nona
 /// <summary>
 /// Merges this group and another group.
 /// </summary>
 /// <param name="group">Group to merge with this group.</param>
 public void MergeGroup(RaidGroup group)
 {
     if (!group.Equals(this) &&
         group.TotalPlayers() != 0 && TotalPlayers() != 0 &&
         (group.TotalPlayers() + TotalPlayers()) <= PlayerLimit)
     {
         Attending = Attending.Union(group.Attending).ToDictionary(k => k.Key, v => v.Value);
         Ready     = Ready.Union(group.Ready).ToDictionary(k => k.Key, v => v.Value);
         Invited   = Invited.Union(group.Invited).ToDictionary(k => k.Key, v => v.Value);
         group.Attending.Clear();
         group.Ready.Clear();
         group.Invited.Clear();
     }
 }