예제 #1
0
        private string DoBossItem(GameUser user, BossItem bossItem, int randId)
        {
            string prizeItemMsg = string.Empty;
            ////筛选物品
            var itemInfoList = new ConfigCacheSet <ItemBaseInfo>().FindAll(m => m.ItemType == bossItem.Type && m.MedicineLv == bossItem.ItemLv);

            if (itemInfoList.Count > 0)
            {
                for (int i = 0; i < bossItem.Num; i++)
                {
                    ItemBaseInfo itemInfo = itemInfoList[RandomUtils.GetRandom(0, itemInfoList.Count)];
                    if (itemInfo == null)
                    {
                        continue;
                    }
                    UserItemHelper.AddUserItem(user.UserID, itemInfo.ItemID, 1);
                    if (prizeItemMsg.Length > 0)
                    {
                        prizeItemMsg += " ";
                    }
                    prizeItemMsg += string.Format(LanguageManager.GetLang().St5405_CombatNum, itemInfo.ItemName, 1);
                }
            }
            return(prizeItemMsg);
        }
예제 #2
0
        protected override void ProcessCmd(string[] args)
        {
            int itemID  = args.Length > 0 ? args[0].Trim().ToInt() : 0;
            int itemNum = args.Length > 1 ? args[1].Trim().ToInt() : 1;

            UserItemHelper.AddUserItem(UserID, itemID, itemNum);
            //AddUserItem(UserID, itemID, itemNum);
        }
예제 #3
0
        /// <summary>
        /// 新手礼包
        /// </summary>
        /// <param name="user"></param>
        /// <param name="item"></param>
        /// <param name="noviceActivities"></param>
        /// <returns></returns>
        public static bool GetNoviceActivities(GameUser user, UserItemInfo item, NoviceActivities noviceActivities)
        {
            List <NoviceReward> noviceArray = noviceActivities.Reward.ToList();
            var package       = UserItemPackage.Get(user.UserID);
            var userItemArray = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus == ItemStatus.BeiBao);
            int subPackNum    = MathUtils.Subtraction(user.GridNum, MathUtils.Subtraction(userItemArray.Count, 5, 0), 0);

            if (noviceArray.Count > subPackNum)
            {
                return(false);
            }

            bool isupdate = false;

            foreach (NoviceReward reward in noviceArray)
            {
                if (reward.Type == 1)
                {
                    isupdate       = true;
                    user.EnergyNum = MathUtils.Addition(user.EnergyNum, (short)reward.Num, short.MaxValue);
                }
                if (reward.Type == 2)
                {
                    isupdate      = true;
                    user.GameCoin = MathUtils.Addition(user.GameCoin, reward.Num, int.MaxValue);
                }
                else if (reward.Type == 3)
                {
                    ItemBaseInfo itemInfo    = new ShareCacheStruct <ItemBaseInfo>().FindKey(reward.Reward);
                    UserGeneral  userGeneral = UserGeneral.GetMainGeneral(user.UserID);
                    if (itemInfo.ItemType == ItemType.ZhuangBei && !itemInfo.CheckCareer(userGeneral.CareerID))
                    {
                        continue;
                    }
                    UserItemHelper.AddUserItem(user.UserID, itemInfo.ItemID, reward.Num);
                }
                else if (reward.Type == 4)
                {
                    //晶石
                    isupdate      = true;
                    user.GiftGold = MathUtils.Addition(user.GiftGold, reward.Num, int.MaxValue);
                }
            }
            UserItemHelper.UseUserItem(user.UserID, item.ItemID, 1);

            if (isupdate)
            {
                //user.Update();
            }

            if (item.ItemID == 5000 || item.ItemID == 5001 ||
                item.ItemID == 5002 || item.ItemID == 5003)
            {
                int itemID = MathUtils.Addition(item.ItemID, 1, int.MaxValue);
                UserItemHelper.AddUserItem(user.UserID, itemID, 1);
            }
            return(true);
        }
예제 #4
0
        private string DoBossItem(GameUser user, BossItem bossItem, int randId)
        {
            string prizeItemMsg = string.Empty;
            //筛选物品
            var itemInfoList = new ConfigCacheSet <ItemBaseInfo>().FindAll(m =>
            {
                bool result = false;
                if (m.ItemType == bossItem.Type)
                {
                    if (m.ItemID == bossItem.ItemId)
                    {
                        return(true);
                    }
                    if (m.ItemType == ItemType.TuZhi)
                    {
                        result = m.MedicineLv <= bossItem.ItemLv;
                    }
                    else
                    {
                        if (bossItem.ItemLv > 0 && bossItem.Quality > 0)
                        {
                            result = m.DemandLv == bossItem.ItemLv && (short)m.QualityType == bossItem.Quality;
                        }
                        else if (bossItem.ItemLv > 0)
                        {
                            result = m.DemandLv == bossItem.ItemLv;
                        }
                        else if (bossItem.Quality > 0)
                        {
                            result = (short)m.QualityType == bossItem.Quality;
                        }
                    }
                }
                return(result);
            });

            if (itemInfoList.Count > 0)
            {
                for (int i = 0; i < bossItem.Num; i++)
                {
                    ItemBaseInfo itemInfo = itemInfoList[RandomUtils.GetRandom(0, itemInfoList.Count)];
                    if (itemInfo == null)
                    {
                        continue;
                    }
                    UserItemHelper.AddUserItem(user.UserID, itemInfo.ItemID, 1);
                    if (prizeItemMsg.Length > 0)
                    {
                        prizeItemMsg += " ";
                    }
                    prizeItemMsg += string.Format("{0}*{1}", itemInfo.ItemName, 1);
                }
            }
            return(prizeItemMsg);
        }
예제 #5
0
        public override bool TakeAction()
        {
            var package       = UserItemPackage.Get(Uid);
            var userItemArray = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus == ItemStatus.BeiBao);

            if (userItemArray.Count >= ContextUser.GridNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St7004_BeiBaoTimeOut;
                return(false);
            }

            ItemBaseInfo itemInfo  = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemID);
            int          mallPrice = 0;

            if (itemInfo != null)
            {
                mallPrice = itemInfo.MysteryPrice; //itemInfo.PackMaxNum * itemInfo.SalePrice;
            }
            if (itemInfo != null && mallPrice > ContextUser.GameCoin)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                return(false);
            }
            if (ContextUser.UserExtend != null && ContextUser.UserExtend.UserShops != null)
            {
                List <MysteryShops> mysteryList = ContextUser.UserExtend.UserShops.ToList();
                MysteryShops        shops       = mysteryList.Find(m => m.ItemID == itemID);
                if (shops != null)
                {
                    if (shops.BuyNum > 0)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St7005_HavePurchasedItem;
                        return(false);
                    }

                    if (shops.BuyNum > 0)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St7005_HavePurchasedItem;
                        return(false);
                    }
                    shops.BuyNum         = 1;
                    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, mallPrice, 0);
                    //ContextUser.Update();

                    UserItemHelper.AddUserItem(ContextUser.UserID, itemID, itemNum);
                }
            }
            return(true);
        }
예제 #6
0
        private static bool IsGridNumFull(GameUser user)
        {
            int itemid         = 5019;
            var userItemsArray = UserItemHelper.GetItems(user.UserID).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);

            if (userItemsArray.Count < user.GridNum)
            {
                UserItemHelper.AddUserItem(user.UserID, itemid, 1);
                return(true);
            }
            return(false);
        }
예제 #7
0
        /// <summary>
        /// 奖励配置
        /// </summary>
        /// <param name="user"></param>
        public static void ChestGetUserTake(TreasureInfo prize, GameUser user)
        {
            switch (prize.Type)
            {
            case RewardType.GameGoin:
                user.GameCoin = MathUtils.Addition(user.GameCoin, prize.Num.ToInt());
                break;

            case RewardType.Obtion:
                user.ObtainNum = MathUtils.Addition(user.ObtainNum, prize.Num.ToInt());
                break;

            case RewardType.ExpNum:
                user.ExpNum = MathUtils.Addition(user.ExpNum, prize.Num.ToInt());
                break;

            case RewardType.EnergyNum:
                user.EnergyNum = MathUtils.Addition(user.EnergyNum, prize.Num.ToShort());
                break;

            case RewardType.Experience:
                break;

            case RewardType.Gold:
                user.GiftGold = MathUtils.Addition(user.GiftGold, prize.Num.ToInt());
                break;

            case RewardType.Item:
                if (!UserAbilityHelper.UseUserItem(user.UserID, prize.ItemID))
                {
                    UserItemHelper.AddUserItem(user.UserID, prize.ItemID, prize.Num.ToInt());
                }
                break;

            case RewardType.CrystalId:
                short crystalLv = prize.ItemLv > 0 ? prize.ItemLv : 1.ToShort();
                CrystalHelper.AppendCrystal(user.UserID, prize.ItemID, crystalLv);
                break;

            case RewardType.Spare:
                AppendSpare(user, prize.ItemID);
                break;

            case RewardType.Enchant:
                short enchantLv = prize.ItemLv > 0 ? prize.ItemLv : 1.ToShort();
                EnchantHelper.AppendEnchat(user.UserID, prize.ItemID, enchantLv);
                break;

            default:
                break;
            }
        }
예제 #8
0
        /// <summary>
        /// 活动奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="reward"></param>
        /// <param name="num"></param>
        public static void GameUserReward(string userID, RewardType reward, int itemID, int num)
        {
            GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID);

            if (userInfo != null)
            {
                if (reward == RewardType.GameGoin)
                {
                    userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, num, int.MaxValue);
                    //userInfo.Update();
                }
                else if (reward == RewardType.Obtion)
                {
                    userInfo.ObtainNum = MathUtils.Addition(userInfo.ObtainNum, num, int.MaxValue);
                    //userInfo.Update();
                }
                else if (reward == RewardType.EnergyNum)
                {
                    userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, (short)num, short.MaxValue);
                    //userInfo.Update();
                }
                else if (reward == RewardType.ExpNum)
                {
                    userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, num, int.MaxValue);
                    //userInfo.Update();
                }
                else if (reward == RewardType.Gold)
                {
                    userInfo.ItemGold = MathUtils.Addition(userInfo.ItemGold, num, int.MaxValue);
                    //userInfo.Update();
                }
                else if (reward == RewardType.Experience)
                {
                    UserHelper.UserGeneralExp(userID, num);
                }
                else if (reward == RewardType.Item)
                {
                    UserItemHelper.AddUserItem(userID, itemID, num);
                }
                else if (reward == RewardType.CrystalType)
                {
                    CrystalQualityType qualityType = CrystalQualityType.PurPle;
                    GetUserCrystal(userInfo, qualityType);
                }
                else if (reward == RewardType.CrystalId)
                {
                    UserHelper.CrystalAppend(userID, itemID, 2);
                }
            }
        }
예제 #9
0
        public static ItemBaseInfo ShowLairReward(LairTreasure lairTreasure, GameUser gameUser, LairTreasureType lairTreasureType)    //��ʾ��õ���Ʒ
        {
            var          cacheSetItem   = new ConfigCacheSet <ItemBaseInfo>();
            ItemBaseInfo itemBaseInfo   = null;
            var          lairRewardList = new ConfigCacheSet <LairRewardInfo>().FindAll(s => s.LairPosition == lairTreasure.LairPosition && s.LairTreasureType == lairTreasureType.ToInt());

            if (lairRewardList.Count > 0)
            {
                var lairRewardInfo = lairRewardList[RandomUtils.GetRandom(0, lairRewardList.Count)];
                itemBaseInfo = cacheSetItem.FindKey(lairRewardInfo.ItemID);
                if (itemBaseInfo != null)
                {
                    UserItemHelper.AddUserItem(gameUser.UserID, lairRewardInfo.ItemID, lairTreasure.Num);
                }
            }

            return(itemBaseInfo);
        }
예제 #10
0
        public override bool TakeAction()
        {
            int itemID = 0;

            if (ContextUser.UserLv <= 20)
            {
                itemID = 3067;
            }
            else if (ContextUser.UserLv <= 40 && ContextUser.UserLv > 20)
            {
                itemID = 3068;
            }
            else if (ContextUser.UserLv <= 60 && ContextUser.UserLv > 40)
            {
                itemID = 3069;
            }
            UserItemHelper.AddUserItem(ContextUser.UserID, itemID, 1);
            return(true);
        }
예제 #11
0
        /// <summary>
        /// 送新手礼包
        /// </summary>
        private void SendGifItem()
        {
            const int newitemID = 5000;

            UserItemHelper.AddUserItem(Uid, newitemID, 1);

            int itemID = 0;  //送武器

            if (_careerID == 1)
            {
                itemID = 1027;
            }
            else if (_careerID == 2)
            {
                itemID = 1020;
            }
            else if (_careerID == 3)
            {
                itemID = 1013;
            }
            UserItemHelper.AddUserItem(Uid, itemID, 1, ItemStatus.YongBing);
        }
예제 #12
0
        private static void SendMessage(CountryLvGroup lvGroup)
        {
            List <KeyValuePair <string, CountryUser> > cuserList = lvGroup.UserList.ToList();

            var chatService = new TjxChatService();

            foreach (KeyValuePair <string, CountryUser> keyPair in cuserList)
            {
                CountryUser cuser    = keyPair.Value;
                GameUser    gameUser = new PersonalCacheStruct <GameUser>().FindKey(cuser.UserId);
                if (gameUser != null)
                {
                    gameUser.UserStatus = UserStatus.Normal;
                    gameUser.GroupType  = CountryType.None;
                    //领土战礼包
                    UserItemHelper.AddUserItem(gameUser.UserID, 5013, 1);
                    CombatHelper.EmbattlePostion(gameUser.UserID);
                }
                string content = string.Format(LanguageManager.GetLang().St5204_CombatTransfusion,
                                               cuser.WinCount, cuser.FailCount, cuser.GameCoin, cuser.ObtainNum);
                chatService.SystemSendWhisper(cuser.UserId, cuser.UserName, cuser.UserVipLv, content);
            }
        }
예제 #13
0
        public static void GetLaiReward(LairTreasureType lairTreasureType, GameUser gameUser, int id, int postion)       //��ȡ��Ʒ
        {
            var          lairTreasuerList = new ConfigCacheSet <LairTreasureInfo>().FindKey(MathUtils.ToInt(lairTreasureType));
            LairTreasure lairTreasure     = lairTreasuerList.LairTreasureList[postion];
            var          lairRewardInfo   = new ConfigCacheSet <LairRewardInfo>().FindKey(id);
            var          rewardTye        = lairRewardInfo.LairRewardType.ToEnum <LairRewardType>();

            switch (rewardTye)
            {
            case LairRewardType.GameGoin:
                gameUser.GameCoin = MathUtils.Addition(gameUser.GameCoin, lairTreasure.Num);
                break;

            case LairRewardType.Gold:
                gameUser.PayGold = MathUtils.Addition(gameUser.PayGold, lairTreasure.Num);
                break;

            case LairRewardType.FunJi:
            case LairRewardType.WuPing:
                UserItemHelper.AddUserItem(gameUser.UserID, lairRewardInfo.ItemID, 1);
                break;
            }
        }
예제 #14
0
        /// <summary>
        /// 物品ID=等级=数量
        /// </summary>
        /// <param name="list"></param>
        /// <param name="userID"></param>
        private static void PutItemPackage(string[] list, string userID)
        {
            foreach (string item in list)
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }
                string[] itemList = item.Split(new char[] { '=' });

                int   itemID  = itemList.Length > 0 ? Convert.ToInt32(itemList[0]) : 0;
                short itemLv  = itemList.Length > 1 ? Convert.ToInt16(itemList[1]) : (short)0;
                int   itemNum = itemList.Length > 2 ? Convert.ToInt32(itemList[2]) : 0;

                if (itemNum > 0 && new ShareCacheStruct <ItemBaseInfo>().FindKey(itemID) != null)
                {
                    UserItemHelper.AddUserItem(userID, itemID, itemNum, ItemStatus.BeiBao, itemLv);
                }
                else
                {
                    new Base.BaseLog().SaveLog("领取物品异常", new Exception(string.Format("userID:{3},itemID:{0},itemNum:{1},itemLv:{2}", itemID, itemNum, itemLv, userID)));
                }
            }
        }
예제 #15
0
        public override bool TakeAction()
        {
            //判断充值礼包是否开启
            FestivalInfo festivalInfo = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);

            if (festivalInfo != null && !festivalInfo.IsStop)
            {
                return(false);
            }

            UserRecharge         recharges   = new GameDataCacheSet <UserRecharge>().FindKey(ContextUser.UserID);
            RechargePacks        rePacksInfo = new ConfigCacheSet <RechargePacks>().FindKey(_packsID);
            List <PackageReward> rewardArray = new List <PackageReward>();

            if (rePacksInfo != null)
            {
                rewardArray = rePacksInfo.Reward.ToList();
                var userItemArray = UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);
                int subPackNum    = MathUtils.Subtraction(ContextUser.GridNum, userItemArray.Count, 0);
                if (rewardArray.Count > subPackNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1606_GridNumNotEnough;
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            if (!isRecevies(ContextUser.UserID, _packsID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9003_AlreadyReceived;
                return(false);
            }
            List <PackageReceive> receiveArray = new GameDataCacheSet <PackageReceive>().FindAll(ContextUser.UserID, m => m.PacksID == _packsID);

            bool           isRece   = false;
            PackageReceive pReceive = null;

            foreach (PackageReceive receive in receiveArray)
            {
                if (!receive.IsReceive)
                {
                    isRece            = true;
                    receive.IsReceive = true;
                    pReceive          = receive;
                    break;
                }
            }
            if (pReceive == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9003_AlreadyReceived;
                return(false);
            }


            pReceive.IsReceive   = true;
            pReceive.ReceiveDate = DateTime.Now;
            //pReceive.Update();


            if (pReceive.PacksType == 1 && recharges != null && isRece)
            {
                int totalPay = (int)(recharges.FirstNum * rePacksInfo.ProportionNum);
                if (totalPay >= 1)
                {
                    ContextUser.ItemGold = MathUtils.Addition(ContextUser.ItemGold, totalPay, int.MaxValue);
                    //ContextUser.Update();
                }
                //ContextUser.PayGold = ContextUser.PayGold.Addition(recharges.FirstNum, int.MaxValue);

                foreach (PackageReward reward in rewardArray)
                {
                    UserItemHelper.AddUserItem(ContextUser.UserID, reward.Num, 1);
                }
            }
            else if (recharges != null && isRece)
            {
                foreach (PackageReward reward in rewardArray)
                {
                    if (reward.Type == 2)
                    {
                        ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, reward.Num, int.MaxValue);
                    }
                    else if (reward.Type == 3)
                    {
                        ContextUser.ExpNum = MathUtils.Addition(ContextUser.ExpNum, reward.Num, int.MaxValue);
                    }
                    else if (reward.Type == 4)
                    {
                        ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, reward.Num, int.MaxValue);
                    }
                    else if (reward.Type == 5)
                    {
                        ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, reward.Num.ToShort(), short.MaxValue);
                    }
                    else if (reward.Type == 6)
                    {
                        GameUserExtend extend = ContextUser.UserExtend;
                        extend.GainBlessing = MathUtils.Addition(extend.GainBlessing, reward.Num, int.MaxValue);

                        //List<GuildMember> memberArray = new ShareCacheStruct<GuildMember>().FindAll(m => m.UserID ==  ContextUser.UserID);
                        //if (memberArray.Length > 0)
                        //{
                        //    memberArray[0].GainBlessing = memberArray[0].GainBlessing.Addition(reward.Num, int.MaxValue);
                        //    memberArray[0].Update();
                        //}
                    }
                    //ContextUser.Update();
                }
            }

            PackageReceiveLog receiveLog = new PackageReceiveLog()
            {
                LogID       = Guid.NewGuid().ToString(),
                ReceiveID   = receiveArray[0].ReceiveID,
                PacksID     = _packsID,
                UserID      = ContextUser.UserID,
                ReceiveDate = DateTime.Now,
            };
            var sender = DataSyncManager.GetDataSender();

            sender.Send(receiveLog);
            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 ConfigCacheSet <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 ConfigCacheSet <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 ConfigCacheSet <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 ConfigCacheSet <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 ConfigCacheSet <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
        public override bool TakeAction()
        {
            var cacheSet = new PersonalCacheStruct <UserGeneral>();

            if (recruitType == RecruitType.SoulRecruit)
            {
                general = new ShareCacheStruct <GeneralInfo>().FindKey(soulID);
                if (general == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
                UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, soulID);
                if (soulID == 0 || userGeneral != null)
                {
                    UserItemHelper.AddUserItem(ContextUser.UserID, general.ItemID, 1);
                }
                else
                {
                    userGeneral        = new UserGeneral();
                    userGeneral.UserID = ContextUser.UserID;
                    cacheSet.Add(userGeneral);
                    userGeneral.GeneralID         = general.GeneralID;
                    userGeneral.GeneralName       = general.GeneralName;
                    userGeneral.HeadID            = general.HeadID;
                    userGeneral.PicturesID        = general.PicturesID;
                    userGeneral.GeneralLv         = (short)general.GeneralLv;
                    userGeneral.LifeNum           = general.LifeNum;
                    userGeneral.GeneralType       = GeneralType.YongBing;
                    userGeneral.CareerID          = general.CareerID;
                    userGeneral.PowerNum          = general.PowerNum;
                    userGeneral.SoulNum           = general.SoulNum;
                    userGeneral.IntellectNum      = general.IntellectNum;
                    userGeneral.TrainingPower     = 0;
                    userGeneral.TrainingSoul      = 0;
                    userGeneral.TrainingIntellect = 0;
                    userGeneral.HitProbability    = ConfigEnvSet.GetDecimal("Combat.HitiNum");
                    userGeneral.AbilityID         = general.AbilityID;
                    userGeneral.Momentum          = 0;
                    userGeneral.Description       = general.Description;
                    userGeneral.GeneralStatus     = GeneralStatus.DuiWuZhong;
                    userGeneral.CurrExperience    = 0;
                    userGeneral.Experience1       = 0;
                    userGeneral.Experience2       = 0;
                }
            }
            else
            {
                RecruitRule recruitRule = new ShareCacheStruct <RecruitRule>().FindKey(recruitType);
                if (recruitRule == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
                int surplusNum = GeneralHelper.SurplusNum(ContextUser.UserID, recruitRule.FreeNum,
                                                          recruitRule.RecruitType.ToEnum <RecruitType>());
                if (surplusNum > 0 && !GeneralHelper.GeneralRecruitColdTime(ContextUser.UserID, recruitType))
                {
                    GeneralHelper.UpdateDailyRecruitNum(ContextUser.UserID, recruitType);
                    GeneralHelper.UpdateRecruitColdTime(ContextUser.UserID, recruitRule);
                }
                else
                {
                    if (ContextUser.GoldNum < recruitRule.GoldNum)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, recruitRule.GoldNum);
                }

                CacheList <RecruitInfo> recruitInfos = recruitRule.GeneralQuality;
                double[] probability = new double[recruitInfos.Count];
                for (int i = 0; i < recruitInfos.Count; i++)
                {
                    probability[i] = (double)recruitInfos[i].Probability;
                }
                int            index2      = RandomUtils.GetHitIndex(probability);
                GeneralQuality quality     = recruitInfos[index2].Quality;
                var            generalList = new ShareCacheStruct <GeneralInfo>().FindAll(s => s.GeneralQuality == quality);
                if (generalList.Count > 0)
                {
                    int indexradom = RandomUtils.GetRandom(0, generalList.Count);
                    if (indexradom < 0 || indexradom >= generalList.Count)
                    {
                        return(false);
                    }
                    general = generalList[indexradom];

                    UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, general.GeneralID);

                    if (userGeneral != null && userGeneral.GeneralStatus != GeneralStatus.YinCang)
                    {
                        currSoulID  = general.SoulID;
                        gainNum     = general.DemandNum;
                        userGeneral = cacheSet.FindKey(ContextUser.UserID, currSoulID);
                        if (userGeneral != null)
                        {
                            userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, gainNum);
                            generalType          = GeneralType.Soul;
                        }
                        else
                        {
                            userGeneral           = new UserGeneral();
                            userGeneral.UserID    = ContextUser.UserID;
                            userGeneral.GeneralID = currSoulID;
                            generalType           = GeneralType.Soul;
                            cacheSet.Add(userGeneral);
                            UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID, 1);
                        }
                    }
                    else if (userGeneral == null)
                    {
                        userGeneral           = new UserGeneral();
                        userGeneral.UserID    = ContextUser.UserID;
                        userGeneral.GeneralID = general.GeneralID;
                        generalType           = GeneralType.YongBing;
                        cacheSet.Add(userGeneral);
                        UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID, 1);
                    }
                    userGeneral.GeneralName       = general.GeneralName;
                    userGeneral.HeadID            = general.HeadID;
                    userGeneral.PicturesID        = general.PicturesID;
                    userGeneral.GeneralLv         = (short)general.GeneralLv;
                    userGeneral.LifeNum           = general.LifeNum;
                    userGeneral.GeneralType       = generalType;
                    userGeneral.CareerID          = general.CareerID;
                    userGeneral.PowerNum          = general.PowerNum;
                    userGeneral.SoulNum           = general.SoulNum;
                    userGeneral.IntellectNum      = general.IntellectNum;
                    userGeneral.TrainingPower     = 0;
                    userGeneral.TrainingSoul      = 0;
                    userGeneral.TrainingIntellect = 0;
                    userGeneral.HitProbability    = ConfigEnvSet.GetDecimal("Combat.HitiNum");
                    userGeneral.AbilityID         = general.AbilityID;
                    userGeneral.Momentum          = 0;
                    userGeneral.Description       = general.Description;
                    userGeneral.GeneralStatus     = GeneralStatus.DuiWuZhong;
                    userGeneral.CurrExperience    = 0;
                    userGeneral.Experience1       = 0;
                    userGeneral.Experience2       = 0;

                    //玩家抽取到蓝色和紫色佣兵时,给予系统频道提示
                    //if (recruitType != RecruitType.SoulRecruit)
                    //{
                    //    if (general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Blue || general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Purple)
                    //    {
                    //        string content = string.Empty;
                    //        content = string.Format(LanguageManager.GetLang().St_UserGetGeneralQuality, ContextUser.NickName,recruitType,
                    //                            general.GeneralQuality.ToEnum<GeneralQuality>(), general.GeneralName);
                    //        new TjxChatService().SystemSend(ChatType.System, content);
                    //    }
                    //}
                }
            }
            return(true);
        }
예제 #18
0
        //protected override bool ValidateElement()
        //{
        //    return UserHelper.GetKeyWordSubstitution(UserName);

        //}
        protected override bool CreateUserRole(out IUser user)
        {
            user = null;
            int MaxLength = ConfigEnvSet.GetInt("User.MaxLength");
            int length    = System.Text.Encoding.Default.GetByteCount(UserName);

            if (UserHelper.GetKeyWordSubstitution(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RegistNameKeyWord;
                return(false);
            }
            if (GameUser.IsNickName(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_Rename;
                return(false);
            }
            if (length <= 0 || length > MaxLength)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = string.Format(LanguageManager.GetLang().St1005_KingNameTooLong, MaxLength);
                return(false);
            }
            Regex re = new Regex(@"^[\u4e00-\u9fa5\w]+$");

            if (!re.IsMatch(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RegistNameExceptional;
                return(false);
            }
            if (!Pid.ToLower().StartsWith("z"))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_PassportError;
                return(false);
            }
            GeneralInfo general = new ConfigCacheSet <GeneralInfo>().FindKey(generalID);

            if (general == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            CareerInfo careerInfo = new ConfigCacheSet <CareerInfo>().FindKey(general.CareerID);

            if (careerInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_Professional;
                return(false);
            }

            GameUser userEntity = new GameDataCacheSet <GameUser>().FindKey(Uid);

            if (userEntity != null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleExist;
                return(false);
            }
            bool userSex = Sex == 0 ? false : true;

            if (new GameDataCacheSet <GameUser>().FindKey(Uid) == null)
            {
                userEntity = CreateGameUser(userSex);
                user       = new SessionUser(userEntity);
                NoviceHelper.RetailLoginDaysReceive(userEntity); //渠道登录奖励
                CreateGeneral(careerInfo);
                CreateMagic(userEntity);
                //每日限制次数
                CreateDailyRestrain();
                //开启默认功能
                EnableFunction();
                //SendGifItem();
                UserPrayHelper.AddUserPray(Uid.ToInt(), PrayType.SanTianQiDao);
                UserPackHelper.AddUserPack(Uid);
                UserLoginLog userLoginLog = new UserLoginLog();
                userLoginLog.UserId     = Uid;
                userLoginLog.SessionID  = Sid;
                userLoginLog.MobileType = MobileType;
                userLoginLog.ScreenX    = ScreenX;
                userLoginLog.ScreenY    = ScreenY;
                userLoginLog.RetailId   = RetailID;
                userLoginLog.AddTime    = DateTime.Now;
                userLoginLog.State      = LoginStatus.Logined;
                userLoginLog.DeviceID   = DeviceID;
                userLoginLog.Ip         = this.GetRealIP();
                userLoginLog.Pid        = userEntity.Pid;
                userLoginLog.UserLv     = userEntity.UserLv;
                var sender = DataSyncManager.GetDataSender();
                sender.Send(userLoginLog);
                BackPackHelper.AddBack(userEntity);
                UserHelper.OpenMagic(Uid, 1);
                //封测注册发放礼包
                UserItemHelper.AddUserItem(Uid, 1704, 1, ItemStatus.BeiBao);
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleExist;
                return(false);
            }
            PlotHelper.EnablePlot(Uid, ConfigEnvSet.GetInt("UserPlot.OpenLockPlotID"));
            return(true);
        }
예제 #19
0
        private void DoCombat(MorePlotTeam team)
        {
            //初始阵形
            var plotNpcTeam = new ShareCacheStruct <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 PersonalCacheStruct <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 PersonalCacheStruct <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));
                }
            }
        }
예제 #20
0
        public override bool TakeAction()
        {
            short        opType            = 0;
            UserItemInfo synthesisUserItem = null;
            var          package           = UserItemPackage.Get(Uid);
            UserItemInfo userItem          = null;

            if (!string.IsNullOrEmpty(_userItemID))
            {
                var userItemList = package.ItemPackage.FindAll(m => !m.IsRemove && m.UserItemID.Equals(_userItemID));
                foreach (var item in userItemList)
                {
                    if (item.ItemStatus == ItemStatus.Sell)
                    {
                        package.RemoveItem(userItem);
                        continue;
                    }
                    else if (item.SoldDate > MathUtils.SqlMinDate)
                    {
                        item.SoldDate = MathUtils.SqlMinDate;
                        //package.Update();
                        userItem = item;
                    }
                    else
                    {
                        userItem = item;
                    }
                }
                if (userItem == null)
                {
                    return(false);
                }
                ItemBaseInfo itemBaseOpType = new ConfigCacheSet <ItemBaseInfo>().FindKey(userItem.ItemID);
                if (itemBaseOpType == null)
                {
                    return(false);
                }
                if (itemBaseOpType.ItemType == ItemType.TuZhi)
                {
                    opType = 1;
                }
                else
                {
                    opType = 2;
                }
            }
            else if (!string.IsNullOrEmpty(_userEquID))
            {
                opType   = 1;
                userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(_userEquID));
            }
            if (userItem == null)
            {
                return(false);
            }
            int genlv = ContextUser.UserLv;
            CacheList <SynthesisInfo> synthesisInfoList = new CacheList <SynthesisInfo>();
            short itemLv = 0;
            List <ItemSynthesisInfo> itemSynthesisArray = new ConfigCacheSet <ItemSynthesisInfo>().FindAll(m => m.SynthesisID == userItem.ItemID); //图纸ID

            if (itemSynthesisArray.Count > 0)
            {
                ItemSynthesisInfo synthesisInfo = itemSynthesisArray[0];
                if (synthesisInfo == null)
                {
                    return(false);
                }
                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(synthesisInfo.ItemID);
                if (itemInfo != null && itemInfo.ItemType == ItemType.ZhuangBei && itemInfo.DemandLv > genlv)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                    return(false);
                }
                List <ItemSynthesisInfo> synthesisArray = new ConfigCacheSet <ItemSynthesisInfo>().FindAll(m => m.ItemID == synthesisInfo.ItemID);//合成物品的材料数组
                if (synthesisArray.Count == 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return(false);
                }
                int useGold = GetSytnthesisGold(ContextUser.UserID, synthesisInfo.ItemID);
                if (_ops == 1)
                {
                    #region 普通合成
                    if (!GetMaterialsNum(ContextUser.UserID, synthesisInfo.ItemID) && ContextUser.VipLv < 4)
                    {
                        ErrorCode = 3;
                        ErrorInfo = LanguageManager.GetLang().St1603_MaterialsNotEnough;
                        return(false);
                    }
                    if (!GetMaterialsNum(ContextUser.UserID, synthesisInfo.ItemID) && ContextUser.VipLv >= 4)
                    {
                        ErrorCode = 2;
                        ErrorInfo = LanguageManager.GetLang().St1603_MaterialsNotEnough + "," + string.Format(LanguageManager.GetLang().St1603_SynthesisEnergyNum, useGold);
                        return(false);
                    }
                    foreach (ItemSynthesisInfo synthesis in synthesisArray)
                    {
                        ItemBaseInfo itemsInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(synthesis.SynthesisID);
                        if (itemInfo == null)
                        {
                            return(false);
                        }
                        if (!string.IsNullOrEmpty(_userEquID) && synthesis.SynthesisID == userItem.ItemID && itemsInfo != null && itemInfo.ItemType == ItemType.ZhuangBei)
                        {
                            if (userItem.ItemStatus == ItemStatus.YongBing)
                            {
                                //if (UserHelper.IsItemEquSpare(ContextUser, userItem.UserItemID))
                                //{
                                //    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                //    ErrorInfo = LanguageManager.GetLang().St_ItemEquIndexOfSpare;
                                //    return false;
                                //}
                                if (IsLevelNotEnough(ContextUser, userItem.GeneralID, synthesisInfo.ItemID))
                                {
                                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                                    return(false);
                                }
                                UserItemHelper.AddItemLog(ContextUser.UserID, userItem.ItemID, userItem.Num, userItem.ItemLv, 9, userItem.UserItemID);
                                synthesisInfoList.Add(new SynthesisInfo()
                                {
                                    DemandID = userItem.ItemID, Num = 1
                                });
                                //package.SyncCache(() =>
                                //{
                                //    userItem.IsRemove = true;
                                //    package.ItemPackage.Remove(userItem);
                                //    package.DelayChange();
                                //});
                            }
                        }
                        else
                        {
                            if (itemsInfo != null && itemsInfo.ItemType == ItemType.ZhuangBei)
                            {
                                synthesisUserItem = GetUserItemInfo(ContextUser.UserID, itemsInfo.ItemID);
                                if (IsLevelNotEnough(ContextUser, synthesisUserItem.GeneralID, synthesisInfo.ItemID))
                                {
                                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                                    return(false);
                                }
                                //synthesisUserItem = GetUserItemInfo(ContextUser.UserID, itemsInfo.ItemID);
                            }
                            else
                            {
                                synthesisInfoList.Add(new SynthesisInfo()
                                {
                                    DemandID = synthesis.SynthesisID, Num = synthesis.DemandNum
                                });
                                UserItemHelper.UseUserItem(ContextUser.UserID, synthesis.SynthesisID, synthesis.DemandNum);
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(_userEquID))
                    {
                        itemLv = MathUtils.Subtraction(userItem.ItemLv, (short)5, (short)1);
                        UpdateUserItem(synthesisInfo.ItemID, userItem);
                        UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                    }
                    else
                    {
                        if (synthesisUserItem != null)
                        {
                            itemLv = MathUtils.Subtraction(synthesisUserItem.ItemLv, (short)5, (short)1);
                            UpdateUserItem(synthesisInfo.ItemID, synthesisUserItem);
                            UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                        }
                        else
                        {
                            UserItemHelper.AddUserItem(ContextUser.UserID, synthesisInfo.ItemID, synthesisArray[0].SynthesisNum);
                            UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                        }
                    }
                    #endregion
                }
                else if (_ops == 2)
                {
                    #region 晶石合成
                    if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.JuanZouZhiJieWanCheng))
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                        return(false);
                    }
                    ErrorCode = 1;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St1603_SynthesisEnergyNum, useGold);
                    return(false);

                    #endregion
                }
                else if (_ops == 3)
                {
                    #region 确认晶石合成
                    if (ContextUser.GoldNum < useGold)
                    {
                        ErrorCode = 1;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                    //原因:配置材料不使用晶石合成时提示
                    string userItemName = UseritemGoldName(ContextUser.UserID, synthesisArray);
                    if (!string.IsNullOrEmpty(userItemName))
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = string.Format(LanguageManager.GetLang().St_ItemIsGold, userItemName);
                        return(false);
                    }

                    foreach (ItemSynthesisInfo synthesis in synthesisArray)
                    {
                        int          curNum    = 0;
                        ItemBaseInfo itemsInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(synthesis.SynthesisID);
                        if (!string.IsNullOrEmpty(_userEquID) && synthesis.SynthesisID == userItem.ItemID)
                        {
                            if (userItem.ItemStatus == ItemStatus.YongBing)
                            {
                                if (IsLevelNotEnough(ContextUser, userItem.GeneralID, synthesisInfo.ItemID))
                                {
                                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                                    return(false);
                                }

                                UserItemHelper.AddItemLog(ContextUser.UserID, userItem.ItemID, userItem.Num, userItem.ItemLv, 9, userItem.UserItemID);
                                synthesisInfoList.Add(new SynthesisInfo()
                                {
                                    DemandID = userItem.ItemID, Num = 1
                                });
                            }
                        }
                        else
                        {
                            if (itemsInfo != null && itemsInfo.ItemType == ItemType.ZhuangBei)
                            {
                                synthesisUserItem = GetUserItemInfo(ContextUser.UserID, itemsInfo.ItemID);
                                if (IsLevelNotEnough(ContextUser, synthesisUserItem.GeneralID, synthesisInfo.ItemID))
                                {
                                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                                    ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough;
                                    return(false);
                                }
                            }
                            else
                            {
                                var itemArray = UserItemHelper.GetItems(Uid).FindAll(u => u.ItemID.Equals(synthesis.SynthesisID) && (u.ItemStatus == ItemStatus.BeiBao || u.ItemStatus == ItemStatus.CangKu));
                                if (itemArray.Count > 0)
                                {
                                    foreach (var item in itemArray)
                                    {
                                        curNum += item.Num;
                                    }
                                    if (synthesis.DemandNum < curNum)
                                    {
                                        UserItemHelper.UseUserItem(ContextUser.UserID, synthesis.SynthesisID, synthesis.DemandNum);
                                        synthesisInfoList.Add(new SynthesisInfo()
                                        {
                                            DemandID = synthesis.SynthesisID, Num = synthesis.DemandNum
                                        });
                                    }
                                    else
                                    {
                                        UserItemHelper.UseUserItem(ContextUser.UserID, synthesis.SynthesisID, curNum);
                                        synthesisInfoList.Add(new SynthesisInfo()
                                        {
                                            DemandID = synthesis.SynthesisID, Num = curNum
                                        });
                                    }
                                }
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(_userEquID))
                    {
                        itemLv = MathUtils.Subtraction(userItem.ItemLv, (short)5, (short)1);
                        UpdateUserItem(synthesisInfo.ItemID, userItem);
                        UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                    }
                    else
                    {
                        if (synthesisUserItem != null)
                        {
                            itemLv = MathUtils.Subtraction(synthesisUserItem.ItemLv, (short)5, (short)1);
                            UpdateUserItem(synthesisInfo.ItemID, synthesisUserItem);
                            UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                        }
                        else
                        {
                            UserItemHelper.AddUserItem(ContextUser.UserID, synthesisInfo.ItemID, synthesisArray[0].SynthesisNum);
                            UserLogHelper.AppenItemSynthesisLog(ContextUser.UserID, opType, synthesisInfo.ItemID, 1, synthesisInfoList, null, 0, itemLv, userItem.ItemLv);
                        }
                    }

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

                    #endregion
                }
            }
            return(true);
        }
예제 #21
0
        public override bool TakeAction()
        {
            TaskStar taskOpsStar = TaskStar.Star1;

            userLv         = ContextUser.UserLv;
            this.ErrorCode = ops;
            if (ops == 1)
            {
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.RefreashDailyTask))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return(false);
                }
                List <UserTask> taskArray = new GameDataCacheSet <UserTask>().FindAll(ContextUser.UserID, u => u.TaskState == TaskState.AllowTake && u.TaskType == TaskType.Daily);
                if (taskArray.Count > 0)
                {
                    if (taskArray[0].TaskStar == TaskStar.Star5)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St3005_RefreashStarFull;
                        return(false);
                    }
                }
                ErrorInfo = string.Format(LanguageManager.GetLang().St3005_RefreashUseGold, useProGold);
                return(false);
            }
            else if (ops == 2)
            {
                if (ContextUser.GoldNum < useProGold)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                List <UserTask> taskArray = new GameDataCacheSet <UserTask>().FindAll(ContextUser.UserID, u => u.TaskState != TaskState.Disable && u.TaskType == TaskType.Daily);
                if (taskArray.Count > 0)
                {
                    taskOpsStar = TaskHelper.GetTaskStar(taskArray[0].TaskStar, taskArray[0].TakeDate);
                }
                foreach (UserTask taskInfo in taskArray)
                {
                    taskInfo.TaskStar = taskOpsStar;
                    //taskInfo.Update();
                }
                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useProGold, int.MaxValue);
                //ContextUser.Update();
                if (taskArray.Count > 0)
                {
                    userTaskList = taskArray;
                    //UserTask userTask = taskArray[0];
                    //刷新任务
                    //userTaskList = TaskHelper.RefreshDailyTask(ContextUser.UserID, userTask);
                }
            }
            else if (ops == 3)
            {
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.ShuanChuMaxXingJiRenWu))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return(false);
                }
                this.ErrorInfo = string.Format(LanguageManager.GetLang().St3005_RefreashUseGold, useFullGold);
                return(false);
            }
            else if (ops == 4)
            {
                if (ContextUser.GoldNum < useFullGold)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                taskOpsStar = TaskStar.Star5;
                List <UserTask> taskArray = new GameDataCacheSet <UserTask>().FindAll(ContextUser.UserID, u => u.TaskState == TaskState.AllowTake && u.TaskType == TaskType.Daily);

                foreach (UserTask taskInfo in taskArray)
                {
                    taskInfo.TaskStar = taskOpsStar;
                    //taskInfo.Update();
                }
                if (taskArray.Count > 0)
                {
                    UserTask userTask = taskArray[0];
                    //刷新任务
                    userTaskList = TaskHelper.RefreshDailyTask(ContextUser.UserID, userTask);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useFullGold, int.MaxValue);
                //ContextUser.Update();
            }
            else if (ops == 5)
            {
                if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.DailyRenWuZhiJieWanCheng))
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion;
                    return(false);
                }
                this.ErrorInfo = string.Format(LanguageManager.GetLang().St3005_CompletedUseGold, completedUseGold);
                return(false);
            }
            else if (ops == 6)
            {
                if (ContextUser.GoldNum < completedUseGold)
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                List <UserTask> taskArray = new GameDataCacheSet <UserTask>().FindAll(ContextUser.UserID, u => u.TaskState == TaskState.Taked && u.TaskType == TaskType.Daily);
                if (taskArray.Count > 0)
                {
                    UserTask      userTask  = taskArray[0];
                    DailyTaskInfo dtaskInfo = new ConfigCacheSet <DailyTaskInfo>().FindKey(taskArray[0].TaskID);
                    //交付任务

                    //奖励
                    int userExp = ContextUser.ExpNum;
                    int expNum  = userTask.GetDailyExpNum(userLv);
                    ContextUser.ExpNum = MathUtils.Addition(ContextUser.ExpNum, expNum, int.MaxValue);
                    //ContextUser.Update();
                    var userItem = userTask.GetDailyItem(userLv);
                    if (userItem != null)
                    {
                        UserItemHelper.AddUserItem(ContextUser.UserID, userItem.ItemID, userItem.Num);
                    }
                    userTask.TaskState   = TaskState.Close;
                    userTask.CompleteNum = MathUtils.Addition(userTask.CompleteNum, 1, int.MaxValue);
                    //userTask.Update();
                    //奖励日志
                    UserTaskLog taskLog = new UserTaskLog()
                    {
                        LogID     = System.Guid.NewGuid().ToString(),
                        TaskID    = userTask.TaskID,
                        UserID    = userTask.UserID,
                        TaskType  = userTask.TaskType,
                        TaskState = userTask.TaskState,
                        TaskPrize = string.Format("ExpNum:{0},item:{1}={2};User expnum:{3}", expNum,
                                                  userItem != null ? userItem.ItemID : 0,
                                                  userItem != null ? userItem.Num : 0,
                                                  userExp
                                                  ),
                        CreateDate = DateTime.Now
                    };
                    var sender = DataSyncManager.GetDataSender();
                    sender.Send(taskLog);
                    //刷新任务
                    userTaskList = TaskHelper.RefreshDailyTask(ContextUser.UserID, userTask);

                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, completedUseGold, int.MaxValue);
                    //ContextUser.Update();
                }
            }
            else if (ops == 0)
            {
                if (TaskID > 0)
                {
                    UserTask userTask = new GameDataCacheSet <UserTask>().FindKey(ContextUser.UserID, TaskID);
                    if (userTask == null || userTask.TaskState != TaskState.Completed)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St3007_NoCompleted;
                        return(false);
                    }
                    if (TaskHelper.GetTaskCompleteNum(ContextUser.UserID) >= TaskHelper.DailyEveryMaxNum)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St3005_CompletedTimeout;
                        return(false);
                    }
                    DailyTaskInfo dtaskInfo = new ConfigCacheSet <DailyTaskInfo>().FindKey(userTask.TaskID);
                    //交付任务

                    //奖励
                    int userExp = ContextUser.ExpNum;
                    int expNum  = userTask.GetDailyExpNum(userLv);
                    ContextUser.ExpNum = MathUtils.Addition(ContextUser.ExpNum, expNum, int.MaxValue);
                    //ContextUser.Update();
                    var userItem = userTask.GetDailyItem(userLv);
                    if (userItem != null)
                    {
                        UserItemHelper.AddUserItem(ContextUser.UserID, userItem.ItemID, userItem.Num);
                    }
                    userTask.TaskState   = TaskState.Close;
                    userTask.CompleteNum = MathUtils.Addition(userTask.CompleteNum, 1, int.MaxValue);
                    //userTask.Update();
                    //奖励日志
                    UserTaskLog taskLog = new UserTaskLog()
                    {
                        LogID     = System.Guid.NewGuid().ToString(),
                        TaskID    = userTask.TaskID,
                        UserID    = userTask.UserID,
                        TaskType  = userTask.TaskType,
                        TaskState = userTask.TaskState,
                        TaskPrize = string.Format("ExpNum:{0},item:{1}={2};User expnum:{3}", expNum,
                                                  userItem != null ? userItem.ItemID : 0,
                                                  userItem != null ? userItem.Num : 0,
                                                  userExp
                                                  ),
                        CreateDate = DateTime.Now
                    };

                    var sender = DataSyncManager.GetDataSender();
                    sender.Send(taskLog);
                    //刷新任务
                    userTaskList = TaskHelper.RefreshDailyTask(ContextUser.UserID, userTask);
                }
                else
                {
                    //刷新当天任务
                    if (!TaskHelper.CheckDailyTaskTimeout(ContextUser.UserID, out userTaskList))
                    {
                        userTaskList = new GameDataCacheSet <UserTask>().FindAll(ContextUser.UserID,
                                                                                 m => m.TaskType.Equals(TaskType.Daily) &&
                                                                                 !m.TaskState.Equals(TaskState.NoTake) &&
                                                                                 !m.TaskState.Equals(TaskState.Disable)
                                                                                 );
                    }

                    if (userTaskList.Count == 0)
                    {
                        //初始化时刷新任务
                        userTaskList = TaskHelper.RefreshDailyTask(ContextUser.UserID, null);
                    }

                    //刷新状态
                    foreach (UserTask userTask in userTaskList)
                    {
                        bool isModify = false;

                        if (userTask.TaskState == TaskState.Taked &&
                            userTask.TaskTargetNum.ToInt() >= (int)userTask.TaskStar)
                        {
                            isModify           = true;
                            userTask.TaskState = TaskState.Completed;
                        }
                        if (isModify)
                        {
                            //userTask.Update();
                        }
                    }
                }
            }

            //计算当天完成次数
            currNum = TaskHelper.GetTaskCompleteNum(ContextUser.UserID);
            return(true);
        }
예제 #22
0
        public override bool TakeAction()
        {
            ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(medicineID);

            if (itemInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (ops == 1)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St11415_ClearMedicine, itemInfo.ItemName, itemInfo.MedicineLv, itemInfo.EffectNum);
                return(false);
            }

            UserGeneral general = new PersonalCacheStruct <UserGeneral>().FindKey(ContextUser.UserID, generalID);

            if (general == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St10006_DoesNotExistTheGeneral;
                return(false);
            }
            var cacheSet = new PersonalCacheStruct <GeneralMedicine>();
            List <GeneralMedicine> generalMedicineArray = cacheSet.FindAll(ContextUser.UserID, g => g.MedicineID.Equals(medicineID) && g.GeneralID == generalID);

            generalMedicineArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(x.BaseNum.CompareTo(y.BaseNum));
            });
            if (generalMedicineArray.Count <= 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1415_MedicineNum;
                return(false);
            }
            if (UserHelper.IsBeiBaoFull(ContextUser))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1415_GridNumNotEnough;
                return(false);
            }

            //UserItem[] userItemArray = UserItem.FindAll(UserItem.Index_UserID, u => (u.ItemStatus == ItemStatus.BeiBao || u.ItemStatus == ItemStatus.CangKu) && u.ItemID == itemID, ContextUser.UserID);
            var package = UserItemPackage.Get(Uid);
            List <UserItemInfo> userItemArray = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemID == itemID);
            //药剂摘除道不足
            int Num = itemInfo.MedicineLv;

            if (userItemArray.Count <= 0 || UserItemMedicineNum(userItemArray) < Num)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1415_MedicineNum;
                return(false);
            }
            UserItemHelper.UseUserItem(ContextUser.UserID, itemID, Num);
            if (RandomUtils.GetRandom() <= itemInfo.EffectNum)
            {
                short propertyNum = MedicinePropertyNum(ContextUser.UserID, medicineID, generalID);
                switch (itemInfo.MedicineType)
                {
                case 1:
                    general.PowerNum = MathUtils.Subtraction(general.PowerNum, propertyNum);
                    break;

                case 2:
                    general.SoulNum = MathUtils.Subtraction(general.SoulNum, propertyNum);
                    break;

                case 3:
                    general.IntellectNum = MathUtils.Subtraction(general.IntellectNum, propertyNum);
                    break;

                default:
                    general.PowerNum = general.PowerNum;;
                    break;
                }
                //general.Update();
                cacheSet.Delete(generalMedicineArray[0]);
                ErrorCode = 2;
                UserItemHelper.AddUserItem(ContextUser.UserID, medicineID, 1);
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St11415_Clearfail;
                return(false);
            }

            return(true);
        }
예제 #23
0
        protected override object ProcessPrize()
        {
            var userGeneral = UserGeneral.GetMainGeneral(UserId.ToString());

            if (userGeneral == null)
            {
                return(null);
            }
            var noviceUser = new GameDataCacheSet <NoviceUser>().FindKey(UserId.ToString());

            if (noviceUser == null)
            {
                return(null);
            }
            var noviceTaskInfo = new ShareCacheStruct <NoviceTaskInfo>().FindKey(noviceUser.CurrGuideId);

            if (noviceTaskInfo == null || noviceTaskInfo.PrizeList.Count <= 0)
            {
                return(null);
            }
            var itemList = new List <ItemBaseInfo>();

            foreach (var prizeInfo in noviceTaskInfo.PrizeList)
            {
                switch (prizeInfo.Key)
                {
                case 0:
                    foreach (var itemId in prizeInfo.Value)
                    {
                        var itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemId);
                        if (itemInfo == null)
                        {
                            continue;
                        }
                        UserItemHelper.AddUserItem(UserId.ToString(), itemId, 1);
                        itemList.Add(itemInfo);

                        var gameUser = new GameDataCacheSet <GameUser>().FindKey(UserId.ToString());
                        if (gameUser != null)
                        {
                            if (gameUser.UserExtend.NoviceIsPase == true)
                            {
                                var noviceTask = new ConfigCacheSet <NoviceTaskInfo>().FindKey("1013");
                                if (noviceTask != null && noviceTask.PrizeList != null)
                                {
                                    foreach (var gift in noviceTask.PrizeList)
                                    {
                                        foreach (var Id in gift.Value)
                                        {
                                            var item = new ConfigCacheSet <ItemBaseInfo>().FindKey(Id);
                                            UserItemHelper.AddUserItem(UserId.ToString(), Id, 1);
                                            itemList.Add(item);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;

                case 1:
                    if (prizeInfo.Value.Count > userGeneral.CareerID)
                    {
                        var itemId   = prizeInfo.Value[userGeneral.CareerID];
                        var itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemId);
                        if (itemInfo == null)
                        {
                            continue;
                        }
                        UserItemHelper.AddUserItem(UserId.ToString(), itemId, 1);
                        itemList.Add(itemInfo);
                    }
                    break;
                }
            }
            return(itemList);
        }
예제 #24
0
        /// <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 ShareCacheStruct <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 ShareCacheStruct <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 ShareCacheStruct <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);
        }
예제 #25
0
        public override void Process(JsonParameter[] paramList)
        {
            JsonParameterList parameters = JsonParameter.Convert(paramList);
            string            op         = parameters["op"];

            string[] UserList       = Convert.ToString(parameters["UserID"]).Split(new char[] { ',' });
            string   itemPackage    = Convert.ToString(parameters["Item"]);
            string   crystalList    = Convert.ToString(parameters["Crystal"]);
            string   sparePackage   = Convert.ToString(parameters["SparePackage"]);
            string   enchantPackage = Convert.ToString(parameters["EnchantPackage"]);

            int obtainNum = 0;

            if (parameters["ObtainNum"].Length > 0)
            {
                obtainNum = Convert.ToInt32(parameters["ObtainNum"]);
            }
            short energyNum = 0;

            if (parameters["EnergyNum"].Length > 0)
            {
                energyNum = Convert.ToInt16(parameters["EnergyNum"]);
            }
            int gameCoin = 0;

            if (parameters["GameCoin"].Length > 0)
            {
                gameCoin = Convert.ToInt32(parameters["GameCoin"]);
            }
            int gold = 0;

            if (parameters["Gold"].Length > 0)
            {
                gold = Convert.ToInt32(parameters["Gold"]);
            }
            int expNum = 0;

            if (parameters["ExpNum"].Length > 0)
            {
                expNum = Convert.ToInt32(parameters["ExpNum"]);
            }
            int vipLv = 0;

            if (parameters["VipLv"].Length > 0)
            {
                vipLv = Convert.ToInt32(parameters["VipLv"]);
            }
            int gainBlessing = 0;

            if (parameters["GainBlessing"].Length > 0)
            {
                gainBlessing = Convert.ToInt32(parameters["GainBlessing"]);
            }
            int honourNum = 0;

            if (parameters["HonourNum"].Length > 0)
            {
                honourNum = Convert.ToInt32(parameters["HonourNum"]);
            }
            string mailContent = Convert.ToString(parameters["MailContent"]);
            int    opUserID    = Convert.ToInt32(parameters["OpUserID"]);
            //var cacheSetUserItem = new GameDataCacheSet<UserItemPackage>();
            var cacheSetItemInfo = new ShareCacheStruct <ItemBaseInfo>();
            var itemArray        = itemPackage.Split(',');

            foreach (string str in UserList)
            {
                try
                {
                    int userID = str.Trim().ToInt();


                    var user = new GameDataCacheSet <GameUser>().FindKey(str);
                    if (user != null)
                    {
                        user.GiftGold  = MathUtils.Addition(user.GiftGold, gold);
                        user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum);
                        user.EnergyNum = MathUtils.Addition(user.EnergyNum, energyNum);
                        user.GameCoin  = MathUtils.Addition(user.GameCoin, gameCoin);
                        user.ExpNum    = MathUtils.Addition(user.ExpNum, expNum);
                        user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum);
                    }


                    foreach (var item in itemArray)
                    {
                        if (item.Split('=').Length == 2)
                        {
                            var itemInfo = cacheSetItemInfo.FindKey(item.Split('=')[0]);
                            if (itemInfo != null)
                            {
                                UserItemHelper.AddUserItem(str, item.Split('=')[0].ToInt(), item.Split('=')[1].ToInt());
                            }
                        }
                    }
                    Guid          newGuid      = Guid.NewGuid();
                    UserTakePrize userPrizeLog = new UserTakePrize
                    {
                        ID             = newGuid.ToString(),
                        UserID         = userID,
                        ObtainNum      = obtainNum,
                        EnergyNum      = energyNum,
                        GameCoin       = gameCoin,
                        Gold           = gold,
                        ExpNum         = expNum,
                        VipLv          = vipLv,
                        GainBlessing   = gainBlessing,
                        ItemPackage    = itemPackage,
                        CrystalPackage = crystalList,
                        SparePackage   = sparePackage,
                        EnchantPackage = enchantPackage,
                        MailContent    = mailContent,
                        IsTasked       = false,
                        TaskDate       = MathUtils.SqlMinDate,
                        OpUserID       = opUserID,
                        CreateDate     = DateTime.Now,
                        HonourNum      = honourNum,
                        Items          = itemPackage,
                    };
                    var cacheSet = new ShareCacheStruct <UserTakePrize>();
                    cacheSet.Add(userPrizeLog);
                    cacheSet.Update();
                    PutCrystal(crystalList.Split(','), str);

                    // 发送系统信件
                    UserMail userMail = new UserMail(newGuid);
                    userMail.UserId   = userID;
                    userMail.MailType = (int)MailType.System;
                    userMail.Title    = LanguageManager.GetLang().St_SystemMailTitle;
                    userMail.Content  = mailContent;
                    userMail.SendDate = DateTime.Now;
                    TjxMailService mailService = new TjxMailService(user);
                    mailService.Send(userMail);
                }
                catch (Exception ex)
                {
                    new BaseLog().SaveLog(ex);
                }
            }
        }
예제 #26
0
        /// <summary>
        /// 假日狂欢活动通关获得金币
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="plotID"></param>
        public static void GetHolidayFestivalReward(string userID, int plotID)
        {
            var          chatService = new TjxChatService();
            int          festivalID  = 0;// 1003;
            FestivalInfo festival    = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);

            if (festival != null)
            {
                GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID);
                PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(plotID);
                if (plotInfo != null)
                {
                    TimePriod priod = festival.TimePriod;
                    if (NoviceHelper.IsFestivalOpen(festivalID))
                    {
                        DateTime priodStart = DateTime.Parse(DateTime.Now.ToString("d") + " " + priod.Start.ToString("T"));
                        DateTime priodEnd   = DateTime.Parse(DateTime.Now.ToString("d") + " " + priod.End.ToString("T"));
                        if (priodStart <= DateTime.Now && DateTime.Now < priodEnd)
                        {
                            if (RandomUtils.IsHit(plotInfo.FestivalProbability))
                            {
                                List <FestivalReward> rewardsArray = plotInfo.FestivalReward.ToList();
                                double[] probability = new double[rewardsArray.Count];
                                for (int i = 0; i < rewardsArray.Count; i++)
                                {
                                    probability[i] = rewardsArray[i].Probability;
                                }
                                int index2 = RandomUtils.GetHitIndex(probability);
                                int itemID = rewardsArray[index2].Item;
                                UserItemHelper.AddUserItem(userID, itemID, 1);
                                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemID);
                                if (userInfo != null && itemInfo != null)
                                {
                                    string content = string.Empty;
                                    if (itemID == 5008)
                                    {
                                        content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName);
                                        chatService.SystemSendWhisper(userInfo, content);
                                    }
                                    else if (itemID == 5009)
                                    {
                                        content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName);
                                        chatService.SystemSendWhisper(userInfo, content);
                                    }
                                    else if (itemID == 5010)
                                    {
                                        content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGift, itemInfo.ItemName);
                                        chatService.SystemSendWhisper(userInfo, content);
                                    }
                                    else if (itemID == 5011)
                                    {
                                        content = string.Format(LanguageManager.GetLang().St_HolidayFestivalGoinGift, userInfo.NickName);
                                        new TjxChatService().SystemSend(ChatType.World, content);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #27
0
        /// <summary>
        /// 活动奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="reward"></param>
        /// <param name="num"></param>
        public static string GameUserRewardNocite(string userID, RewardType reward, int itemID, int num, CrystalQualityType qualityType)
        {
            string   content  = string.Empty;
            GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID);

            if (userInfo != null)
            {
                if (reward == RewardType.GameGoin)
                {
                    userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, num, int.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().St_SummerThreeGameCoinNotice, num);
                }
                else if (reward == RewardType.Obtion)
                {
                    userInfo.ObtainNum = MathUtils.Addition(userInfo.ObtainNum, num, int.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().St_SummerThreeObtionNotice, num);
                }
                else if (reward == RewardType.EnergyNum)
                {
                    userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, (short)num, short.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().St_SummerThreeEnergyNotice, num);
                }
                else if (reward == RewardType.ExpNum)
                {
                    userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, num, int.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().St_SummerThreeExpNumNotice, num);
                }
                else if (reward == RewardType.Gold)
                {
                    userInfo.ItemGold = MathUtils.Addition(userInfo.ItemGold, num, int.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().St_SummerThreeGoldNotice, num);
                }
                else if (reward == RewardType.Experience)
                {
                    UserHelper.UserGeneralExp(userID, num);
                    content = string.Format(LanguageManager.GetLang().St_SummerThreeExperienceNotice, num);
                }
                else if (reward == RewardType.Item)
                {
                    UserItemHelper.AddUserItem(userID, itemID, num);
                    ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemID);
                    if (itemInfo != null)
                    {
                        content = string.Format(LanguageManager.GetLang().St_SummerThreeItemNotice, num, itemInfo.ItemName);
                    }
                }
                else if (reward == RewardType.CrystalType)
                {
                    GetUserCrystal(userInfo, qualityType);
                }
                else if (reward == RewardType.CrystalId)
                {
                    UserHelper.CrystalAppend(userID, itemID, 2);
                    CrystalInfo info = new ConfigCacheSet <CrystalInfo>().FindKey(itemID);
                    if (info != null)
                    {
                        content = string.Format(LanguageManager.GetLang().St_SummerCrystalNotice, info.CrystalName);
                    }
                }
            }
            return(content);
        }
예제 #28
0
        public override bool TakeAction()
        {
            ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(_itemId);

            //UserItemHelper.AddUserItem(ContextUser.UserID, 1702, 1);
            //UserItemHelper.AddUserItem(ContextUser.UserID, 1701, 1);
            //UserItemHelper.AddUserItem(ContextUser.UserID, 1213, 1);
            if (itemInfo == null)
            {
                return(false);
            }
            //判断背包是否已满

            string fullTitle = string.Empty;
            bool   isFull    = false;

            if (itemInfo.ItemType == ItemType.ZhuangBei)
            {
                isFull = UserPackHelper.PackIsFull(ContextUser, BackpackType.ZhuangBei, _num, out fullTitle);
            }
            else
            {
                isFull = UserPackHelper.PackIsFull(ContextUser, BackpackType.BeiBao, _num, out fullTitle);
            }

            if (isFull)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = fullTitle;
                //ErrorInfo = LanguageManager.GetLang().St7004_BeiBaoTimeOut;
                return(false);
            }
            //读取物品信息
            MallItemsInfo mallItemInfo = new ConfigCacheSet <MallItemsInfo>().FindKey(_itemId, CityId, _commandType);

            if (mallItemInfo == null)
            {
                return(false);
            }
            //物品价格
            int mallPrice = mallItemInfo.Price;

            if (mallItemInfo.MallType == ShopType.Props || mallItemInfo.MallType == ShopType.PresendBox)
            {
                mallPrice = (FestivalHelper.StoreDiscount() * mallPrice).ToInt();
            }
            else if (mallItemInfo.SpecialPrice > 0)
            {
                mallPrice = mallItemInfo.SpecialPrice;
            }
            //根据物品类型进行扣钱
            if (_commandType == ShopType.Props || _commandType == ShopType.PresendBox)
            {
                int useGold = mallPrice * _num;
                //if (mallItemInfo.MallType == ShopType.PresendBox)
                //{
                if (ContextUser.GoldNum < useGold)
                {
                    ErrorCode = 3;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
                //增加道具日志统计
                var mallItemLog = new MallItemLog
                {
                    Amount     = useGold,
                    CreateDate = DateTime.Now,
                    ItemID     = _itemId,
                    ItemName   = itemInfo.ItemName,
                    ItemNum    = _num,
                    MobileType = ContextUser.MobileType,
                    Pid        = ContextUser.Pid,
                    PropType   = itemInfo.PropType,
                    RetailID   = ContextUser.RetailID,
                    Uid        = ContextUser.UserID.ToInt()
                };

                var sender = DataSyncManager.GetDataSender();
                sender.Send(mallItemLog);
                UserItemHelper.AddUserItem(ContextUser.UserID, _itemId, _num);
                UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 8, 1, 1, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue));
                //}
                //预留判断消耗的是金币还是晶石
                //else
                //{
                //    if (ContextUser.GameCoin <useGold)
                //    {
                //        ErrorCode = LanguageManager.GetLang().ErrorCode;
                //        ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough;
                //        return false;
                //    }
                //    ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, useGold);
                //    UserItemHelper.AddUserItem(ContextUser.UserID, _itemId, _num);
                //}
            }
            return(true);
        }
예제 #29
0
        /// <summary>
        /// 通用活动奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="reward"></param>
        /// <param name="num"></param>
        public static string GameUserUniversalNocite(string userID, RewardType reward, int itemID, int num, string systemContent)
        {
            string   content  = string.Empty;
            GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID);

            if (userInfo != null)
            {
                if (reward == RewardType.GameGoin)
                {
                    userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, num, int.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_GameCoin, num));
                }
                else if (reward == RewardType.Obtion)
                {
                    userInfo.ObtainNum = MathUtils.Addition(userInfo.ObtainNum, num, int.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_ObtionNum, num));
                }
                else if (reward == RewardType.EnergyNum)
                {
                    userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, (short)num, short.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_EnergyNum, num));
                }
                else if (reward == RewardType.ExpNum)
                {
                    userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, num, int.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_ExpNum, num));
                }
                else if (reward == RewardType.Gold)
                {
                    userInfo.ItemGold = MathUtils.Addition(userInfo.ItemGold, num, int.MaxValue);
                    //userInfo.Update();
                    content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_GiftGoldNum, num));
                }
                else if (reward == RewardType.Experience)
                {
                    UserHelper.UserGeneralExp(userID, num);
                    content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_Experience, num));
                }
                else if (reward == RewardType.Item)
                {
                    UserItemHelper.AddUserItem(userID, itemID, num);
                    ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemID);
                    if (itemInfo != null)
                    {
                        string itemcontent = string.Format(LanguageManager.GetLang().St_Item, itemInfo.ItemName, 1, num);
                        content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, itemcontent);
                    }
                }
                else if (reward == RewardType.CrystalType)
                {
                    CrystalQualityType qualityType = CrystalQualityType.PurPle;
                    content = UserUserUniversalCrystal(userInfo, qualityType, systemContent);
                    //GetUserCrystal(userInfo, qualityType);
                }
                else if (reward == RewardType.CrystalId)
                {
                    var             packageCrystal = UserCrystalPackage.Get(userID);
                    UserCrystalInfo userCrystal    = new UserCrystalInfo()
                    {
                        UserCrystalID = Guid.NewGuid().ToString(),
                        CrystalID     = itemID,
                        CrystalLv     = 1,
                        CurrExprience = 0,
                        GeneralID     = 0,
                        IsSale        = 2,
                        CreateDate    = DateTime.Now
                    };
                    packageCrystal.SaveCrystal(userCrystal);
                    CrystalInfo info = new ConfigCacheSet <CrystalInfo>().FindKey(itemID);
                    if (info != null)
                    {
                        content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_Crystal, info.CrystalQuality, info.CrystalName));
                    }
                }
            }
            return(content);
        }
예제 #30
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);
        }