Beispiel #1
0
        public Group CreateGroup(Player habbo, int roomId, string roomName, string name, string description, string badge, int colourOne, int colourTwo)
        {
            Group group = new Group(0, name, description, habbo.Id, 0, roomId, 0, true, colourOne, colourTwo, badge, new List <GroupMember>());

            group.Id = GroupDatabase.CreateGroup(group);
            group.Members.Add(new GroupMember(habbo.Id, habbo.Username, habbo.Look, group.CreatedAt, 0));
            Groups.Add(group);
            return(group);
        }
Beispiel #2
0
        public void SetMemberRank(int userId, int rank)
        {
            GroupMember member = GetMember(userId);

            if (member == null || (int)member.Rank == rank)
            {
                return;
            }

            GroupDatabase.SetMemberRank(this.Id, userId, rank);
            member.Rank = (GroupRank)rank;
        }
Beispiel #3
0
        public void RemoveMember(int userId)
        {
            GroupMember member = GetMember(userId);

            if (member == null)
            {
                return;
            }

            GroupDatabase.RemoveMember(this.Id, userId);
            this.Members.Remove(member);
        }
Beispiel #4
0
        public Group GetGroup(int id)
        {
            Group group = null;

            if (this.Groups.Where(g => g.Id == id && !g.Disposing).ToList().Count > 0)
            {
                group          = this.Groups.Where(g => g.Id == id).First();
                group.IdleTime = 0;
            }
            else
            {
                group = GroupDatabase.TryGetGroup(id);
                if (group != null)
                {
                    this.Groups.Add(group);
                }
            }
            return(group);
        }
Beispiel #5
0
        public void JoinGroup(Session session, int userId, bool acceptRequest)
        {
            int groupsCount = GroupDatabase.GetGroupsCount(userId);

            if (groupsCount >= 100)
            {
                if (acceptRequest)
                {
                    session.Send(new GroupJoinErrorComposer(GroupJoinErrorComposer.MEMBER_FAIL_JOIN_LIMIT_EXCEED_NON_HC));
                    return;
                }
                else
                {
                    session.Send(new GroupJoinErrorComposer(GroupJoinErrorComposer.GROUP_LIMIT_EXCEED));
                    return;
                }
            }

            if (this.GetMembers >= 50000)
            {
                session.Send(new GroupJoinErrorComposer(GroupJoinErrorComposer.GROUP_FULL));
                return;
            }

            if (!acceptRequest && this.GetRequests >= 100)
            {
                session.Send(new GroupJoinErrorComposer(GroupJoinErrorComposer.GROUP_NOT_ACCEPT_REQUESTS));
                return;
            }

            if (acceptRequest)
            {
                this.SetMemberRank(userId, (int)GroupRank.MEMBER);
            }
            else
            {
                GroupMember member = new GroupMember(userId, session.Player.Username, session.Player.Look, (int)UnixTimestamp.Now, this.State == GroupState.LOCKED ? (int)GroupRank.REQUESTED : (int)GroupRank.MEMBER);
                GroupDatabase.AddMember(this.Id, userId, (int)member.Rank);
                this.Members.Add(member);
            }
        }
Beispiel #6
0
 public void DeleteGroup(Group group)
 {
     GroupDatabase.RemoveGroup(group);
     RemoveGroup(group);
 }
Beispiel #7
0
        public void Initialize()
        {
            this.BadgeParts.Clear();

            GroupDatabase.ReadBadgeParts(this);
        }
Beispiel #8
0
 public void Dispose()
 {
     this.Disposing = true;
     GroupDatabase.UpdateGroup(this);
     Alias.Server.GroupManager.RemoveGroup(this);
 }