Example #1
0
        internal bool LeaveGroup(GroupInfo group, GroupMemberInfo member)
        {
            if (null == group || null == member)
            {
                return(false);
            }
            if (member.Guid == group.CreatorGuid && group.Members.Count > 1)
            {
                m_Groups.Remove(group.CreatorGuid);
                group.CreatorGuid = group.Members[1].Guid;
                if (!m_Groups.ContainsKey(group.CreatorGuid))
                {
                    m_Groups.Add(group.CreatorGuid, group);
                }
                ///
                UserInfo leader = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(group.CreatorGuid);
                if (null != leader)
                {
                    JsonMessageWithGuid slgMsg = new JsonMessageWithGuid(JsonMessageID.ChangeCaptain);
                    slgMsg.m_Guid = group.CreatorGuid;
                    ArkCrossEngineMessage.Msg_LC_ChangeCaptain protoData = new ArkCrossEngineMessage.Msg_LC_ChangeCaptain();
                    protoData.m_CreatorGuid = group.CreatorGuid;
                    slgMsg.m_ProtoData      = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(leader.NodeName, slgMsg);
                }
            }
            bool result = group.Members.Remove(member);

            if (group.Members.Count == 0)
            {
                recycles.Enqueue(group);
            }
            return(result);
        }
Example #2
0
        internal GroupInfo CreateGroup(ulong guid, int count)
        {
            GroupInfo group;

            if (!m_Groups.TryGetValue(guid, out group))
            {
                DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
                UserInfo             creator     = dataProcess.GetUserInfo(guid);
                if (null != creator && UserState.Online == creator.CurrentState)
                {
                    group             = NewGroupInfo();
                    group.CreatorGuid = guid;
                    group.Count       = count;
                    GroupMemberInfo member = new GroupMemberInfo();
                    member.Guid          = guid;
                    member.HeroId        = creator.HeroId;
                    member.Nick          = creator.Nickname;
                    member.Level         = creator.Level;
                    member.FightingScore = creator.FightingScore;
                    member.Status        = creator.CurrentState;
                    List <GroupMemberInfo> members = new List <GroupMemberInfo>();
                    members.Add(member);
                    group.Members = members;
                    m_Groups.Add(guid, group);
                    UserInfo info = dataProcess.GetUserInfo(guid);
                    if (info != null)
                    {
                        info.Group = group;
                    }
                }
            }
            return(group);
        }
Example #3
0
        internal TeamOperateResult RequestJoinGroup(ulong guid, ulong groupid)
        {
            TeamOperateResult result = TeamOperateResult.OR_Busyness;

            if (guid == groupid)
            {
                return(result);
            }
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             intrant     = dataProcess.GetUserInfo(guid);

            if (null != intrant && UserState.Online == intrant.CurrentState)
            {
                GroupInfo ginfo;
                if (m_Groups.TryGetValue(groupid, out ginfo))
                {
                    if (null != ginfo.Confirms &&
                        ginfo.Confirms.Count < GroupInfo.c_ConfirmNumMax)
                    {
                        bool ishave = false;
                        foreach (GroupMemberInfo info in ginfo.Confirms)
                        {
                            if (info.Guid == guid)
                            {
                                ishave = true;
                                result = TeamOperateResult.OR_Exists;
                                break;
                            }
                        }
                        if (!ishave)
                        {
                            GroupMemberInfo member = new GroupMemberInfo();
                            member.Guid          = guid;
                            member.HeroId        = intrant.HeroId;
                            member.Nick          = intrant.Nickname;
                            member.Level         = intrant.Level;
                            member.FightingScore = intrant.FightingScore;
                            member.Status        = intrant.CurrentState;
                            ginfo.Confirms.Add(member);
                            result = TeamOperateResult.OR_Succeed;
                        }
                    }
                    else
                    {
                        result = TeamOperateResult.OR_Overflow;
                    }
                }
            }
            return(result);
        }
Example #4
0
        internal void AutoJoinGroup(ulong guid, ulong groupid)
        {
            if (guid == groupid)
            {
                return;
            }
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            GroupInfo            info;

            if (m_Groups.TryGetValue(groupid, out info))
            {
                if (info.Count > info.Members.Count)
                {
                    UserInfo player = dataProcess.GetUserInfo(guid);
                    if (null != player)
                    {
                        GroupMemberInfo member = new GroupMemberInfo();
                        member.Guid          = guid;
                        member.HeroId        = player.HeroId;
                        member.Nick          = player.Nickname;
                        member.Level         = player.Level;
                        member.FightingScore = player.FightingScore;
                        member.Status        = player.CurrentState;
                        bool isExist = false;
                        foreach (GroupMemberInfo atom in info.Members)
                        {
                            if (atom.Guid == guid)
                            {
                                isExist = true;
                                break;
                            }
                        }
                        if (!isExist)
                        {
                            info.Members.Add(member);
                            player.Group = info;
                        }
                    }
                }
            }
            else
            {
                UserInfo creator = dataProcess.GetUserInfo(groupid);
                UserInfo intrant = dataProcess.GetUserInfo(guid);
                if (null != creator && null != intrant)
                {
                    GroupInfo group = NewGroupInfo();
                    group.CreatorGuid = groupid;
                    group.Count       = GroupInfo.c_MemberNumMax;
                    List <GroupMemberInfo> members = new List <GroupMemberInfo>();
                    GroupMemberInfo        leader  = new GroupMemberInfo();
                    leader.Guid          = groupid;
                    leader.HeroId        = creator.HeroId;
                    leader.Nick          = creator.Nickname;
                    leader.Level         = creator.Level;
                    leader.FightingScore = creator.FightingScore;
                    leader.Status        = creator.CurrentState;
                    members.Add(leader);
                    GroupMemberInfo member = new GroupMemberInfo();
                    member.Guid          = guid;
                    member.HeroId        = intrant.HeroId;
                    member.Nick          = intrant.Nickname;
                    member.Level         = intrant.Level;
                    member.FightingScore = intrant.FightingScore;
                    member.Status        = intrant.CurrentState;
                    members.Add(member);
                    group.Members = members;
                    m_Groups.Add(groupid, group);
                    ///
                    creator.Group = group;
                    intrant.Group = group;
                }
            }
        }
Example #5
0
        internal TeamOperateResult JoinGroup(ulong guid, ulong groupid, int count)
        {
            if (guid == groupid)
            {
                return(TeamOperateResult.OR_Unknown);
            }
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            TeamOperateResult    result      = TeamOperateResult.OR_OutDate;
            GroupInfo            info;

            if (m_Groups.TryGetValue(groupid, out info))
            {
                if (info.Count > info.Members.Count)
                {
                    UserInfo player = dataProcess.GetUserInfo(guid);
                    if (null != player && player.CurrentState == UserState.Online)
                    {
                        GroupMemberInfo member = new GroupMemberInfo();
                        member.Guid          = guid;
                        member.HeroId        = player.HeroId;
                        member.Nick          = player.Nickname;
                        member.Level         = player.Level;
                        member.FightingScore = player.FightingScore;
                        member.Status        = player.CurrentState;
                        bool isExist = false;
                        foreach (GroupMemberInfo atom in info.Members)
                        {
                            if (atom.Guid == guid)
                            {
                                isExist = true;
                                result  = TeamOperateResult.OR_Exists;
                                break;
                            }
                        }
                        if (!isExist)
                        {
                            info.Members.Add(member);
                            player.Group = info;
                            result       = TeamOperateResult.OR_Succeed;
                        }
                    }
                }
                else
                {
                    result = TeamOperateResult.OR_Overflow;
                }
            }
            else
            {
                UserInfo creator = dataProcess.GetUserInfo(groupid);
                UserInfo intrant = dataProcess.GetUserInfo(guid);
                if (null != creator && creator.CurrentState == UserState.Online &&
                    null != intrant && intrant.CurrentState == UserState.Online)
                {
                    GroupInfo group = NewGroupInfo();
                    group.CreatorGuid = groupid;
                    group.Count       = count;
                    List <GroupMemberInfo> members = new List <GroupMemberInfo>();
                    GroupMemberInfo        leader  = new GroupMemberInfo();
                    leader.Guid          = groupid;
                    leader.HeroId        = creator.HeroId;
                    leader.Nick          = creator.Nickname;
                    leader.Level         = creator.Level;
                    leader.FightingScore = creator.FightingScore;
                    leader.Status        = creator.CurrentState;
                    members.Add(leader);
                    GroupMemberInfo member = new GroupMemberInfo();
                    member.Guid          = guid;
                    member.HeroId        = intrant.HeroId;
                    member.Nick          = intrant.Nickname;
                    member.Level         = intrant.Level;
                    member.FightingScore = intrant.FightingScore;
                    member.Status        = intrant.CurrentState;
                    members.Add(member);
                    group.Members = members;
                    m_Groups.Add(groupid, group);
                    ///
                    creator.Group = group;
                    intrant.Group = group;
                    result        = TeamOperateResult.OR_Succeed;
                }
                else
                {
                    result = TeamOperateResult.OR_OutDate;
                }
            }
            return(result);
        }