Beispiel #1
0
        public ClanKick(Client User, XmlDocument Packet)
            : base(User, Packet)
        {
            long num = long.Parse(this.Query.Attributes["profile_id"].InnerText);

            if (User.Player.Clan == null || User.Player.ClanPlayer.ClanRole != Clan.CLAN_ROLE.LEADER)
            {
                throw new StanzaException(User, Packet, 4);
            }
            Client client = ArrayList.OnlineUsers.Find((Predicate <Client>)(Attribute => Attribute.Player.UserID == long.Parse(this.Query.Attributes["profile_id"].InnerText)));

            if (client != null)
            {
                User.Player.Clan.RemovePlayer(client.Player);
                client.Player.Clan       = new Clan();
                client.Player.ClanPlayer = new ClanProperties();
                client.ShowMessage("@clans_you_was_kicked", false);
                client.Player.Save();
                if (client.Player.RoomPlayer.Room != null)
                {
                    if (client.Player.RoomPlayer.Room.Core.RoomType == (byte)4)
                    {
                        GameRoom_OnKicked gameRoomOnKicked = new GameRoom_OnKicked(client.Player.RoomPlayer.Room.Players.Users.ToList <Client>().Find((Predicate <Client>)(Attribute => Attribute.Player.UserID == client.Player.UserID)), GameRoom_OnKicked.Reason.KickedByUser);
                    }
                    else
                    {
                        client.Player.RoomPlayer.Room.Sync((Client)null);
                    }
                }
                ClanInfo clanInfo = new ClanInfo(client, (XmlDocument)null);
            }
            else
            {
                client        = new Client();
                client.Player = new Player()
                {
                    UserID = num
                };
                User.Player.Clan.RemovePlayer(client.Player);
                if (!client.Player.Load(true).Result)
                {
                    throw new StanzaException(User, Packet, 4);
                }
                client.Player.ClanPlayer = new ClanProperties();
                client.Player.Clan       = new Clan();
                client.Player.AddCustomMessage("@clans_you_was_kicked");
                client.Player.Save();
            }
            foreach (XElement xelement in User.Player.Clan.ClanMembers.Elements((XName)"clan_member_info").ToList <XElement>())
            {
                XElement clanMember = xelement;
                Client   User1      = ArrayList.OnlineUsers.Find((Predicate <Client>)(x => x.Player.UserID == long.Parse(clanMember.Attribute((XName)"profile_id").Value)));
                if (User1 != null)
                {
                    ClanInfo clanInfo = new ClanInfo(User1, (XmlDocument)null);
                }
            }
            this.Process();
        }
Beispiel #2
0
        public ClanLeave(Client User, XmlDocument Packet = null)
            : base(User, Packet)
        {
            if (User.Player.Clan == null)
            {
                throw new StanzaException(User, Packet, 2);
            }
            User.Player.Clan.RemovePlayer(User.Player);
            if (User.Player.Clan.ClanMembers.Elements((XName)"clan_member_info").Count <XElement>() == 0)
            {
                User.Player.Clan.DeleteClan();
            }
            else if (User.Player.ClanPlayer.ClanRole == Clan.CLAN_ROLE.LEADER)
            {
                XElement new_leader = User.Player.Clan.ClanMembers.Descendants((XName)"clan_member_info").ToList <XElement>().First <XElement>();
                Client   client     = ArrayList.OnlineUsers.Find((Predicate <Client>)(Attribute => Attribute.Player.UserID == Convert.ToInt64(new_leader.Attribute((XName)"profile_id").Value)));
                if (client != null)
                {
                    client.Player.Clan                = User.Player.Clan;
                    client.Player.Clan.LeaderName     = client.Player.Nickname;
                    client.Player.ClanPlayer.ClanRole = Clan.CLAN_ROLE.LEADER;
                    client.ShowMessage("@clans_you_are_promoted_to_master", false);
                    User.Player.Clan.UpdatePlayer(client.Player);
                }
                else
                {
                    Player player = new Player()
                    {
                        UserID = Convert.ToInt64(new_leader.Attribute((XName)"profile_id").Value)
                    };
                    player.Clan.ID = User.Player.Clan.ID;
                    if (player.Load(true).Result)
                    {
                        player.Clan = User.Player.Clan;
                        player.ClanPlayer.ClanRole = Clan.CLAN_ROLE.LEADER;
                        player.Clan.LeaderName     = player.Nickname;
                        player.Save();
                        User.Player.Clan.UpdatePlayer(player);
                    }
                }
            }
            foreach (XElement xelement in User.Player.Clan.ClanMembers.Elements((XName)"clan_member_info").ToList <XElement>())
            {
                XElement clanMember = xelement;
                Client   User1      = ArrayList.OnlineUsers.Find((Predicate <Client>)(x => x.Player.UserID == long.Parse(clanMember.Attribute((XName)"profile_id").Value)));
                if (User1 != null)
                {
                    ClanInfo clanInfo = new ClanInfo(User1, (XmlDocument)null);
                }
            }
            User.Player.ClanPlayer = new ClanProperties();
            User.Player.Clan       = new Clan();
            ClanInfo clanInfo1 = new ClanInfo(User, (XmlDocument)null);

            if (User.Player.RoomPlayer.Room != null)
            {
                if (User.Player.RoomPlayer.Room.Core.RoomType == (byte)4)
                {
                    GameRoom_OnKicked gameRoomOnKicked = new GameRoom_OnKicked(User.Player.RoomPlayer.Room.Players.Users.ToList <Client>().Find((Predicate <Client>)(Attribute => Attribute.Player.UserID == User.Player.UserID)), GameRoom_OnKicked.Reason.KickedByUser);
                }
                else
                {
                    User.Player.RoomPlayer.Room.Sync((Client)null);
                }
            }
            User.Player.Save();
            this.Process();
        }