Пример #1
0
        /// <summary>
        /// 处理伤害奖励
        /// </summary>
        private void DoDamagePrize(GameUser user, int damageNum, BossCombatProcess bossCombatProcess)
        {
            BossActivePrize bossPrize = UserGuild.BossPrize;

            if (bossPrize == null)
            {
                return;
            }
            int obtainNum = MathUtils.Addition(((int)Math.Ceiling((double)damageNum / bossPrize.ObtainRate)), 0, bossPrize.MaxObtain);
            int maxCoin   = user.UserLv * bossPrize.MaxCoin;
            int gameCoin  = MathUtils.Addition((int)Math.Ceiling((double)damageNum / bossPrize.CoinRate), 0, maxCoin);

            user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum, int.MaxValue);
            user.GameCoin  = MathUtils.Addition(user.GameCoin, gameCoin, int.MaxValue);
            if (gameCoin <= 0)
            {
                gameCoin = 1;
            }
            if (obtainNum <= 0)
            {
                obtainNum = 1;
            }
            bossCombatProcess.ObtainNum = obtainNum;
            bossCombatProcess.GameCoin  = gameCoin;
            CountryCombat.Contribution(user.UserID, obtainNum); //公会贡献

            //发到聊天里
            var chatService = new TjxChatService();

            chatService.SystemSendWhisper(user, string.Format(LanguageManager.GetLang().St6105_CombatHarmReward, gameCoin, obtainNum));
        }
Пример #2
0
        /// <summary>
        /// 竞技场每日奖励
        /// </summary>
        /// <param name="user"></param>
        public static void DailySportsRankPrize(GameUser user)
        {
            UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(user.UserID);

            if (IsGainSportsReward(user.UserID) && dailyRestrain != null && dailyRestrain.UserExtend != null)
            {
                //var envSet = ServerEnvSet.Get(ServerEnvKey.JingJiChangReward, "");
                SportsRewardInfo sportsInfo = new ConfigCacheSet <SportsRewardInfo>().FindKey(dailyRestrain.UserExtend.UserRankID);
                //if (envSet != null && sportsInfo != null && envSet.ToDateTime().Date > dailyRestrain.Funtion11.Date &&
                // dailyRestrain.UserExtend.UserRankID > 0)
                if (sportsInfo != null && DateTime.Now.Date != dailyRestrain.Funtion11.Date &&
                    dailyRestrain.UserExtend.UserRankID > 0)
                {
                    dailyRestrain.Funtion11             = DateTime.Now;
                    dailyRestrain.UserExtend.UserRankID = 0;

                    user.SportsIntegral = MathUtils.Addition(user.SportsIntegral, sportsInfo.RewardObtian,
                                                             int.MaxValue);
                    user.GameCoin = MathUtils.Addition(user.GameCoin, sportsInfo.RewardGoin, int.MaxValue);
                    string sportContent = string.Format(LanguageManager.GetLang().St5106_JingJiChangRankReward,
                                                        sportsInfo.RewardObtian, sportsInfo.RewardGoin);
                    var chatService = new TjxChatService();
                    chatService.SystemSendWhisper(user, sportContent);
                }
            }
        }
Пример #3
0
        private static bool GetPayment(int game, int server, string account, string userID)
        {
            try
            {
                GameUser userInfo = new PersonalCacheStruct <GameUser>().FindKey(userID);
                if (userInfo == null)
                {
                    return(false);
                }
                var         chatService = new TjxChatService();
                OrderInfo[] model       = PayManager.getPayment(game, server, account);
                foreach (OrderInfo order in model)
                {
                    userInfo.PayGold = MathUtils.Addition(userInfo.PayGold, order.GameCoins, int.MaxValue);
                    //userInfo.Update();
                    PayManager.Abnormal(order.OrderNO);

                    DialHelper.ReturnRatioGold(userID, order.GameCoins);  //大转盘抽奖奖励充值返还
                    chatService.SystemSendWhisper(userInfo, string.Format(LanguageManager.GetLang().PaySuccessMsg, order.GameCoins));

                    DoGiff(userID, order);
                    FestivalHelper.GetPayReward(userInfo, order.GameCoins, FestivalType.PayReward);
                }
                return(true);
            }
            catch (Exception ex)
            {
                BaseLog log = new BaseLog("PaymentLog");
                log.SaveLog(ex);
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 奖励物品
        /// </summary>
        /// <param name="prize"></param>
        /// <returns></returns>
        public static void ChestGainTreasureInfo(GameUser user, DialInfo dialInfo, int count)
        {
            var treasure = new TreasureInfo();

            treasure.UserID = user.UserID;
            treasure.Type   = dialInfo.RewardType;
            treasure.ItemID = dialInfo.ItemID;
            treasure.Num    = dialInfo.ItemNum;
            treasure.ItemLv = 1;
            UserDial userDial = new PersonalCacheStruct <UserDial>().FindKey(user.UserID);

            if (userDial == null)
            {
                userDial = new UserDial();
            }
            userDial.GroupID     = 0;
            userDial.RefreshDate = DateTime.Now;
            userDial.Treasure.Add(treasure);
            if (count == 0)
            {
                userDial.PrizeInfo = treasure;
                userDial.HeadID    = dialInfo.HeadID;
            }
            if (GameConfigSet.Treasure > 0 && userDial.Treasure.Count > GameConfigSet.Treasure)
            {
                for (int i = 0; i < userDial.Treasure.Count - GameConfigSet.Treasure; i++)
                {
                    userDial.Treasure.Remove(userDial.Treasure[i]);
                }
            }

            if (dialInfo.IsShow)
            {
                var cacheSet     = new ShareCacheStruct <ServerEnvSet>();
                var serverEnvSet = cacheSet.FindKey(ServerEnvKey.UserTreasure);
                if (serverEnvSet == null)
                {
                    serverEnvSet        = new ServerEnvSet();
                    serverEnvSet.EnvKey = ServerEnvKey.UserTreasure;
                    cacheSet.Add(serverEnvSet);
                }
                var treasureInfoList = ServerEnvSetTreasure(treasure);
                serverEnvSet.EnvValue = JsonUtils.Serialize(treasureInfoList);
            }

            if (dialInfo.IsBroadcast && !string.IsNullOrEmpty(dialInfo.BroadContent))
            {
                TjxChatService chatService = new TjxChatService();
                chatService.SystemSend(ChatType.World, string.Format(dialInfo.BroadContent, user.NickName));
            }
            if (dialInfo.RewardType == RewardType.Again || dialInfo.RewardType == RewardType.Mood || dialInfo.RewardType == RewardType.Recharge)
            {
                if (dialInfo.RewardType == RewardType.Recharge)
                {
                    userDial.ReturnRatio = treasure.Num;
                }
                return;
            }
            ChestGetUserTake(treasure, user);
        }
Пример #5
0
        /// <summary>
        /// 假日狂欢活动--竞技场幸运数字七
        /// </summary>
        /// <param name="userID"></param>
        public static void HolidayFestival(string userID)
        {
            GameUser         userInfo   = new GameDataCacheSet <GameUser>().FindKey(userID);
            int              festivalID = 0;// 1004;
            FestivalRestrain restrain   = new GameDataCacheSet <FestivalRestrain>().FindKey(userID, festivalID);

            if (restrain != null)
            {
                if (restrain.RefreashDate.Date != DateTime.Now.Date)
                {
                    restrain.RestrainNum  = 0;
                    restrain.RefreashDate = DateTime.Now;
                }
            }
            var          chatService = new TjxChatService();
            FestivalInfo festival    = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);

            if (festival != null)
            {
                List <PrizeInfo> rewardsArray = festival.Reward.ToList();
                if (NoviceHelper.IsFestivalOpen(festivalID))
                {
                    if (restrain != null && restrain.RestrainNum <= festival.RestrainNum)
                    {
                        restrain.RestrainNum  = MathUtils.Addition(restrain.RestrainNum, 1, int.MaxValue);
                        restrain.RefreashDate = DateTime.Now;
                        //restrain.Update();
                        foreach (PrizeInfo reward in rewardsArray)
                        {
                            GameUserReward(userID, reward.Type, reward.ItemID, reward.Num);
                        }
                        if (userInfo != null)
                        {
                            chatService.SystemSendWhisper(userInfo, LanguageManager.GetLang().St_HolidayFestival);
                        }
                    }
                    else if (restrain == null)
                    {
                        foreach (PrizeInfo reward in rewardsArray)
                        {
                            GameUserReward(userID, reward.Type, reward.ItemID, reward.Num);
                        }
                        if (userInfo != null)
                        {
                            chatService.SystemSendWhisper(userInfo, LanguageManager.GetLang().St_HolidayFestival);
                        }
                        restrain = new FestivalRestrain
                        {
                            UserID       = userID,
                            FestivalID   = festivalID,
                            RefreashDate = DateTime.Now,
                            RestrainNum  = 1,
                        };
                        new GameDataCacheSet <FestivalRestrain>().Add(restrain);
                    }
                }
            }
        }
Пример #6
0
        public override bool TakeAction()
        {
            if (_chatType == ChatType.Guild && string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9203_ChaTypeNotGuildMember;
                return(false);
            }

            //查找背包中的聊天道具
            var chatLeng    = ConfigEnvSet.GetInt("Chat.ContentLeng");
            int chatItemId  = ConfigEnvSet.GetInt("UserItem.ChatItemID");
            int charItemNum = UserItemHelper.CheckItemNum(ContextUser.UserID, chatItemId);

            //判断是否有聊天道具
            if (charItemNum <= 0)
            {
                ErrorCode = 3;
                ErrorInfo = LanguageManager.GetLang().St9203_ItemEmpty;
                return(false);
            }

            if (_content.IndexOf("<label") >= 0 || _content.IndexOf("<image") >= 0)
            {
                chatLeng += 150;
            }
            if (_content.Trim().Length == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9201_contentNotEmpty;
                return(false);
            }
            //LogHelper.WriteError(string.Format("contentLength={0};length={1};content={2}", _content.Length, chatLeng, _content));
            if (_content.Length >= chatLeng)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9201_TheInputTextTooLong;
                return(false);
            }

            if (!TjxChatService.IsAllow(ContextUser, _chatType))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9203_ChatNotSend;
                return(false);
            }

            NoviceHelper.WingFestival(ContextUser.UserID, _content);
            NoviceHelper.WingZhongYuanFestival(ContextUser, _content);
            //使用聊天道具
            UserItemHelper.UseUserItem(ContextUser.UserID, chatItemId, 1);
            var chatService = new TjxChatService(ContextUser);

            chatService.Send(_chatType, _content);

            return(true);
        }
Пример #7
0
        /// <summary>
        /// 处理击杀奖励
        /// </summary>
        private void DoKillPrize(GameUser user)
        {
            BossActivePrize bossPrize = GameActive.BossPrize;

            if (bossPrize == null)
            {
                return;
            }
            TjxChatService chatService = new TjxChatService();

            var rankingList = RefreshRanking();

            ServerEnvSet.Set(ServerEnvKey.FirstHalfBoss, rankingList.ToJson());
            int length = rankingList.Count > bossPrize.TopObtain ? bossPrize.TopObtain : rankingList.Count;

            //处理排名奖励
            for (int i = 0; i < length; i++)
            {
                string   prizeItemMsg = string.Empty;
                GameUser tempUser     = new GameDataCacheSet <GameUser>().FindKey(rankingList[i].UserId);
                tempUser.GameCoin = MathUtils.Addition(tempUser.GameCoin, bossPrize.TopObtainNum, int.MaxValue);
                //前3名奖励
                if (i == 0)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank1, bossPrize.Items, out prizeItemMsg);
                }
                else if (i == 1)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank2, bossPrize.Items, out prizeItemMsg);
                }
                else if (i == 2)
                {
                    DoTopThreePrize(i + 1, tempUser, bossPrize.Rank3, bossPrize.Items, out prizeItemMsg);
                }
                //tempUser.Update();

                if (!string.IsNullOrEmpty(prizeItemMsg))
                {
                    prizeItemMsg = "," + prizeItemMsg;
                }

                chatService.SystemSend(ChatType.World, string.Format(LanguageManager.GetLang().St5405_CombatRankmReward,
                                                                     tempUser.NickName,
                                                                     (i + 1),
                                                                     bossPrize.TopObtainNum,
                                                                     prizeItemMsg));
                TraceLog.ReleaseWriteDebug(string.Format(LanguageManager.GetLang().St5405_CombatRankmReward,
                                                         tempUser.NickName,
                                                         (i + 1),
                                                         bossPrize.TopObtainNum,
                                                         prizeItemMsg));
                // CountryCombat.Contribution(tempUser.UserID, bossPrize.TopObtainNum); //公会贡献
            }
        }
Пример #8
0
        public override bool TakeAction()
        {
            var chatService = new TjxChatService(ContextUser);

            _currVersion           = chatService.CurrVersion;
            _chatArray             = chatService.Receive();
            ContextUser.ChatVesion = _currVersion;
            //查找背包中的聊天道具
            int chatItemId = ConfigEnvSet.GetInt("UserItem.ChatItemID");

            _charItemNum = UserItemHelper.CheckItemNum(ContextUser.UserID, chatItemId);
            return(true);
        }
Пример #9
0
        private bool doProcessPrize(UserTakePrize userPrize)
        {
            Base.BaseLog log = new Base.BaseLog();
            if (userPrize == null)
            {
                return(false);
            }
            string userID   = userPrize.UserID.ToString();
            var    gameUser = new PersonalCacheStruct <GameUser>().FindKey(userID);

            if (gameUser == null)
            {
                return(false);
            }

            log.SaveDebugLog(string.Format("玩家{0}领取奖励{1}:{2}", userID, userPrize.ID, userPrize.MailContent));
            userPrize.IsTasked = true;
            userPrize.TaskDate = DateTime.Now;
            //userPrize.Update();

            gameUser.ObtainNum = MathUtils.Addition(gameUser.ObtainNum, userPrize.ObtainNum);
            gameUser.EnergyNum = MathUtils.Addition(gameUser.EnergyNum, userPrize.EnergyNum.ToShort());
            gameUser.GameCoin  = MathUtils.Addition(gameUser.GameCoin, userPrize.GameCoin);
            gameUser.GiftGold  = MathUtils.Addition(gameUser.GiftGold, userPrize.Gold);
            gameUser.ExpNum    = MathUtils.Addition(gameUser.ExpNum, userPrize.ExpNum);
            if (gameUser.UserExtend == null)
            {
                gameUser.UserExtend = new GameUserExtend();
            }
            gameUser.UserExtend.GainBlessing = MathUtils.Addition(gameUser.UserExtend.GainBlessing, userPrize.GainBlessing);
            if (userPrize.VipLv > 0)
            {
                var vipLv = new ShareCacheStruct <VipLvInfo>().FindKey(userPrize.VipLv.ToShort()) ?? new VipLvInfo();
                gameUser.ExtGold = vipLv.PayGold;
            }
            //gameUser.Update();

            PutItemPackage(userPrize.ItemPackage.Split(','), userID);
            PutCrystal(userPrize.CrystalPackage.Split(','), userID);
            PutSparePackage(userPrize.SparePackage.Split(','), userID);
            if (!string.IsNullOrEmpty(userPrize.EnchantPackage))
            {
                PutEnchant(userPrize.EnchantPackage.Split(','), userID);
            }
            var chatService = new TjxChatService();

            chatService.SystemSendWhisper(gameUser, string.Format("{0}", userPrize.MailContent));

            return(true);
        }
Пример #10
0
        /// <summary>
        /// 七夕、端午节奖励
        /// </summary>
        public static void DragonBoatFestival(string userID, int festivalID)
        {
            GameUser         userInfo = new GameDataCacheSet <GameUser>().FindKey(userID);
            FestivalRestrain restrain = new GameDataCacheSet <FestivalRestrain>().FindKey(userID, festivalID);
            FestivalInfo     festival = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID);
            var chatService           = new TjxChatService();

            if (festival != null)
            {
                CacheList <PrizeInfo> rewardsArray = festival.Reward;
                if (NoviceHelper.IsFestivalOpen(festivalID))
                {
                    if (restrain != null && restrain.RestrainNum <= festival.RestrainNum)
                    {
                        restrain.RestrainNum  = MathUtils.Addition(restrain.RestrainNum, 1, int.MaxValue);
                        restrain.RefreashDate = DateTime.Now;
                        //restrain.Update();
                        foreach (PrizeInfo reward in rewardsArray)
                        {
                            GameUserReward(userID, reward.Type, reward.ItemID, reward.Num);
                        }
                        if (userInfo != null && festival.FestivalExtend != null)
                        {
                            chatService.SystemSendWhisper(userInfo, festival.FestivalExtend.Desc);
                        }
                    }
                    else if (restrain == null)
                    {
                        foreach (PrizeInfo reward in rewardsArray)
                        {
                            GameUserReward(userID, reward.Type, reward.ItemID, reward.Num);
                        }
                        if (userInfo != null && festival.FestivalExtend != null)
                        {
                            chatService.SystemSendWhisper(userInfo, festival.FestivalExtend.Desc);
                        }
                        restrain = new FestivalRestrain
                        {
                            UserID       = userID,
                            FestivalID   = festivalID,
                            RefreashDate = DateTime.Now,
                            RestrainNum  = 1,
                        };
                        new GameDataCacheSet <FestivalRestrain>().Add(restrain);
                    }
                }
            }
        }
Пример #11
0
        /// <summary>
        /// 获得灵件
        /// </summary>
        /// <param name="user"></param>
        /// <param name="spareID"></param>
        public static void AppendSpare(GameUser user, int spareID)
        {
            SparePartInfo partInfo  = new ShareCacheStruct <SparePartInfo>().FindKey(spareID);
            UserSparePart sparePart = UserSparePart.GetRandom(spareID);

            if (partInfo == null || sparePart == null || !SparePartInfo.IsExist(spareID))
            {
                return;
            }
            if (!UserHelper.AddSparePart(user, sparePart))
            {
                var chatService = new TjxChatService();
                //掉落灵件
                chatService.SystemSendWhisper(user, string.Format(LanguageManager.GetLang().St4303_SparePartFalling, partInfo.Name));
            }
        }
Пример #12
0
        public override bool TakeAction()
        {
            int chatLeng = ConfigEnvSet.GetInt("Chat.ContentLeng");

            if (_content.IndexOf("<label") >= 0)
            {
                chatLeng += 150;
            }
            GameUser toUser = new GameDataCacheSet <GameUser>().FindKey(_toUserID);

            if (toUser == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9103_DoesNotExistTheUser;
                return(false);
            }
            if (_content.Trim().Length == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9201_contentNotEmpty;
                return(false);
            }
            if (_content.Length > chatLeng)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9201_TheInputTextTooLong;
                return(false);
            }
            //if (!CacheChat.IsAllow(ContextUser))
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St9203_ChatNotSend;
            //    return false;
            //}
            var chatService = new TjxChatService(ContextUser);

            chatService.SendWhisper(toUser, _content);
            UserFriends friends = new ShareCacheStruct <UserFriends>().FindKey(ContextUser.UserID, _toUserID);

            if (friends != null)
            {
                friends.ChatTime = DateTime.Now;
                //friends.Update();
            }

            return(true);
        }
Пример #13
0
        /// <summary>
        /// 替换佣兵功能开启相关数值
        /// </summary>
        /// <param name="user"></param>
        public static void OpenReplaceGeneral(GameUser user)
        {
            var              cachePrize   = new ShareCacheStruct <UserTakePrize>();
            string           generalPrize = ConfigEnvSet.GetString("General.ReplaceGeneralPrize");
            string           content      = LanguageManager.GetLang().St1901_OpenGeneralReplace;
            List <PrizeInfo> prizeList    = new List <PrizeInfo>();

            if (!string.IsNullOrEmpty(generalPrize))
            {
                prizeList = JsonUtils.Deserialize <List <PrizeInfo> >(generalPrize);
            }
            foreach (PrizeInfo info in prizeList)
            {
                var takePrize = GetUserTake(info, user.UserID);
                cachePrize.Add(takePrize, GameEnvironment.CacheGlobalPeriod);
            }
            var chatService = new TjxChatService(user);

            chatService.SystemSendWhisper(user, content);
        }
Пример #14
0
        /// <summary>
        /// 灵件ID=数量=属性ID:区间|属性ID:区间
        /// </summary>
        /// <param name="list"></param>
        /// <param name="userID"></param>
        private static void PutSparePackage(string[] list, string userID)
        {
            var chatService = new TjxChatService();

            foreach (var item in list)
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }
                string[] itemList = item.Split(new char[] { '=' });

                int      spareID       = itemList.Length > 0 ? Convert.ToInt32(itemList[0]) : 0;
                int      spareNum      = itemList.Length > 1 ? Convert.ToInt32(itemList[1]) : 0;
                string[] propertys     = itemList.Length > 2 ? itemList[2].ToNotNullString().Split('|') : new string[0];
                var      sparePartInfo = new ShareCacheStruct <SparePartInfo>().FindKey(spareID);
                if (spareNum > 0 && propertys.Length > 0 && sparePartInfo != null)
                {
                    for (int i = 0; i < spareNum; i++)
                    {
                        UserSparePart sparePart = UserSparePart.CreateSparePart(spareID, propertys, ':');
                        if (sparePart == null)
                        {
                            continue;
                        }
                        GameUser user = new PersonalCacheStruct <GameUser>().FindKey(userID);
                        if (!UserHelper.AddSparePart(user, sparePart))
                        {
                            chatService.SystemSendWhisper(user, string.Format(LanguageManager.GetLang().St4303_SparePartFalling, sparePartInfo.Name) + "*" + spareNum);
                        }
                    }
                }
                else
                {
                    new Base.BaseLog().SaveLog("领取灵件异常", new Exception(string.Format("userID:{3},spareID:{0},spareNum:{1},propertys:{2}", spareID, spareNum, propertys.Length, userID)));
                }
            }
        }
Пример #15
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);
            }
        }
Пример #16
0
        public static string HuntingLife(GameUser user, out string errStr)
        {
            #region
            errStr = string.Empty;
            int huntingID  = UserLightLit(user.UserID);
            int huntingID2 = UserNextLight(user.UserID, huntingID);
            UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(user.UserID);
            var probabilityInfo            = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率
            if (probabilityInfo == null)
            {
                return(errStr);
            }
            ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2);
            if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date)
            {
                if (probabilityInfo.Price > user.GameCoin)
                {
                    errStr = LanguageManager.GetLang().St_GameCoinNotEnough;
                    return(errStr);
                }
            }
            //暑期第三弹
            if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(user))
            {
                errStr = LanguageManager.GetLang().St1305_BeiBaoBackpackFull;
                return(errStr);
            }
            var lightCacheSet = new PersonalCacheStruct <UserLight>();
            if (huntingID != 1001)
            {
                UserLight userLight1 = lightCacheSet.FindKey(user.UserID, huntingID);
                if (userLight1.IsLight == 2)
                {
                    return(string.Empty);
                }
                if (userLight1.IsLight == 1)
                {
                    userLight1.IsLight = 2;
                }
            }
            UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(user.UserID, huntingID2);
            if (RandomUtils.IsHit(probability1.Light))
            {
                if (userLight != null)
                {
                    userLight.IsLight = 1;
                    if (userLight.HuntingID == 1005)
                    {
                        errStr = LanguageManager.GetLang().St1305_HuntingIDLight;
                    }
                }
                else
                {
                    userLight = new UserLight()
                    {
                        UserID    = user.UserID,
                        HuntingID = huntingID2,
                        IsLight   = 1
                    };
                    lightCacheSet.Add(userLight);
                }
            }

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

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

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

            #endregion
        }
Пример #17
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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #18
0
        /// <summary>
        /// 增加物品
        /// </summary>
        public static void AddUserItem(string userID, int itemID, int itemNum, ItemStatus itemStatus, short itemLv, List <UniversalInfo> universalInfoList = null)
        {
            // 增加玩家集邮册
            AddUserAlbum(userID, itemID);

            var      chatService = new TjxChatService();
            GameUser user        = new GameDataCacheSet <GameUser>().FindKey(userID);

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

            if (user == null || itemInfo == null)
            {
                return;
            }
            AddUniversalInfo(universalInfoList, itemInfo, itemNum);

            if (itemInfo.ItemType == ItemType.DaoJu && itemInfo.PropType == 17)
            {
                for (int i = 0; i < itemNum; i++)
                {
                    if (!PackIsFull(userID, BackpackType.HunJi, 1))
                    {
                        AddUserAbility(itemInfo.EffectNum, userID.ToInt(), 0, 0);
                    }
                }
            }
            else
            {
                if (itemInfo.ItemType == ItemType.DaoJu && itemInfo.PropType == 20)
                {
                    AddGeneralSoul(userID, itemInfo.ItemID, itemNum);
                }
                else
                {
                    int gridMaxNum = 0;
                    if (itemInfo.ItemType == ItemType.ZhuangBei)
                    {
                        gridMaxNum = GetPackTypePositionNum(BackpackType.ZhuangBei, userID);
                    }
                    else
                    {
                        gridMaxNum = GetPackTypePositionNum(BackpackType.BeiBao, userID);
                    }
                    int packNum = itemNum / itemInfo.PackMaxNum;
                    int num     = itemNum % itemInfo.PackMaxNum;
                    ////判断背包是否有空位
                    //bool isOut = false;
                    //if (itemStatus == ItemStatus.BeiBao)
                    //{
                    //    isOut = CheckItemOut(user, itemStatus);
                    //}

                    var package  = UserItemPackage.Get(userID);
                    var itemList = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemStatus.Equals(ItemStatus.BeiBao));
                    //背包中是否有余
                    var packItemList = package.ItemPackage.FindAll(
                        m => !m.IsRemove && m.ItemStatus.Equals(itemStatus) &&
                        m.ItemID == itemID &&
                        m.Num < itemInfo.PackMaxNum);

                    //当前空位
                    int currGridNum = gridMaxNum - itemList.Count;
                    // if ((isOut && packItemList.Count == 0) || currGridNum < packNum)
                    if (packItemList.Count == 0 && currGridNum <= 0)
                    {
                        AddItemLog(userID, itemID, itemNum, 1, 0, null);
                        chatService.SystemSendWhisper(user, string.Format("掉落物品{0}*{1}", itemInfo.ItemName, itemNum));
                        return;
                    }
                    currGridNum = MathUtils.Subtraction(currGridNum, packNum, 0);

                    for (int i = 0; i < packNum; i++)
                    {
                        //增加整包
                        UserItemInfo userItem = new UserItemInfo();
                        string       uitemID  = SetUserItem(userItem, userID, itemInfo, itemStatus, itemLv);
                        userItem.Num = itemInfo.PackMaxNum;

                        package.SaveItem(userItem);
                        AddItemLog(userID, itemID, userItem.Num, userItem.ItemLv, 1, uitemID);
                    }
                    //背包中是否有余
                    foreach (var item in packItemList)
                    {
                        if (num == 0)
                        {
                            break;
                        }

                        int gridNum = itemInfo.PackMaxNum - item.Num;
                        int tempNum = gridNum > num ? num : gridNum;

                        item.Num = MathUtils.Addition(item.Num, tempNum, itemInfo.PackMaxNum);

                        package.SaveItem(item);
                        num = num > tempNum ? num - tempNum : 0;
                    }
                    //数据是否有余
                    if (num > 0)
                    {
                        if (currGridNum <= 0)
                        {
                            AddItemLog(userID, itemInfo.ItemID, num, 1, 0, null);
                            chatService.SystemSendWhisper(user, string.Format("掉落物品{0}*{1}", itemInfo.ItemName, num));
                        }
                        else
                        {
                            var    userItem = new UserItemInfo();
                            string uitemID  = SetUserItem(userItem, userID, itemInfo, itemStatus, itemLv);
                            userItem.Num = num;
                            package.SaveItem(userItem);

                            AddItemLog(userID, itemID, userItem.Num, userItem.ItemLv, 1, uitemID);
                        }
                    }
                }
            }
        }
Пример #19
0
        public override bool TakeAction()
        {
            UserHelper.GetUserLightOpen(ContextUser.UserID);
            short opType     = 0;
            int   huntingID2 = 0;

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

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

            ProbabilityInfo probabilityInfo = null;

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

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

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

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

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

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

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

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

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

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

            //日常任务-猎命
            TaskHelper.TriggerDailyTask(Uid, 4009);
            return(true);
        }
Пример #20
0
        public override bool TakeAction()
        {
            if (_userId.Equals(Uid))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptError;
                return(false);
            }
            if (new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid) != null)
            {
                var userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid);
                int maxNum       = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PetIntercept).MaxNum;
                if (userRestrain.UserExtend != null && userRestrain.UserExtend.PetIntercept >= maxNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St3206_PetInterceptTimesOut;
                    return(false);
                }
            }

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

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

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

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

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

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

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

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

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

            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

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

                restrain.UserExtend.UpdateNotify(obj =>
                {
                    restrain.UserExtend.PetIntercept = MathUtils.Addition(restrain.UserExtend.PetIntercept, 1);
                    return(true);
                });
                //restrain.Update();
            }
            return(true);
        }
Пример #21
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));
                }
            }
        }
Пример #22
0
        public override bool TakeAction()
        {
            short     optype       = 0;
            short     plantQuality = 0;
            PlantType pType        = (PlantType)Enum.Parse(typeof(PlantType), plantType.ToString());

            if (pType == PlantType.Experience)
            {
                optype = 6;
            }
            else
            {
                optype = 7;
            }
            short       generalLv   = 0;
            UserGeneral userGeneral = new PersonalCacheStruct <UserGeneral>().FindKey(ContextUser.UserID, generalID);

            if (userGeneral == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().LoadDataError;
                return(false);
            }
            generalLv = userGeneral.GeneralLv;

            if (pType == PlantType.Experience)
            {
                generalLv = ContextUser.UserLv;
            }
            else if (pType == PlantType.GameGoin)
            {
                generalLv = userGeneral.GeneralLv;
            }
            int      upexpNum = 0;
            int      expeNum  = 0;
            double   addNum   = FestivalHelper.SurplusPurchased(ContextUser.UserID, FestivalType.ManorAddition);//活动加成
            UserLand userLand = new PersonalCacheStruct <UserLand>().FindKey(ContextUser.UserID, landPositon);

            if (userLand != null)
            {
                if (userLand.IsGain == 2 || userLand.GeneralID == 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return(false);
                }
                plantQuality = (short)userLand.PlantQuality;
                PlantInfo plantInfo = new ShareCacheStruct <PlantInfo>().FindKey(generalLv, plantType, userLand.PlantQuality);
                if (plantInfo != null)
                {
                    if (userLand.IsGain == 1)
                    {
                        userLand.GeneralID    = 0;
                        userLand.PlantType    = PlantType.Experience;
                        userLand.IsGain       = 2;
                        userLand.GainDate     = DateTime.Now;
                        userLand.PlantQuality = PlantQualityType.PuTong;
                    }
                    else
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        return(false);
                    }
                    gainNum = plantInfo.GainNum;
                    UserLand land = new PersonalCacheStruct <UserLand>().FindKey(ContextUser.UserID, landPositon);
                    if (land != null && land.IsRedLand == 1)
                    {
                        gainNum = MathUtils.Addition(gainNum, (int)(gainNum * 0.2), int.MaxValue);
                    }
                    if (land != null && land.IsBlackLand == 1)
                    {
                        gainNum = MathUtils.Addition(gainNum, (int)(gainNum * 0.4), int.MaxValue);
                    }
                    gainNum = (gainNum * addNum).ToInt();
                    if (pType == PlantType.Experience)
                    {
                        expeNum = MathUtils.Addition(userGeneral.CurrExperience, gainNum, int.MaxValue);

                        GeneralEscalateInfo generalEscalate = new ShareCacheStruct <GeneralEscalateInfo>().FindKey(userGeneral.GeneralLv);
                        if (generalEscalate != null)
                        {
                            upexpNum = generalEscalate.UpExperience;
                        }

                        if (gainNum > 0)
                        {
                            userGeneral.Experience2 = MathUtils.Addition(userGeneral.Experience2, gainNum, int.MaxValue);
                            //userGeneral.CurrExperience = MathUtils.Addition(userGeneral.CurrExperience, gainNum, int.MaxValue);
                            UserHelper.TriggerGeneral(userGeneral, gainNum);
                        }
                    }
                    else if (pType == PlantType.GameGoin)
                    {
                        if (gainNum > 0)
                        {
                            ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, gainNum, int.MaxValue);
                        }
                    }
                }
                UserLogHelper.AppenLandLog(ContextUser.UserID, optype, generalID, landPositon, 0, plantQuality, gainNum, 0);
            }

            if (pType == PlantType.Experience && expeNum >= upexpNum)
            {
                var    chatService = new TjxChatService();
                string content     = string.Format(LanguageManager.GetLang().St10006_UserGeneralUpLv,
                                                   userGeneral.GeneralName,
                                                   userGeneral.GeneralLv);
                chatService.SystemSendWhisper(ContextUser, content);
            }

            return(true);
        }