Example #1
0
        public override bool TakeAction()
        {
            if (!UserHelper.IsOpenFunction(ContextUser.UserID, FunctionEnum.Trump))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_NoFun;
                return(false);
            }
            short     trumpLv   = 1;
            TrumpInfo trumpInfo = new ConfigCacheSet <TrumpInfo>().FindKey(TrumpInfo.CurrTrumpID, trumpLv);

            if (trumpInfo != null && trumpInfo.Property.Count > 0)
            {
                lifeNum         = TrumpHelper.GetTrumpProperty(trumpInfo, AbilityType.ShengMing).ToInt();
                powerNum        = TrumpHelper.GetTrumpProperty(trumpInfo, AbilityType.PowerNum);
                soulNum         = TrumpHelper.GetTrumpProperty(trumpInfo, AbilityType.SoulNum);
                intelligenceNum = TrumpHelper.GetTrumpProperty(trumpInfo, AbilityType.IntelligenceNum);
            }
            storyTaskArray = new ConfigCacheSet <StoryTaskInfo>().FindAll(m => m.TaskType == TaskType.Trump).ToArray();
            if (TrumpHelper.IsTrumpPractice(ContextUser.UserID))
            {
                isPractice = 1;
            }
            else
            {
                iscomplete = 0;
            }
            return(true);
        }
Example #2
0
        public override bool TakeAction()
        {
            if (!UserHelper.IsOpenFunction(ContextUser.UserID, FunctionEnum.Trump))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_NoFun;
                return(false);
            }
            if (UserHelper.IsOpenFunction(ContextUser.UserID, FunctionEnum.TrumpPractice))
            {
                return(false);
            }
            if (!TrumpHelper.IsTrumpPractice(ContextUser.UserID))
            {
                return(false);
            }
            var       cacheTrump = new PersonalCacheStruct <UserTrump>();
            UserTrump userTrump  = cacheTrump.FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID);

            if (userTrump == null)
            {
                TrumpInfo trumpInfo = new ShareCacheStruct <TrumpInfo>().FindKey(TrumpInfo.CurrTrumpID, 1);
                if (trumpInfo == null)
                {
                    return(false);
                }
                StoryTaskInfo[] storyTaskArray = new ShareCacheStruct <StoryTaskInfo>().FindAll(m => m.TaskType == TaskType.Trump).ToArray();
                foreach (StoryTaskInfo taskInfo in storyTaskArray)
                {
                    UserItemHelper.UseUserItem(ContextUser.UserID, taskInfo.TargetItemID, taskInfo.TargetItemNum);
                }
                userTrump            = new UserTrump(ContextUser.UserID, TrumpInfo.CurrTrumpID);
                userTrump.TrumpLv    = 1;
                userTrump.WorshipLv  = 1;
                userTrump.LiftNum    = trumpInfo.MaxLift;
                userTrump.Experience = 0;
                userTrump.MatureNum  = trumpInfo.BeseMature;
                userTrump.Zodiac     = TrumpHelper.GetZodiacType(ZodiacType.NoZodiac);
                //userTrump.SkillInfo = new List<SkillInfo>();
                //userTrump.PropertyInfo = new List<GeneralProperty>();
                cacheTrump.Add(userTrump);
                cacheTrump.Update();
            }
            var          cacheSet     = new PersonalCacheStruct <UserFunction>();
            UserFunction userFunction = cacheSet.FindKey(ContextUser.UserID, FunctionEnum.TrumpPractice);

            if (userFunction == null)
            {
                UserFunction function = new UserFunction()
                {
                    FunEnum    = FunctionEnum.TrumpPractice,
                    UserID     = ContextUser.UserID,
                    CreateDate = DateTime.Now,
                };
                cacheSet.Add(function);
                cacheSet.Update();
            }
            var usergeneral = UserGeneral.GetMainGeneral(ContextUser.UserID);

            if (userTrump.LiftNum > 0 && usergeneral != null)
            {
                usergeneral.RefreshMaxLife();
            }
            return(true);
        }