Exemple #1
0
        /// <summary>
        /// 精力,金矿洞,免费猎命,竞技场挑战次数
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static HelperInfo GetDailyEnergy(GameUser user, RestrainType restrainType)
        {
            UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(user.UserID);
            int maxNum     = VipHelper.GetVipUseNum(user.VipLv, restrainType);
            int currPayNum = 0;

            if (dailyRestrain != null && DateTime.Now.Date == dailyRestrain.RefreshDate.Date)
            {
                if (restrainType == RestrainType.GouMaiJingLi)
                {
                    currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion4, 0);
                }
                else if (restrainType == RestrainType.WaJinKuang)
                {
                    currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion3, 0);
                }
                else if (restrainType == RestrainType.MianFeiLieMing)
                {
                    currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion2, 0);
                }
                else if (restrainType == RestrainType.JingJiChangTiaoZhan)
                {
                    UserChallengeNum userChallenge = new GameDataCacheSet <UserChallengeNum>().FindKey(user.UserID);
                    if (userChallenge != null && DateTime.Now.Date == userChallenge.InsertDate.Date)
                    {
                        //当日总挑战次数
                        currPayNum = MathUtils.Addition(maxNum, userChallenge.ChallengeNum, int.MaxValue);
                        currPayNum = MathUtils.Subtraction(currPayNum, dailyRestrain.Funtion9, 0);
                    }
                    else
                    {
                        currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion9, 0);
                    }
                }
            }
            else
            {
                currPayNum = maxNum;
            }
            //if (restrainType == RestrainType.JingJiChangTiaoZhan)
            //{
            //    UserChallengeNum userChallenge = new GameDataCacheSet<UserChallengeNum>().FindKey(user.UserID);
            //    if (userChallenge != null && DateTime.Now.Date == userChallenge.InsertDate.Date)
            //    {
            //        currPayNum = currPayNum.Addition(userChallenge.ChallengeNum, int.MaxValue); //当日总挑战次数
            //        currPayNum = maxNum.Subtraction(currPayNum, 0);
            //    }
            //}
            return(new HelperInfo()
            {
                Type = restrainType, SurplusNum = currPayNum, TotalNum = maxNum
            });
        }
Exemple #2
0
        public static string HuntingLife(GameUser user, out string errStr)
        {
            #region
            errStr = string.Empty;
            int huntingID  = UserLightLit(user.UserID);
            int huntingID2 = UserNextLight(user.UserID, huntingID);
            UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(user.UserID);
            var probabilityInfo            = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
            if (probabilityInfo == null)
            {
                return(errStr);
            }
            ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2);
            if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
            {
                if (probabilityInfo.Price > user.GameCoin)
                {
                    errStr = LanguageManager.GetLang().St_GameCoinNotEnough;
                    return(errStr);
                }
            }
            //暑期第三弹
            if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(user))
            {
                errStr = LanguageManager.GetLang().St1305_BeiBaoBackpackFull;
                return(errStr);
            }
            var lightCacheSet = new PersonalCacheStruct <UserLight>();
            if (huntingID != 1001)
            {
                UserLight userLight1 = lightCacheSet.FindKey(user.UserID, huntingID);
                if (userLight1.IsLight == 2)
                {
                    return(string.Empty);
                }
                if (userLight1.IsLight == 1)
                {
                    userLight1.IsLight = 2;
                }
            }
            UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(user.UserID, huntingID2);
            if (RandomUtils.IsHit(probability1.Light))
            {
                if (userLight != null)
                {
                    userLight.IsLight = 1;
                    if (userLight.HuntingID == 1005)
                    {
                        errStr = LanguageManager.GetLang().St1305_HuntingIDLight;
                    }
                }
                else
                {
                    userLight = new UserLight()
                    {
                        UserID    = user.UserID,
                        HuntingID = huntingID2,
                        IsLight   = 1
                    };
                    lightCacheSet.Add(userLight);
                }
            }

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

            //每种品质的概率
            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 <= user.UserLv);
            if (crystalArray2.Count > 0)
            {
                int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                var crystal   = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID);
                if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray)
                {
                    //wuzf修改 8-15 灰色放在临时背包不存DB
                    CrystalHelper.AppendGrayCrystal(user, crystal.CrystalID);
                }
                else if (crystal != null)
                {
                    var package = UserCrystalPackage.Get(user.UserID);

                    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(user.UserID, 5, crystal.CrystalID, probabilityInfo.Price, 0, null, 1, 0);
                    //高品质聊天通知);
                    if (crystal.CrystalQuality >= CrystalQualityType.Yellow)
                    {
                        var    cacheChat = new TjxChatService();
                        string content   = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice,
                                                         user.NickName,
                                                         CrystalHelper.GetQualityName(crystal.CrystalQuality),
                                                         crystal.CrystalName
                                                         );
                        cacheChat.SystemSend(ChatType.World, content);
                    }
                }
            }
            return(errStr);

            #endregion
        }