예제 #1
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6011_GuildMemberNotMember;
                return(false);
            }
            idolInfo = new ShareCacheStruct <GuildIdol>().FindKey(guildID);
            if (idolInfo != null)
            {
                maxAura = new ConfigCacheSet <IdolLvInfo>().FindKey(idolInfo.IdolLv).UpExperience;
            }
            idolInfoArray = new ConfigCacheSet <GuildIdolInfo>().FindAll();

            var memberLog = new ShareCacheStruct <GuildMemberLog>().FindKey(guildID) ?? new GuildMemberLog();
            List <MemberLog> guildArray = memberLog.GetLog(u => u.LogType == 2);

            foreach (MemberLog guildLog in guildArray)
            {
                if (guildLog.UserID == ContextUser.UserID && DateTime.Now.Date == guildLog.InsertDate.Date)
                {
                    isXs = 2;
                    break;
                }
            }
            guildArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(y.InsertDate.CompareTo(x.InsertDate));
            });
            int recordCount = 0;

            guildLogArray = guildArray.GetPaging(0, guildArray.Count > 5 ? 5 : guildArray.Count, out recordCount);

            return(true);
        }
예제 #2
0
        public override bool TakeAction()
        {
            int nameLength = System.Text.Encoding.Default.GetByteCount(guildName);
            List <UserQueue> queueArray = new GameDataCacheSet <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TuiChuGongHui);

            if (queueArray.Count > 0 && queueArray[0].DoRefresh() > 0 && queueArray[0].IsSuspend == false)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6006_GuildMemberNotDate;
                return(false);
            }
            int createGoinNum = ConfigEnvSet.GetInt("UserGuild.CreateGoinNum");
            int createLv      = ConfigEnvSet.GetInt("UserGuild.CreateUserLv");

            if (ContextUser.UserLv < createLv)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                return(false);
            }

            if (ContextUser.GameCoin < createGoinNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                return(false);
            }
            if (guildName == "")
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6017_GuildNameNotEmpty;
                return(false);
            }

            if (nameLength < 4 || nameLength > 12)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6017_GuildNameTooLong;
                return(false);
            }

            List <GuildMember> memberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.UserID == ContextUser.UserID);

            if (memberArray.Count > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6017_UnionMembers;
                return(false);
            }
            List <UserGuild> guildArray = new ShareCacheStruct <UserGuild>().FindAll(u => u.GuildName == guildName);

            if (guildArray.Count > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6017_GuildRename;
                return(false);
            }
            List <UserGuild> userGuildArray = new ShareCacheStruct <UserGuild>().FindAll();
            int rankID = 0;

            if (userGuildArray.Count > 0)
            {
                rankID = MathUtils.Addition(userGuildArray.Count, 1, int.MaxValue);
            }
            else
            {
                rankID = 1;
            }

            string guildID = Guid.NewGuid().ToString();

            ContextUser.MercenariesID = guildID;

            ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, createGoinNum, 0);

            UserGuild userGuild = new UserGuild()
            {
                GuildID        = guildID,
                UserID         = ContextUser.UserID,
                GuildName      = guildName,
                GuildLv        = 1,
                GuildRank      = rankID,
                WeekExperience = 0,
                CurrExperience = 0,
                CreateDate     = DateTime.Now,
            };

            new ShareCacheStruct <UserGuild>().Add(userGuild, GameEnvironment.CacheGlobalPeriod);


            GuildMember member = new GuildMember()
            {
                GuildID           = guildID,
                UserID            = ContextUser.UserID,
                PostType          = PostType.Chairman,
                Contribution      = 0,
                TotalContribution = 0,
                DevilNum          = 0,
                SummonNum         = 0,
                IsDevil           = 0,
                IncenseNum        = 0,
                InsertDate        = DateTime.Now
            };

            new ShareCacheStruct <GuildMember>().Add(member, GameEnvironment.CacheGlobalPeriod);
            var temp = new ShareCacheStruct <GuildMember>().FindKey(guildID, ContextUser.UserID);

            if (temp.HasChanged)
            {
                TraceLog.WriteInfo("6017 GuildMember update success.");
            }
            GuildIdol idolInfo = new GuildIdol()
            {
                GuildID        = guildID,
                IdolLv         = 1,
                CurrExperience = 0
            };

            new ShareCacheStruct <GuildIdol>().Add(idolInfo, GameEnvironment.CacheGlobalPeriod);
            return(true);
        }