예제 #1
0
        public override bool TakeAction()
        {
            GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(guildID, ContextUser.UserID);

            if (member != null && member.PostType == PostType.Member)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6007_AuditPermissions;
                return(false);
            }

            List <GuildMember> memberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.GuildID == guildID);
            UserGuild          guildInfo   = new ShareCacheStruct <UserGuild>().FindKey(guildID);

            if (guildInfo != null)
            {
                GuildLvInfo guildLvInfo = new ShareCacheStruct <GuildLvInfo>().FindKey(guildInfo.GuildLv);
                if (guildLvInfo != null)
                {
                    int maxPeople = MathUtils.Addition(guildInfo.AddMember, guildLvInfo.MaxPeople);
                    if (memberArray.Count > 0 && memberArray.Count >= maxPeople)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St6019_GuildMaxPeople;
                        return(false);
                    }
                }
            }
            GameUser userInfo = UserCacheGlobal.CheckLoadUser(memberID);

            if (userInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            var memberList = new ShareCacheStruct <GuildMember>().FindAll(s => s.UserID == memberID);

            if (memberList.Count > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6019_AddGuild;
                return(false);
            }

            GuildMember gMember = new GuildMember()
            {
                GuildID           = guildID,
                UserID            = memberID,
                PostType          = PostType.Member,
                Contribution      = 0,
                TotalContribution = 0,
                IncenseNum        = 0,
                DevilNum          = 0,
                IsDevil           = 0,
                InsertDate        = DateTime.Now
            };

            new ShareCacheStruct <GuildMember>().Add(gMember);
            userInfo.MercenariesID = guildID;
            CombatHelper.LoadGuildAbility(userInfo.UserID); //加载公会技能

            var cacheSet = new ShareCacheStruct <UserApply>();
            List <UserApply> appliesArray = cacheSet.FindAll(m => m.UserID == memberID);

            foreach (UserApply apply in appliesArray)
            {
                cacheSet.Delete(apply);
            }

            return(true);
        }