Exemplo n.º 1
0
        /// <summary>
        /// Adds a new guild member
        /// Calls GuildMgr.OnJoinGuild
        /// </summary>
        /// <param name="chr">character to add</param>
        /// <param name="update">if true, sends event to the guild</param>
        /// <returns>GuildMember of new member</returns>
        public GuildMember AddMember(CharacterRecord chr)
        {
            GuildMember guildMember;

            lock (this)
            {
                if (this.Members.TryGetValue(chr.EntityLowId, out guildMember))
                {
                    return(guildMember);
                }
                guildMember = new GuildMember(chr, this, this.m_ranks.Last <GuildRank>());
                this.Members.Add(guildMember.Id, guildMember);
                guildMember.Create();
            }

            Singleton <GuildMgr> .Instance.RegisterGuildMember(guildMember);

            this.EventLog.AddJoinEvent(guildMember.Id);
            GuildHandler.SendEventToGuild(this, GuildEvents.JOINED, guildMember);
            Character characterByAccId = World.GetCharacterByAccId((uint)chr.AccountId);

            foreach (GuildSkill activeSkill in this.ActiveSkills)
            {
                activeSkill.ApplyToCharacter(characterByAccId);
            }
            characterByAccId.GuildMember = guildMember;
            Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.Joined, guildMember);
            Asda2GuildHandler.SendGuildMembersInfoResponse(characterByAccId.Client, this);
            this.AddHistoryMessage(Asda2GuildHistoryType.Joined, 0, chr.Name, DateTime.Now.ToLongTimeString());
            return(guildMember);
        }
Exemplo n.º 2
0
        private void ImpeachmentCallback()
        {
            float num = (float)((double)this._acceptedMembers.Count / (double)(this.MemberCount - 2) * 100.0);

            this.SendSystemMsg(string.Format("{0}% members accepted new leader.", (object)num));
            if ((double)num > 70.0)
            {
                this.Leader.Asda2RankId = (byte)3;
                Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.RankChanged, this.Leader);
                this.Leader             = this._newLeader;
                this.Leader.Asda2RankId = (byte)4;
                Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.ApointedAsNewGuildLeader,
                                                                this.Leader);
                Asda2GuildHandler.SendImpeachmentResultResponse(this, Asda2GuildHandler.ImpeachmentResult.Success);
                Asda2GuildHandler.SendUpdateGuildInfoResponse(this, GuildInfoMode.Silent, (Character)null);
                this.AddHistoryMessage(Asda2GuildHistoryType.ApointedAsGuildLeaderThorowVote, 0, this.Leader.Name,
                                       DateTime.Now.ToLongTimeString());
            }
            else
            {
                Asda2GuildHandler.SendImpeachmentResultResponse(this, Asda2GuildHandler.ImpeachmentResult.Failed);
            }

            this._acceptedMembers.Clear();
            this._newLeader            = (GuildMember)null;
            this._impeachmentStartTime = DateTime.MinValue;
        }
Exemplo n.º 3
0
        private void ImpeachmentCallback()
        {
            float num = (float)(_acceptedMembers.Count / (double)(MemberCount - 2) * 100.0);

            SendSystemMsg(string.Format("{0}% members accepted new leader.", num));
            if (num > 70.0)
            {
                Leader.Asda2RankId = 3;
                Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.RankChanged, Leader);
                Leader             = _newLeader;
                Leader.Asda2RankId = 4;
                Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.ApointedAsNewGuildLeader,
                                                                Leader);
                Asda2GuildHandler.SendImpeachmentResultResponse(this, Asda2GuildHandler.ImpeachmentResult.Success);
                Asda2GuildHandler.SendUpdateGuildInfoResponse(this, GuildInfoMode.Silent, null);
                AddHistoryMessage(Asda2GuildHistoryType.ApointedAsGuildLeaderThorowVote, 0, Leader.Name,
                                  DateTime.Now.ToLongTimeString());
            }
            else
            {
                Asda2GuildHandler.SendImpeachmentResultResponse(this, Asda2GuildHandler.ImpeachmentResult.Failed);
            }

            _acceptedMembers.Clear();
            _newLeader            = null;
            _impeachmentStartTime = DateTime.MinValue;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a new guild member
        /// Calls GuildMgr.OnJoinGuild
        /// </summary>
        /// <param name="chr">character to add</param>
        /// <param name="update">if true, sends event to the guild</param>
        /// <returns>GuildMember of new member</returns>
        public GuildMember AddMember(CharacterRecord chr)
        {
            GuildMember newMember;

            /*using (syncRoot.Enter())
             * {*/
            lock (this)
            {
                if (Members.TryGetValue(chr.EntityLowId, out newMember))
                {
                    return(newMember);
                }
                newMember = new GuildMember(chr, this, m_ranks.Last());
                Members.Add(newMember.Id, newMember);
                newMember.Create();
            }
            /*}*/

            GuildMgr.Instance.RegisterGuildMember(newMember);

            EventLog.AddJoinEvent(newMember.Id);
            GuildHandler.SendEventToGuild(this, GuildEvents.JOINED, newMember);
            var character = World.GetCharacterByAccId((uint)chr.AccountId);

            foreach (var activeSkill in ActiveSkills)
            {
                activeSkill.ApplyToCharacter(character);
            }
            character.GuildMember = newMember;
            Asda2GuildHandler.SendGuildNotificationResponse(this, GuildNotificationType.Joined, newMember);
            Asda2GuildHandler.SendGuildMembersInfoResponse(character.Client, this);
            AddHistoryMessage(Asda2GuildHistoryType.Joined, 0, chr.Name, DateTime.Now.ToLongTimeString());
            return(newMember);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Removes GuildMember from the guild
        /// </summary>
        /// <param name="member">member to remove</param>
        /// <param name="update">if false, changes to the guild will not be promoted anymore (used when the Guild is being disbanded)</param>
        public bool RemoveMember(GuildMember member, bool update, bool kicked = false)
        {
            AddHistoryMessage(kicked ? Asda2GuildHistoryType.Kicked : Asda2GuildHistoryType.Left, 0, member.Name, DateTime.Now.ToLongTimeString());
            if (member.Character != null)
            {
                foreach (var activeSkill in ActiveSkills)
                {
                    activeSkill.RemoveFromCharacter(member.Character);
                }
            }
            if (update)
            {
                EventLog.AddLeaveEvent(member.Id);
                Asda2GuildHandler.SendGuildNotificationResponse(this, kicked ? GuildNotificationType.Kicked : GuildNotificationType.Left, member);
                //GuildHandler.SendEventToGuild(this, GuildEvents.LEFT, member);
            }
            OnRemoveMember(member);

            if (update && member == m_leader)
            {
                Disband();
                return(true);
            }

            /*using (syncRoot.Enter())
             * {*/
            lock (this)
            {
                if (!Members.Remove(member.Id))
                {
                    return(false);
                }
            }
            //}



            RealmServer.IOQueue.AddMessage(() =>
            {
                member.Delete();
                if (update)
                {
                    Update();
                }
            });
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>Removes GuildMember from the guild</summary>
        /// <param name="member">member to remove</param>
        /// <param name="update">if false, changes to the guild will not be promoted anymore (used when the Guild is being disbanded)</param>
        public bool RemoveMember(GuildMember member, bool update, bool kicked = false)
        {
            this.AddHistoryMessage(kicked ? Asda2GuildHistoryType.Kicked : Asda2GuildHistoryType.Left, 0, member.Name,
                                   DateTime.Now.ToLongTimeString());
            if (member.Character != null)
            {
                foreach (GuildSkill activeSkill in this.ActiveSkills)
                {
                    activeSkill.RemoveFromCharacter(member.Character);
                }
            }

            if (update)
            {
                this.EventLog.AddLeaveEvent(member.Id);
                Asda2GuildHandler.SendGuildNotificationResponse(this,
                                                                kicked ? GuildNotificationType.Kicked : GuildNotificationType.Left, member);
            }

            this.OnRemoveMember(member);
            if (update && member == this.m_leader)
            {
                this.Disband();
                return(true);
            }

            lock (this)
            {
                if (!this.Members.Remove(member.Id))
                {
                    return(false);
                }
            }

            ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
            {
                member.Delete();
                if (!update)
                {
                    return;
                }
                this.Update();
            }));

            return(true);
        }