public void ChangeParameters(GuildMemberInstance source, uint rights, ushort rank, sbyte xpPercent)
        {
            if (source.IsBoss && rank == 1)
            {
                this.Guild.SetBoss(this);
            }
            else if (source == this || !this.IsBoss)
            {
                if (source.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_RANKS) && rank >= 0 && rank <= 35)
                {
                    this.Record.Rank = rank;
                }
                if (source.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_RIGHTS))
                {
                    this.Record.Rights = rights;
                }
            }
            if (source.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_XP_CONTRIBUTION) || (source == this && source.HasRight(GuildRightsBitEnum.GUILD_RIGHT_MANAGE_MY_XP_CONTRIBUTION)))
            {
                this.Record.experienceGivenPercent = (sbyte)((xpPercent < 90) ? xpPercent : 90);
            }
            this.Guild.Record.UpdateElement();
            this.Update();

            if (this.Connected)
            {
                this.Character.SendGuildMembership();
            }
        }
        public void Leave(GuildMemberInstance member, bool kicked)
        {
            if (member.IsBoss)
            {
                return;
            }

            this.Record.Members.Remove(member.Record);
            Members.Remove(member);
            member.CharacterRecord.GuildId = 0;

            if (member.Connected)
            {
                member.Character.Guild = null;
                member.Character.RemoveHumanOption <CharacterHumanOptionGuild>();
                member.Character.Client.Send(new GuildLeftMessage());
            }
            else
            {
                member.CharacterRecord.HumanOptions.RemoveAll(x => x is CharacterHumanOptionGuild);
                member.CharacterRecord.UpdateElement();
            }

            this.Record.UpdateElement();
            Send(new GuildMemberLeavingMessage(kicked, (ulong)member.Id));

            if (Members.Count == 0)
            {
                GuildProvider.Instance.RemoveGuild(this);
            }
        }
        public void Join(Character character, bool isBoss)
        {
            var memberRecord = ContextGuildMember.New(character, isBoss);

            Record.Members.Add(memberRecord);
            GuildMemberInstance member = new GuildMemberInstance(character, this, memberRecord);

            Members.Add(member);
            Record.UpdateElement();
        }
 public void SetMotd(GuildMemberInstance member, string content)
 {
     if (content.Length > GuildProvider.MOTD_MAX_LENGHT)
     {
         Send(new GuildMotdSetErrorMessage(0));
     }
     Record.Motd = new GuildMotd()
     {
         Content    = content,
         MemberId   = (ulong)member.Id,
         MemberName = member.CharacterRecord.Name,
         Timestamp  = DateTime.Now.DateTimeToUnixTimestampSeconds(),
     };
     Record.UpdateElement();
     Send(new GuildMotdMessage(Record.Motd.Content, Record.Motd.Timestamp, Record.Motd.MemberId, Record.Motd.MemberName));
 }
        public void SetBoss(GuildMemberInstance member)
        {
            if (this.Boss != member)
            {
                var oldBoss = this.Boss;
                oldBoss.Record.Rank = 0;
                oldBoss.Rights      = GuildRightsBitEnum.GUILD_RIGHT_NONE;
                oldBoss.Update();

                member.Record.Rank = 1;
                member.Rights      = GuildRightsBitEnum.GUILD_RIGHT_BOSS;
                member.Update();

                if (Members.Count > 1)
                {
                    Foreach(x => x.Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 199, new string[]
                    {
                        member.Character.Name,
                        oldBoss.Character.Name,
                        this.Record.Name,
                    }));
                }
            }
        }