Exemple #1
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);
                    }
                }
            }
        }
Exemple #2
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);
                    }
                }
            }
        }
Exemple #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);
            }
        }
Exemple #4
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);
                }
            }
        }
Exemple #5
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));
        }
Exemple #6
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);
        }
Exemple #7
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));
            }
        }
Exemple #8
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);
        }
Exemple #9
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)));
                }
            }
        }
        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);
            }
        }
Exemple #11
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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #12
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));
                }
            }
        }
Exemple #13
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);
        }
Exemple #14
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);
        }
Exemple #15
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);
                        }
                    }
                }
            }
        }