コード例 #1
0
        /// <summary>
        /// 累计消费活动
        /// </summary>
        public static void TriggerFestivalConsume(string userID, int consumeNum, FestivalType festivalType)
        {
            FestivalInfo fest = GetInfo(festivalType);

            if (fest == null)
            {
                return;
            }
            var         cacheSet    = new GameDataCacheSet <UserConsume>();
            UserConsume userConsume = cacheSet.FindKey(userID);

            if (userConsume == null)
            {
                userConsume           = new UserConsume();
                userConsume.UserID    = userID;
                userConsume.GameCoin  = 0;
                userConsume.GoldNum   = 0;
                userConsume.EnergyNum = 0;
                cacheSet.Add(userConsume);
                cacheSet.Update();
                userConsume = new GameDataCacheSet <UserConsume>().FindKey(userID);
            }
            //晶石
            if (festivalType == FestivalType.SparConsumption)
            {
                if (userConsume.GoldDate < fest.StartDate)
                {
                    userConsume.GoldDate = fest.StartDate;
                    userConsume.GoldNum  = consumeNum;
                }
                else
                {
                    userConsume.GoldNum = MathUtils.Addition(userConsume.GoldNum, consumeNum);
                }
            }

            //金币
            if (festivalType == FestivalType.GameCoin)
            {
                if (userConsume.CoinDate < fest.StartDate)
                {
                    userConsume.CoinDate = fest.StartDate;
                    userConsume.GameCoin = consumeNum;
                }
                else
                {
                    userConsume.GameCoin = MathUtils.Addition(userConsume.GameCoin, consumeNum);
                }
            }

            //精力
            if (festivalType == FestivalType.Energy)
            {
                if (userConsume.EnergyDate < fest.StartDate)
                {
                    userConsume.EnergyDate = fest.StartDate;
                    userConsume.EnergyNum  = consumeNum;
                }
                else
                {
                    userConsume.EnergyNum = MathUtils.Addition(userConsume.EnergyNum, consumeNum);
                }
            }
            FestivalInfo[] festivalInfosArray =
                new ShareCacheStruct <FestivalInfo>().FindAll(m => m.FestivalType == festivalType).ToArray();
            foreach (FestivalInfo festivalInfo in festivalInfosArray)
            {
                FestivalConsumeCount(festivalInfo, userID);
            }
        }
コード例 #2
0
        private static GeneralProperty GetAbilityProperty(string userID, int generalID, AbilityType abilityType)
        {
            decimal     val         = 0;
            int         careerID    = 0;
            UserGeneral ugeneral    = new GameDataCacheSet <UserGeneral>().FindKey(userID, generalID);
            GeneralInfo generalInfo = new ConfigCacheSet <GeneralInfo>().FindKey(generalID);

            if (ugeneral != null)
            {
                careerID = ugeneral.CareerID;
            }
            else if (generalInfo != null)
            {
                careerID = generalInfo.CareerID;
            }

            if (abilityType == AbilityType.WuLiGongJi || abilityType == AbilityType.WuLiFangYu || abilityType == AbilityType.HunJiGongJi || abilityType == AbilityType.HunJiFangYu || abilityType == AbilityType.MoFaGongJi || abilityType == AbilityType.MoFaFangYu)
            {
                int equNum      = GetEquNum(userID, generalID, abilityType).ToInt();
                int fateNum     = GetFateNum(userID, generalID, abilityType).ToInt();
                int propertyNum = GetPropertyNum(userID, generalID, abilityType).ToInt();
                int magicNum    = (int)GetEmbattleNum(userID, abilityType);
                int upgradeNum  = GeneralUpGradeProperty(userID, generalID, abilityType).ToInt();

                val = MathUtils.Addition(equNum, fateNum, int.MaxValue);
                val = MathUtils.Addition(val, propertyNum, int.MaxValue);
                val = MathUtils.Addition(val, magicNum, int.MaxValue);
                val = MathUtils.Addition(val, upgradeNum);

                //佣兵好感度数值加成
                int feelNum = FeelEffectNum(userID, generalID, abilityType);
                val = MathUtils.Addition(val, feelNum, int.MaxValue);
                //法宝附加属性值
                int trumpPro = (int)TrumpAbilityAttack.TrumpGeneralProperty(userID, generalID, abilityType);
                val = MathUtils.Addition(val, trumpPro, int.MaxValue);

                //附魔符属性值
                int enchantNum = EnchantProprety(userID, generalID, abilityType).ToInt();
                val = MathUtils.Addition(val, enchantNum);

                //属性转换
                //val = MathUtils.Addition(val, (int)TrumpAbilityAttack.ConversionPropertyNum(userID, val, abilityType), int.MaxValue);
            }
            else if (abilityType == AbilityType.BaoJi || abilityType == AbilityType.MingZhong || abilityType == AbilityType.PoJi || abilityType == AbilityType.RenXing || abilityType == AbilityType.ShanBi || abilityType == AbilityType.GeDang || abilityType == AbilityType.BiSha)
            {
                val = GetCareerNum(careerID, abilityType);
                val = MathUtils.Addition(val, GetEquNum(userID, generalID, abilityType), decimal.MaxValue);
                val = MathUtils.Addition(val, GetFateNum(userID, generalID, abilityType), decimal.MaxValue);
                val = MathUtils.Addition(val, GetEmbattleNum(userID, abilityType), decimal.MaxValue);
                val = MathUtils.Addition(val, GeneralUpGradeProperty(userID, generalID, abilityType).ToDecimal());
                //法宝附加属性值
                decimal trumpPro = TrumpAbilityAttack.TrumpGeneralProperty(userID, generalID, abilityType);
                val = MathUtils.Addition(val, trumpPro, int.MaxValue);

                //附魔符属性值
                decimal enchantNum = EnchantProprety(userID, generalID, abilityType);
                val = MathUtils.Addition(val, enchantNum);

                //属性转换
                //val = MathUtils.Addition(val, TrumpAbilityAttack.ConversionPropertyNum(userID, val, abilityType), decimal.MaxValue);
            }
            return(new GeneralProperty()
            {
                AbilityType = abilityType, AbilityValue = val
            });
        }
コード例 #3
0
        /// <summary>
        /// 佣兵属性集合
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="generalID"></param>
        /// <returns></returns>
        public static List <GeneralProperty> GetAbility(string userID, int generalID, UserGeneral userGeneral)
        {
            List <GeneralProperty> gPropertyList = new List <GeneralProperty>();
            var             cacheSetUserEmbattle = new GameDataCacheSet <UserEmbattle>();
            GeneralProperty generalProperty      = new GeneralProperty();
            var             userMagic            = new GameDataCacheSet <UserMagic>().Find(userID, s => s.IsEnabled);
            CombatGeneral   combatGeneral        = new CombatGeneral()
            {
                UserID       = userID,
                GeneralID    = generalID,
                ExtraAttack  = new CombatProperty(),
                ExtraDefense = new CombatProperty(),
                LifeNum      = userGeneral.LifeNum,
                LifeMaxNum   = userGeneral.LifeMaxNum
            };


            var userEmbattleList = cacheSetUserEmbattle.FindAll(userID,
                                                                s =>
                                                                s.MagicID == (userMagic != null ? userMagic.MagicID : 0));

            UserEmbattleQueue.embattleList = userEmbattleList;
            UserEmbattleQueue.KarmaAddition(userID, combatGeneral);
            userGeneral.TLifeNum    = combatGeneral.LifeNum;
            userGeneral.TLifeMaxNun = combatGeneral.LifeMaxNum;
            //int LifeReply = 0; // 生命回复
            //物理攻击
            generalProperty = GetAbilityProperty(userID, generalID, AbilityType.WuLiGongJi);
            generalProperty.AbilityValue = MathUtils.Addition(generalProperty.AbilityValue, generalProperty.AbilityValue * combatGeneral.ExtraAttack.AdditionWuliNum);
            gPropertyList.Add(generalProperty);
            //物理防御
            generalProperty = GetAbilityProperty(userID, generalID, AbilityType.WuLiFangYu);
            generalProperty.AbilityValue = MathUtils.Addition(generalProperty.AbilityValue, generalProperty.AbilityValue * combatGeneral.ExtraDefense.AdditionWuliNum);
            gPropertyList.Add(generalProperty);
            //魂技攻击
            generalProperty = GetAbilityProperty(userID, generalID, AbilityType.HunJiGongJi);
            generalProperty.AbilityValue = MathUtils.Addition(generalProperty.AbilityValue, generalProperty.AbilityValue * combatGeneral.ExtraAttack.AdditionHunjiNum);
            gPropertyList.Add(generalProperty);
            //魂技防御
            generalProperty = GetAbilityProperty(userID, generalID, AbilityType.HunJiFangYu);
            generalProperty.AbilityValue = MathUtils.Addition(generalProperty.AbilityValue, generalProperty.AbilityValue * combatGeneral.ExtraDefense.AdditionHunjiNum);
            gPropertyList.Add(generalProperty);
            //魔法攻击
            generalProperty = GetAbilityProperty(userID, generalID, AbilityType.MoFaGongJi);
            generalProperty.AbilityValue = MathUtils.Addition(generalProperty.AbilityValue, generalProperty.AbilityValue * combatGeneral.ExtraAttack.AdditionMofaNum);
            gPropertyList.Add(generalProperty);
            //魔法防御
            generalProperty = GetAbilityProperty(userID, generalID, AbilityType.MoFaFangYu);
            generalProperty.AbilityValue = MathUtils.Addition(generalProperty.AbilityValue, generalProperty.AbilityValue * combatGeneral.ExtraDefense.AdditionMofaNum);
            gPropertyList.Add(generalProperty);

            //暴击
            gPropertyList.Add(GetAbilityProperty(userID, generalID, AbilityType.BaoJi));
            //命中
            gPropertyList.Add(GetAbilityProperty(userID, generalID, AbilityType.MingZhong));
            //破击
            gPropertyList.Add(GetAbilityProperty(userID, generalID, AbilityType.PoJi));
            //韧性
            gPropertyList.Add(GetAbilityProperty(userID, generalID, AbilityType.RenXing));
            //闪避
            gPropertyList.Add(GetAbilityProperty(userID, generalID, AbilityType.ShanBi));
            //格挡
            gPropertyList.Add(GetAbilityProperty(userID, generalID, AbilityType.GeDang));
            //必杀
            gPropertyList.Add(GetAbilityProperty(userID, generalID, AbilityType.BiSha));

            //先攻
            gPropertyList.Add(new GeneralProperty()
            {
                AbilityType = AbilityType.FirstStrike, AbilityValue = (decimal)TotalPriorityNum(userID, generalID)
            });

            return(gPropertyList);
        }
コード例 #4
0
ファイル: Action1403.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            int    currMaxLv  = GameConfigSet.CurrMaxLv;
            string lifeUserID = string.Empty;

            UserCrystalInfo[] userCrystalsArrray = new UserCrystalInfo[0];
            if (!string.IsNullOrEmpty(toUserID))
            {
                var packageCrystal = UserCrystalPackage.Get(toUserID);
                userGeneral        = new GameDataCacheSet <UserGeneral>().FindKey(toUserID, generalID);
                userCrystalsArrray = packageCrystal.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)).ToArray();
                var package = UserItemPackage.Get(toUserID);
                userItemArray = package.ItemPackage.FindAll(
                    u => !u.IsRemove && u.GeneralID.Equals(generalID) &&
                    u.ItemStatus == ItemStatus.YongBing);
                lifeUserID = toUserID;
            }
            else
            {
                var packageCrystal = UserCrystalPackage.Get(ContextUser.UserID);
                userGeneral        = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID);
                userCrystalsArrray = packageCrystal.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)).ToArray();

                var package = UserItemPackage.Get(ContextUser.UserID);
                userItemArray = package.ItemPackage.FindAll(u => !u.IsRemove && u.GeneralID.Equals(generalID) && u.ItemStatus == ItemStatus.YongBing);
                lifeUserID    = ContextUser.UserID;
            }
            UserCacheGlobal.LoadOffline(lifeUserID);
            GeneralInfo generalInfo = new ConfigCacheSet <GeneralInfo>().FindKey(generalID);

            generalQuality = generalInfo == null ? (short)0 : generalInfo.GeneralQuality;
            if (generalInfo != null && userGeneral != null)
            {
                description = generalInfo.Description;
                if (userGeneral.GeneralLv >= currMaxLv)
                {
                    genLv = (short)currMaxLv;
                    userGeneral.CurrExperience = 0;
                }
                else
                {
                    genLv = userGeneral.GeneralLv;
                }
                generalName     = userGeneral.GeneralName;
                headID          = userGeneral.HeadID;
                picturesID      = userGeneral.PicturesID;
                _battleHeadId   = generalInfo.BattleHeadID;
                _hitProbability = generalInfo.HitProbability;
                careerInfo      = new ConfigCacheSet <CareerInfo>().FindKey(userGeneral.CareerID);
                GeneralEscalateInfo generalEscalate = new ConfigCacheSet <GeneralEscalateInfo>().FindKey(genLv);
                if (generalEscalate != null)
                {
                    currExperience = userGeneral.CurrExperience;
                    maxExperience  = generalEscalate.UpExperience;
                }
                powerNum     = MathUtils.Addition(userGeneral.PowerNum, userGeneral.TrainingPower, short.MaxValue);
                soulNum      = MathUtils.Addition(userGeneral.SoulNum, userGeneral.TrainingSoul, short.MaxValue);
                intellectNum = MathUtils.Addition(userGeneral.IntellectNum, userGeneral.TrainingIntellect, short.MaxValue);
                if (!string.IsNullOrEmpty(ContextUser.MercenariesID) && generalID == LanguageManager.GetLang().GameUserGeneralID)
                {
                    //公会技能加成
                    powerNum     = MathUtils.RoundCustom(powerNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.PowerNum)).ToShort();
                    soulNum      = MathUtils.RoundCustom(soulNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.SoulNum)).ToShort();
                    intellectNum = MathUtils.RoundCustom(intellectNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.IntellectNum)).ToShort();
                }
                if (generalID == LanguageManager.GetLang().GameUserGeneralID)
                {
                    //法宝基础属性加成
                    powerNum     = MathUtils.Addition(powerNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.PowerNum));
                    soulNum      = MathUtils.Addition(soulNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.SoulNum));
                    intellectNum = MathUtils.Addition(intellectNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.IntelligenceNum));

                    //法宝--技能属性转换获得的值
                    //法宝--技能属性转换获得的值
                    decimal trumpPower     = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.PowerNum);
                    decimal trumpsoul      = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.SoulNum);
                    decimal trumpintellect = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.IntelligenceNum);
                    powerNum     = MathUtils.Addition(trumpPower.ToShort(), powerNum);
                    soulNum      = MathUtils.Addition(trumpsoul.ToShort(), soulNum);
                    intellectNum = MathUtils.Addition(trumpintellect.ToShort(), intellectNum);
                }
                lifeNum       = userGeneral.LifeNum;
                lifeMaxNum    = UserHelper.GetMaxLife(lifeUserID, generalID);
                genLv         = userGeneral.GeneralLv;
                generalStatus = (short)userGeneral.GeneralStatus;

                talentAbility = userGeneral.AbilityID;
                _potential    = userGeneral.Potential;
                _battleHeadID = generalInfo.BattleHeadID;
                //玩家佣兵职业名称
                userCareerName = careerInfo.CareerName;
            }
            else if (generalInfo != null)
            {
                genLv         = 1;
                generalName   = generalInfo.GeneralName;
                headID        = generalInfo.HeadID;
                picturesID    = generalInfo.PicturesID;
                _battleHeadId = generalInfo.BattleHeadID;
                careerInfo    = new ConfigCacheSet <CareerInfo>().FindKey(generalInfo.CareerID);
                GeneralEscalateInfo generalEscalate = new ConfigCacheSet <GeneralEscalateInfo>().FindKey(genLv);
                if (generalEscalate != null)
                {
                    currExperience = 0;
                    maxExperience  = generalEscalate.UpExperience;
                }
                powerNum      = generalInfo.PowerNum;
                soulNum       = generalInfo.SoulNum;
                intellectNum  = generalInfo.IntellectNum;
                lifeNum       = generalInfo.LifeNum;
                lifeMaxNum    = generalInfo.LifeNum;
                genLv         = generalInfo.GeneralLv;
                generalStatus = (short)GeneralStatus.KeZhaoMu;

                talentAbility = generalInfo.AbilityID;
            }
            AbilityInfo ability = new ConfigCacheSet <AbilityInfo>().FindKey(talentAbility);

            talentName = ability == null ? string.Empty : ability.AbilityName;

            gPropertyList = CombatHelper.GetAbility(lifeUserID, generalID, userGeneral);

            int sumCrystal = 0;

            foreach (UserCrystalInfo crystal in userCrystalsArrray)
            {
                sumCrystal = MathUtils.Addition(sumCrystal, crystal.CurrExprience, int.MaxValue);
            }
            vitalityNum  = (sumCrystal / 10);
            functionList = ViewHelper.GetFunctionList(lifeUserID);

            //佣兵魂技
            UserAbility userAbility = new GameDataCacheSet <UserAbility>().FindKey(ContextUser.UserID);

            if (userAbility != null)
            {
                abilityList = userAbility.AbilityList.FindAll(s => s.GeneralID == generalID);
            }
            soulGrid = UserPackHelper.GetPackTypePositionNum(BackpackType.HunJi, ContextUser.UserID);

            // 缘分系统
            KarmaInfo karmaInfo = new ShareCacheStruct <KarmaInfo>().FindKey(generalID);

            if (karmaInfo != null && karmaInfo.KarmaList != null)
            {
                // 满足缘分条件显示激活状态

                // 判断佣兵
                UserMagic    userMagic            = new GameDataCacheSet <UserMagic>().Find(ContextUser.UserID, s => s.IsEnabled);
                var          cacheSetUserEmbattle = new GameDataCacheSet <UserEmbattle>();
                List <Karma> yongBingList         = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.YongBing);
                yongBingList.ForEach(yongBingInfo =>
                {
                    //yongBingInfo.IsActive = 1;
                    // 若阵型中存在该记录,该缘分为激活状态
                    if (yongBingInfo.ValueID.Contains(","))
                    {
                        string[] valueID = yongBingInfo.ValueID.Split(',');
                        int i            = 0;
                        foreach (var id in valueID)
                        {
                            if (cacheSetUserEmbattle.Find(ContextUser.UserID, s => s.MagicID == userMagic.MagicID && s.GeneralID == MathUtils.ToInt(id)) != null)
                            {
                                i++;
                            }
                        }
                        yongBingInfo.IsActive = i == valueID.Length ? 1 : 0;
                    }
                    else
                    {
                        if (cacheSetUserEmbattle.Find(ContextUser.UserID, s => s.MagicID == userMagic.MagicID && s.GeneralID == MathUtils.ToInt(yongBingInfo.ValueID)) != null)
                        {
                            yongBingInfo.IsActive = 1;
                        }
                        else
                        {
                            yongBingInfo.IsActive = 0;
                        }
                    }
                });
                // 判断装备
                UserItemPackage itemPackage = new GameDataCacheSet <UserItemPackage>().FindKey(UserId.ToString());
                if (itemPackage != null)
                {
                    List <Karma> itemList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.ZhuangBei);
                    itemList.ForEach(itemInfo =>
                    {
                        if (itemPackage.ItemPackage.Find(s => s.ItemID == MathUtils.ToInt(itemInfo.ValueID) && s.GeneralID == generalID) != null)
                        {
                            itemInfo.IsActive = 1;
                        }
                        else
                        {
                            itemInfo.IsActive = 0;
                        }
                    });
                }

                // 判断命运水晶
                UserCrystalPackage crystalPackage = new GameDataCacheSet <UserCrystalPackage>().FindKey(UserId.ToString());
                if (itemPackage != null)
                {
                    List <Karma> crystalList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.ShuiJing);
                    crystalList.ForEach(crystalInfo =>
                    {
                        if (crystalPackage.CrystalPackage.Find(s => s.CrystalID == MathUtils.ToInt(crystalInfo.ValueID) && s.GeneralID == generalID) != null)
                        {
                            crystalInfo.IsActive = 1;
                        }
                        else
                        {
                            crystalInfo.IsActive = 0;
                        }
                    });
                }

                // 判断技能
                UserAbility userAbilityInfo = new GameDataCacheSet <UserAbility>().FindKey(UserId.ToString());
                if (userAbilityInfo != null)
                {
                    List <Karma> abilityList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.JiNen);
                    abilityList.ForEach(abilityInfo =>
                    {
                        if (userAbilityInfo.AbilityList.Find(s => s.AbilityID == MathUtils.ToInt(abilityInfo.ValueID) && s.GeneralID == generalID) != null)
                        {
                            abilityInfo.IsActive = 1;
                        }
                        else
                        {
                            abilityInfo.IsActive = 0;
                        }
                    });
                }
                karmaList = karmaInfo.KarmaList;
                if (userGeneral != null)
                {
                    lifeNum    = userGeneral.TLifeNum;
                    lifeMaxNum = userGeneral.TLifeMaxNun;
                }
            }
            return(true);
        }
コード例 #5
0
        /// <summary>
        /// 玩家荣誉值升级
        /// </summary>
        /// <param name="user"></param>
        /// <param name="honourNum"></param>
        public static void AddUserLv(GameUser user, int honourNum)
        {
            short generalMaxLv = GameConfigSet.CurrMaxLv.ToShort();

            if (user.UserLv >= generalMaxLv)
            {
                CheckFun(user);
                return;
            }
            short rankLv = user.UserLv;

            user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum);
            short nextLv = MathUtils.Addition(user.UserLv, 1.ToShort());

            while (nextLv <= generalMaxLv)
            {
                GeneralEscalateInfo generalEscalate = new ShareCacheStruct <GeneralEscalateInfo>().FindKey(nextLv, GeneralType.YongHu);
                if (generalEscalate != null && user.HonourNum >= generalEscalate.UpExperience)
                {
                    user.UserLv = nextLv;
                    user.IsLv   = true;
                    UserHelper.OpenMagic(user.UserID, user.UserLv);
                    user.HonourNum = MathUtils.Subtraction(user.HonourNum, generalEscalate.UpExperience);

                    if (generalEscalate.FunctionEnum != null && generalEscalate.FunctionEnum != "")
                    {
                        var feArray = generalEscalate.FunctionEnum.Split(',');
                        foreach (var fun in feArray)
                        {
                            var userFun = _cacheSetUserFun.FindKey(user.UserID, fun);
                            if (userFun == null)
                            {
                                userFun            = new UserFunction();
                                userFun.UserID     = user.UserID;
                                userFun.FunEnum    = fun.ToEnum <FunctionEnum>();
                                userFun.CreateDate = DateTime.Now;
                                _cacheSetUserFun.Add(userFun);
                                _cacheSetUserFun.Update();
                                user.OpenFun.Add(userFun);
                            }
                        }
                    }
                    FestivalHelper.GetUpgradeGiveGift(user.UserID, nextLv);
                    nextLv = MathUtils.Addition(user.UserLv, 1.ToShort());
                }
                else
                {
                    break;
                }
            }
            if (user.UserLv > rankLv)
            {
                Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
                UserRank           rankInfo;
                int rankID;
                if (ranking.TryGetRankNo(m => m.UserID == user.UserID, out rankID))
                {
                    rankInfo = ranking.Find(s => s.UserID == user.UserID);
                    if (rankInfo != null)
                    {
                        rankInfo.UserLv         = user.UserLv;
                        rankInfo.TotalCombatNum = user.CombatNum;
                        rankInfo.ObtainNum      = user.ObtainNum;
                    }
                }
            }
            CheckFun(user);
        }
コード例 #6
0
 /// <summary>
 /// ��õȼ�Ч��
 /// </summary>
 /// <param name="lv"></param>
 /// <returns></returns>
 public int GetEffectNum(short lv)
 {
     return(MathUtils.Addition(BaseNum, lv * IncreaseNum, int.MaxValue));
 }
コード例 #7
0
ファイル: PrizeHelper.cs プロジェクト: zxx0367/Scut-samples
        /// <summary>
        /// 玩家获得奖励
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="prizeList"></param>
        /// <returns></returns>
        public static string GetPrizeUserTake(GameUser userInfo, List <PrizeInfo> prizeList)
        {
            string prizeContent = string.Empty;

            foreach (var prize in prizeList)
            {
                switch (prize.Type)
                {
                case RewardType.GameGoin:
                    userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, prize.Num);
                    prizeContent     += string.Format(LanguageManager.GetLang().St_GameCoin, prize.Num) + ",";
                    break;

                case RewardType.ExpNum:
                    userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, prize.Num);
                    prizeContent   += string.Format(LanguageManager.GetLang().St_ExpNum, prize.Num) + ",";
                    break;

                case RewardType.EnergyNum:
                    userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, prize.Num.ToShort());
                    prizeContent      += string.Format(LanguageManager.GetLang().St_EnergyNum, prize.Num) + ",";
                    break;

                case RewardType.HonourNum:
                    GeneralEscalateHelper.AddUserLv(userInfo, prize.Num);
                    prizeContent += string.Format(LanguageManager.GetLang().St_HonourNum, prize.Num) + ",";
                    break;

                case RewardType.Experience:
                    UserHelper.UserGeneralExp(userInfo.UserID, prize.Num);
                    prizeContent += string.Format(LanguageManager.GetLang().St_Experience, prize.Num) + ",";
                    break;

                case RewardType.Gold:
                    userInfo.GiftGold = MathUtils.Addition(userInfo.GiftGold, prize.Num);
                    prizeContent     += string.Format(LanguageManager.GetLang().St_GiftGoldNum, prize.Num) + ",";
                    break;

                case RewardType.Item:
                    short        itemLv   = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
                    int          priNum   = prize.Num > 0 ? prize.Num : 1;
                    ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(prize.ItemID);
                    if (itemInfo != null)
                    {
                        UserItemHelper.AddUserItem(userInfo.UserID, itemInfo.ItemID, priNum, itemLv);
                        prizeContent += string.Format("{0}*{1}", itemInfo.ItemName, priNum) + ",";
                    }
                    break;

                case RewardType.CrystalType:
                    List <CrystalInfo> crystalArray = new ConfigCacheSet <CrystalInfo>().FindAll(s => s.CrystalQuality == prize.CrystalType);
                    if (crystalArray.Count > 0)
                    {
                        int         index1      = RandomUtils.GetRandom(0, crystalArray.Count);
                        CrystalInfo crystalInfo = crystalArray[index1];
                        short       crystalLv   = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
                        CrystalHelper.AppendCrystal(userInfo.UserID, crystalInfo.CrystalID, crystalLv);
                    }
                    break;

                case RewardType.CrystalId:
                    short       cLv     = prize.UserLv > 0 ? prize.UserLv : 1.ToShort();
                    CrystalInfo crystal = new ConfigCacheSet <CrystalInfo>().FindKey(prize.ItemID);
                    if (crystal != null)
                    {
                        CrystalHelper.AppendCrystal(userInfo.UserID, crystal.CrystalID, cLv);
                        prizeContent += string.Format("{0}*{1}", crystal.CrystalName, prize.Num) + ",";
                    }
                    break;

                case RewardType.Spare:
                    break;

                case RewardType.Enchant:
                    break;

                case RewardType.PayGold:
                    userInfo.PayGold = MathUtils.Addition(userInfo.PayGold, prize.Num);
                    prizeContent    += string.Format(LanguageManager.GetLang().St_PayGoldNum, prize.Num) + ",";
                    break;

                default:
                    break;
                }
            }
            return(prizeContent);
        }
コード例 #8
0
ファイル: Action1202.cs プロジェクト: dongliang/Scut
        public override void BuildPacket()
        {
            PushIntoStack(_itemInfo == null ? string.Empty : _itemInfo.ItemName.ToNotNullString());
            PushIntoStack(_itemInfo == null ? string.Empty : _itemInfo.HeadID.ToNotNullString());
            PushIntoStack(_itemInfo == null ? LanguageManager.GetLang().shortInt : (short)_itemInfo.QualityType);
            PushIntoStack(_userItem == null ? LanguageManager.GetLang().shortInt : _userItem.ItemLv);
            PushIntoStack(_demandLv);
            PushIntoStack(_userItem == null ? 0 : _strongMoney);
            PushIntoStack(_coldTime);
            PushIntoStack(_isStrong);

            string[] careerArray = _itemInfo == null ? new string[0] : _itemInfo.CareerRange.Split(',');
            PushIntoStack(careerArray.Length);
            foreach (string career in careerArray)
            {
                DataStruct ds         = new DataStruct();
                CareerInfo careerInfo = new ConfigCacheSet <CareerInfo>().FindKey(career);
                ds.PushIntoStack(careerInfo == null ? 0 : careerInfo.CareerID);
                ds.PushIntoStack(careerInfo == null ? string.Empty : careerInfo.CareerName.ToNotNullString());
                PushIntoStack(ds);
            }
            //当前属性
            PushIntoStack(_itemEquArray.Count);
            foreach (ItemEquAttrInfo equ in _itemEquArray)
            {
                int strengNum = 0;
                if (_userItem != null)
                {
                    strengNum = MathUtils.Addition(equ.BaseNum, (equ.IncreaseNum * _userItem.ItemLv), int.MaxValue);
                }
                DataStruct ds = new DataStruct();
                ds.PushIntoStack((int)equ.AttributeID);
                ds.PushIntoStack(strengNum);

                PushIntoStack(ds);
            }

            //下级别装备属性
            PushIntoStack(_itemEquArray.Count);
            foreach (ItemEquAttrInfo equ in _itemEquArray)
            {
                DataStruct dsDetail = new DataStruct();
                dsDetail.PushIntoStack((int)equ.AttributeID);
                if (_userItem != null)
                {
                    _stengBaseNum = MathUtils.Addition(equ.BaseNum, MathUtils.Addition(_userItem.ItemLv, (short)1, short.MaxValue) * equ.IncreaseNum, int.MaxValue);
                }
                dsDetail.PushIntoStack(_stengBaseNum);
                PushIntoStack(dsDetail);
            }

            PushIntoStack(_itemInfo == null ? string.Empty : _itemInfo.ItemDesc);
            //PushIntoStack(PropertyArray.Length);
            //foreach (SparePartProperty item in PropertyArray)
            //{
            //    DataStruct dsItem = new DataStruct();
            //    dsItem.PushIntoStack((int)item.AbilityType);
            //    dsItem.PushIntoStack(UserHelper.PropertyAbility(item.Num));

            //    this.PushIntoStack(dsItem);
            //}

            PushIntoStack(UserHelper.StrongEquPayPrice(Uid, _userItemId));
            PushIntoStack(_userItemId.ToNotNullString());
            PushIntoStack(_itemInfo == null ? string.Empty : _itemInfo.MaxHeadID);
            PushIntoStack(_userItem.ItemLv >= (GameConfigSet.CurrMaxLv * 3) ? 1 : 0);
            PushIntoStack(_userItem == null ? 0 : _tenTimesStrongMoney);
        }
コード例 #9
0
        public override void BuildPacket()
        {
            PushIntoStack(_itemInfo.HeadID.ToNotNullString());
            PushIntoStack(_itemInfo.ItemName.ToNotNullString());
            PushIntoStack((short)_useritem.ItemType);
            PushIntoStack((short)_itemInfo.QualityType);
            PushIntoStack((short)_itemInfo.QualityType);
            PushIntoStack(_useritem.ItemLv);
            PushIntoStack(demandLv);

            PushIntoStack(_itemEquArray.Count);
            foreach (ItemEquAttrInfo equ in _itemEquArray)
            {
                int strengNum = 0;
                if (equ != null)
                {
                    strengNum = MathUtils.Addition(equ.BaseNum, (equ.IncreaseNum * _useritem.ItemLv), int.MaxValue);
                }
                DataStruct ds = new DataStruct();
                ds.PushIntoStack(equ == null ? (short)0 : (short)equ.AttributeID);
                ds.PushIntoStack(equ == null ? 0 : strengNum);
                PushIntoStack(ds);
            }

            PushIntoStack(_careerList.Length);
            foreach (string career in _careerList)
            {
                DataStruct ds         = new DataStruct();
                CareerInfo careerInfo = new ConfigCacheSet <CareerInfo>().FindKey(career);
                ds.PushIntoStack(careerInfo == null ? (short)0 : (short)careerInfo.CareerID);
                ds.PushIntoStack(careerInfo == null ? string.Empty : careerInfo.CareerName.ToNotNullString());
                PushIntoStack(ds);
            }

            PushIntoStack(_salePrice);
            PushIntoStack(_itemInfo == null ? string.Empty : _itemInfo.ItemDesc.ToNotNullString());

            PushIntoStack(_itemSynthsisArray.Count);
            foreach (ItemSynthesisInfo synthesis in _itemSynthsisArray)
            {
                int          maxNum   = GetItemMaxNum(synthesis);
                ItemBaseInfo tempItem = new ConfigCacheSet <ItemBaseInfo>().FindKey(synthesis.SynthesisID);

                DataStruct ds = new DataStruct();
                ds.PushIntoStack(synthesis.SynthesisID);
                ds.PushIntoStack(tempItem != null ? tempItem.ItemName.ToNotNullString() : string.Empty);
                ds.PushIntoStack((short)synthesis.DemandNum);
                ds.PushIntoStack((short)maxNum);

                PushIntoStack(ds);
            }
            PushIntoStack(PropertyArray.Length);
            foreach (SparePartProperty item in PropertyArray)
            {
                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack((int)item.AbilityType);
                dsItem.PushIntoStack(UserHelper.PropertyAbility(item.Num));

                PushIntoStack(dsItem);
            }
        }
コード例 #10
0
        public override bool TakeAction()
        {
            if (_userId.Equals(Uid))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptError;
                return(false);
            }
            if (new PersonalCacheStruct <UserDailyRestrain>().FindKey(Uid) != null)
            {
                var userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(Uid);
                int maxNum       = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PetIntercept).MaxNum;
                if (userRestrain.UserExtend != null && userRestrain.UserExtend.PetIntercept >= maxNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptTimesOut;
                    return(false);
                }
            }

            var petRunPool = new ShareCacheStruct <PetRunPool>().FindKey(_userId);

            if (petRunPool == null || !petRunPool.IsRunning)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptFaild;
                return(false);
            }
            if (!string.IsNullOrEmpty(petRunPool.FriendID) && petRunPool.FriendID.Equals(Uid))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3206_PetFriendError;
                return(false);
            }

            if (!string.IsNullOrEmpty(petRunPool.InterceptUser))
            {
                string[] InterceptUserList = petRunPool.InterceptUser.Split(',');
                foreach (string intercept in InterceptUserList)
                {
                    if (intercept == ContextUser.UserID)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptFull;
                        return(false);
                    }
                }
                petRunPool.InterceptUser = petRunPool.InterceptUser + ContextUser.UserID + ",";
            }
            else
            {
                petRunPool.InterceptUser = ContextUser.UserID + ",";
            }
            //petRunPool.Update();
            var    chatService = new TjxChatService();
            string toUserId    = petRunPool.UserID;

            if (!string.IsNullOrEmpty(petRunPool.FriendID))
            {
                toUserId = petRunPool.FriendID;
            }
            GameUser      toGameUser  = UserCacheGlobal.LoadOffline(toUserId);
            ISingleCombat combatProxy = CombatFactory.TriggerTournament(ContextUser, toGameUser);

            isWin             = combatProxy.Doing();
            combatProcessList = (CombatProcessContainer)combatProxy.GetProcessResult();
            if (isWin)
            {
                _interceptGameCoin  = petRunPool.InterceptGameCoin;
                _interceptObtainNum = petRunPool.InterceptObtainNum;

                petRunPool.GameCoin  = MathUtils.Subtraction(petRunPool.GameCoin, _interceptGameCoin, 0);
                petRunPool.ObtainNum = MathUtils.Subtraction(petRunPool.ObtainNum, _interceptObtainNum, 0);
                //petRunPool.Update();

                ContextUser.GameCoin  = MathUtils.Addition(ContextUser.GameCoin, _interceptGameCoin);
                ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, _interceptObtainNum);
                //ContextUser.Update();
                var user = UserCacheGlobal.LoadOffline(petRunPool.UserID) ?? new GameUser();
                chatService.SystemSendWhisper(user, string.Format(LanguageManager.GetLang().Chat_PetWasBlocked,
                                                                  (new ShareCacheStruct <PetInfo>().FindKey(petRunPool.PetID) ?? new PetInfo()).PetName, ContextUser.NickName, _interceptGameCoin, _interceptObtainNum
                                                                  ));

                chatService.SystemSendWhisper(ContextUser, string.Format(LanguageManager.GetLang().Chat_PetInterceptSucess,
                                                                         ContextUser.NickName,
                                                                         user.NickName,
                                                                         (new ShareCacheStruct <PetInfo>().FindKey(petRunPool.PetID) ?? new PetInfo()).PetName,
                                                                         _interceptGameCoin,
                                                                         _interceptObtainNum));
            }
            //日志
            UserCombatLog log = new UserCombatLog();

            log.CombatLogID   = Guid.NewGuid().ToString();
            log.UserID        = Uid;
            log.CityID        = ContextUser.CityID;
            log.PlotID        = 0;
            log.NpcID         = 0;
            log.CombatType    = CombatType.PetRun;
            log.HostileUser   = toUserId;
            log.IsWin         = isWin;
            log.CombatProcess = JsonUtils.Serialize(combatProcessList);
            log.PrizeItem     = new CacheList <PrizeItemInfo>();
            log.CreateDate    = DateTime.Now;

            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

            if (new PersonalCacheStruct <UserDailyRestrain>().FindKey(Uid) != null)
            {
                var restrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(Uid);

                restrain.UserExtend.UpdateNotify(obj =>
                {
                    restrain.UserExtend.PetIntercept = MathUtils.Addition(restrain.UserExtend.PetIntercept, 1);
                    return(true);
                });
                //restrain.Update();
            }
            return(true);
        }
コード例 #11
0
ファイル: Action1305.cs プロジェクト: dongliang/Scut
        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 GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID);
                probabilityInfo = new ConfigCacheSet <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
                if (probabilityInfo == null)
                {
                    return(false);
                }
                ProbabilityInfo probability1 = new ConfigCacheSet <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 GameDataCacheSet <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 GameDataCacheSet <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, GameEnvironment.CacheUserPeriod);
                    }
                }

                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 GameDataCacheSet <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 ConfigCacheSet <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 GameDataCacheSet <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 GameDataCacheSet <UserLight>().Add(uLightInfo, GameEnvironment.CacheUserPeriod);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue);
                lightArray          = new GameDataCacheSet <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 ConfigCacheSet <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv);
            if (crystalArray2.Count > 0)
            {
                int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                crystal = new ConfigCacheSet <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);
        }
コード例 #12
0
ファイル: BossCombat.cs プロジェクト: zxx0367/Scut-samples
        /// <summary>
        /// 触发战斗
        /// </summary>
        /// <param name="user"></param>
        /// <param name="bossCombatProcess"></param>
        /// <returns></returns>
        public bool Combat(GameUser user, BossCombatProcess bossCombatProcess)
        {
            CombatGeneral bossGeneral = Boss;

            bossGeneral.LossLifeNum = 0;

            BossUser          bossUser       = GetCombatUser(user.UserID);
            ICombatController controller     = new TjxCombatController();
            ISingleCombat     plotCombater   = controller.GetSingleCombat(CombatType.BossPlot);
            double            inspirePercent = bossUser.InspirePercent + bossUser.ReliveInspirePercent;

            plotCombater.SetAttack(new UserEmbattleQueue(user.UserID, user.UseMagicID, inspirePercent, CombatType.BossPlot));
            plotCombater.SetDefend(new MonsterQueue(Boss));

            bool isWin = plotCombater.Doing();

            bossCombatProcess.ProcessContainer = (CombatProcessContainer)plotCombater.GetProcessResult();
            bossUser.CombatNum         += 1;
            bossUser.DamageNum          = MathUtils.Addition(bossUser.DamageNum, bossGeneral.LossLifeNum, int.MaxValue);
            bossCombatProcess.LiveNum   = bossGeneral.LifeNum;
            bossCombatProcess.DamageNum = bossGeneral.LossLifeNum;
            bossCombatProcess.IsWin     = isWin;
            bossCombatProcess.UserId    = user.UserID;

            DoDamagePrize(user, bossGeneral.LossLifeNum, bossCombatProcess);
            if (isWin && bossGeneral.IsOver)
            {
                GameActive active   = GameActive;
                short      lv       = MathUtils.Subtraction(bossGeneral.Lv, (short)active.BossPrize.KillBossLv, (short)1);
                int        killCoin = lv * active.BossPrize.KillBossRate;
                user.GameCoin = MathUtils.Addition(user.GameCoin, killCoin, int.MaxValue);

                new TjxChatService().SystemSend(ChatType.World, string.Format(LanguageManager.GetLang().St5405_CombatKillReward, user.NickName, killCoin));
                TraceLog.ReleaseWriteDebug(string.Format(LanguageManager.GetLang().St5405_CombatKillReward, user.NickName, killCoin));
                bossCombatProcess.KillGameCoin = killCoin;

                ServerEnvSet.Set(ServerEnvKey.KillBossUserID, user.UserID);
                DoKillPrize(user);

                int tempMinute = active.Minutes - ConfigEnvSet.GetInt("BossCombat.KillTime");
                if (new TimeSpan(0, tempMinute, 0).TotalSeconds - active.ColdTime < 0)
                {
                    //Boss自动升级
                    active.BossLv = MathUtils.Addition(active.BossLv, (short)1);
                    //active.Update();
                }
                active.CombatStatus = CombatStatus.Killed;
                CombatHelper.BossKillDate(); //增加boss被杀时间
            }
            else
            {
                bossUser.IsRelive        = true;
                bossUser.ReliveBeginDate = DateTime.Now;
            }
            //日志
            var log = new UserCombatLog
            {
                CombatLogID   = Guid.NewGuid().ToString(),
                UserID        = user.UserID,
                CityID        = user.CityID,
                PlotID        = GameActive == null ? 0 : GameActive.BossPlotID,
                NpcID         = bossGeneral.GeneralID,
                CombatType    = CombatType.BossPlot,
                HostileUser   = string.Empty,
                IsWin         = isWin,
                CombatProcess = JsonUtils.Serialize(bossCombatProcess),
                CreateDate    = DateTime.Now
            };
            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

            //user.Update();

            return(isWin);
        }
コード例 #13
0
ファイル: Action1605.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            int subLifeNum = 0;

            var          package  = UserItemPackage.Get(Uid);
            UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(userItemID));

            if (userItem == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            //wuzf modify 2012-05-19
            ItemBaseInfo itemInfo   = new ConfigCacheSet <ItemBaseInfo>().FindKey(userItem.ItemID);
            var          propsArray = new GameDataCacheSet <UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1);

            if (propsArray.Count > 0 && propsArray[0].SurplusNum > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1605_BandageUse;
                return(false);
            }

            //判断背包是否有血包,没有提示去商城
            var userItems = package.ItemPackage.FindAll(m => !m.IsRemove && new UserItemHelper(m).PropType == 1);

            if (userItems.Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1605_UseTwoGold;
                return(false);
            }

            //给佣兵补血
            var userGeneralArray = new GameDataCacheSet <UserGeneral>().FindAll(ContextUser.UserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong);
            int effectNum        = itemInfo.EffectNum;

            foreach (var userGeneral in userGeneralArray)
            {
                int maxLifeNum = UserHelper.GetMaxLife(ContextUser.UserID, userGeneral.GeneralID);
                if (userGeneral.LifeNum < maxLifeNum)
                {
                    subLifeNum          = MathUtils.Subtraction(maxLifeNum, userGeneral.LifeNum, 0);
                    userGeneral.LifeNum = MathUtils.Addition(userGeneral.LifeNum, effectNum, maxLifeNum);
                    //userGeneral.Update();
                    effectNum = MathUtils.Subtraction(effectNum, subLifeNum, 0);
                }
            }
            var       cacheSet = new GameDataCacheSet <UserProps>();
            UserProps props    = new GameDataCacheSet <UserProps>().FindKey(ContextUser.UserID, userItem.ItemID);

            if (props != null)
            {
                props.SurplusNum = effectNum;
                //props.Update();
            }
            else
            {
                props = new UserProps(ContextUser.UserID, itemInfo.ItemID)
                {
                    SurplusNum = effectNum
                };
                cacheSet.Add(props, GameEnvironment.CacheUserPeriod);
            }

            ContextUser.IsUseupItem = false;
            UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1);
            foreach (UserProps userPropse in propsArray)
            {
                if (userPropse.SurplusNum == 0)
                {
                    cacheSet.Delete(userPropse);
                }
            }
            return(true);
        }
コード例 #14
0
ファイル: Action12004.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            DialHelper.CheckDialNum(ContextUser.UserID);
            UserDial userDial = new GameDataCacheSet <UserDial>().FindKey(ContextUser.UserID);

            if (userDial == null || string.IsNullOrEmpty(userDial.UserItemID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (ops == 1)
            {
                string errContent = string.Empty;
                if (UserPackHelper.PackIsFull(ContextUser, BackpackType.BeiBao, 0, out errContent))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = errContent;
                    return(false);
                }
                int itemid   = UserItemHelper.GetUserItemInfoID(ContextUser.UserID, userDial.UserItemID);
                var itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemid);
                if (itemInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1107_UserItemNotEnough;
                    return(false);
                }
                // 根据宝箱取得该宝箱对应的钥匙ID
                int itemNum = UserItemHelper.CheckItemNum(ContextUser.UserID, itemInfo.EffectNum);
                if (itemNum <= 0)
                {
                    ItemBaseInfo itemKey = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemInfo.EffectNum);
                    if (itemKey == null)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1107_UserItemNotEnough;
                        return(false);
                    }
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St12004_ChestKeyNotEnough, itemKey.ItemName);
                    return(false);
                }
                UserItemHelper.UseUserItem(ContextUser.UserID, itemid, 1);
                UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.EffectNum, 1);
                postion = DialHelper.ChestDialPrizePostion(ContextUser);
                postion = MathUtils.Addition(postion, (short)1);

                // 是否还可以继续使用
                //var package = UserItemPackage.Get(ContextUser.UserID);
                bool hasBox = UserItemHelper.IsEnoughBeiBaoItem(ContextUser.UserID, itemid, 1);
                bool hasKey = UserItemHelper.IsEnoughBeiBaoItem(ContextUser.UserID, itemInfo.EffectNum, 1);
                // 如果钥匙和宝箱的数各 >= 1
                if (hasBox && hasKey)
                {
                    hasNextBox = 1;
                }
            }

            //int useGold = 0;
            //if (ops == 1)
            //{
            //    //if (!DialHelper.IsDialFree(ContextUser.UserID))
            //    //{
            //    //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    //    ErrorInfo = LanguageManager.GetLang().St12004_FreeNotEnough;
            //    //    return false;
            //    //}
            //}
            //else if (ops == 2)
            //{
            //    useGold = GameConfigSet.SweepstakesRequiredGold;
            //    ErrorCode = ops;
            //    ErrorInfo = string.Format(LanguageManager.GetLang().St12004_SpendSparDraw, useGold, 1);
            //    return false;
            //}
            //else if (ops == 3)
            //{
            //    if (DialHelper.IsDialFree(ContextUser.UserID))
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St12004_FreeNumEnough;
            //        return false;
            //    }
            //    useGold = GameConfigSet.SweepstakesRequiredGold;
            //    if (ContextUser.GoldNum < useGold)
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
            //        return false;
            //    }
            //    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
            //}
            //else if (ops == 4)
            //{
            //    useGold = GameConfigSet.FiveRequiredGold;
            //    ErrorCode = ops;
            //    ErrorInfo = string.Format(LanguageManager.GetLang().St12004_SpendSparDraw, useGold, 5);
            //    return false;
            //}
            //else if (ops == 5)
            //{
            //    if (DialHelper.IsDialFree(ContextUser.UserID))
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St12004_FreeNumEnough;
            //        return false;
            //    }
            //    useGold = GameConfigSet.FiveRequiredGold;
            //    if (ContextUser.GoldNum < useGold)
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
            //        return false;
            //    }
            //    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
            //}
            //ErrorCode = ops;
            //postion = DialHelper.DialPrizePostion(ContextUser.UserID, ops);
            //postion = MathUtils.Addition(postion, (short)1);
            return(true);
        }
コード例 #15
0
ファイル: Action1407.cs プロジェクト: zxx0367/Scut-samples
        public override bool TakeAction()
        {
            ItemBaseInfo itemInfo      = new ConfigCacheSet <ItemBaseInfo>().FindKey(medicineID);
            var          userItemArray = UserItemHelper.GetItems(Uid).FindAll(u => (u.ItemStatus == ItemStatus.BeiBao || u.ItemStatus == ItemStatus.CangKu));

            if (userItemArray.Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1407_MedicineNum;
                return(false);
            }
            UserGeneral general = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID);

            if (general == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St10006_DoesNotExistTheGeneral;
                return(false);
            }
            if (itemInfo.DemandLv > general.GeneralLv)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                return(false);
            }

            int   sum     = 0;
            short baseNum = 0;
            //佣兵服用ID为medicineID的丹药
            var generalMedicineArray = new GameDataCacheSet <GeneralMedicine>().FindAll(ContextUser.UserID, g => g.MedicineID.Equals(medicineID) && g.GeneralID == generalID);

            if (generalMedicineArray.Count > 0)
            {
                int mLv  = itemInfo.MedicineLv;
                int mNum = generalMedicineArray.Count;
                if (mLv == 1 && mNum >= 2 || mLv == 2 && mNum >= 3 || mLv == 3 && mNum >= 4 || mLv == 4 && mNum >= 5 || mLv == 5 && mNum >= 6 || mLv == 6 && mNum >= 7)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1407_MedicineNumFull;
                    return(false);
                }

                sum     = mNum * 5; //
                baseNum = MathUtils.Subtraction(itemInfo.MedicineNum, (short)sum, (short)0);
            }
            else
            {
                baseNum = itemInfo.MedicineNum;
            }

            //vip
            int useGold = 0;

            int[] vipMeArray = { 30, 150, 300, 600, 1200, 2400 };
            for (int i = 1; i <= vipMeArray.Length; i++)
            {
                if (itemInfo.MedicineLv == i)
                {
                    useGold = vipMeArray[i - 1];
                }
            }

            if (ops == 0)
            {
                GeneralMedicine generalMedicine = new GeneralMedicine()
                {
                    GeneralMedicineID = Guid.NewGuid().ToString(),
                    UserID            = ContextUser.UserID,
                    GeneralID         = generalID,
                    MedicineID        = medicineID,
                    BaseNum           = (int)baseNum
                };
                var cacheSet = new GameDataCacheSet <GeneralMedicine>();
                cacheSet.Add(generalMedicine);

                UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1);

                if (itemInfo.MedicineType == 1)
                {
                    general.PowerNum = MathUtils.Addition(general.PowerNum, baseNum, short.MaxValue);
                }
                else if (itemInfo.MedicineType == 2)
                {
                    general.SoulNum = MathUtils.Addition(general.SoulNum, baseNum, short.MaxValue);
                }
                else if (itemInfo.MedicineType == 3)
                {
                    general.IntellectNum = MathUtils.Addition(general.IntellectNum, baseNum, short.MaxValue);
                }
                //general.Update();
            }
            else if (ops == 1)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St1407_MedicineUseGold, useGold);
                return(false);
            }
            else if (ops == 2)
            {
                if (ContextUser.GoldNum < useGold)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                GeneralMedicine generalMedicine = new GeneralMedicine()
                {
                    GeneralMedicineID = Guid.NewGuid().ToString(),
                    UserID            = ContextUser.UserID,
                    GeneralID         = generalID,
                    MedicineID        = medicineID,
                    BaseNum           = (int)baseNum
                };
                var cacheSet = new GameDataCacheSet <GeneralMedicine>();
                cacheSet.Add(generalMedicine);

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
                //ContextUser.Update();

                if (itemInfo.MedicineType == 1)
                {
                    general.PowerNum = MathUtils.Addition(general.PowerNum, baseNum, short.MaxValue);
                }
                else if (itemInfo.MedicineType == 2)
                {
                    general.SoulNum = MathUtils.Addition(general.SoulNum, baseNum, short.MaxValue);
                }
                else if (itemInfo.MedicineType == 3)
                {
                    general.IntellectNum = MathUtils.Addition(general.IntellectNum, baseNum, short.MaxValue);
                }
                //general.Update();
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().UrlElement;
                return(false);
            }
            return(true);
        }
コード例 #16
0
        /// <summary>
        /// 获得物品
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="prize"></param>
        /// <returns></returns>
        public bool DoPrize(GameUser userInfo, List <PrizeInfo> prizeList)
        {
            try
            {
                bool        isDeduct = false;
                CrystalInfo crystal  = new CrystalInfo();
                content = LanguageManager.GetLang().St_SummerThreeGameCoinNotice.Substring(0, 5);
                foreach (PrizeInfo prize in prizeList)
                {
                    int num = prize.Num;
                    switch (prize.Type)
                    {
                    case RewardType.GameGoin:
                        userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeGameCoinNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_GameCoin, num) + ",";
                        }
                        break;

                    case RewardType.Obtion:
                        userInfo.ObtainNum = MathUtils.Addition(userInfo.ObtainNum, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeObtionNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_ObtionNum, num) + ",";
                        }
                        break;

                    case RewardType.ExpNum:
                        userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeExpNumNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_ExpNum, num) + ",";
                        }
                        break;

                    case RewardType.EnergyNum:
                        userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, (short)num, short.MaxValue);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeEnergyNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_EnergyNum, num) + ",";
                        }
                        break;

                    case RewardType.Experience:
                        UserHelper.UserGeneralExp(userInfo.UserID, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeExperienceNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_Experience, num) + ",";
                        }
                        break;

                    case RewardType.Gold:
                        userInfo.ItemGold = MathUtils.Addition(userInfo.ItemGold, num);
                        if (content.Length == 0)
                        {
                            content = string.Format(LanguageManager.GetLang().St_SummerThreeGoldNotice, num);
                        }
                        else
                        {
                            content += string.Format(LanguageManager.GetLang().St_GiftGoldNum, num) + ",";
                        }
                        break;

                    case RewardType.Item:
                        if (UserHelper.IsBeiBaoFull(userInfo))
                        {
                            content = LanguageManager.GetLang().St1107_GridNumFull;
                            return(false);
                        }
                        UserItemHelper.AddUserItem(userInfo.UserID, prize.ItemID, num);
                        ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(prize.ItemID);
                        if (itemInfo != null)
                        {
                            if (content.Length == 0)
                            {
                                content = string.Format(LanguageManager.GetLang().St_SummerThreeItemNotice, num);
                            }
                            else
                            {
                                content += string.Format("{0}*{1}", itemInfo.ItemName, num) + ",";
                            }
                        }
                        break;

                    case RewardType.CrystalType:
                        if (!UserCrystalInfo.CheckFull(userInfo.UserID, 0))
                        {
                            content = LanguageManager.GetLang().St1307_FateBackpackFull;
                            return(false);
                        }
                        List <CrystalInfo> crystalArray2 = new ShareCacheStruct <CrystalInfo>().FindAll(m => m.CrystalQuality == prize.CrystalType);
                        if (crystalArray2.Count > 0)
                        {
                            int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count);
                            int crystalID = crystalArray2[randomNum].CrystalID;
                            UserHelper.CrystalAppend(userInfo.UserID, crystalID, 2);
                            CrystalHelper.SendChat(crystalArray2[randomNum].CrystalID, userInfo);
                            crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalID);
                            if (crystal != null)
                            {
                                content += string.Format(LanguageManager.GetLang().St_Crystal, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName) + ",";
                            }
                        }
                        else
                        {
                            TraceLog.WriteError("配置出错");
                            return(false);
                        }
                        break;

                    case RewardType.CrystalId:
                        if (!UserCrystalInfo.CheckFull(userInfo.UserID, 0))
                        {
                            content = LanguageManager.GetLang().St1307_FateBackpackFull;
                            return(false);
                        }
                        UserHelper.CrystalAppend(userInfo.UserID, prize.ItemID, 2);
                        CrystalHelper.SendChat(prize.ItemID, userInfo);
                        crystal = new ShareCacheStruct <CrystalInfo>().FindKey(prize.ItemID);
                        if (crystal != null)
                        {
                            content += string.Format(LanguageManager.GetLang().St_Crystal, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName) + ",";
                        }
                        break;

                    case RewardType.Spare:
                        int currNum = userInfo.SparePartList.FindAll(m => string.IsNullOrEmpty(m.UserItemID)).Count;
                        if (currNum >= userInfo.UserExtend.SparePartGridNum)
                        {
                            content = LanguageManager.GetLang().St1213_GridNumFull;
                            return(false);
                        }
                        UserSparePart sparePart = UserSparePart.GetRandom(prize.ItemID);
                        SparePartInfo partInfo  = new ShareCacheStruct <SparePartInfo>().FindKey(prize.ItemID);
                        if (partInfo != null && sparePart != null && UserHelper.AddSparePart(userInfo, sparePart))
                        {
                            SendChat(prize, userInfo.NickName, partInfo.Name);
                        }
                        content = string.Empty;
                        break;

                    default:
                        break;
                    }
                    if (prize.Reward == 3 && !string.IsNullOrEmpty(prize.Desc))
                    {
                        content = prize.Desc;
                    }
                    //原因:开启礼包消耗的物品
                    if (prize.DemandItem > 0 && !isDeduct)
                    {
                        UserItemHelper.UseUserItem(userInfo.UserID, prize.DemandItem, prize.DemandNum);
                        isDeduct = true;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                content = "使用礼包出错!";
                TraceLog.WriteError("使用礼包出错!", ex);
            }
            return(false);
        }
コード例 #17
0
ファイル: Action4004.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            //if (ContextUser.EnergyNum <= 0)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            //if (ContextUser.EnergyNum <= 0 && ContextUser.TempEnergyNum == 0)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            if (ContextUser.UserStatus == UserStatus.SaoDang)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return(false);
            }
            if (ContextUser.UseMagicID == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic;
                return(false);
            }
            if (new PersonalCacheStruct <UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty;
                return(false);
            }

            //if (ContextUser.TempEnergyNum == 0)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}

            ContextUser.UserStatus = UserStatus.Combat;
            try
            {
                //触发战斗
                PlotNPCInfo npcInfo = new ShareCacheStruct <PlotNPCInfo>().FindKey(PlotNpcID);

                //原因:碰npc时掉线,再请求战斗详情
                if (npcInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return(false);
                }

                //原因:最后一个npc时,清空玩家保存副本
                if (ContextUser.UserExtend != null && ContextUser.UserExtend.MercenarySeq > npcInfo.NpcSeqNo)
                {
                    ContextUser.UserStatus = UserStatus.Normal;
                    ContextUser.UserExtend.UpdateNotify(obj =>
                    {
                        ContextUser.UserExtend.PlotStatusID = 0;
                        ContextUser.UserExtend.PlotNpcID    = -1;
                        ContextUser.UserExtend.MercenarySeq = 1;
                        ContextUser.UserExtend.IsBoss       = false;
                        return(true);
                    });
                    //ErrorCode = LanguageManager.GetLang().ErrorCode;
                    //ErrorInfo = LanguageManager.GetLang().St4011_NoMonster;
                    //return false;
                }

                PlotInfo plotInfo = new ShareCacheStruct <PlotInfo>().FindKey(npcInfo.PlotID);
                if (plotInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return(false);
                }

                var cacheSetUserPlot = new PersonalCacheStruct <UserPlotPackage>();
                var cacheSetItemInfo = new ShareCacheStruct <ItemBaseInfo>();
                var cacheSet         = new PersonalCacheStruct <UserPlotCombat>();
                var userPlotPack     = cacheSetUserPlot.FindKey(ContextUser.UserID);
                var userPlot         = userPlotPack != null?userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null;

                //PlotHelper.IsKill(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID)
                if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum)
                {
                    if (plotInfo.PlotType == PlotType.Elite)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed;
                        return(false);
                    }
                    else if (plotInfo.PlotType == PlotType.HeroPlot)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum;
                        return(false);
                    }
                }

                //if (userPlot != null && userPlot.ItemList != null)
                //{
                //    userPlot.UpdateNotify(obj =>
                //    {
                //        userPlot.ItemList.Clear();
                //        return true;
                //    });
                //}
                if (npcInfo.NpcSeqNo == 1)
                {
                    userPlot.ItemList.Clear();
                    ContextUser.IsItem = false;
                }
                userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID);
                if (userPlotCombat != null && userPlotCombat.IsWin && ContextUser.UserExtend != null &&
                    PlotNpcID == ContextUser.UserExtend.PlotNpcID && !ContextUser.IsItem)
                {
                    prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID);
                }
                else
                {
                    ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID);
                    if (plotCombater == null)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().LoadDataError;
                        return(false);
                    }
                    if (userPlotCombat == null)
                    {
                        userPlotCombat = new UserPlotCombat()
                        {
                            UserID    = ContextUser.UserID,
                            PlotNpcID = PlotNpcID
                        };
                        cacheSet.Add(userPlotCombat);
                        userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID);
                    }
                    userPlotCombat.PlotID     = npcInfo.PlotID;
                    userPlotCombat.CombatDate = DateTime.Now;
                    userPlotCombat.IsWin      = plotCombater.Doing();
                    if (!userPlotCombat.IsWin)
                    {
                        userPlotCombat.OverNum += 1;
                    }
                    ContextUser.IsItem            = npcInfo.NpcSeqNo == 1 ? false : ContextUser.IsItem;
                    combatProcessList             = (CombatProcessContainer)plotCombater.GetProcessResult();
                    userPlotCombat.GeneralNum     = combatProcessList.AttackList.Count;
                    userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList());
                    //userPlotCombat.CombatProcess = JsonUtils.Serialize(combatProcessList);
                    int generalNum = combatProcessList.DefenseList.FindAll(s => s.LiveNum > 0).Count;
                    if (userPlotCombat.IsWin)
                    {
                        if (ContextUser.UserExtend != null)
                        {
                            ContextUser.UserExtend.UpdateNotify(obj =>
                            {
                                ContextUser.UserExtend.PlotStatusID = npcInfo.PlotID;
                                ContextUser.UserExtend.PlotNpcID    = PlotNpcID;
                                ContextUser.UserExtend.MercenarySeq = MathUtils.Addition(npcInfo.NpcSeqNo, (short)1);
                                ContextUser.UserExtend.IsBoss       = npcInfo.IsBoss; //是否最后一个副本npc
                                return(true);
                            });
                        }
                        //玩家通过一个城市的所有副本时,增加聊天频道系统提示
                        if (userPlot.PlotStatus != PlotStatus.Completed && npcInfo.IsBoss)      //玩家此副本胜利
                        {
                            var city     = new ShareCacheStruct <CityInfo>().FindKey(plotInfo.CityID);
                            var nextPlot = new ShareCacheStruct <PlotInfo>().FindKey(plotInfo.AftPlotID);
                            if (city != null && nextPlot != null && nextPlot.CityID != plotInfo.CityID)            //此城市的最后一个副本
                            {
                                string content = string.Format(LanguageManager.GetLang().St_systemprompts, ContextUser.NickName,
                                                               city.CityName);
                                new TjxChatService().SystemSend(ChatType.World, content);
                            }
                        }
                        PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, generalNum, out _honourNum);
                        if (npcInfo.NpcSeqNo == 1)
                        {
                            ContextUser.EnergyNum = MathUtils.Subtraction(ContextUser.EnergyNum, ContextUser.TempEnergyNum).ToShort();
                            //原因:刷晶石BUG
                            ContextUser.TempEnergyNum = 0;
                        }
                        if (!ContextUser.IsItem)
                        {
                            prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID);
                        }
                        TaskHelper.KillPlotMonster(Uid, npcInfo.PlotID, PlotNpcID);

                        //var stroyTaskList = new ShareCacheStruct<StoryTaskInfo>().FindAll(s => s.PlotID == plotInfo.AftPlotID);
                        //foreach (var story in stroyTaskList)
                        //{
                        //    var usertask = new PersonalCacheStruct<UserTask>().FindKey(ContextUser.UserID, story.PlotID);
                        //    if (usertask != null)
                        //    {
                        PlotHelper.EnablePlot(Uid, plotInfo.AftPlotID);
                        //    }
                        //}

                        if (plotInfo.PlotType == PlotType.Elite)
                        {
                            EliteDailyRestrain(npcInfo);
                            NoviceHelper.ElitePlotFestivalList(ContextUser); //通关精英副本获得奖励
                        }
                        else if (plotInfo.PlotType == PlotType.Kalpa)
                        {
                            KalpaDailyRestrain(npcInfo);
                        }
                        else if (plotInfo.PlotType == PlotType.HeroPlot)
                        {
                            PlotHelper.EnableHeroPlot(ContextUser.UserID, plotInfo.PlotID);
                            PlotHelper.HeroDailyRestrain(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID);
                        }
                    }
                    else
                    {
                        ContextUser.GeneralAllCount  = 0;
                        ContextUser.GeneralKillCount = 0;
                    }


                    var restrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(Uid);
                    if (restrain != null)
                    {
                        var restrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PlotGoto);
                        if (restrainSet != null)
                        {
                            GotoNum = MathUtils.Subtraction(restrainSet.MaxNum, restrain.Funtion14, 0);
                        }
                    }
                }
                //原因:最后一个npc时,清空玩家保存副本
                if (ContextUser.UserExtend != null && ContextUser.UserExtend.IsBoss)
                {
                    ContextUser.UserExtend.UpdateNotify(obj =>
                    {
                        ContextUser.UserExtend.PlotStatusID = 0;
                        ContextUser.UserExtend.PlotNpcID    = -1;
                        ContextUser.UserExtend.MercenarySeq = 0;
                        ContextUser.UserExtend.IsBoss       = npcInfo.IsBoss;
                        return(true);
                    });
                }

                if (!ContextUser.IsItem)
                {
                    foreach (var prize in prizeItems)
                    {
                        if (prize.Type == 0 && userPlot != null)
                        {
                            var           itemInfo      = cacheSetItemInfo.FindKey(prize.ItemID);
                            UniversalInfo universalInfo = new UniversalInfo();
                            universalInfo.HeadID    = itemInfo != null ? itemInfo.HeadID : string.Empty;
                            universalInfo.ItemID    = itemInfo != null ? itemInfo.ItemID : 0;
                            universalInfo.ItemDesc  = itemInfo != null ? itemInfo.ItemDesc : string.Empty;
                            universalInfo.MaxHeadID = itemInfo != null ? itemInfo.MaxHeadID : string.Empty;
                            universalInfo.Name      = itemInfo != null ? itemInfo.ItemName : string.Empty;
                            universalInfo.Num       = prize.Num;
                            if (userPlot.ItemList != null && userPlot.ItemList.Count > 0)
                            {
                                var item = userPlot.ItemList.Find(s => s.ItemID == prize.ItemID);
                                if (item != null)
                                {
                                    item.UpdateNotify(obj =>
                                    {
                                        item.Num = MathUtils.Addition(item.Num, prize.Num);
                                        return(true);
                                    });
                                }
                                else
                                {
                                    userPlot.UpdateNotify(obj =>
                                    {
                                        userPlot.ItemList.Add(universalInfo);
                                        return(true);
                                    });
                                }
                            }
                            else
                            {
                                userPlot.UpdateNotify(obj =>
                                {
                                    userPlot.ItemList.Add(universalInfo);
                                    return(true);
                                });
                            }
                        }
                        ContextUser.IsItem = true;
                    }
                }
                var a = userPlot.ItemList;
            }
            finally
            {
                ContextUser.UserStatus = UserStatus.Normal;
            }
            //日志
            UserCombatLog log = new UserCombatLog();

            log.CombatLogID   = Guid.NewGuid().ToString("N");
            log.UserID        = userPlotCombat.UserID;
            log.CityID        = ContextUser.CityID;
            log.PlotID        = userPlotCombat.PlotID;
            log.NpcID         = userPlotCombat.PlotNpcID;
            log.CombatType    = CombatType.Plot;
            log.HostileUser   = string.Empty;
            log.IsWin         = userPlotCombat.IsWin;
            log.CombatProcess = JsonUtils.Serialize(combatProcessList);
            log.PrizeItem     = prizeItems;
            log.CreateDate    = DateTime.Now;
            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

            UserHelper.GetGeneralLife(ContextUser.UserID);
            UserHelper.RegainGeneralLife(ContextUser.UserID);

            //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true);
            //           foreach (var userEmbattle in userEmbattleList)
            //           {
            //               _userTalPriority = MathUtils.Addition(_userTalPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID));
            //           }
            selfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0);
            //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true);

            _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0);

            return(true);
        }
コード例 #18
0
ファイル: Action11002.cs プロジェクト: zxx0367/Scut-samples
        public override bool TakeAction()
        {
            //List<UserQueue> queueArray = new GameDataCacheSet<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TianXianStrong);

            //if (queueArray.Count > 0)
            //{
            //    int codeDate = queueArray[0].DoRefresh();
            //    if (codeDate > 0)
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St11002_Colding;
            //        return false;
            //    }
            //}

            UserExpedition userExpedition = new GameDataCacheSet <UserExpedition>().FindKey(ContextUser.UserID);

            if (userExpedition != null && userExpedition.ExpeditionNum >= 10 && userExpedition.InsertDate.Date == DateTime.Now.Date)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St11002_ExpeditionFull;
                return(false);
            }

            if (userExpedition != null && userExpedition.DoRefresh() > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St11002_Colding;
                return(false);
            }

            int sumGold = MathUtils.Addition((GetExpCodeTime(ContextUser.UserID) / 60), 1);

            if (isRemove == 1)
            {
                if (ContextUser.GoldNum < sumGold)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                codeTime = 0;

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, sumGold);
            }
            else if (isRemove == 2)
            {
                codeTime = GetExpCodeTime(ContextUser.UserID);

                //if (queueArray.Count > 0)
                //{
                //    queueArray[0].ColdTime = codeTime;
                //    queueArray[0].TotalColdTime = codeTime;
                //    queueArray[0].Timing = DateTime.Now;
                //    //queueArray[0].Update();
                //}
                //else
                //{
                //    UserQueue queue = new UserQueue()
                //    {
                //        QueueID = Guid.NewGuid().ToString(),
                //        QueueType = QueueType.TianXianStrong,
                //        QueueName = QueueType.TianXianStrong.ToString(),
                //        UserID = ContextUser.UserID,
                //        ColdTime = codeTime,
                //        IsSuspend = false,
                //        TotalColdTime = codeTime,
                //        Timing = DateTime.Now,
                //    };
                //    new GameDataCacheSet<UserQueue>().Add(queue, ContextUser.UserID.ToInt());
                //}
            }

            if (userExpedition == null)
            {
                userExpedition = new UserExpedition()
                {
                    UserID = ContextUser.UserID,
                };
                new GameDataCacheSet <UserExpedition>().Add(userExpedition, ContextUser.UserID.ToInt());
            }
            if (DateTime.Now.Date == userExpedition.InsertDate.Date)
            {
                userExpedition.ExpeditionNum = MathUtils.Addition(userExpedition.ExpeditionNum, 1, int.MaxValue);
            }
            else
            {
                userExpedition.ExpeditionNum = 1;
            }
            userExpedition.CodeTime   = codeTime;
            userExpedition.InsertDate = DateTime.Now;

            ExpeditionInfo expInfo = new ConfigCacheSet <ExpeditionInfo>().FindKey(questionID);

            if (expInfo != null)
            {
                if (answerID == 1)
                {
                    rewardShowArray = expInfo.RewardNum1.ToList();
                }
                else if (answerID == 2)
                {
                    rewardShowArray = expInfo.RewardNum2.ToList();
                }
                GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);

                foreach (RewardShow show in rewardShowArray)
                {
                    if (show.RewardType == RewardType.Obtion)
                    {
                        if (member != null)
                        {
                            GuildMemberLog.AddLog(member.GuildID, new MemberLog()
                            {
                                UserID     = ContextUser.UserID,
                                LogType    = 1,
                                IdolID     = 0,
                                GainObtion = show.RewardNum,
                                GainAura   = 0,
                                Experience = show.RewardNum,
                                InsertDate = DateTime.Now
                            });
                            UserHelper.Contribution(ContextUser.UserID, show.RewardNum);
                        }
                        ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, show.RewardNum, int.MaxValue);
                    }
                    else if (show.RewardType == RewardType.GameGoin)
                    {
                        ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, (show.RewardNum * ContextUser.UserLv), int.MaxValue);
                    }
                    else if (show.RewardType == RewardType.ExpNum)
                    {
                        ContextUser.ExpNum = MathUtils.Addition(ContextUser.ExpNum, show.RewardNum, int.MaxValue);
                    }
                    else if (show.RewardType == RewardType.Experience)
                    {
                        UserHelper.UserGeneralExp(ContextUser.UserID, (show.RewardNum * ContextUser.UserLv));
                    }
                    else if (show.RewardType == RewardType.EnergyNum)
                    {
                        ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, (short)show.RewardNum, short.MaxValue);
                    }
                    else if (show.RewardType == RewardType.Gold)
                    {
                        ContextUser.GiftGold = MathUtils.Addition(ContextUser.GiftGold, show.RewardNum, int.MaxValue);
                    }
                }
                string prizeContent = string.Empty;
                MysteryHelper.IsTriggerMyStery(ContextUser, MysteryType.Meiritanxian, out prizeContent);
                MysteryInfo mysteryInfo = new ConfigCacheSet <MysteryInfo>().FindKey(MysteryType.Meiritanxian);
                if (!string.IsNullOrEmpty(prizeContent) && mysteryInfo != null)
                {
                    string prompt           = string.Format(mysteryInfo.Prompt, prizeContent);
                    string broadContent     = string.Format(mysteryInfo.Broadcast, ContextUser.NickName, prizeContent);
                    var    broadcastService = new TjxBroadcastService(null);
                    var    msg = broadcastService.Create(NoticeType.System, broadContent);
                    broadcastService.Send(msg);
                    ErrorCode = 1;
                    ErrorInfo = prompt;
                }
            }
            return(true);
        }
コード例 #19
0
ファイル: Action1201.cs プロジェクト: xushenghan/Scut-samples
        public override void BuildPacket()
        {
            PushIntoStack(_coldTime);
            PushIntoStack(_userGeneralArray.Count);
            foreach (UserGeneral general in _userGeneralArray)
            {
                UserGeneral         general1      = general;
                List <UserItemInfo> userItemArray = UserItemHelper.GetItems(Uid).FindAll(u => u.GeneralID.Equals(general1.GeneralID) && u.ItemStatus == ItemStatus.YongBing);
                userItemArray.QuickSort((x, y) =>
                {
                    if (x == null && y == null)
                    {
                        return(0);
                    }
                    if (x != null && y == null)
                    {
                        return(1);
                    }
                    if (x == null)
                    {
                        return(-1);
                    }
                    return(new ShareCacheStruct <ItemBaseInfo>().FindKey(x.ItemID).EquParts.CompareTo(new ShareCacheStruct <ItemBaseInfo>().FindKey(y.ItemID).EquParts));
                });

                DataStruct ds = new DataStruct();
                ds.PushIntoStack(general == null ? 0 : general.GeneralID);
                ds.PushIntoStack(general == null ? string.Empty : general.GeneralName.ToNotNullString());
                // List<UserItem> itemList = userItemDict.ContainsKey(general.UserID) ? userItemDict[general.UserID] : new List<UserItem>();

                ds.PushIntoStack(userItemArray.Count);
                foreach (UserItemInfo userItem in userItemArray)
                {
                    int   equCodeTime = ConfigEnvSet.GetInt("UserItem.EquColdTime");
                    short isStrong    = 0;
                    int   strongMoney = new UserItemHelper(userItem).StrongMoney;
                    if (strongMoney > ContextUser.GameCoin)
                    {
                        isStrong = 1;
                    }
                    else if (userItem.ItemLv >= general.GeneralLv)
                    {
                        isStrong = 2;
                    }
                    ItemBaseInfo             itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(userItem.ItemID);
                    List <ItemSynthesisInfo> itemSynthesisInfosArray =
                        new ShareCacheStruct <ItemSynthesisInfo>().FindAll(m => m.SynthesisID == userItem.ItemID);
                    if (itemSynthesisInfosArray.Count > 0 && itemInfo.DemandLv <= ContextUser.UserLv)
                    {
                        isSynthesis = 1;
                    }
                    else
                    {
                        isSynthesis = 2;
                    }

                    DataStruct dsItem = new DataStruct();
                    dsItem.PushIntoStack(userItem.UserItemID);
                    dsItem.PushIntoStack(itemInfo == null ? 0 : itemInfo.ItemID);
                    dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.ItemName.ToNotNullString());
                    dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.HeadID.ToNotNullString());
                    dsItem.PushIntoStack(userItem.ItemLv);
                    dsItem.PushIntoStack(itemInfo == null ? LanguageManager.GetLang().shortInt : (short)itemInfo.QualityType);
                    dsItem.PushIntoStack(strongMoney);
                    dsItem.PushIntoStack(equCodeTime);
                    dsItem.PushIntoStack(isStrong);
                    dsItem.PushIntoStack(isSynthesis);

                    if (itemInfo != null)
                    {
                        List <ItemEquAttrInfo> itemEquArray = new ShareCacheStruct <ItemEquAttrInfo>().FindAll(e => e.ItemID.Equals(itemInfo.ItemID));
                        dsItem.PushIntoStack(itemEquArray.Count);
                        foreach (ItemEquAttrInfo equ in itemEquArray)
                        {
                            DataStruct dsDetail = new DataStruct();
                            dsDetail.PushIntoStack((int)equ.AttributeID);
                            int baseNum;
                            {
                                baseNum = MathUtils.Addition(equ.BaseNum, userItem.ItemLv * equ.IncreaseNum, int.MaxValue);
                            }
                            dsDetail.PushIntoStack(baseNum);
                            dsItem.PushIntoStack(dsDetail);
                        }

                        dsItem.PushIntoStack(itemEquArray.Count);
                        foreach (ItemEquAttrInfo equ in itemEquArray)
                        {
                            DataStruct dsDetail = new DataStruct();
                            dsDetail.PushIntoStack((int)equ.AttributeID);
                            int baseNum;
                            {
                                baseNum = MathUtils.Addition(equ.BaseNum, (int)(MathUtils.Addition(userItem.ItemLv, (short)1, short.MaxValue)) * equ.IncreaseNum, int.MaxValue);
                            }
                            dsDetail.PushIntoStack(baseNum);
                            dsItem.PushIntoStack(dsDetail);
                        }
                    }

                    ds.PushIntoStack(dsItem);
                }

                PushIntoStack(ds);
            }
            PushIntoStack(queueID);
        }
コード例 #20
0
ファイル: Action1503.cs プロジェクト: KevinWxy/Scut-samples
        public override bool TakeAction()
        {
            //List<UserQueue> queueList = new GameDataCacheSet<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.MagicStrong);
            //if (queueList.Count > 0)
            //{
            //    if (queueList[0].StrengNum >= 2 && queueList[0].DoRefresh() > 0)
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St1503_MagicColding;
            //        return false;
            //    }
            //}
            magicInfo = new ConfigCacheSet <MagicInfo>().FindKey(magicID);
            if (magicInfo == null)
            {
                return(false);
            }
            int maxMagicLv = ConfigEnvSet.GetInt("Queue.MaxLength");

            UserMagic userMagic = new GameDataCacheSet <UserMagic>().FindKey(ContextUser.UserID, magicID);

            if (userMagic == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1503_MagicIDNotEnough;
                return(false);
            }
            sumMagicLv = MathUtils.Addition(userMagic.MagicLv, (short)1, (short)100);
            MagicLvInfo magicLvInfo = new ConfigCacheSet <MagicLvInfo>().FindKey(magicID, sumMagicLv);

            if (magicLvInfo == null || userMagic.MagicLv == maxMagicLv)
            {
                guideID = 1;
                //等级已达到最高
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1503_MaxMagicLv;
                return(false);
            }
            if (ContextUser.UserLv < magicLvInfo.EscalateMinLv)
            {
                //超出用户等级
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1503_MagicLevel;
                return(false);
            }


            experience = magicLvInfo.ExpNum;
            //codeTime = magicLvInfo.ColdTime;
            if (experience > ContextUser.ExpNum)
            {
                guideID = 3;
                //阅历不足
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = string.Format(LanguageManager.GetLang().St1503_UpgradeExpNum);
                return(false);
            }
            int useGold = 0;

            if (ops == 1)
            {
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.EquXiaoChuLengQueShiJian))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return(false);
                }
                useGold = (codeTime / 60);
                if (ContextUser.GoldNum < useGold)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
            }
            else
            {
                //放入队列中
                // List<UserQueue> queueList = new GameDataCacheSet<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType ==QueueType.MagicStrong);
                //todo
                //if (queueList.Count > 0)
                //{
                //    UserQueue queue = queueList[0];
                //    if (queue.DoRefresh() > 0 && queue.StrengNum < 2)
                //    {
                //        queue.TotalColdTime = MathUtils.Addition(queue.TotalColdTime, codeTime, int.MaxValue);
                //        queue.ColdTime = MathUtils.Addition(queue.ColdTime, codeTime, int.MaxValue);
                //        queue.IsSuspend = false;
                //        queue.StrengNum = MathUtils.Addition(queue.StrengNum, 1, int.MaxValue);
                //        //queue.Update();
                //    }
                //    else
                //    {
                //        queue.TotalColdTime = codeTime;
                //        queue.Timing = DateTime.Now;
                //        queue.ColdTime = codeTime;
                //        queue.IsSuspend = false;
                //        queue.StrengNum = 1;
                //        //queue.Update();
                //    }
                //}
                //else
                //{
                //    UserQueue userQueue = new UserQueue()
                //    {
                //        QueueID = Guid.NewGuid().ToString(),
                //        UserID = ContextUser.UserID,
                //        QueueType = QueueType.MagicStrong,
                //        QueueName = QueueType.MagicStrong.ToString(),
                //        TotalColdTime = codeTime,
                //        Timing = DateTime.Now,
                //        ColdTime = codeTime,
                //        StrengNum = 1,
                //        IsSuspend = false
                //    };
                //    new GameDataCacheSet<UserQueue>().Add(userQueue);
                //}
            }

            if (userMagic != null)
            {
                if (userMagic.MagicType == MagicType.MoFaZhen)
                {
                    MagicLvInfo mLvInfo    = new ConfigCacheSet <MagicLvInfo>().FindKey(userMagic.MagicID, userMagic.MagicLv);
                    string[]    mGridRange = mLvInfo.GridRange.Split(',');
                    foreach (string gridRange in mGridRange)
                    {
                        UserEmbattle userEmbattle = new GameDataCacheSet <UserEmbattle>().FindKey(ContextUser.UserID, userMagic.MagicID, gridRange.ToShort());
                        if (userEmbattle == null)
                        {
                            UserEmbattle embattle = new UserEmbattle()
                            {
                                UserID    = ContextUser.UserID,
                                MagicID   = userMagic.MagicID,
                                Position  = gridRange.ToShort(),
                                GeneralID = 0
                            };
                            new GameDataCacheSet <UserEmbattle>().Add(embattle);
                        }
                    }
                }

                if (experience < ContextUser.ExpNum)
                {
                    ContextUser.ExpNum = MathUtils.Subtraction(ContextUser.ExpNum, experience, 0);
                    userMagic.MagicLv  = MathUtils.Addition(userMagic.MagicLv, (short)1, (short)maxMagicLv);
                }
                UserLogHelper.AppenStrongLog(ContextUser.UserID, 1, null, magicID, 2, (short)userMagic.MagicLv, useGold, 0);
            }

            List <UserGeneral> userGeneralsArray = new GameDataCacheSet <UserGeneral>().FindAll(ContextUser.UserID, s => s.GeneralStatus == GeneralStatus.DuiWuZhong && s.GeneralType != GeneralType.Soul);

            foreach (UserGeneral general in userGeneralsArray)
            {
                general.RefreshMaxLife();
            }
            //日常任务-魔术升级
            TaskHelper.TriggerDailyTask(Uid, 4004);
            return(true);
        }
コード例 #21
0
        /// <summary>
        /// 处理礼包
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="order"></param>
        private static void DoGiff(string userID, OrderInfo order)
        {
            int packType = 0;
            List <PackageReceive> packageReceivess = new List <PackageReceive>();
            UserRechargeLog       rechargeLog      = new UserRechargeLog
            {
                LogID        = Guid.NewGuid().ToString(),
                UserID       = userID,
                OrderNo      = order.OrderNO,
                ChargeAmount = order.Amount,
                PayGold      = order.GameCoins,
                ReargeDate   = DateTime.Now
            };
            var sender = DataSyncManager.GetDataSender();

            sender.Send(rechargeLog);

            UserRecharge recharge = new GameDataCacheSet <UserRecharge>().FindKey(userID);

            if (recharge == null)
            {
                recharge = new UserRecharge()
                {
                    UserID = userID
                };
            }
            //处理充值活动
            recharge.LastNum = order.GameCoins;
            TriggerFestivalPack(recharge, order.GameCoins);
            if (IsCurrentWeek(recharge.ChargeDate))
            {
                recharge.WeekNum = MathUtils.Addition(recharge.WeekNum, order.GameCoins, int.MaxValue);
            }
            else
            {
                recharge.WeekNum = order.GameCoins;
            }
            if (recharge.ChargeDate.Month == DateTime.Now.Month)
            {
                recharge.MonthNum = MathUtils.Addition(recharge.MonthNum, order.GameCoins, int.MaxValue);
            }
            else
            {
                recharge.MonthNum = order.GameCoins;
            }

            recharge.TotalGoldNum = MathUtils.Addition(recharge.TotalGoldNum, order.GameCoins, int.MaxValue);
            recharge.ChargeDate   = DateTime.Now;
            var rechargeCacheSet = new GameDataCacheSet <UserRecharge>();

            if (rechargeCacheSet.FindKey(userID) == null)
            {
                packType          = 1;
                recharge.FirstNum = order.GameCoins;
                TriggerReceivePack(userID, packType, recharge.FirstNum);
                rechargeCacheSet.Add(recharge, GameEnvironment.CacheUserPeriod);
                FestivalHelper.GetFirstReward(userID, FestivalType.FirstReward);
                GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID);
                if (userInfo != null)
                {
                    FestivalHelper.GetPayReward(userInfo, order.GameCoins, FestivalType.FirstPayDoubleSpar);
                }
            }

            //触发总累计充值礼包
            packType = 2;
            TriggerReceivePack(userID, packType, recharge.TotalGoldNum);
            List <RechargePacks> rechargePackseArray = new ConfigCacheSet <RechargePacks>().FindAll(m => m.PacksType == packType);

            foreach (RechargePacks rechargePackse in rechargePackseArray)
            {
                RemoveCharge(userID, rechargePackse.PacksID);
            }
            TriggerWeekPack(userID, recharge.WeekNum);   //每周礼包
            TriggerMonthPack(userID, recharge.MonthNum); //每月礼包
        }
コード例 #22
0
        /// <summary>
        /// 奖励配置
        /// </summary>
        /// <param name="user"></param>
        /// <param name="status">状态值为1时,下发图片</param>
        public static string GetUserTake(List <PrizeInfo> prizeInfoList, string userID, int status = 0)
        {
            string           HeadID    = string.Empty;
            int              quality   = 0;
            List <PrizeInfo> prizeList = new List <PrizeInfo>();
            var              prize     = prizeInfoList[0];
            string           content   = string.Empty;

            switch (prize.Reward)
            {
            //随机
            case 1:
                if (prizeInfoList.Count > 0)
                {
                    int randomNum = RandomUtils.GetRandom(0, prizeInfoList.Count);
                    prizeList.Add(prizeInfoList[randomNum]);
                }

                break;

            //概率
            case 2:
                int   count   = prizeInfoList.Count;
                int[] precent = new int[count];
                for (int i = 0; i < count; i++)
                {
                    var prize2 = prizeInfoList[i];
                    precent[i] = (prize2.Probability * 1000).ToInt();
                }
                int index = RandomUtils.GetHitIndexByTH(precent);
                prizeList.Add(prizeInfoList[index]);
                break;

            //全部
            case 3:
                prizeList.AddRange(prizeInfoList);
                break;
            }
            prizeList.ForEach(prizeInfo =>
            {
                var cacheSetUser = new PersonalCacheStruct <GameUser>();
                var user         = cacheSetUser.FindKey(userID);

                if (user != null)
                {
                    switch (prizeInfo.Type)
                    {
                    case RewardType.GameGoin:
                        //content += string.Format(LanguageManager.GetLang().St_GameCoin, prizeInfo.Num) + ",";
                        //user.GameCoin = MathUtils.Addition(user.GameCoin, prizeInfo.Num);
                        HeadID = prizeInfo.HeadID;
                        // 1: 乘玩家等级
                        if (prizeInfo.IsMultiplyUserLv == 1)
                        {
                            int coinNumber = 0;
                            // 获取当前玩家等级
                            if (user.UserLv >= 1 && user.UserLv <= 100)
                            {
                                coinNumber = prizeInfo.Num * user.UserLv;
                            }

                            else if (user.UserLv < 1)
                            {
                                coinNumber = prizeInfo.Num * 1;
                            }
                            else
                            {
                                coinNumber = prizeInfo.Num * 100;
                            }
                            content      += string.Format(LanguageManager.GetLang().St_GameCoin, coinNumber) + ",";
                            user.GameCoin = MathUtils.Addition(user.GameCoin, coinNumber);
                        }
                        else
                        {
                            content      += string.Format(LanguageManager.GetLang().St_GameCoin, prizeInfo.Num) + ",";
                            user.GameCoin = MathUtils.Addition(user.GameCoin, prizeInfo.Num);
                        }
                        break;

                    case RewardType.Gold:
                        HeadID        = prizeInfo.HeadID;
                        content      += string.Format(LanguageManager.GetLang().St_GiftGoldNum, prizeInfo.Num) + ",";
                        user.GiftGold = MathUtils.Addition(user.GiftGold, prizeInfo.Num);
                        break;

                    case RewardType.EnergyNum:
                        content       += string.Format(LanguageManager.GetLang().St_EnergyNum, prizeInfo.Num) + ",";
                        user.EnergyNum = MathUtils.Addition(user.EnergyNum, prizeInfo.Num).ToShort();
                        break;

                    case RewardType.ExpNum:
                        content    += string.Format(LanguageManager.GetLang().St_ExpNum, prizeInfo.Num) + ",";
                        user.ExpNum = MathUtils.Addition(user.ExpNum, prizeInfo.Num);
                        break;

                    case RewardType.Experience:
                        content += string.Format(LanguageManager.GetLang().St_Experience, prizeInfo.Num) + ",";
                        GeneralEscalateHelper.AddUserLv(user, prizeInfo.Num);
                        break;

                    case RewardType.CrystalId:
                        var crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(prizeInfo.ItemID);
                        if (crystalInfo != null)
                        {
                            //content += string.Format(LanguageManager.GetLang().St_Crystal, crystalInfo.CrystalName) + ",";
                            content += crystalInfo.CrystalName + ",";
                            CrystalHelper.AppendCrystal(user.UserID, crystalInfo.CrystalID, prizeInfo.UserLv);
                        }
                        break;

                    case RewardType.Item:
                        var itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(prizeInfo.ItemID);
                        if (itemInfo != null)
                        {
                            //content += string.Format(LanguageManager.GetLang().St_Item, itemInfo.ItemName,  prizeInfo.Num) + ",";
                            //UserItemHelper.AddUserItem(user.UserID, prizeInfo.ItemID, prizeInfo.Num, prizeInfo.UserLv);
                            if (status == 1)
                            {
                                HeadID   = prizeInfo.HeadID;
                                content += string.Format(LanguageManager.GetLang().St_ItemReward, itemInfo.ItemName, prizeInfo.Num) + ",";
                                UserItemHelper.AddUserItem(user.UserID, prizeInfo.ItemID, prizeInfo.Num, prizeInfo.UserLv);
                            }
                            else
                            {
                                content += string.Format(LanguageManager.GetLang().St_Item, itemInfo.ItemName, prizeInfo.UserLv, prizeInfo.Num) + ",";
                                UserItemHelper.AddUserItem(user.UserID, prizeInfo.ItemID, prizeInfo.Num, prizeInfo.UserLv);
                            }
                        }
                        break;

                    case RewardType.MonsterCard:
                        //  获取 JSON 中的怪物记录
                        var monsterCard = prizeInfoList.Find(s => s.Type == RewardType.MonsterCard);

                        var userPlotInfo = new PersonalCacheStruct <UserPlotPackage>().FindKey(user.UserID);
                        if (userPlotInfo != null)
                        {
                            List <PlotNPCInfo> plotNpcInfoList = new List <PlotNPCInfo>();
                            var userPlotPackageList            = userPlotInfo.PlotPackage.FindAll(x => x.PlotStatus == PlotStatus.Completed);
                            // PlotID
                            if (userPlotPackageList.Count > 0)
                            {
                                userPlotPackageList.ForEach(userPlot =>
                                {
                                    var plotNPCInfo = new ShareCacheStruct <PlotNPCInfo>().Find(x => x.PlotID == userPlot.PlotID);
                                    if (plotNPCInfo != null)
                                    {
                                        plotNpcInfoList.Add(plotNPCInfo);
                                    }
                                });
                                if (plotNpcInfoList.Count > 0)
                                {
                                    int index     = RandomUtils.GetRandom(0, plotNpcInfoList.Count);
                                    int plotNpcID = plotNpcInfoList[index].PlotNpcID;

                                    var plotEmbattleInfo = new ShareCacheStruct <PlotEmbattleInfo>().Find(x => x.PlotNpcID == plotNpcID);

                                    if (plotEmbattleInfo != null)
                                    {
                                        var monsterInfo = new ShareCacheStruct <MonsterInfo>().FindKey(plotEmbattleInfo.MonsterID);
                                        if (monsterInfo != null)
                                        {
                                            var itemMonster = new ShareCacheStruct <ItemBaseInfo>().FindKey(monsterInfo.ItemID);
                                            HeadID          = itemMonster.HeadID;

                                            content += string.Format(LanguageManager.GetLang().St_MonsterCard, itemMonster.ItemName,
                                                                     prizeInfo.Num) + ",";
                                            UserItemHelper.AddUserItem(user.UserID, monsterInfo.ItemID, prizeInfo.Num, prizeInfo.UserLv);
                                        }
                                    }
                                }
                            }
                            #region 注释
                            //else
                            //{
                            //    // 副本没有通关默认奖励为第一种金币奖励
                            //    HeadID = prize.HeadID;
                            //    int coinNumber = prize.Num;  // 第一条记录中金币数
                            //    // 获取当前玩家等级
                            //    if (user.UserLv >= 1 && user.UserLv <= 100)
                            //    {
                            //        coinNumber = coinNumber * user.UserLv;
                            //    }

                            //    else if (user.UserLv < 1)
                            //    {
                            //        coinNumber = coinNumber * 1;
                            //    }
                            //    else
                            //    {
                            //        coinNumber = coinNumber * 100;
                            //    }
                            //    content += string.Format(LanguageManager.GetLang().St_GameCoin, coinNumber) + ",";
                            //    user.GameCoin = MathUtils.Addition(user.GameCoin, coinNumber);
                            //}
                            #endregion
                        }

                        break;

                    case RewardType.GeneralSoul:
                        var generalInfoList = new ShareCacheStruct <GeneralInfo>().FindAll(x => x.GeneralQuality == prizeInfo.GeneralQuality);
                        if (generalInfoList != null)
                        {
                            if (generalInfoList.Count > 0)
                            {
                                int index = RandomUtils.GetRandom(0, generalInfoList.Count);
                                GeneralInfo generalInfo = generalInfoList[index];
                                HeadID   = generalInfo.HeadID;
                                quality  = generalInfo.GeneralQuality.ToInt();
                                content += string.Format(LanguageManager.GetLang().St_GeneralSoul,
                                                         generalInfo.GeneralName, prizeInfo.Num) + ",";
                                UserItemHelper.AddGeneralSoul(user.UserID, generalInfo.SoulID, prizeInfo.Num);
                            }
                        }
                        break;

                    case RewardType.Ability:
                        // 查找绿色技能列表
                        var abilityInfoList = new ShareCacheStruct <AbilityInfo>().FindAll(x => x.AbilityQuality == prizeInfo.AbilityQuality);
                        if (abilityInfoList != null)
                        {
                            if (abilityInfoList.Count > 0)
                            {
                                int index = RandomUtils.GetRandom(0, abilityInfoList.Count);
                                AbilityInfo abilityInfo = abilityInfoList[index];
                                HeadID   = abilityInfo.HeadID;
                                quality  = abilityInfo.AbilityQuality;
                                content += string.Format(LanguageManager.GetLang().St_Ability, abilityInfo.AbilityName, prizeInfo.Num) + ",";
                                UserAbilityHelper.AddUserAbility(abilityInfo.AbilityID, Convert.ToInt32(user.UserID), 0, 0);
                            }
                        }
                        break;
                    }
                }
                // 状态值为1时下发图片
                if (status == 1)
                {
                    #region  如果奖励为空,则默认奖励金币

                    string[] rewardInfo = content.TrimEnd(',').Split('*');
                    if (String.IsNullOrEmpty(rewardInfo[0]))
                    {
                        // 默认奖励为第一种金币奖励
                        HeadID         = prize.HeadID;
                        int coinNumber = prize.Num;  // 第一条记录中金币数
                        // 获取当前玩家等级
                        if (user.UserLv >= 1 && user.UserLv <= 100)
                        {
                            coinNumber = coinNumber * user.UserLv;
                        }

                        else if (user.UserLv < 1)
                        {
                            coinNumber = coinNumber * 1;
                        }
                        else
                        {
                            coinNumber = coinNumber * 100;
                        }
                        content      += string.Format(LanguageManager.GetLang().St_GameCoin, coinNumber) + ",";
                        user.GameCoin = MathUtils.Addition(user.GameCoin, coinNumber);
                    }

                    #endregion
                    content = content.TrimEnd(',') + "*" + HeadID + "*" + quality + ",";
                }
            });
            content = content.TrimEnd(',');

            return(content);
        }
コード例 #23
0
ファイル: UserPackHelper.cs プロジェクト: dongliang/Scut
        /// <summary>
        /// 判断背包是否已满
        /// </summary>
        /// <param name="backpackType"></param>
        /// <returns></returns>
        public static bool PackIsFull(GameUser user, BackpackType backpackType, int buyNum, out string prizeContent)
        {
            prizeContent = "";
            bool isFull   = false;
            var  userPack = _cacheSetUserPack.FindKey(user.UserID);
            var  pack     = userPack != null && userPack.PackTypeList != null
                           ? userPack.PackTypeList.Find(s => s.BackpackType == backpackType)
                           : null;

            int position = pack != null ? pack.Position : 0;
            int num      = 0;

            switch (backpackType)
            {
            case BackpackType.BeiBao:
                var userItem = _cacheSetUserItem.FindKey(user.UserID);
                var bdList   = userItem != null && userItem.ItemPackage != null
                                  ? userItem.ItemPackage.FindAll(s => s.ItemType != ItemType.BengDai)
                                  : null;

                if (bdList != null && bdList.Count > 0)
                {
                    foreach (var userItemInfo in bdList)
                    {
                        num = MathUtils.Addition(num, userItemInfo.Num);
                    }
                }
                if ((num + buyNum) > position * 99)
                {
                    prizeContent = LanguageManager.GetLang().PackFull;
                    isFull       = true;
                }
                break;

            case BackpackType.ZhuangBei:
                var userItem2 = _cacheSetUserItem.FindKey(user.UserID);
                num = userItem2 != null && userItem2.ItemPackage != null
                                  ? userItem2.ItemPackage.FindAll(s => s.ItemType == ItemType.ZhuangBei).Count
                                  : 0;

                //if (zbList != null && zbList.Count > 0)
                //{
                //    foreach (var userItemInfo in zbList)
                //    {
                //        num = MathUtils.Addition(num, userItemInfo.Num);
                //    }
                //}
                if ((num + buyNum) >= position)
                {
                    prizeContent = LanguageManager.GetLang().EquipFull;
                    isFull       = true;
                }

                break;

            case BackpackType.YongBing:
                var userGeneralList = _cacheSetUserGeneral.FindAll(user.UserID);
                num = userGeneralList != null ? userGeneralList.Count : 0;
                if ((num + buyNum) >= position)
                {
                    prizeContent = LanguageManager.GetLang().GeneralFull;
                    isFull       = true;
                }
                break;

            case BackpackType.HunJi:
                var userAbility = _cacheSetUserAbility.FindKey(user.UserID);
                num = userAbility != null && userAbility.AbilityList != null ? userAbility.AbilityList.Count : 0;
                if ((num + buyNum) >= position)
                {
                    prizeContent = LanguageManager.GetLang().AbilityFull;
                    isFull       = true;
                }
                break;
            }

            return(isFull);
        }
コード例 #24
0
        private void DoCombat(MorePlotTeam team)
        {
            //初始阵形
            var plotNpcTeam = new ConfigCacheSet <PlotNPCInfo>().FindAll(m => m.PlotID == team.MorePlot.PlotID);
            List <MonsterQueue> monsterQueueList = new List <MonsterQueue>(plotNpcTeam.Count);
            var userEmbattleList = new List <UserEmbattleQueue>(team.UserList.Count);

            foreach (var npcInfo in plotNpcTeam)
            {
                monsterQueueList.Add(new MonsterQueue(npcInfo.PlotNpcID));
            }
            foreach (var user in team.UserList)
            {
                var gameUser = new GameDataCacheSet <GameUser>().FindKey(user.UserId);
                userEmbattleList.Add(new UserEmbattleQueue(user.UserId, gameUser.UseMagicID, 0, CombatType.MultiPlot));
            }
            bool isLoop   = true;
            int  maxCount = 0;

            while (isLoop)
            {
                if (maxCount > 500)
                {
                    break;
                }
                int overNum = 0;
                for (int i = 0; i < userEmbattleList.Count; i++)
                {
                    maxCount++;
                    int position;
                    var userEmbattle = userEmbattleList[i];
                    if (userEmbattle.IsOver)
                    {
                        overNum++;
                        continue;
                    }
                    var monster = GetMonster(monsterQueueList, i, out position);
                    if (monster == null || monster.IsOver)
                    {
                        team.CombatResult = true;
                        isLoop            = false;
                        break;
                    }
                    ICombatController controller   = new TjxCombatController();
                    ISingleCombat     plotCombater = controller.GetSingleCombat(CombatType.MultiPlot);
                    plotCombater.SetAttack(userEmbattle);
                    plotCombater.SetDefend(monster);
                    bool IsWin = plotCombater.Doing();


                    var processLost = new TeamCombatProcess
                    {
                        TeamID           = team.TeamID,
                        PlotID           = team.MorePlot.PlotID,
                        Position         = position,
                        ProcessContainer = (CombatProcessContainer)plotCombater.GetProcessResult(),
                        UserId           = team.UserList[i].UserId,
                        PlotNpcID        = plotNpcTeam[position].PlotNpcID,
                        IsWin            = IsWin
                    };
                    //new BaseLog().SaveDebuLog(string.Format("多人副本>>{4}组队{0}打{1}位置{2}结果{3}", processLost.UserId, processLost.PlotNpcID, position + 1, IsWin, team.TeamID));

                    AppendLog(team.TeamID, processLost);
                }
                if (overNum == userEmbattleList.Count)
                {
                    team.CombatResult = false;
                    isLoop            = false;
                }
            }

            //奖励
            if (team.CombatResult)
            {
                //new BaseLog().SaveDebuLog(string.Format("多人副本>>组队{0}结果{1}", team.TeamID, team.CombatResult));
                SetCombatResult(team.TeamID, team.CombatResult);

                var chatService = new TjxChatService();
                foreach (var user in team.UserList)
                {
                    GameUser gameUser = new GameDataCacheSet <GameUser>().FindKey(user.UserId);
                    gameUser.ExpNum = MathUtils.Addition(gameUser.ExpNum, team.MorePlot.ExpNum, int.MaxValue);
                    //gameUser.Update();
                    UserItemHelper.AddUserItem(user.UserId, team.MorePlot.ItemId, team.MorePlot.ItemNum);
                    new BaseLog("参加多人副本获得奖励:" + team.MorePlot.ItemName);
                    SetWinNum(user.UserId, team.MorePlot.PlotID);
                    CombatHelper.DailyMorePlotRestrainNum(gameUser.UserID, team.MorePlot.PlotID); // 多人副本获胜加一次
                    chatService.SystemSendWhisper(gameUser, string.Format(LanguageManager.GetLang().St4211_MorePlotReward,
                                                                          team.MorePlot.ExpNum, team.MorePlot.ItemName, team.MorePlot.ItemNum));
                }
            }
        }
コード例 #25
0
ファイル: Action1210.cs プロジェクト: xushenghan/Scut-samples
        public override void BuildPacket()
        {
            this.PushIntoStack(_lingshiNum);
            this.PushIntoStack(_userGeneralArray.Count);
            foreach (var general in _userGeneralArray)
            {
                List <UserItemInfo> userItemArray = userItemDict.ContainsKey(general.GeneralID)
                    ? userItemDict[general.GeneralID] : new List <UserItemInfo>();

                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(general.GeneralID);
                dsItem.PushIntoStack(general.GeneralName.ToNotNullString());
                dsItem.PushIntoStack(userItemArray.Count);
                foreach (var item in userItemArray)
                {
                    var        itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(item.ItemID) ?? new ItemBaseInfo();
                    DataStruct dsItem1  = new DataStruct();
                    dsItem1.PushIntoStack(item.UserItemID.ToNotNullString());
                    dsItem1.PushIntoStack(item.ItemID);
                    dsItem1.PushIntoStack(itemInfo.ItemName.ToNotNullString());
                    dsItem1.PushIntoStack(itemInfo.HeadID.ToNotNullString());
                    dsItem1.PushIntoStack(itemInfo.QualityType.ToShort());
                    dsItem1.PushIntoStack(itemInfo.EquParts.ToShort());

                    dsItem.PushIntoStack(dsItem1);
                }

                PushIntoStack(dsItem);
            }
            this.PushIntoStack(_sparePartList.Length);
            for (int i = 0; i < _sparePartList.Length; i++)
            {
                var sparePart = _sparePartList[i] ?? new UserSparePart();
                if (sparePart.Position == 0)
                {
                    sparePart.SetPosition((short)(i + 1));
                }
                short enableStatus = 0;
                if (sparePart.CheckEnable(user.UserExtend.MaxLayerNum))
                {
                    enableStatus = 1;
                }
                var sparePartInfo = new ShareCacheStruct <SparePartInfo>().FindKey(sparePart.SparePartId) ?? new SparePartInfo();

                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(sparePart.Position);
                dsItem.PushIntoStack(enableStatus);
                dsItem.PushIntoStack(sparePart.UserSparepartID.ToNotNullString());
                dsItem.PushIntoStack(sparePartInfo.Name.ToNotNullString());
                dsItem.PushIntoStack(sparePartInfo.HeadID.ToNotNullString());
                dsItem.PushIntoStack(sparePartInfo.QualityType.ToShort());
                dsItem.PushIntoStack(sparePartInfo.CoinPrice);
                dsItem.PushIntoStack(sparePartInfo.LingshiPrice);

                dsItem.PushIntoStack(sparePart.Propertys.Count);
                for (int r = 0; r < sparePart.Propertys.Count; r++)
                {
                    var   property = sparePart.Propertys[r];
                    short proPos   = MathUtils.Addition(property.ValueIndex, (short)1, short.MaxValue);
                    short isEnable = 0;
                    if (property.IsEnable)
                    {
                        isEnable = 1;
                    }
                    DataStruct dsItem1 = new DataStruct();
                    dsItem1.PushIntoStack(property.AbilityType.ToShort());
                    dsItem1.PushIntoStack(property.Num.ToNotNullString());
                    dsItem1.PushIntoStack(property.HitMinValue.ToNotNullString());
                    dsItem1.PushIntoStack(property.HitMaxValue.ToNotNullString());
                    dsItem1.PushIntoStack(isEnable);
                    dsItem1.PushIntoStack(proPos);

                    dsItem.PushIntoStack(dsItem1);
                }

                this.PushIntoStack(dsItem);
            }
        }
コード例 #26
0
        public override bool TakeAction()
        {
            UserGeneral userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID);

            if (userGeneral == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            int useGoldNum = 0;

            int jiaQiang = ConfigEnvSet.GetInt("User.JiaQiangTraining");
            int ZuanShi  = ConfigEnvSet.GetInt("User.ZuanShiTraining");
            int BaiJin   = ConfigEnvSet.GetInt("User.BaiJinTraining");
            int ZhiZun   = ConfigEnvSet.GetInt("User.ZhiZunTraining");

            int maxTrainingNum = MathUtils.Addition((userGeneral.GeneralLv * 2), 20, int.MaxValue); //培养上限

            int trainingPower     = (int)userGeneral.TrainingPower;
            int trainingSoul      = (int)userGeneral.TrainingSoul;
            int trainingIntellect = (int)userGeneral.TrainingIntellect;

            if (trainingPower >= maxTrainingNum && trainingSoul >= maxTrainingNum && trainingIntellect >= maxTrainingNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St1409_maxTrainingNum;
                return(false);
            }

            if (CultureType.PuTong == cultureType)
            {
                newPower     = (short)random.Next(1, MathUtils.Addition(trainingPower, 5, maxTrainingNum));
                newSoul      = (short)random.Next(1, MathUtils.Addition(trainingSoul, 5, maxTrainingNum));
                newIntellect = (short)random.Next(1, MathUtils.Addition(trainingIntellect, 5, maxTrainingNum));
                if (ContextUser.GameCoin < UserHelper.GetCultureMoney(ContextUser.UserID, generalID))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                    return(false);
                }
                ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, UserHelper.GetCultureMoney(ContextUser.UserID, generalID), 0);
            }
            else if (CultureType.JiaQiang == cultureType)
            {
                newPower     = (short)random.Next(3, MathUtils.Addition(trainingPower, 6, maxTrainingNum));
                newSoul      = (short)random.Next(3, MathUtils.Addition(trainingSoul, 6, maxTrainingNum));
                newIntellect = (short)random.Next(3, MathUtils.Addition(trainingIntellect, 6, maxTrainingNum));
                useGoldNum   = jiaQiang;
            }
            else if (CultureType.BaiJin == cultureType)
            {
                newPower     = (short)random.Next(5, MathUtils.Addition(trainingPower, 7, maxTrainingNum));
                newSoul      = (short)random.Next(5, MathUtils.Addition(trainingSoul, 7, maxTrainingNum));
                newIntellect = (short)random.Next(5, MathUtils.Addition(trainingIntellect, 7, maxTrainingNum));
                useGoldNum   = BaiJin;
            }
            else if (CultureType.ZuanShi == cultureType)
            {
                newPower     = (short)random.Next(7, MathUtils.Addition(trainingPower, 8, maxTrainingNum));
                newSoul      = (short)random.Next(7, MathUtils.Addition(trainingSoul, 8, maxTrainingNum));
                newIntellect = (short)random.Next(7, MathUtils.Addition(trainingIntellect, 8, maxTrainingNum));
                useGoldNum   = ZuanShi;
            }
            else if (CultureType.ZhiZun == cultureType)
            {
                newPower     = (short)MathUtils.Addition(trainingPower, 5, maxTrainingNum);
                newSoul      = (short)MathUtils.Addition(trainingSoul, 5, maxTrainingNum);
                newIntellect = (short)MathUtils.Addition(trainingIntellect, 5, maxTrainingNum);
                useGoldNum   = ZhiZun;
            }
            if (useGoldNum > ContextUser.GoldNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                return(false);
            }
            ContextUser.UseGold           = MathUtils.Addition(ContextUser.UseGold, useGoldNum, int.MaxValue);
            ContextUser.GeneralID         = generalID;
            ContextUser.TrainingPower     = newPower;
            ContextUser.TrainingSoul      = newSoul;
            ContextUser.TrainingIntellect = newIntellect;

            //日常任务-培养
            TaskHelper.TriggerDailyTask(Uid, 4002);

            return(true);
        }
コード例 #27
0
        /// <summary>
        /// 人物属性
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="generalID"></param>
        /// <param name="abilityType"></param>
        /// <returns></returns>
        public static int GetPropertyNum(string userID, int generalID, AbilityType abilityType)
        {
            GameUser    user         = new GameDataCacheSet <GameUser>().FindKey(userID);
            int         propertyNum  = 0;
            int         powerNum     = 0; //力量
            int         soulNum      = 0; //魂力
            int         intellectNum = 0; //智力
            int         generalLv    = 0;
            UserGeneral general      = new GameDataCacheSet <UserGeneral>().FindKey(userID, generalID);

            if (general != null)
            {
                generalLv    = (int)general.GeneralLv;
                powerNum     = (int)MathUtils.Addition(general.PowerNum, general.TrainingPower);
                soulNum      = (int)MathUtils.Addition(general.SoulNum, general.TrainingSoul);
                intellectNum = (int)MathUtils.Addition(general.IntellectNum, general.TrainingIntellect);
                //公会技能加成
                if (user != null && !string.IsNullOrEmpty(user.MercenariesID) && general.GeneralID == LanguageManager.GetLang().GameUserGeneralID)
                {
                    powerNum     = MathUtils.RoundCustom(powerNum * GetGuildAbilityNum(user.UserID, GuildAbilityType.PowerNum)).ToShort();
                    soulNum      = MathUtils.RoundCustom(soulNum * GetGuildAbilityNum(user.UserID, GuildAbilityType.SoulNum)).ToShort();
                    intellectNum = MathUtils.RoundCustom(intellectNum * GetGuildAbilityNum(user.UserID, GuildAbilityType.IntellectNum)).ToShort();
                }

                if (general.GeneralID == LanguageManager.GetLang().GameUserGeneralID)
                {
                    //法宝基础属性加成
                    powerNum     = MathUtils.Addition(powerNum, TrumpAbilityAttack.TrumpPropertyNum(userID, general.GeneralID, AbilityType.PowerNum));
                    soulNum      = MathUtils.Addition(soulNum, TrumpAbilityAttack.TrumpPropertyNum(userID, general.GeneralID, AbilityType.SoulNum));
                    intellectNum = MathUtils.Addition(intellectNum, TrumpAbilityAttack.TrumpPropertyNum(userID, general.GeneralID, AbilityType.IntelligenceNum));

                    //法宝--技能属性转换获得的值
                    decimal trumpPower     = TrumpAbilityAttack.ConversionPropertyNum(userID, powerNum, soulNum, intellectNum, AbilityType.PowerNum);
                    decimal trumpsoul      = TrumpAbilityAttack.ConversionPropertyNum(userID, powerNum, soulNum, intellectNum, AbilityType.SoulNum);
                    decimal trumpintellect = TrumpAbilityAttack.ConversionPropertyNum(userID, powerNum, soulNum, intellectNum, AbilityType.IntelligenceNum);
                    powerNum     = MathUtils.Addition(trumpPower.ToInt(), powerNum);
                    soulNum      = MathUtils.Addition(trumpsoul.ToInt(), soulNum);
                    intellectNum = MathUtils.Addition(trumpintellect.ToInt(), intellectNum);
                }
                if (abilityType == AbilityType.WuLiGongJi)
                {
                    //物理攻击
                    propertyNum = (generalLv * powerNum * 1 / 10);
                }
                else if (abilityType == AbilityType.WuLiFangYu)
                {
                    //物理防御
                    propertyNum = (generalLv * powerNum * 7 / 100);
                }
                else if (abilityType == AbilityType.HunJiGongJi)
                {
                    //魂技攻击
                    propertyNum = (generalLv * soulNum * 7 / 100);
                }
                else if (abilityType == AbilityType.HunJiFangYu)
                {
                    //魂技防御
                    propertyNum = (generalLv * soulNum * 7 / 100);
                }
                else if (abilityType == AbilityType.MoFaGongJi)
                {
                    //魔法攻击
                    propertyNum = (generalLv * intellectNum * 7 / 100);
                }
                else if (abilityType == AbilityType.MoFaFangYu)
                {
                    //魔法防御
                    propertyNum = (generalLv * intellectNum * 7 / 100);
                }
            }
            if (propertyNum.IsValid())
            {
                return(propertyNum);
            }
            throw new ArgumentOutOfRangeException(string.Format("玩家{0}佣兵{1}属性值溢出:{2}", userID, generalID, propertyNum));
        }
コード例 #28
0
        public override bool TakeAction()
        {
            List <GeneralHeritage> heritageList = new List <GeneralHeritage>();

            if (ContextUser.HeritageList.Count > 0)
            {
                heritageList = ContextUser.HeritageList.ToList();
                GeneralHeritage heritage  = heritageList.Find(m => m.Type == HeritageType.Heritage);
                GeneralHeritage gheritage = heritageList.Find(m => m.Type == HeritageType.IsHeritage);
                if (heritage == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1418_HeritageNotEnough;
                    return(false);
                }
                else if (gheritage == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1419_IsHeritageNotEnough;
                    return(false);
                }
                var         cacheSet        = new GameDataCacheSet <UserGeneral>();
                UserGeneral general         = cacheSet.FindKey(ContextUser.UserID, heritage.GeneralID);
                UserGeneral heritagegeneral = cacheSet.FindKey(ContextUser.UserID, gheritage.GeneralID);
                if (general == null || heritagegeneral == null || general.GeneralID == heritagegeneral.GeneralID)
                {
                    return(false);
                }
                if (general.GeneralID == heritagegeneral.GeneralID)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1419_HeritageNotInIsHeritage;
                    return(false);
                }
                if (general.HeritageType == HeritageType.Heritage)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1419_HeritageInUse;
                    return(false);
                }
                int useGold = 0;
                int opsType = 0;
                int vipLv   = 0;
                if (ops == 1)
                {
                    ErrorCode = ops;
                    if (!IsNomalHeritage(ContextUser.UserID, ops))
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1419_DanInsufficientHeritage;
                        return(false);
                    }
                }
                else if (ops == 2)
                {
                    opsType   = 2;
                    useGold   = HeritageUseGold(opsType, out vipLv);
                    ErrorCode = ops;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St1419_GoldHeritage, useGold);
                    return(false);
                }
                else if (ops == 3)
                {
                    opsType = 2;
                    useGold = HeritageUseGold(opsType, out vipLv);
                    if (ContextUser.GoldNum < useGold)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                    if (gheritage.opsType != opsType)
                    {
                        return(false);
                    }
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
                }

                else if (ops == 4)
                {
                    opsType   = 3;
                    useGold   = HeritageUseGold(opsType, out vipLv);
                    ErrorCode = ops;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St1419_ExtremeHeritage, useGold);
                    return(false);
                }
                else if (ops == 5)
                {
                    opsType = 3;
                    useGold = HeritageUseGold(opsType, out vipLv);
                    if (vipLv > ContextUser.VipLv)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
                        return(false);
                    }
                    if (ContextUser.GoldNum < useGold)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                    if (gheritage.opsType != opsType)
                    {
                        return(false);
                    }
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
                }
                ErrorCode = ops;
                heritagegeneral.GeneralLv = gheritage.GeneralLv;
                general.GeneralStatus     = GeneralStatus.YinCang;
                var embattleList = new GameDataCacheSet <UserEmbattle>().FindAll(ContextUser.UserID, s => s.GeneralID == general.GeneralID);
                foreach (var embattle in embattleList)
                {
                    embattle.GeneralID = 0;
                }
                //heritagegeneral.TrainingPower = gheritage.PowerNum;
                //heritagegeneral.TrainingSoul = gheritage.SoulNum;
                //heritagegeneral.TrainingIntellect = gheritage.IntellectNum;
                //heritagegeneral.HeritageType = HeritageType.IsHeritage;
                //general.HeritageType = HeritageType.Heritage;
                ContextUser.HeritageList = new CacheList <GeneralHeritage>();
                ErrorInfo = LanguageManager.GetLang().St1419_HeritageSuccess;
            }
            return(true);
        }
コード例 #29
0
ファイル: Action3204.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            if (!string.IsNullOrEmpty(_friendId) && new GameDataCacheSet <GameUser>().FindKey(_friendId) == null)
            {
                UserCacheGlobal.LoadOffline(_friendId);
            }
            if (ContextUser.UserExtend == null || (_petId != petMinLevel && ContextUser.UserExtend.LightPetID != _petId))
            {
                //SaveLog(string.Format("宠物赛跑开始接口请求ID{0},当前点亮ID{1}", _petId, ContextUser.UserExtend.LightPetID));
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3204_PetNoEnable;
                return(false);
            }

            PetRunPool petRunPool = new ShareCacheStruct <PetRunPool>().FindKey(Uid);

            if (petRunPool != null && petRunPool.IsRunning)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo      = LanguageManager.GetLang().St3204_PetRunning;
                return(false);
            }
            if (new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid) != null)
            {
                var userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid);
                int maxNum       = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PetRun).MaxNum;
                if (userRestrain.UserExtend != null)
                {
                    if (userRestrain.UserExtend.PetRunTimes >= maxNum)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St3204_PetRunTimesOut;
                        return(false);
                    }
                }
            }
            if (new GameDataCacheSet <UserDailyRestrain>().FindKey(_friendId) != null)
            {
                var userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(_friendId);
                int maxNum       = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PetHelp).MaxNum;
                if (userRestrain.UserExtend != null)
                {
                    if (userRestrain.UserExtend.PetHelp >= maxNum)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo      = LanguageManager.GetLang().St3204_PetHelpeTimesOut;
                        return(false);
                    }
                }
            }

            decimal minusNum = (decimal)FestivalHelper.TortoiseHare(ContextUser.UserID);

            ContextUser.UserExtend.UpdateNotify(obj =>
            {
                ContextUser.UserExtend.LightPetID = 0;
                return(true);
            }
                                                );
            //ContextUser.Update();
            var petCacheSet = new ShareCacheStruct <PetRunPool>();
            var petInfo     = new ConfigCacheSet <PetInfo>().FindKey(_petId) ?? new PetInfo();

            if (petRunPool == null)
            {
                petRunPool = new PetRunPool(Uid);
                petCacheSet.Add(petRunPool, GameEnvironment.CacheGlobalPeriod);
                petRunPool = petCacheSet.FindKey(Uid);
            }
            petRunPool.FriendID      = _friendId;
            petRunPool.PetID         = _petId;
            petRunPool.StartDate     = DateTime.Now;
            petRunPool.EndDate       = DateTime.Now.AddSeconds(petInfo.ColdTime);
            petRunPool.GameCoin      = (int)Math.Floor(petInfo.CoinRate * ContextUser.UserLv * minusNum);
            petRunPool.ObtainNum     = (int)Math.Floor(petInfo.ObtainRate * ContextUser.UserLv * minusNum);
            petRunPool.InterceptUser = string.Empty;



            if (new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid) != null)
            {
                var userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid);
                userRestrain.UserExtend.UpdateNotify(obj =>
                {
                    userRestrain.UserExtend.PetRunTimes = MathUtils.Addition(userRestrain.UserExtend.PetRunTimes, 1);
                    return(true);
                });
                //userRestrain.Update();
            }

            if (new GameDataCacheSet <UserDailyRestrain>().FindKey(petRunPool.FriendID) != null)
            {
                var userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(petRunPool.FriendID);
                if (userRestrain.UserExtend == null)
                {
                    userRestrain.UserExtend = new DailyUserExtend();
                }
                userRestrain.UserExtend.UpdateNotify(obj =>
                {
                    userRestrain.UserExtend.PetHelp = MathUtils.Addition(userRestrain.UserExtend.PetHelp, 1);
                    return(true);
                });
                //userRestrain.Update();
            }
            return(true);
        }
コード例 #30
0
        /// <summary>
        /// 日常活动领取
        /// </summary>
        /// <param name="user"></param>
        /// <param name="festivalID"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static bool UseFestivalRestrain(GameUser user, int festivalID, out string content)
        {
            content = string.Empty;
            FestivalInfo     info      = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);
            var              cacheSet  = new GameDataCacheSet <FestivalRestrain>();
            FestivalRestrain restrain  = cacheSet.FindKey(user.UserID, festivalID);
            short            isReceive = FestivalIsReceive(user, festivalID);

            if (info != null && isReceive == 1)
            {
                if (info.FestivalType == FestivalType.UpgradeGiveGift && user.UserLv < info.RestrainNum)
                {
                    content = LanguageManager.GetLang().St_LevelNotEnough;
                    return(false);
                }
                if (info.FestivalType == FestivalType.FirstReward ||
                    info.FestivalType == FestivalType.UpgradeGiveGift || info.FestivalType == FestivalType.PayAccumulation)
                {
                    content = PrizeHelper.PrizeContent(user, info.Reward.ToList());
                    if (!string.IsNullOrEmpty(content))
                    {
                        return(false);
                    }
                    content = PrizeHelper.GetPrizeUserTake(user, info.Reward.ToList());
                    if (!string.IsNullOrEmpty(content))
                    {
                        if (info.FestivalExtend != null && !string.IsNullOrEmpty(info.FestivalExtend.Desc))
                        {
                            content = string.Format(info.FestivalExtend.Desc, content);
                        }
                        return(true);
                    }
                }
                if (restrain != null && (info.FestivalType == FestivalType.PayReward || info.FestivalType == FestivalType.FirstPayDoubleSpar))
                {
                    if (info.FestivalExtend != null)
                    {
                        int payNum = (info.RestrainNum * info.FestivalExtend.MinusNum).ToInt();
                        user.GiftGold = MathUtils.Addition(user.GiftGold, payNum);
                        if (!string.IsNullOrEmpty(info.FestivalExtend.Desc))
                        {
                            content = string.Format(info.FestivalExtend.Desc, payNum);
                        }
                        return(true);
                    }
                }
                if (info.FestivalType == FestivalType.LoginGiveGift)
                {
                    List <PrizeInfo> prizeList = info.Reward.FindAll(s => s.RefreshDate.Date == DateTime.Now.Date);
                    content = PrizeHelper.GetPrizeUserTake(user, prizeList);
                    if (!string.IsNullOrEmpty(content))
                    {
                        if (info.FestivalExtend != null && !string.IsNullOrEmpty(info.FestivalExtend.Desc))
                        {
                            content = string.Format(info.FestivalExtend.Desc, content);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }