示例#1
0
        public override bool TakeAction()
        {
            var guildData = new ShareCacheStruct <GuildsCache>().FindKey(GetGuild.GuildID);

            if (guildData == null)
            {
                return(false);
            }


            if (Current.UserId == _DestUid ||
                (guildData.FindAtevent().UserID != Current.UserId && guildData.FindVice(Current.UserId) == null))
            {
                receipt = RequestGuildResult.NoAuthority;
                return(true);
            }

            var basis  = UserHelper.FindUserBasis(_DestUid);
            var guild  = UserHelper.FindUserGuild(_DestUid);
            var member = guildData.FindMember(_DestUid);

            if (basis == null || member == null)
            {
                return(false);
            }


            GuildLogData log = new GuildLogData()
            {
                UserId   = basis.UserID,
                UserName = basis.NickName,
                LogTime  = DateTime.Now,
                Content  = string.Format("玩家 {0} 被移出公会。", basis.NickName),
            };

            guildData.NewLog(log);

            foreach (var v in guildData.MemberList)
            {
                PushMessageHelper.GuildMemberRemoveNotification(GameSession.Get(v.UserID), _DestUid);
                PushMessageHelper.NewGuildLogNotification(GameSession.Get(v.UserID));
            }

            guildData.RemoveMember(member);
            guild.GuildID = string.Empty;
            GlobalRemoteService.SendUserData(basis, guild.GuildID);

            receipt = RequestGuildResult.Successfully;
            return(true);
        }
示例#2
0
        public override bool TakeAction()
        {
            var guildData = new ShareCacheStruct <GuildsCache>().FindKey(GetGuild.GuildID);

            if (guildData == null)
            {
                return(false);
            }

            var guildcfg = new ShareCacheStruct <Config_Society>().FindKey(guildData.Lv);

            if (guildcfg == null)
            {
                return(false);
            }


            if (guildData.FindAtevent().UserID != Current.UserId &&
                guildData.FindVice(Current.UserId) == null)
            {
                receipt = RequestGuildResult.NoAuthority;
                return(true);
            }

            var basis = UserHelper.FindUserBasis(_DestUid);
            var guild = UserHelper.FindUserGuild(_DestUid);

            if (basis == null)
            {
                return(false);
            }



            if (_isAgree)
            {
                if (guildData.MemberList.Count >= guildcfg.Number)
                {
                    receipt = RequestGuildResult.Full;
                }

                else if (!guild.GuildID.IsEmpty())
                {
                    receipt = RequestGuildResult.HadGuild;
                }
                else
                {
                    GuildCharacter member = new GuildCharacter()
                    {
                        UserID   = basis.UserID,
                        JobTitle = GuildJobTitle.Normal,
                        Liveness = 0
                    };

                    GuildLogData log = new GuildLogData()
                    {
                        UserId   = basis.UserID,
                        UserName = basis.NickName,
                        LogTime  = DateTime.Now,
                        Content  = string.Format("玩家 {0} 加入了公会。", basis.NickName),
                    };
                    guildData.NewLog(log);

                    // 通知公会成员有新成员加入
                    foreach (var v in guildData.MemberList)
                    {
                        PushMessageHelper.NewGuildMemberNotification(GameSession.Get(v.UserID), _DestUid);
                        PushMessageHelper.NewGuildLogNotification(GameSession.Get(v.UserID));
                    }

                    guildData.AddNewMember(member);
                    guild.GuildID  = guildData.GuildID;
                    guild.IsSignIn = false;

                    // 通知新成员公会信息
                    PushMessageHelper.JoinGuildNotification(GameSession.Get(_DestUid));

                    GlobalRemoteService.SendUserData(basis, guild.GuildID);

                    receipt = RequestGuildResult.Successfully;
                }
            }
            // 从邀请列表里清除
            guildData.RemoveRequest(_DestUid);

            foreach (var v in guildData.MemberList)
            {
                PushMessageHelper.GuildApplyRemoveNotification(GameSession.Get(v.UserID), _DestUid);
            }
            return(true);
        }