コード例 #1
0
ファイル: Action1010.cs プロジェクト: xushenghan/Scut-samples
        /// <summary>
        /// 获得精力
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="vipLv"></param>
        /// <param name="payType"></param>
        /// <returns></returns>
        public static short GetEnergyNum(string userID, int vipLv, int payType)
        {
            UserDailyRestrain dailyRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(userID);
            int maxNum  = VipHelper.GetVipUseNum(vipLv, RestrainType.GouMaiJingLi);
            int currNum = 0;

            if (DateTime.Now.Date == dailyRestrain.RefreshDate.Date)
            {
                currNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion4, 0);
            }
            else
            {
                currNum = maxNum;
            }
            short energyNum = 0;

            if (payType == 1)
            {
                energyNum = ConfigEnvSet.GetInt("User.EnergyNum").ToShort();
            }
            else if (payType == 2)
            {
                energyNum = (short)(currNum * 40);
            }
            return(energyNum);
        }
コード例 #2
0
ファイル: Action1011.cs プロジェクト: dongliang/Scut
        /// <summary>
        /// 挖金矿获得的金币
        /// </summary>
        /// <param name="vipLv"></param>
        /// <param name="payType"></param>
        /// <param name="userLv"></param>
        /// <returns></returns>
        public static int GetPayCoinNum(string userID, int vipLv, int payType, int userLv)
        {
            int baseNum      = MathUtils.Addition((userLv * 2000), 3000);
            int totalCoinNum = 0;
            UserDailyRestrain userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(userID);
            int maxNum = VipHelper.GetVipUseNum(vipLv, RestrainType.WaJinKuang);

            int currNum = 0;

            if (DateTime.Now.Date == userRestrain.RefreshDate.Date)
            {
                currNum = MathUtils.Subtraction(maxNum, userRestrain.Funtion3);
            }
            else
            {
                currNum = maxNum;
            }
            if (payType == 1)
            {
                totalCoinNum = baseNum;
            }
            else if (payType == 2)
            {
                totalCoinNum = (currNum * baseNum);
            }
            return(totalCoinNum);
        }
コード例 #3
0
ファイル: Action1303.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            UserHelper.GetUserLightOpen(ContextUser.UserID);
            DailyRestrainSet  dailyRestrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.MianFeiLieMing);
            UserDailyRestrain userRestrain     = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID);

            if (dailyRestrainSet != null && userRestrain != null)
            {
                if (DateTime.Now.Date == userRestrain.RefreshDate.Date)
                {
                    freeNum = VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing);
                    freeNum = MathUtils.Subtraction(freeNum, userRestrain.Funtion2, 0);
                }
                else
                {
                    freeNum = VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing);
                }
            }

            userLightArray = new GameDataCacheSet <UserLight>().FindAll(ContextUser.UserID);
            userLightArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(x.HuntingID.CompareTo(y.HuntingID));
            });
            bool allowSale;
            bool allowTake;

            grayCrystalArray = CrystalHelper.GetNotSaleCrystalNum(ContextUser, out allowSale, out allowTake);
            grayCrystalArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(x.CreateDate.CompareTo(y.CreateDate));
            });
            isSale       = allowSale ? 1 : 2;
            issTelegrams = allowTake ? 1 : 2;
            return(true);
        }
コード例 #4
0
        /// <summary>
        /// 剩余挑战次数
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public int GetChallGeNum(string userID)
        {
            int currNum = 0;
            UserDailyRestrain dailyRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(userID);

            if (dailyRestrain != null && dailyRestrain.RefreshDate.Date == DateTime.Now.Date)
            {
                currNum = dailyRestrain.Funtion9;
            }

            int InitialNum = VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.JingJiChangTiaoZhan); //当日挑战次数
            UserChallengeNum userChallenge = new PersonalCacheStruct <UserChallengeNum>().FindKey(userID);

            if (userChallenge != null && DateTime.Now.Date == userChallenge.InsertDate.Date)
            {
                InitialNum = MathUtils.Addition(InitialNum, userChallenge.ChallengeNum, int.MaxValue); //当日总挑战次数
            }
            return(MathUtils.Subtraction(InitialNum, currNum, 0));
        }
コード例 #5
0
ファイル: Action5107.cs プロジェクト: zxx0367/Scut-samples
        ///<summary>
        /// 剩余次数
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public int GetChallGeNum(string userID)
        {
            int InitialNum = VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.JingJiChangTiaoZhan);
            int totalNum   = 0;
            int AddNum     = 0;
            int currNum    = 0;
            UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(userID);

            if (dailyRestrain != null && dailyRestrain.RefreshDate.Date == DateTime.Now.Date)
            {
                currNum = dailyRestrain.Funtion9;
            }

            UserChallengeNum userChallenge = new GameDataCacheSet <UserChallengeNum>().FindKey(userID);

            if (userChallenge != null && DateTime.Now.Date == userChallenge.InsertDate.Date)
            {
                AddNum = userChallenge.ChallengeNum;
            }

            totalNum = MathUtils.Addition(InitialNum, AddNum, int.MaxValue);
            totalNum = MathUtils.Subtraction(totalNum, currNum, 0);
            return(totalNum);
        }
コード例 #6
0
ファイル: Action1012.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            UserFunction userFunction = new PersonalCacheStruct <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Xiulian);

            if (userFunction != null)
            {
                UserHelper.XiuLianGianExperience(ContextUser.UserID); //修炼完成后更改修炼状态

                int inerDate = (int)(DateTime.Now - ContextUser.OnlineDate).TotalSeconds;
                if (inerDate > 300 && ContextUser.UserStatus != UserStatus.XiuLian)
                {
                    int totalTime = 0;
                    GeneralPracticeInfo generalpractice = new ShareCacheStruct <GeneralPracticeInfo>().FindKey(ContextUser.UserLv);
                    if (VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.XiuLianYanChangErShiSiXiaoShi))
                    {
                        totalTime = ConfigEnvSet.GetInt("User.XiuLianDate");
                    }
                    else
                    {
                        if (generalpractice != null)
                        {
                            totalTime = (generalpractice.MaxHour * 60 * 60);
                        }
                    }

                    if (inerDate > 300 && ContextUser.UserStatus != UserStatus.XiuLian && ContextUser.UserStatus != UserStatus.FightCombat)
                    {
                        ContextUser.UserStatus = UserStatus.XiuLian;
                        //ContextUser.Update();

                        List <UserQueue> userQueueArray = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.XiuLian);
                        if (userQueueArray.Count > 0)
                        {
                            UserQueue userQueue = userQueueArray[0];
                            userQueue.TotalColdTime = totalTime;
                            userQueue.ColdTime      = totalTime;
                            userQueue.Timing        = DateTime.Now;
                            userQueue.IsSuspend     = false;
                            userQueue.StrengNum     = 0;
                            //userQueue.Update();
                        }
                        _statusList.Add(MessageState.XiuLian);
                    }
                }
            }

            UserDailyRestrain dailyRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID);

            if (new TjxChatService(ContextUser).HasMessage(ContextUser.ChatVesion))
            {
                _statusList.Add(MessageState.Chat);
            }

            if (NoviceHelper.CheckOnlinePrize(Uid))
            {
                _statusList.Add(MessageState.TakeOnline);
            }

            if (NoviceHelper.CheckLoginPrize(Uid))
            {
                _statusList.Add(MessageState.TakeLogin);
            }
            if (new TjxBroadcastService(ContextUser).HasMessage())
            {
                _statusList.Add(MessageState.Broadcast);
            }

            if (NoviceHelper.CheckDailyExpPrize(Uid))
            {
                _statusList.Add(MessageState.TakeDailyExp);
            }

            if (RankingHelper.IsGainSportsReward(ContextUser.UserID))
            {
                _statusList.Add(MessageState.JingJiChangReward);
            }

            UserFunction countryFunction = new PersonalCacheStruct <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Country);

            if (countryFunction != null && dailyRestrain != null && dailyRestrain.Funtion8 < VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.LingQuFengLu))
            {
                _statusList.Add(MessageState.LingQuFengLv);
            }

            if (NoviceHelper.DailyEnergy(ContextUser.UserID))
            {
                _statusList.Add(MessageState.SurplusEnergy);
            }
            if (new GameActiveCenter(Uid).HasActive())
            {
                _statusList.Add(MessageState.Huodong);
            }
            if (NoviceHelper.IsAugustSecondWeekEnergy(ContextUser))
            {
                _statusList.Add(MessageState.FestivalEnergy);
            }
            if (NoviceHelper.IsWingFestivalInfo(ContextUser.UserID))
            {
                _statusList.Add(MessageState.Wing);
            }

            if (GuildFightBroadcast(ContextUser.UserID, stakecount, ContextUser.MercenariesID))
            {
                _statusList.Add(MessageState.GuildFight);
            }
            else
            {
                stakecount = 0;
            }

            var userPrizeList = new ShareCacheStruct <UserTakePrize>().FindAll(m => !m.IsTasked && m.UserID == Uid.ToInt());

            if (userPrizeList.Count > 0)
            {
                _statusList.Add(MessageState.TaskPrize);
            }
            return(true);
        }
コード例 #7
0
ファイル: Action1010.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            int energyNum = ConfigEnvSet.GetInt("User.EnergyNum");

            UserHelper.ChechDailyRestrain(ContextUser.UserID);
            var               cacheSet     = new PersonalCacheStruct <UserDailyRestrain>();
            double            addNum       = FestivalHelper.SurplusPurchased(ContextUser.UserID, FestivalType.PurchasedEnergy);//活动加成
            int               payNum       = FestivalHelper.SurplusEnergyNum(ContextUser.UserID);
            UserDailyRestrain userRestrain = cacheSet.FindKey(ContextUser.UserID);

            if (payNum == 0)
            {
                if (userRestrain != null && DateTime.Now.Date != userRestrain.RefreshDate.Date)
                {
                    userRestrain.Funtion4 = 0;
                }

                if (userRestrain != null && userRestrain.Funtion4 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.GouMaiJingLi) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St1010_JingliFull;
                    return(false);
                }
            }

            int useGold = (GetPayEnergyGold(ContextUser.UserID, ContextUser.VipLv, payType) * addNum).ToInt();

            if (payType == 1)
            {
                if (ops == 1)
                {
                    this.ErrorCode = 1;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1010_PayEnergyUseGold, useGold, energyNum);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum < useGold)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }

                    ContextUser.UseGold   = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
                    ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, GetEnergyNum(ContextUser.UserID, ContextUser.VipLv, payType), short.MaxValue);
                    if (payNum == 0)
                    {
                        if (userRestrain != null)
                        {
                            userRestrain.Funtion4 = MathUtils.Addition(userRestrain.Funtion4, 1, int.MaxValue);
                        }
                        else
                        {
                            userRestrain             = new UserDailyRestrain();
                            userRestrain.UserID      = ContextUser.UserID;
                            userRestrain.RefreshDate = DateTime.Now;
                            userRestrain.Funtion4    = 1;
                            cacheSet.Add(userRestrain);
                        }
                    }

                    UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, 0, userRestrain.Funtion4, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue));
                    FestivalHelper.PurchasedEnergy(ContextUser.UserID);
                }
            }
            else if (payType == 2)
            {
                short payEnergy = GetEnergyNum(ContextUser.UserID, ContextUser.VipLv, payType);
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.ZiDongGouMaiJingLi))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return(false);
                }
                if (ops == 1)
                {
                    this.ErrorCode = 1;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1010_PayEnergyUseGold, useGold, payEnergy);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum < useGold)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }

                    ContextUser.UseGold   = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
                    ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, payEnergy, short.MaxValue);

                    if (userRestrain != null)
                    {
                        userRestrain.Funtion4 = MathUtils.Addition(userRestrain.Funtion4, 1, int.MaxValue);
                    }
                    else
                    {
                        userRestrain             = new UserDailyRestrain();
                        userRestrain.UserID      = ContextUser.UserID;
                        userRestrain.RefreshDate = DateTime.Now;
                        userRestrain.Funtion4    = 1;
                        cacheSet.Add(userRestrain);
                    }

                    UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, userRestrain.Funtion4, 1, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue));
                }
            }
            return(true);
        }
コード例 #8
0
ファイル: Action1010.cs プロジェクト: xushenghan/Scut-samples
        public static int GetPayEnergyGold(string userID, int vipLv, int payType)
        {
            int payNum  = FestivalHelper.SurplusEnergyNum(userID);
            int currNum = 0;
            int maxNum  = 0;

            if (payNum == 0)
            {
                UserDailyRestrain dailyRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(userID);
                maxNum = VipHelper.GetVipUseNum(vipLv, RestrainType.GouMaiJingLi);

                if (DateTime.Now.Date == dailyRestrain.RefreshDate.Date)
                {
                    currNum = dailyRestrain.Funtion4;
                }
                else
                {
                    currNum = 0;
                }
            }
            int useGold = 0;

            if (payType == 1)
            {
                if (currNum == 0)
                {
                    useGold = 20;
                }
                else if (currNum > 0 && currNum <= 5)
                {
                    useGold = 20;
                }
                else if (currNum > 5 && currNum <= 20)
                {
                    useGold = 80;
                }
                else if (currNum > 20 && currNum <= 45)
                {
                    useGold = 200;
                }
                else if (currNum > 45 && currNum <= 80)
                {
                    useGold = 400;
                }
            }
            else if (payType == 2)
            {
                for (int i = currNum; i < maxNum; i++)
                {
                    if (currNum == 1)
                    {
                        useGold = 20;
                    }
                    else if (currNum > 1 && currNum <= 5)
                    {
                        useGold += 40;
                    }
                    else if (currNum > 5 && currNum <= 20)
                    {
                        useGold += 80;
                    }
                    else if (currNum > 20 && currNum <= 45)
                    {
                        useGold += 200;
                    }
                    else if (currNum > 45 && currNum <= 80)
                    {
                        useGold += 400;
                    }
                }
            }
            return(useGold);
        }
コード例 #9
0
ファイル: Action1011.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            UserHelper.ChechDailyRestrain(ContextUser.UserID);
            int wjkNum = 0;
            int subNum = 0;
            int maxNum = VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.WaJinKuang);
            UserDailyRestrain userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID);

            if (userRestrain != null && DateTime.Now.Date == userRestrain.RefreshDate.Date)
            {
                wjkNum = userRestrain.Funtion3;
                subNum = MathUtils.Subtraction(maxNum, wjkNum);
            }
            else
            {
                wjkNum = 0;
                subNum = maxNum;
            }

            if ((userRestrain != null && userRestrain.Funtion3 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.WaJinKuang) && DateTime.Now.Date == userRestrain.RefreshDate.Date))
            {
                ErrorCode = 2;
                ErrorInfo = LanguageManager.GetLang().St1011_WaJinKuangFull;
                return(false);
            }

            int useGold    = GetPayCoinGold(ContextUser.UserID, ContextUser.VipLv, payType);
            int payCoinNum = GetPayCoinNum(ContextUser.UserID, ContextUser.VipLv, payType, ContextUser.UserLv);

            if (payType == 1)
            {
                if (ops == 1)
                {
                    this.ErrorCode = 1;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1011_PayUseGold, useGold, payCoinNum, subNum);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum < useGold)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }

                    if (ContextUser.GoldNum >= useGold)
                    {
                        int goldNum = ContextUser.GoldNum;
                        ContextUser.UseGold  = MathUtils.Addition(ContextUser.UseGold, useGold);
                        ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, payCoinNum);
                        //ContextUser.Update();

                        if (userRestrain != null)
                        {
                            userRestrain.Funtion3 = MathUtils.Addition(wjkNum, 1);
                            //userRestrain.Update();
                            UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 2, 0, userRestrain.Funtion3, useGold,
                                                          ContextUser.GoldNum, goldNum);
                        }
                    }
                    this.ErrorCode = 0;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1011_PayCoinUseGold, useGold, payCoinNum, subNum - 1);
                    return(false);
                }
            }
            else if (payType == 2)
            {
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.ZiDongJinRuJinKuangDong))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return(false);
                }
                if (ops == 1)
                {
                    this.ErrorCode = 0;
                    this.ErrorInfo = string.Format(LanguageManager.GetLang().St1011_PayCoinUseGold, useGold, payCoinNum, subNum);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.VipLv < 6)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
                        return(false);
                    }
                    if (ContextUser.GoldNum < useGold)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }


                    if (userRestrain != null)
                    {
                        userRestrain.Funtion3 = MathUtils.Addition(wjkNum, 1);
                        //userRestrain.Update();
                    }
                    int gamecoin = GetPayCoinNum(ContextUser.UserID, ContextUser.VipLv, payType, ContextUser.UserLv);
                    ContextUser.UseGold  = MathUtils.Addition(ContextUser.UseGold, useGold);
                    ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, gamecoin);
                    //ContextUser.Update();
                }
            }
            return(true);
        }
コード例 #10
0
ファイル: Action1011.cs プロジェクト: dongliang/Scut
        /// <summary>
        /// 挖金矿花费晶石
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="payType"></param>
        /// <param name="vipLv"></param>
        /// <returns></returns>
        public static int GetPayCoinGold(string userID, int vipLv, int payType)
        {
            UserDailyRestrain userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(userID);
            int maxNum  = VipHelper.GetVipUseNum(vipLv, RestrainType.WaJinKuang);
            int subNum  = 0;
            int currNum = 0;

            if (DateTime.Now.Date == userRestrain.RefreshDate.Date)
            {
                subNum = MathUtils.Addition(userRestrain.Funtion3, 1, int.MaxValue);

                currNum = MathUtils.Subtraction(maxNum, userRestrain.Funtion3, 0);
            }
            else
            {
                currNum = 0;
            }
            int useGold = 0;

            if (payType == 1)
            {
                if (subNum >= 1 && subNum <= 9)
                {
                    useGold = (subNum * 2);
                }
                else if (subNum >= 10 && subNum <= 30)
                {
                    useGold = 20;
                }
                else if (subNum >= 31 && subNum <= 50)
                {
                    useGold = 50;
                }
                else if (subNum >= 51 && subNum <= 100)
                {
                    useGold = 100;
                }
                else if (subNum >= 101 && subNum <= 200)
                {
                    useGold = 200;
                }
                else
                {
                    useGold = 2;
                }
            }
            else if (payType == 2)
            {
                for (int i = currNum; i < maxNum; i++)
                {
                    if (currNum >= 1 && currNum <= 9)
                    {
                        useGold += (currNum * 2);
                    }
                    else if (currNum > 10 && currNum <= 30)
                    {
                        useGold += 20;
                    }
                    else if (currNum > 31 && currNum <= 50)
                    {
                        useGold += 50;
                    }
                    else if (currNum > 51 && currNum <= 100)
                    {
                        useGold += 100;
                    }
                    else if (currNum > 101 && currNum <= 200)
                    {
                        useGold += 200;
                    }
                }
            }
            return(useGold);
        }
コード例 #11
0
ファイル: Action6012.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                return(false);
            }
            if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.GuildMemberShangSuHeXiang) && idolID == 2)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                return(false);
            }

            if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.GuildMemberShangTianMuXiang) && idolID == 3)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                return(false);
            }

            GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);

            if (member != null)
            {
                GuildIdolInfo     idolInfo      = new ShareCacheStruct <GuildIdolInfo>().FindKey(idolID);
                var               memberLog     = new ShareCacheStruct <GuildMemberLog>().FindKey(ContextUser.MercenariesID) ?? new GuildMemberLog();
                List <MemberLog>  guildLogArray = memberLog.GetLog(u => u.UserID == ContextUser.UserID && DateTime.Now.Date == u.InsertDate.Date);
                UserDailyRestrain userRestrain  = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID);
                if (guildLogArray.Count > 0 && userRestrain.Funtion6 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.BangPaiShangXiang) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St6012_HasIncenseToday;
                    return(false);
                }
                if (idolInfo.UseExpNum != 0 && ContextUser.ExpNum <= idolInfo.UseExpNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_ExpNumNotEnough;
                    return(false);
                }
                else if (idolInfo.UseGold != 0 && ContextUser.GoldNum < idolInfo.UseGold)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                //UserGuild userGuild = new ShareCacheStruct<UserGuild>().FindKey(guildID);


                userRestrain.Funtion6 = MathUtils.Addition(userRestrain.Funtion6, 1, int.MaxValue);
                //userRestrain.Update();
                UpIdolLv(ContextUser.MercenariesID, idolInfo.GainAura);

                ContextUser.UseGold   = MathUtils.Addition(ContextUser.UseGold, idolInfo.UseGold, int.MaxValue);
                ContextUser.ExpNum    = MathUtils.Subtraction(ContextUser.ExpNum, idolInfo.UseExpNum, 0);
                ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, idolInfo.GainObtion, int.MaxValue);
                //ContextUser.Update();

                UserHelper.UserGuildUpLv(ContextUser.MercenariesID, idolInfo.GainObtion);
                if (DateTime.Now.Date == member.IncenseDate.Date)
                {
                    member.GainBlessing = idolInfo.GainBlessing;
                    member.IncenseNum   = MathUtils.Addition(member.IncenseNum, 1, int.MaxValue);
                    member.Contribution = MathUtils.Addition(member.Contribution, idolInfo.GainObtion, int.MaxValue);
                }
                else
                {
                    member.IncenseNum   = 1;
                    member.GainBlessing = idolInfo.GainBlessing;
                    member.Contribution = idolInfo.GainObtion;
                }
                member.TotalContribution = MathUtils.Addition(member.TotalContribution, idolInfo.GainObtion, int.MaxValue);
                member.IncenseDate       = DateTime.Now;
                //member.Update();

                GuildMemberLog.AddLog(member.GuildID, new MemberLog()
                {
                    UserID     = ContextUser.UserID,
                    IdolID     = idolID,
                    LogType    = 2,
                    GainObtion = idolInfo.GainObtion,
                    Experience = idolInfo.GainObtion,
                    GainAura   = idolInfo.GainAura,
                    InsertDate = DateTime.Now,
                });
            }

            return(true);
        }
コード例 #12
0
ファイル: Action1305.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            UserHelper.GetUserLightOpen(ContextUser.UserID);
            short opType     = 0;
            int   huntingID2 = 0;

            if (huntingID < 1005)
            {
                huntingID2 = MathUtils.Addition(huntingID, 1, int.MaxValue);
            }
            else
            {
                huntingID2 = 1001; //huntingID;
            }
            UserHelper.ChechDailyRestrain(ContextUser.UserID);

            if (!CrystalHelper.CheckAllowCrystall(ContextUser))
            {
                ErrorCode = 1000;
                ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull;
                return(false);
            }
            else
            {
                if (!CrystalHelper.CheckAllowCrystall(ContextUser))
                {
                    ErrorCode = errorNum;
                    ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull;
                    return(false);
                }
            }

            ProbabilityInfo probabilityInfo = null;

            if (ops == 1)
            {
                #region
                opType = 1;
                UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID);
                probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
                if (probabilityInfo == null)
                {
                    return(false);
                }
                ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2);
                if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                {
                    if (probabilityInfo.Price > ContextUser.GameCoin)
                    {
                        ErrorCode = errorNum;
                        ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                        return(false);
                    }
                }
                //暑期第三弹
                if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(ContextUser))
                {
                    ErrorCode = errorNum;
                    ErrorInfo = LanguageManager.GetLang().St1305_BeiBaoBackpackFull;
                    return(false);
                }
                var lightCacheSet = new PersonalCacheStruct <UserLight>();
                if (huntingID != 1001)
                {
                    UserLight userLight1 = lightCacheSet.FindKey(ContextUser.UserID, huntingID);
                    if (userLight1.IsLight == 2)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        return(false);
                    }

                    if (userLight1.IsLight == 1)
                    {
                        userLight1.IsLight = 2;
                        //userLight1.Update();
                    }
                }
                UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, huntingID2);
                if (RandomUtils.IsHit(probability1.Light))
                {
                    ErrorCode = ErrorCode;
                    ErrorInfo = probability1.HuntingName;

                    if (userLight != null)
                    {
                        userLight.IsLight = 1;
                        //userLight.Update();
                    }
                    else
                    {
                        userLight = new UserLight()
                        {
                            UserID    = ContextUser.UserID,
                            HuntingID = huntingID2,
                            IsLight   = 1
                        };
                        lightCacheSet.Add(userLight);
                    }
                }

                if (userRestrain != null)
                {
                    if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
                    {
                        ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0);
                        //ContextUser.Update();
                    }
                    else
                    {
                        userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue);
                        //userRestrain.Update();
                    }
                }
                else
                {
                    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0);
                    //ContextUser.Update();
                }

                lightArray = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID);
                #endregion
            }
            else if (ops == 2)
            {
                #region
                opType = 2;
                if (ContextUser.VipLv < 5)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
                    return(false);
                }

                probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
                if (probabilityInfo == null)
                {
                    return(false);
                }

                if (ContextUser.GoldNum < probabilityInfo.Price)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                UserLight uLightInfo = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, probabilityInfo.GoldHunting);
                if (uLightInfo != null && uLightInfo.IsLight == 1)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1305_HuntingIDLight;
                    return(false);
                }
                else if (uLightInfo != null && (uLightInfo.IsLight == 2 || uLightInfo.IsLight == 0))
                {
                    uLightInfo.IsLight = 1;
                }
                else
                {
                    uLightInfo = new UserLight()
                    {
                        UserID    = ContextUser.UserID,
                        HuntingID = probabilityInfo.GoldHunting,
                        IsLight   = 1
                    };
                    new PersonalCacheStruct <UserLight>().Add(uLightInfo);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue);
                lightArray          = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID);
                #endregion
            }

            //每种品质的概率
            double[]           probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red };
            int                index2            = RandomUtils.GetHitIndex(probabilityArray2);
            CrystalQualityType qualityType       = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString());
            List <CrystalInfo> crystalArray2     = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv);
            if (crystalArray2.Count > 0)
            {
                int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID);
                if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray)
                {
                    //wuzf修改 8-15 灰色放在临时背包不存DB
                    CrystalHelper.AppendGrayCrystal(ContextUser, crystal.CrystalID);
                }
                else if (crystal != null)
                {
                    var package = UserCrystalPackage.Get(Uid);

                    UserCrystalInfo userCrystal = new UserCrystalInfo()
                    {
                        UserCrystalID = Guid.NewGuid().ToString(),
                        CrystalID     = crystal.CrystalID,
                        CrystalLv     = 1,
                        CurrExprience = 0,
                        GeneralID     = 0,
                        IsSale        = 1,
                        CreateDate    = DateTime.Now
                    };
                    package.SaveCrystal(userCrystal);
                    UserLogHelper.AppenCtystalLog(ContextUser.UserID, opType, crystal.CrystalID, probabilityInfo.Price, probabilityInfo.Price, null, 1, 0);
                    //高品质聊天通知);
                    if (crystal.CrystalQuality >= CrystalQualityType.Yellow)
                    {
                        var    cacheChat = new TjxChatService();
                        string content   = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice,
                                                         ContextUser.NickName,
                                                         CrystalHelper.GetQualityName(crystal.CrystalQuality),
                                                         crystal.CrystalName
                                                         );
                        cacheChat.SystemSend(ChatType.World, content);
                    }
                }
            }

            //日常任务-猎命
            TaskHelper.TriggerDailyTask(Uid, 4009);
            return(true);
        }