コード例 #1
0
        /// <summary>
        /// 删除累计充值礼包多个,只余一个
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="packID"></param>
        /// <returns></returns>
        public static void RemoveCharge(string userID, int packID)
        {
            List <PackageReceive> packageReceiveArray = new PersonalCacheStruct <PackageReceive>().FindAll(userID, m => m.PacksID == packID);

            if (packageReceiveArray.Count > 1)
            {
                var packCacheSet = new PersonalCacheStruct <PackageReceive>();
                packageReceiveArray = packCacheSet.FindAll(userID, u => u.IsReceive && u.PacksID == packID);
                if (packageReceiveArray.Count > 0)
                {
                    packageReceiveArray = packCacheSet.FindAll(userID, u => !u.IsReceive && u.PacksID == packID);
                    foreach (PackageReceive packageReceive in packageReceiveArray)
                    {
                        packCacheSet.Delete(packageReceive);
                    }
                }
                else
                {
                    packageReceiveArray = packCacheSet.FindAll(userID, u => !u.IsReceive && u.PacksID == packID);
                    for (int i = 1; i <= packageReceiveArray.Count - 1; i++)
                    {
                        packCacheSet.Delete(packageReceiveArray[i]);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Action4010.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            var cacheSet = new PersonalCacheStruct<UserQueue>();
            List<UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            foreach (UserQueue queue in userQueueList)
            {
                if (queue != null)
                {
                    int npcCount = new ShareCacheStruct<PlotNPCInfo>().FindAll(m => m.PlotID == plotID).Count;
                    //战斗次数
                    int totalBattleNum = (int)Math.Floor((double)(queue.TotalColdTime - queue.DoRefresh()) / PlotInfo.BattleSpeedNum);
                    int turnsNum = totalBattleNum / npcCount;
                    int battleNum = totalBattleNum % npcCount;
                    //没发生战斗或上未通关都返还精力
                    //if (turnsNum == 0 || battleNum > 0)
                    //{
                    //    ContextUser.EnergyNum = ContextUser.EnergyNum.Addition(PlotInfo.BattleEnergyNum, short.MaxValue);
                    //}
                    cacheSet.Delete(queue);
                }
            }

            if (ContextUser.UserStatus == UserStatus.SaoDang)
            {
                ContextUser.ResetSweepPool(0);
                ContextUser.UserStatus = UserStatus.Normal;
                //ContextUser.Update();
            }
            return true;
        }
コード例 #3
0
        public override bool TakeAction()
        {
            var cacheSet = new PersonalCacheStruct <UserQueue>();
            List <UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            foreach (UserQueue queue in userQueueList)
            {
                if (queue != null)
                {
                    int npcCount = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID).Count;
                    //战斗次数
                    int totalBattleNum = (int)Math.Floor((double)(queue.TotalColdTime - queue.DoRefresh()) / PlotInfo.BattleSpeedNum);
                    int turnsNum       = totalBattleNum / npcCount;
                    int battleNum      = totalBattleNum % npcCount;
                    //没发生战斗或上未通关都返还精力
                    //if (turnsNum == 0 || battleNum > 0)
                    //{
                    //    ContextUser.EnergyNum = ContextUser.EnergyNum.Addition(PlotInfo.BattleEnergyNum, short.MaxValue);
                    //}
                    cacheSet.Delete(queue);
                }
            }

            if (ContextUser.UserStatus == UserStatus.SaoDang)
            {
                ContextUser.ResetSweepPool(0);
                ContextUser.UserStatus = UserStatus.Normal;
                //ContextUser.Update();
            }
            return(true);
        }
コード例 #4
0
ファイル: Action9003.cs プロジェクト: xushenghan/Scut-samples
        /// <summary>
        ///  //删除不是本周,本月已领取的数据
        /// </summary>
        /// <param name="userID"></param>
        public static void RemovePack(string userID)
        {
            var cacheSet = new PersonalCacheStruct <PackageReceive>();
            List <PackageReceive> packageReceiveArray = cacheSet.FindAll(userID, u => u.PacksType == 3 || u.PacksType == 4);

            foreach (PackageReceive packageReceive in packageReceiveArray)
            {
                if (!PaymentService.IsCurrentWeek(packageReceive.ReceiveDate) && packageReceive.PacksType == 3)
                {
                    cacheSet.Delete(packageReceive);
                }
                if (packageReceive.ReceiveDate.Month != DateTime.Now.Month && packageReceive.PacksType == 4)
                {
                    cacheSet.Delete(packageReceive);
                }
            }
        }
コード例 #5
0
        static void checkMap()
        {
            var cache   = new PersonalCacheStruct <The3rdUserIDMap>();
            var theData = cache.FindKey("888");

            if (theData == null)
            {
                return;
            }

            var happyDataCache = new PersonalCacheStruct <HappyModeData>();

            List <string> delKey = new List <string>();

            theData.the3rdMap.Foreach((string key, int val) => {
                if (happyDataCache.FindKey(val.ToString()) == null)
                {
                    delKey.Add(key);
                }
                return(true);
            });

            foreach (var k in delKey)
            {
                if (theData.the3rdMap.ContainsKey(k))
                {
                    theData.the3rdMap.Remove(k);
                    ConsoleLog.showErrorInfo(0, "map del:" + k);
                }
            }

            var payCache = new PersonalCacheStruct <PayUserInfoEx>();

            payCache.LoadFrom(null);

            List <int> delPUILst = new List <int>();

            payCache.Foreach((string s1, string s2, PayUserInfoEx pui) => {
                delPUILst.Add(pui.UserId);
                return(true);
            });

            foreach (var v in delPUILst)
            {
                var pui = payCache.FindKey(v.ToString());
                if (null != pui)
                {
                    payCache.Delete(pui);
                }
                ConsoleLog.showErrorInfo(0, "del pui:" + v);
            }
        }
コード例 #6
0
        private static bool UseProps(string userID, ItemBaseInfo itemInfo)
        {
            var cacheSet = new PersonalCacheStruct <UserProps>();
            List <UserProps> propsArray = cacheSet.FindAll(userID, u => u.PropType == itemInfo.PropType);

            if (itemInfo.PropType == 9 && propsArray.Count > 0)
            {
                int refreshNum = propsArray[0].DoRefresh();
                if (refreshNum > 0)
                {
                    return(false);
                }
            }
            bool isUsed = false;

            foreach (UserProps propse in propsArray)
            {
                if (propse.ItemID == 7003 || propse.ItemID == 5200)
                {
                    continue;
                }
                if (!isUsed && propse.ItemID == itemInfo.ItemID)
                {
                    isUsed             = true;
                    propse.SurplusNum += itemInfo.EffectNum;
                    propse.ChangeTime  = DateTime.Now;
                    //propse.Update();
                }
                else
                {
                    cacheSet.Delete(propse);
                }
            }
            //List<UserProps> propsArray1 = new PersonalCacheStruct<UserProps>().FindAll(UserProps.Index_UserID, u => u.PropType == itemInfo.PropType && u.ItemID == itemInfo.ItemID, userID);
            if (!isUsed)
            {
                UserProps uProps = new UserProps(userID, itemInfo.ItemID)
                {
                    SurplusNum = itemInfo.EffectNum,
                    ChangeTime = DateTime.Now
                };
                new PersonalCacheStruct <UserProps>().Add(uProps);
            }
            return(true);
        }
コード例 #7
0
        public static void TriggerMonthPack(string userID, int gameCoin)
        {
            int packType = 4;
            List <RechargePacks> rechargePackseArray = new ShareCacheStruct <RechargePacks>().FindAll(m => m.PacksType == packType);

            foreach (RechargePacks rechargePackse in rechargePackseArray)
            {
                if (rechargePackse.RechargeNum <= gameCoin)
                {
                    List <PackageReceive> packageReceivess = new PersonalCacheStruct <PackageReceive>().FindAll(userID, m => m.PacksID == rechargePackse.PacksID);
                    if (packageReceivess.Count == 0)
                    {
                        PackageReceive receive = new PackageReceive();
                        receive.ReceiveID   = Guid.NewGuid().ToString();
                        receive.PacksID     = rechargePackse.PacksID;
                        receive.UserID      = userID;
                        receive.IsReceive   = false;
                        receive.ReceiveDate = DateTime.Now;
                        new PersonalCacheStruct <PackageReceive>().Add(receive);
                    }
                    else if (!IsHaveMonth(packageReceivess))
                    {
                        PackageReceive receive = packageReceivess[0];

                        if (receive.IsReceive)
                        {
                            receive.IsReceive   = false;
                            receive.ReceiveDate = DateTime.Now;
                            //receive.Update();
                        }


                        var cacheSet = new PersonalCacheStruct <PackageReceive>();
                        for (int i = 1; i <= packageReceivess.Count - 1; i++)
                        {
                            cacheSet.Delete(packageReceivess[i]);
                        }
                    }
                }
            }
        }
コード例 #8
0
        public override bool TakeAction()
        {
            var cacheSet = new PersonalCacheStruct <UserQueue>();
            List <UserQueue> userQueueArray = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.JingJiTiaoZhan);

            if (userQueueArray.Count > 0)
            {
                UserQueue userQueue     = userQueueArray[0];
                int       queueColdTime = userQueue.DoRefresh();
                queueColdTime = queueColdTime < 0 ? 0 : queueColdTime;
                if (ops == 1)
                {
                    this.ErrorCode = ops;
                    this.ErrorInfo = GetPrice().ToString();
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum >= GetPrice())
                    {
                        this.ErrorCode      = ops;
                        ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, GetPrice(), int.MaxValue);
                        //ContextUser.Update();
                        cacheSet.Delete(userQueue);
                    }
                    else
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                }
                else
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
            }
            return(true);
        }
コード例 #9
0
        /// <summary>
        /// 业务逻辑处理
        /// </summary>
        /// <returns>false:中断后面的方式执行并返回Error</returns>
        public override bool TakeAction()
        {
            int roleId = (int)requestPack.charid;

            responsePack        = new ClientDelCharacterRsp();
            responsePack.charId = (uint)roleId;

            var RoleCache = new PersonalCacheStruct <UserRole>();

            var      RoleList = RoleCache.FindAll(Current.UserId.ToString());
            UserRole userRole = RoleList.Find(role => role.RoleId == roleId);

            if (userRole == null)
            {
                responsePack.retcode = (int)ERetCode.RET_FAIL;
                return(true);
            }

            RoleCache.Delete(userRole);
            RoleCache.Update();

            responsePack.retcode = (int)ERetCode.RET_SUCCESS;
            return(true);
        }
コード例 #10
0
ファイル: Action4009.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            //刷新副本奖励
            if (!PlotHelper.RefleshPrize(ContextUser.UserID, plotID))
            {
                //this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                //this.ErrorInfo = LanguageManager.GetLang().St4007_SaodangOver;
            }
            var sweepCacheSet = new PersonalCacheStruct<UserSweepPool>();
            var tempSweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID, m => m.IsSend == false);
            tempSweepPoolList.QuickSort((x, y) =>
            {
                if (x == null && y == null) return 0;
                if (x != null && y == null) return 1;
                if (x == null) return -1;
                int result = 0;
                x.UserID = x.UserID == null ? "" : x.UserID;
                y.UserID = y.UserID == null ? "" : y.UserID;

                result = x.UserID.CompareTo(y.UserID);
                if (result == 0)
                {
                    if (x.TurnsNum < y.TurnsNum)
                    {
                        return -1;
                    }
                    else if (x.TurnsNum > y.TurnsNum)
                    {
                        return 1;
                    }
                    else
                    {
                        if (x.BattleNum < y.BattleNum)
                        {
                            return -1;
                        }
                        else if (x.BattleNum > y.BattleNum)
                        {
                            return 1;
                        }
                    }
                }
                return result;
            });


            userEmbattleList = new PersonalCacheStruct<UserEmbattle>().FindAll(ContextUser.UserID, m => m.GeneralID > 0 && m.MagicID == ContextUser.UseMagicID);

            foreach (UserSweepPool userSweepPool in tempSweepPoolList)
            {
                if (userSweepPool != null)
                {
                    sweepCacheSet.Delete(userSweepPool);
                }
            }

            var tempList = new List<UserSweepPool>(tempSweepPoolList);
            int pageSize = 12;
            int index = 0;
            if (tempList.Count > pageSize)
            {
                index = tempList.Count - pageSize;
            }
            else
            {
                pageSize = tempList.Count;
            }
            if (tempList.Count > 0)
            {
                userSweepPoolList = tempList.GetRange(index, pageSize);
            }

            return true;
        }
コード例 #11
0
ファイル: Action4006.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            List <PlotNPCInfo> plotNPCInfoList = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);

            npcCount = (short)plotNPCInfoList.Count;
            var cacheSet = new PersonalCacheStruct <UserQueue>();
            List <UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            if (userQueueList.Count > 0)
            {
                UserQueue userQueue = userQueueList[0];
                coldTime = userQueue.DoRefresh();
                if (coldTime == 0)
                {
                    cacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                int tempNum = PlotHelper.GetBattleNum(userQueue.GetTiming()) + 1;
                if (npcCount > 0)
                {
                    turnsNum = PlotHelper.GetTurnsNum(npcCount, tempNum);
                    timesNum = PlotHelper.GetTimesNum(npcCount, tempNum);
                }
                //PlotHelper.CheckSweepCount(npcCount, userQueue.GetTiming(), out turnsNum, out battleNum);

                //if (battleNum >= npcCount)
                //{
                //    turnsNum = turnsNum + 1;
                //}
                //else
                //{
                //    battleNum = battleNum + 1;
                //}
            }
            userItemCount = (short)UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao).Count;
            plotInfo      = new ShareCacheStruct <PlotInfo>().FindKey(plotID);
            if (plotInfo == null)
            {
                return(false);
            }
            foreach (PlotNPCInfo npcInfo in plotNPCInfoList)
            {
                if (npcInfo == null)
                {
                    continue;
                }
                List <PlotEmbattleInfo> embattleInfoList = new ShareCacheStruct <PlotEmbattleInfo>().FindAll(m => m.PlotNpcID == npcInfo.PlotNpcID);
                foreach (PlotEmbattleInfo embattleInfo in embattleInfoList)
                {
                    if (monsterDict.ContainsKey(embattleInfo.MonsterID))
                    {
                        if (monsterNumDict.ContainsKey(embattleInfo.MonsterID))
                        {
                            monsterNumDict[embattleInfo.MonsterID] = monsterNumDict[embattleInfo.MonsterID] + 1;
                        }
                    }
                    else
                    {
                        MonsterInfo monsterInfo = new ShareCacheStruct <MonsterInfo>().FindKey(embattleInfo.MonsterID);
                        if (monsterInfo != null)
                        {
                            monsterDict.Add(embattleInfo.MonsterID, monsterInfo);
                            monsterNumDict.Add(embattleInfo.MonsterID, 1);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #12
0
ファイル: Action3007.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            bool result = true;

            taskInfo = new ShareCacheStruct <StoryTaskInfo>().FindKey(TaskID);
            if (taskInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                //this.ErrorInfo = LanguageManager.GetLang().St3002_NotFind;
                SaveLog(new Exception(string.Format("{0},User:{1},task:{2}", LanguageManager.GetLang().St3002_NotFind, ContextUser.UserID, TaskID)));
                return(false);
            }
            _userGeneral = UserGeneral.GetMainGeneral(Uid);
            //获得奖励
            UserTask userTask = new PersonalCacheStruct <UserTask>().FindKey(ContextUser.UserID, TaskID);

            if (userTask == null || userTask.TaskState != TaskState.Completed)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3007_NoCompleted;
                return(false);
            }
            //交付物品任务扣除材料
            if (taskInfo.TermsType == PlotTermsType.Shouji || taskInfo.TermsType == PlotTermsType.Delivery)
            {
                UserItemHelper.UseUserItem(Uid, taskInfo.TargetItemID, taskInfo.TargetItemNum);
            }
            userTask.TaskState = TaskState.Close;
            UserTaskLog taskLog = new UserTaskLog()
            {
                LogID     = Guid.NewGuid().ToString(),
                TaskID    = userTask.TaskID,
                UserID    = userTask.UserID,
                TaskType  = userTask.TaskType,
                TaskState = userTask.TaskState,
                TaskPrize = string.Format("Experience:{0},GameCoin:{1};GameCoin:{2} ",
                                          taskInfo.Experience,
                                          taskInfo.GameCoin,
                                          ContextUser.GameCoin
                                          ),
                CreateDate = DateTime.Now
            };
            var sender = DataSyncManager.GetDataSender();

            sender.Send(taskLog);

            ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, taskInfo.GameCoin, int.MaxValue);
            if (taskInfo.TaskType == TaskType.Master && ContextUser.TaskProgress < TaskID)
            {
                ContextUser.TaskProgress = TaskID;
            }
            //ContextUser.Update();

            //任务加佣兵经验
            //var userEmbattles = new PersonalCacheStruct<UserEmbattle>().FindAll(UserEmbattle.Index_UserID_MagicID, Uid, ContextUser.UseMagicID);
            //foreach (var userEmbattle in userEmbattles)
            //{
            //    UserGeneral userGeneral = new PersonalCacheStruct<UserGeneral>().FindKey(ContextUser.UserID, userEmbattle.GeneralID);
            //    if (userGeneral == null) continue;
            //    userGeneral.CurrExperience = MathUtils.Addition(userGeneral.CurrExperience, taskInfo.Experience, int.MaxValue);
            //    //userGeneral.Update();
            //}
            UserHelper.UserGeneralExp(ContextUser.UserID, taskInfo.Experience);

            //开启功能
            TaskHelper.EnableFunction(ContextUser, taskInfo.FunctionEnum);

            //下发可接任务
            TaskHelper.SendAllowTask(ContextUser, TaskID);

            //开启副本
            PlotHelper.EnablePlot(Uid, taskInfo.EnablePlot);

            //保留主线任务
            var cacheSet = new PersonalCacheStruct <UserTask>();

            if (userTask.TaskType == TaskType.Master)
            {
                //userTask.Update();
            }
            else
            {
                //原因:最后支线任务无限刷新BUG
                if (!TaskHelper.IsLastTask(userTask))
                {
                    cacheSet.Delete(userTask);
                }
            }
            return(result);
        }
コード例 #13
0
ファイル: Action1605.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            int subLifeNum = 0;

            var package = UserItemPackage.Get(Uid);
            UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(userItemID));
            if (userItem == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            //wuzf modify 2012-05-19
            ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(userItem.ItemID);
            var propsArray = new PersonalCacheStruct<UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1);
            if (propsArray.Count > 0 && propsArray[0].SurplusNum > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1605_BandageUse;
                return false;
            }

            //判断背包是否有血包,没有提示去商城
            var userItems = package.ItemPackage.FindAll(m => !m.IsRemove && new UserItemHelper(m).PropType == 1);
            if (userItems.Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1605_UseTwoGold;
                return false;
            }

            //给佣兵补血
            var userGeneralArray = new PersonalCacheStruct<UserGeneral>().FindAll(ContextUser.UserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong);
            int effectNum = itemInfo.EffectNum;
            foreach (var userGeneral in userGeneralArray)
            {
                int maxLifeNum = UserHelper.GetMaxLife(ContextUser.UserID, userGeneral.GeneralID);
                if (userGeneral.LifeNum < maxLifeNum)
                {
                    subLifeNum = MathUtils.Subtraction(maxLifeNum, userGeneral.LifeNum, 0);
                    userGeneral.LifeNum = MathUtils.Addition(userGeneral.LifeNum, effectNum, maxLifeNum);
                    //userGeneral.Update();
                    effectNum = MathUtils.Subtraction(effectNum, subLifeNum, 0);
                }
            }
            var cacheSet = new PersonalCacheStruct<UserProps>();
            UserProps props = new PersonalCacheStruct<UserProps>().FindKey(ContextUser.UserID, userItem.ItemID);
            if (props != null)
            {
                props.SurplusNum = effectNum;
                //props.Update();
            }
            else
            {
                props = new UserProps(ContextUser.UserID, itemInfo.ItemID)
                {
                    SurplusNum = effectNum
                };
                cacheSet.Add(props);
            }

            ContextUser.IsUseupItem = false;
            UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1);
            foreach (UserProps userPropse in propsArray)
            {
                if (userPropse.SurplusNum == 0)
                {
                    cacheSet.Delete(userPropse);
                }
            }
            return true;
        }
コード例 #14
0
        public override bool TakeAction()
        {
            equMaxNum    = ConfigEnvSet.GetInt("UserQueue.EquStrengMaxNum");
            _magicMaxNum = ConfigEnvSet.GetInt("UserQueue.MagicStrengMaxNum");

            equCount = ContextUser.QueueNum;
            List <UserLand> landArray = new PersonalCacheStruct <UserLand>().FindAll(ContextUser.UserID, u => u.IsGain == 1 || u.DoRefresh() > 0);

            currPlantNum = landArray.Count;
            UserPlant plant = new PersonalCacheStruct <UserPlant>().FindKey(ContextUser.UserID);

            if (plant != null)
            {
                maxPlantNum = plant.LandNum;
            }
            else
            {
                maxPlantNum = 0;
            }

            UserExpedition expedition = new PersonalCacheStruct <UserExpedition>().FindKey(ContextUser.UserID);

            if (expedition != null && DateTime.Now.Date == expedition.InsertDate.Date)
            {
                currExploreNum = expedition.ExpeditionNum;
            }
            else
            {
                currExploreNum = 0;
            }

            UserFunction function = new PersonalCacheStruct <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Meiritanxian);

            if (function != null)
            {
                maxExploreNum = 10;
            }
            else
            {
                maxExploreNum = 0;
            }
            var cacheSet = new PersonalCacheStruct <UserQueue>();
            List <UserQueue> uQueueArray = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.EquipmentStrong);

            if (uQueueArray.Count > 3)
            {
                for (int i = 0; i < uQueueArray.Count - 3; i++)
                {
                    cacheSet.Delete(uQueueArray[i]);
                }
            }
            queueArray = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, u => u.QueueType == QueueType.EquipmentStrong || u.QueueType == QueueType.MagicStrong || u.QueueType == QueueType.TianXianStrong);
            queueArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(y.Timing.CompareTo(x.Timing));
            });
            equOpenCount = EquStrongQueue(ContextUser.UserID);
            return(true);
        }
コード例 #15
0
ファイル: Action4008.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            UserQueue userQueue = null;
            int energyNum;
            int coleTime = GetSweepColdTime(out energyNum);
            short surEnergy = MathUtils.Addition(ContextUser.EnergyNum, ContextUser.SurplusEnergy, short.MaxValue);

            if ((ContextUser.EnergyNum == 0 && ContextUser.SurplusEnergy == 0) || surEnergy < energyNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return false;
            }
            int goldNum = GetGoldNum(out userQueue);
            if (goldNum == 0)
            {
                return false;
            }
            if (ops == 1)
            {
                //提示晶石操作
                ErrorCode = ops;
                ErrorInfo = string.Format(LanguageManager.GetLang().St4008_Tip, goldNum);
            }
            else if (ops == 2)
            {
                //使用晶石确认操作
                int userGoldNum = ContextUser.GoldNum;
                if (userGoldNum < goldNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return false;
                }
                //晶石扫荡
                if (userQueue != null)
                {
                    DoAccelerateQueue(goldNum, userQueue.DoRefresh(), userQueue.GetTiming(), userQueue.TotalColdTime);
                    //加速完清除队列
                    var queueCacheSet = new PersonalCacheStruct<UserQueue>();
                    queueCacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    //ContextUser.Update();
                }
                else
                {
                    //清除扫荡池
                    var sweepCacheSet = new PersonalCacheStruct<UserSweepPool>();
                    List<UserSweepPool> sweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID);
                    foreach (UserSweepPool sweepPool in sweepPoolList)
                    {
                        if (sweepPool != null)
                        {
                            sweepCacheSet.Delete(sweepPool);
                        }
                    }
                    var itemList = UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);
                    if (itemList.Count >= ContextUser.GridNum)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St4007_BeiBaoTimeOut;
                        return false;
                    }
                    DoAccelerateQueue(goldNum, coleTime, 0, coleTime);
                }
                DateTime startDate = userQueue != null ? userQueue.Timing : DateTime.Now;
                UserLogHelper.AppenRaidsLog(ContextUser.UserID, 2, startDate, DateTime.Now, (short)GetSweepEnergy(out energyNum), goldNum);
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            return true;
        }
コード例 #16
0
ファイル: PlotHelper.cs プロジェクト: daneric/Scut-samples
        /// <summary>
        /// 刷新副本奖励
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="plotID"></param>
        public static bool RefleshPrize(string userID, int plotID)
        {
            int turnsNum = 0;
            int battleNum = 0;

            List<UserQueue> queueList = new PersonalCacheStruct<UserQueue>().FindAll(userID, m => m.QueueType == QueueType.SaoDang);
            if (queueList.Count == 0)
            {
                return false;
            }
            UserQueue saodangQueue = queueList[0];
            var npcList = new ShareCacheStruct<PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            int npcCount = npcList.Count;
            GameUser gameUser = new PersonalCacheStruct<GameUser>().FindKey(userID);

            while (HasSweep(userID, plotID, saodangQueue.GetTiming(), npcCount, out turnsNum, out battleNum))
            {
                int tempbattleNum = 0;
                if (gameUser.SweepPool.TurnsNum > 0)
                {
                    tempbattleNum = (gameUser.SweepPool.TurnsNum - 1) * npcCount + gameUser.SweepPool.BattleNum;
                }
                tempbattleNum += 1;
                turnsNum = GetTurnsNum(npcCount, tempbattleNum);
                battleNum = GetTimesNum(npcCount, tempbattleNum);
                DoPlotSweepPrize(userID, plotID, turnsNum, battleNum, npcCount);
                if (gameUser.SweepPool.TurnsNum < turnsNum)
                {
                    if (gameUser.SurplusEnergy > 0)
                    {
                        //每轮扣一次精力
                        gameUser.SurplusEnergy = MathUtils.Subtraction(gameUser.SurplusEnergy, PlotInfo.BattleEnergyNum, (short)0);
                    }
                    else
                    {
                        //每轮扣一次精力
                        gameUser.EnergyNum = MathUtils.Subtraction(gameUser.EnergyNum, PlotInfo.BattleEnergyNum, (short)0);
                    }
                }

                gameUser.SweepPool.UpdateNotify(obj =>
                {
                    gameUser.SweepPool.PlotID = plotID;
                    gameUser.SweepPool.TurnsNum = turnsNum;
                    gameUser.SweepPool.BattleNum = battleNum;
                    return true;
                });
                //gameUser.Update();

            }
            if (saodangQueue.DoRefresh() == 0)
            {
                if (gameUser.UserStatus != UserStatus.Normal)
                {
                    var cacheSet = new PersonalCacheStruct<UserQueue>();
                    cacheSet.Delete(saodangQueue);

                    gameUser.UserStatus = UserStatus.Normal;
                    gameUser.ResetSweepPool(0);
                    //gameUser.Update();
                }
            }

            return true;
        }
コード例 #17
0
ファイル: UserHelper.cs プロジェクト: daneric/Scut-samples
 /// <summary>
 /// 佣兵自动使用绷带补血
 /// </summary>
 public static void UserGeneralPromptBlood(GameUser user)
 {
     int subLifeNum = 0;
     if (IsPromptBlood(user.UserID))
     {
         var userItemArray = UserItemHelper.GetItems(user.UserID).FindAll(u => u.ItemType == ItemType.BengDai && u.ItemStatus != ItemStatus.Sell);
         if (userItemArray.Count > 0)
         {
             int itemID = userItemArray[0].ItemID;
             ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(itemID);
             var propsCacheSet = new PersonalCacheStruct<UserProps>();
             List<UserProps> propsArray = propsCacheSet.FindAll(user.UserID, u => u.PropType == 1);
             if (propsArray.Count > 0 && propsArray[0].SurplusNum == 0)
             {
                 foreach (UserProps userPropse in propsArray)
                 {
                     if (userPropse.SurplusNum == 0)
                     {
                         propsCacheSet.Delete(userPropse);
                     }
                 }
             }
             //给佣兵补血
             List<UserGeneral> userGeneralArray = new PersonalCacheStruct<UserGeneral>().FindAll(user.UserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong);
             int effectNum = itemInfo.EffectNum;
             foreach (var userGeneral in userGeneralArray)
             {
                 int maxLifeNum = GetMaxLife(user.UserID, userGeneral.GeneralID);
                 if (userGeneral.LifeNum < maxLifeNum)
                 {
                     subLifeNum = MathUtils.Subtraction(maxLifeNum, userGeneral.LifeNum, 0);
                     userGeneral.LifeNum = MathUtils.Addition(userGeneral.LifeNum, effectNum, maxLifeNum);
                     //userGeneral.Update();
                     effectNum = MathUtils.Subtraction(effectNum, subLifeNum, 0);
                 }
             }
             UserProps props = new UserProps(user.UserID, itemInfo.ItemID)
             {
                 SurplusNum = effectNum
             };
             propsCacheSet.Add(props);
             user.IsUseupItem = false;
             UserItemHelper.UseUserItem(user.UserID, itemInfo.ItemID, 1);
         }
     }
 }
コード例 #18
0
ファイル: Action9003.cs プロジェクト: daneric/Scut-samples
 /// <summary>
 ///  //删除不是本周,本月已领取的数据
 /// </summary>
 /// <param name="userID"></param>
 public static void RemovePack(string userID)
 {
     var cacheSet = new PersonalCacheStruct<PackageReceive>();
     List<PackageReceive> packageReceiveArray = cacheSet.FindAll(userID, u => u.PacksType == 3 || u.PacksType == 4);
     foreach (PackageReceive packageReceive in packageReceiveArray)
     {
         if (!PaymentService.IsCurrentWeek(packageReceive.ReceiveDate) && packageReceive.PacksType == 3)
         {
             cacheSet.Delete(packageReceive);
         }
         if (packageReceive.ReceiveDate.Month != DateTime.Now.Month && packageReceive.PacksType == 4)
         {
             cacheSet.Delete(packageReceive);
         }
     }
 }
コード例 #19
0
ファイル: Action4006.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            List<PlotNPCInfo> plotNPCInfoList = new ShareCacheStruct<PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            npcCount = (short)plotNPCInfoList.Count;
            var cacheSet = new PersonalCacheStruct<UserQueue>();
            List<UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);
            if (userQueueList.Count > 0)
            {
                UserQueue userQueue = userQueueList[0];
                coldTime = userQueue.DoRefresh();
                if (coldTime == 0)
                {
                    cacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                int tempNum = PlotHelper.GetBattleNum(userQueue.GetTiming()) + 1;
                if (npcCount > 0)
                {
                    turnsNum = PlotHelper.GetTurnsNum(npcCount, tempNum);
                    timesNum = PlotHelper.GetTimesNum(npcCount, tempNum);
                }
                //PlotHelper.CheckSweepCount(npcCount, userQueue.GetTiming(), out turnsNum, out battleNum);

                //if (battleNum >= npcCount)
                //{
                //    turnsNum = turnsNum + 1;
                //}
                //else
                //{
                //    battleNum = battleNum + 1;
                //}
            }
            userItemCount = (short)UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao).Count;
            plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(plotID);
            if (plotInfo == null)
            {
                return false;
            }
            foreach (PlotNPCInfo npcInfo in plotNPCInfoList)
            {
                if (npcInfo == null)
                {
                    continue;
                }
                List<PlotEmbattleInfo> embattleInfoList = new ShareCacheStruct<PlotEmbattleInfo>().FindAll(m => m.PlotNpcID == npcInfo.PlotNpcID);
                foreach (PlotEmbattleInfo embattleInfo in embattleInfoList)
                {
                    if (monsterDict.ContainsKey(embattleInfo.MonsterID))
                    {
                        if (monsterNumDict.ContainsKey(embattleInfo.MonsterID))
                        {
                            monsterNumDict[embattleInfo.MonsterID] = monsterNumDict[embattleInfo.MonsterID] + 1;
                        }
                    }
                    else
                    {
                        MonsterInfo monsterInfo = new ShareCacheStruct<MonsterInfo>().FindKey(embattleInfo.MonsterID);
                        if (monsterInfo != null)
                        {
                            monsterDict.Add(embattleInfo.MonsterID, monsterInfo);
                            monsterNumDict.Add(embattleInfo.MonsterID, 1);
                        }
                    }
                }
            }
            return true;
        }
コード例 #20
0
ファイル: Action4007.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            List <UserQueue> queueList = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            if (queueList.Count > 0)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return(false);
            }
            var itemList = UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);

            if (itemList.Count >= ContextUser.GridNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St4007_BeiBaoTimeOut;
                return(false);
            }
            List <PlotNPCInfo> npcList = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            //战斗次数
            int plotNpcNum = npcList.Count;
            int energyNum  = 0;
            int battleNum;

            if (ops == 1)
            {
                //用尽精力,玩家可扫荡轮数
                energyNum = ContextUser.EnergyNum > 200 ? 200 : ContextUser.EnergyNum.ToInt();
                int userTurnsNum = (int)Math.Floor((double)energyNum / PlotInfo.BattleEnergyNum);
                battleNum = userTurnsNum * plotNpcNum;
                coldTime  = battleNum * PlotInfo.BattleSpeedNum;
            }
            else if (ops == 2)
            {
                //30分钟
                coldTime  = Time_30;
                battleNum = PlotHelper.GetBattleNum(Time_30);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else if (ops == 3)
            {
                //60分钟
                coldTime  = Time_60;
                battleNum = PlotHelper.GetBattleNum(Time_60);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (ContextUser.EnergyNum == 0 || ContextUser.EnergyNum < energyNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            //清除扫荡池
            var sweepCacheSet = new PersonalCacheStruct <UserSweepPool>();
            List <UserSweepPool> sweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID);

            foreach (UserSweepPool sweepPool in sweepPoolList)
            {
                if (sweepPool != null)
                {
                    sweepCacheSet.Delete(sweepPool);
                }
            }

            if (coldTime > 0)
            {
                //在开始战斗时扣一次玩家精力,无战斗离开返还
                ContextUser.ResetSweepPool(plotID);
                //开始扫荡暂不扣精力
                //ContextUser.RemoveEnergyNum(PlotInfo.BattleEnergyNum);
                ContextUser.UserStatus = UserStatus.SaoDang;
                //ContextUser.Update();

                //放入队列中
                UserQueue userQueue = new UserQueue()
                {
                    QueueID       = Guid.NewGuid().ToString(),
                    UserID        = ContextUser.UserID,
                    QueueType     = QueueType.SaoDang,
                    QueueName     = QueueType.SaoDang.ToString(),
                    TotalColdTime = coldTime,
                    Timing        = DateTime.Now,
                    ColdTime      = coldTime,
                    IsSuspend     = false
                };
                new PersonalCacheStruct <UserQueue>().Add(userQueue);
            }
            return(true);
        }
コード例 #21
0
        public override bool TakeAction()
        {
            int subLifeNum = 0;

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

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

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

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

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

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

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

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

            ContextUser.IsUseupItem = false;
            UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1);
            foreach (UserProps userPropse in propsArray)
            {
                if (userPropse.SurplusNum == 0)
                {
                    cacheSet.Delete(userPropse);
                }
            }
            return(true);
        }
コード例 #22
0
 /// <summary>
 /// 删除累计充值礼包多个,只余一个
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="packID"></param>
 /// <returns></returns>
 public static void RemoveCharge(string userID, int packID)
 {
     List<PackageReceive> packageReceiveArray = new PersonalCacheStruct<PackageReceive>().FindAll(userID, m => m.PacksID == packID);
     if (packageReceiveArray.Count > 1)
     {
         var packCacheSet = new PersonalCacheStruct<PackageReceive>();
         packageReceiveArray = packCacheSet.FindAll(userID, u => u.IsReceive && u.PacksID == packID);
         if (packageReceiveArray.Count > 0)
         {
             packageReceiveArray = packCacheSet.FindAll(userID, u => !u.IsReceive && u.PacksID == packID);
             foreach (PackageReceive packageReceive in packageReceiveArray)
             {
                 packCacheSet.Delete(packageReceive);
             }
         }
         else
         {
             packageReceiveArray = packCacheSet.FindAll(userID, u => !u.IsReceive && u.PacksID == packID);
             for (int i = 1; i <= packageReceiveArray.Count - 1; i++)
             {
                 packCacheSet.Delete(packageReceiveArray[i]);
             }
         }
     }
 }
コード例 #23
0
        public static void TriggerMonthPack(string userID, int gameCoin)
        {
            int packType = 4;
            List<RechargePacks> rechargePackseArray = new ShareCacheStruct<RechargePacks>().FindAll(m => m.PacksType == packType);
            foreach (RechargePacks rechargePackse in rechargePackseArray)
            {
                if (rechargePackse.RechargeNum <= gameCoin)
                {
                    List<PackageReceive> packageReceivess = new PersonalCacheStruct<PackageReceive>().FindAll(userID, m => m.PacksID == rechargePackse.PacksID);
                    if (packageReceivess.Count == 0)
                    {
                        PackageReceive receive = new PackageReceive();
                        receive.ReceiveID = Guid.NewGuid().ToString();
                        receive.PacksID = rechargePackse.PacksID;
                        receive.UserID = userID;
                        receive.IsReceive = false;
                        receive.ReceiveDate = DateTime.Now;
                        new PersonalCacheStruct<PackageReceive>().Add(receive);
                    }
                    else if (!IsHaveMonth(packageReceivess))
                    {
                        PackageReceive receive = packageReceivess[0];

                        if (receive.IsReceive)
                        {
                            receive.IsReceive = false;
                            receive.ReceiveDate = DateTime.Now;
                            //receive.Update();
                        }


                        var cacheSet = new PersonalCacheStruct<PackageReceive>();
                        for (int i = 1; i <= packageReceivess.Count - 1; i++)
                        {
                            cacheSet.Delete(packageReceivess[i]);
                        }
                    }
                }
            }
        }
コード例 #24
0
ファイル: Action4009.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            //刷新副本奖励
            if (!PlotHelper.RefleshPrize(ContextUser.UserID, plotID))
            {
                //this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                //this.ErrorInfo = LanguageManager.GetLang().St4007_SaodangOver;
            }
            var sweepCacheSet     = new PersonalCacheStruct <UserSweepPool>();
            var tempSweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID, m => m.IsSend == false);

            tempSweepPoolList.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                int result = 0;
                x.UserID   = x.UserID == null ? "" : x.UserID;
                y.UserID   = y.UserID == null ? "" : y.UserID;

                result = x.UserID.CompareTo(y.UserID);
                if (result == 0)
                {
                    if (x.TurnsNum < y.TurnsNum)
                    {
                        return(-1);
                    }
                    else if (x.TurnsNum > y.TurnsNum)
                    {
                        return(1);
                    }
                    else
                    {
                        if (x.BattleNum < y.BattleNum)
                        {
                            return(-1);
                        }
                        else if (x.BattleNum > y.BattleNum)
                        {
                            return(1);
                        }
                    }
                }
                return(result);
            });


            userEmbattleList = new PersonalCacheStruct <UserEmbattle>().FindAll(ContextUser.UserID, m => m.GeneralID > 0 && m.MagicID == ContextUser.UseMagicID);

            foreach (UserSweepPool userSweepPool in tempSweepPoolList)
            {
                if (userSweepPool != null)
                {
                    sweepCacheSet.Delete(userSweepPool);
                }
            }

            var tempList = new List <UserSweepPool>(tempSweepPoolList);
            int pageSize = 12;
            int index    = 0;

            if (tempList.Count > pageSize)
            {
                index = tempList.Count - pageSize;
            }
            else
            {
                pageSize = tempList.Count;
            }
            if (tempList.Count > 0)
            {
                userSweepPoolList = tempList.GetRange(index, pageSize);
            }

            return(true);
        }
コード例 #25
0
ファイル: Action3007.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            bool result = true;
            taskInfo = new ShareCacheStruct<StoryTaskInfo>().FindKey(TaskID);
            if (taskInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                //this.ErrorInfo = LanguageManager.GetLang().St3002_NotFind;
                SaveLog(new Exception(string.Format("{0},User:{1},task:{2}", LanguageManager.GetLang().St3002_NotFind, ContextUser.UserID, TaskID)));
                return false;
            }
            _userGeneral = UserGeneral.GetMainGeneral(Uid);
            //获得奖励
            UserTask userTask = new PersonalCacheStruct<UserTask>().FindKey(ContextUser.UserID, TaskID);
            if (userTask == null || userTask.TaskState != TaskState.Completed)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3007_NoCompleted;
                return false;
            }
            //交付物品任务扣除材料
            if (taskInfo.TermsType == PlotTermsType.Shouji || taskInfo.TermsType == PlotTermsType.Delivery)
            {
                UserItemHelper.UseUserItem(Uid, taskInfo.TargetItemID, taskInfo.TargetItemNum);
            }
            userTask.TaskState = TaskState.Close;
            UserTaskLog taskLog = new UserTaskLog()
            {
                LogID = Guid.NewGuid().ToString(),
                TaskID = userTask.TaskID,
                UserID = userTask.UserID,
                TaskType = userTask.TaskType,
                TaskState = userTask.TaskState,
                TaskPrize = string.Format("Experience:{0},GameCoin:{1};GameCoin:{2} ",
                    taskInfo.Experience,
                    taskInfo.GameCoin,
                    ContextUser.GameCoin
                ),
                CreateDate = DateTime.Now
            };
            var sender = DataSyncManager.GetDataSender();
            sender.Send(taskLog);

            ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, taskInfo.GameCoin, int.MaxValue);
            if (taskInfo.TaskType == TaskType.Master && ContextUser.TaskProgress < TaskID)
            {
                ContextUser.TaskProgress = TaskID;
            }
            //ContextUser.Update();

            //任务加佣兵经验
            //var userEmbattles = new PersonalCacheStruct<UserEmbattle>().FindAll(UserEmbattle.Index_UserID_MagicID, Uid, ContextUser.UseMagicID);
            //foreach (var userEmbattle in userEmbattles)
            //{
            //    UserGeneral userGeneral = new PersonalCacheStruct<UserGeneral>().FindKey(ContextUser.UserID, userEmbattle.GeneralID);
            //    if (userGeneral == null) continue;
            //    userGeneral.CurrExperience = MathUtils.Addition(userGeneral.CurrExperience, taskInfo.Experience, int.MaxValue);
            //    //userGeneral.Update();
            //}
            UserHelper.UserGeneralExp(ContextUser.UserID,taskInfo.Experience);

            //开启功能
            TaskHelper.EnableFunction(ContextUser, taskInfo.FunctionEnum);

            //下发可接任务
            TaskHelper.SendAllowTask(ContextUser, TaskID);

            //开启副本
            PlotHelper.EnablePlot(Uid, taskInfo.EnablePlot);

            //保留主线任务
            var cacheSet = new PersonalCacheStruct<UserTask>();
            if (userTask.TaskType == TaskType.Master)
            {
                //userTask.Update();
            }
            else
            {
                //原因:最后支线任务无限刷新BUG
                if (!TaskHelper.IsLastTask(userTask))
                {
                    cacheSet.Delete(userTask);
                }
            }
            return result;
        }
コード例 #26
0
ファイル: NoviceHelper.cs プロジェクト: daneric/Scut-samples
        /// <summary>
        /// 中元节变身活动功能
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="chatContent"></param>
        public static void WingZhongYuanFestival(GameUser user, string chatContent)
        {
            int festivalID = 0;// 1019;
            FestivalInfo festival = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID);
            if (festival != null && festival.FestivalExtend != null)
            {
                if (chatContent.IndexOf(festival.FestivalExtend.KeyWord) != -1)
                {
                    FestivalRestrain restrain = new PersonalCacheStruct<FestivalRestrain>().FindKey(user.UserID);
                    if (restrain == null)
                    {
                        List<PrizeInfo> prizeInfosArray = festival.Reward.ToList();
                        double[] probability = new double[prizeInfosArray.Count];
                        for (int i = 0; i < prizeInfosArray.Count; i++)
                        {
                            probability[i] = (double)prizeInfosArray[i].Probability;
                        }
                        int index2 = RandomUtils.GetHitIndex(probability);
                        PrizeInfo prizeInfo = prizeInfosArray[index2];
                        if (prizeInfo != null)
                        {
                            var cacheSet = new PersonalCacheStruct<UserProps>();
                            UserProps props = cacheSet.FindKey(user.UserID, prizeInfo.ItemID);
                            if (props != null && !IsFestivalOpen(festivalID))
                            {
                                cacheSet.Delete(props);
                            }
                            else if (props == null && IsFestivalOpen(festivalID))
                            {
                                props = new UserProps(user.UserID, prizeInfo.ItemID)
                                            {
                                                ChangeTime = festival.StartDate,
                                                SurplusNum = 0
                                            };

                                cacheSet.Add(props);

                                restrain = new FestivalRestrain()
                                {
                                    UserID = user.UserID,
                                    FestivalID = festivalID,
                                    RefreashDate = DateTime.Now,
                                    RestrainNum = 1
                                };
                                new PersonalCacheStruct<FestivalRestrain>().Add(restrain);
                            }
                        }
                    }
                }
            }
        }
コード例 #27
0
        public override bool TakeAction()
        {
            ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(medicineID);

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

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

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

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

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

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

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

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

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

            return(true);
        }
コード例 #28
0
ファイル: NoviceHelper.cs プロジェクト: daneric/Scut-samples
 /// <summary>
 /// 是否本次活动时间
 /// </summary>
 /// <param name="festivalID"></param>
 /// <returns></returns>
 public static void FestivalStop(string userID, int festivalID)
 {
     FestivalInfo festival = new ShareCacheStruct<FestivalInfo>().FindKey(festivalID);
     if (festival != null)
     {
         DateTime startDate = festival.StartDate;
         var cacheSet = new PersonalCacheStruct<FestivalRestrain>();
         FestivalRestrain festivalRestrain = cacheSet.FindKey(userID, festivalID);
         if (festivalRestrain != null && festivalRestrain.RefreashDate < startDate)
         {
             cacheSet.Delete(festivalRestrain);
         }
     }
 }
コード例 #29
0
ファイル: Action1701.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            equMaxNum = ConfigEnvSet.GetInt("UserQueue.EquStrengMaxNum");
            _magicMaxNum = ConfigEnvSet.GetInt("UserQueue.MagicStrengMaxNum");

            equCount = ContextUser.QueueNum;
            List<UserLand> landArray = new PersonalCacheStruct<UserLand>().FindAll(ContextUser.UserID, u => u.IsGain == 1 || u.DoRefresh() > 0);
            currPlantNum = landArray.Count;
            UserPlant plant = new PersonalCacheStruct<UserPlant>().FindKey(ContextUser.UserID);
            if (plant != null)
            {
                maxPlantNum = plant.LandNum;
            }
            else
            {
                maxPlantNum = 0;
            }

            UserExpedition expedition = new PersonalCacheStruct<UserExpedition>().FindKey(ContextUser.UserID);
            if (expedition != null && DateTime.Now.Date == expedition.InsertDate.Date)
            {
                currExploreNum = expedition.ExpeditionNum;
            }
            else
            {
                currExploreNum = 0;
            }

            UserFunction function = new PersonalCacheStruct<UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Meiritanxian);
            if (function != null)
            {
                maxExploreNum = 10;
            }
            else
            {
                maxExploreNum = 0;
            }
            var cacheSet = new PersonalCacheStruct<UserQueue>();
            List<UserQueue> uQueueArray = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.EquipmentStrong);
            if (uQueueArray.Count > 3)
            {
                for (int i = 0; i < uQueueArray.Count - 3; i++)
                {
                    cacheSet.Delete(uQueueArray[i]);
                }
            }
            queueArray = new PersonalCacheStruct<UserQueue>().FindAll(ContextUser.UserID, u => u.QueueType == QueueType.EquipmentStrong || u.QueueType == QueueType.MagicStrong || u.QueueType == QueueType.TianXianStrong);
            queueArray.QuickSort((x, y) =>
            {
                if (x == null && y == null) return 0;
                if (x != null && y == null) return 1;
                if (x == null) return -1;
                return y.Timing.CompareTo(x.Timing);
            });
            equOpenCount = EquStrongQueue(ContextUser.UserID);
            return true;
        }
コード例 #30
0
ファイル: Action1415.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(medicineID);
            if (itemInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            if (ops == 1)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St11415_ClearMedicine, itemInfo.ItemName, itemInfo.MedicineLv, itemInfo.EffectNum);
                return false;
            }

            UserGeneral general = new PersonalCacheStruct<UserGeneral>().FindKey(ContextUser.UserID, generalID);
            if (general == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St10006_DoesNotExistTheGeneral;
                return false;
            }
            var cacheSet = new PersonalCacheStruct<GeneralMedicine>();
            List<GeneralMedicine> generalMedicineArray = cacheSet.FindAll(ContextUser.UserID, g => g.MedicineID.Equals(medicineID) && g.GeneralID == generalID);
            generalMedicineArray.QuickSort((x, y) =>
            {
                if (x == null && y == null) return 0;
                if (x != null && y == null) return 1;
                if (x == null) return -1;
                return x.BaseNum.CompareTo(y.BaseNum);
            });
            if (generalMedicineArray.Count <= 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1415_MedicineNum;
                return false;
            }
            if (UserHelper.IsBeiBaoFull(ContextUser))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1415_GridNumNotEnough;
                return false;
            }

            //UserItem[] userItemArray = UserItem.FindAll(UserItem.Index_UserID, u => (u.ItemStatus == ItemStatus.BeiBao || u.ItemStatus == ItemStatus.CangKu) && u.ItemID == itemID, ContextUser.UserID);
            var package = UserItemPackage.Get(Uid);
            List<UserItemInfo> userItemArray = package.ItemPackage.FindAll(m => !m.IsRemove && m.ItemID == itemID);
            //药剂摘除道不足
            int Num = itemInfo.MedicineLv;
            if (userItemArray.Count <= 0 || UserItemMedicineNum(userItemArray) < Num)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1415_MedicineNum;
                return false;
            }
            UserItemHelper.UseUserItem(ContextUser.UserID, itemID, Num);
            if (RandomUtils.GetRandom() <= itemInfo.EffectNum)
            {
                short propertyNum = MedicinePropertyNum(ContextUser.UserID, medicineID, generalID);
                switch (itemInfo.MedicineType)
                {
                    case 1:
                        general.PowerNum = MathUtils.Subtraction(general.PowerNum, propertyNum);
                        break;
                    case 2:
                        general.SoulNum = MathUtils.Subtraction(general.SoulNum, propertyNum);
                        break;
                    case 3:
                        general.IntellectNum = MathUtils.Subtraction(general.IntellectNum, propertyNum);
                        break;
                    default:
                        general.PowerNum = general.PowerNum; ;
                        break;
                }
                //general.Update();
                cacheSet.Delete(generalMedicineArray[0]);
                ErrorCode = 2;
                UserItemHelper.AddUserItem(ContextUser.UserID, medicineID, 1);
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St11415_Clearfail;
                return false;
            }

            return true;
        }
コード例 #31
0
ファイル: Action4007.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            List<UserQueue> queueList = new PersonalCacheStruct<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);
            if (queueList.Count > 0)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return false;
            }
            var itemList = UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);
            if (itemList.Count >= ContextUser.GridNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St4007_BeiBaoTimeOut;
                return false;
            }
            List<PlotNPCInfo> npcList = new ShareCacheStruct<PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            //战斗次数
            int plotNpcNum = npcList.Count;
            int energyNum = 0;
            int battleNum;

            if (ops == 1)
            {
                //用尽精力,玩家可扫荡轮数
                energyNum = ContextUser.EnergyNum > 200 ? 200 : ContextUser.EnergyNum.ToInt();
                int userTurnsNum = (int)Math.Floor((double)energyNum / PlotInfo.BattleEnergyNum);
                battleNum = userTurnsNum * plotNpcNum;
                coldTime = battleNum * PlotInfo.BattleSpeedNum;
            }
            else if (ops == 2)
            {
                //30分钟
                coldTime = Time_30;
                battleNum = PlotHelper.GetBattleNum(Time_30);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else if (ops == 3)
            {
                //60分钟
                coldTime = Time_60;
                battleNum = PlotHelper.GetBattleNum(Time_60);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            if (ContextUser.EnergyNum == 0 || ContextUser.EnergyNum < energyNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return false;
            }
            //清除扫荡池
            var sweepCacheSet = new PersonalCacheStruct<UserSweepPool>();
            List<UserSweepPool> sweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID);
            foreach (UserSweepPool sweepPool in sweepPoolList)
            {
                if (sweepPool != null)
                {
                    sweepCacheSet.Delete(sweepPool);
                }
            }

            if (coldTime > 0)
            {
                //在开始战斗时扣一次玩家精力,无战斗离开返还
                ContextUser.ResetSweepPool(plotID);
                //开始扫荡暂不扣精力
                //ContextUser.RemoveEnergyNum(PlotInfo.BattleEnergyNum);
                ContextUser.UserStatus = UserStatus.SaoDang;
                //ContextUser.Update();

                //放入队列中                    
                UserQueue userQueue = new UserQueue()
                {
                    QueueID = Guid.NewGuid().ToString(),
                    UserID = ContextUser.UserID,
                    QueueType = QueueType.SaoDang,
                    QueueName = QueueType.SaoDang.ToString(),
                    TotalColdTime = coldTime,
                    Timing = DateTime.Now,
                    ColdTime = coldTime,
                    IsSuspend = false
                };
                new PersonalCacheStruct<UserQueue>().Add(userQueue);

            }
            return true;
        }
コード例 #32
0
ファイル: Action5105.cs プロジェクト: daneric/Scut-samples
        public override bool TakeAction()
        {
            var cacheSet = new PersonalCacheStruct<UserQueue>();
            List<UserQueue> userQueueArray = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.JingJiTiaoZhan);
            if (userQueueArray.Count > 0)
            {
                UserQueue userQueue = userQueueArray[0];
                int queueColdTime = userQueue.DoRefresh();
                queueColdTime = queueColdTime < 0 ? 0 : queueColdTime;
                if (ops == 1)
                {
                    this.ErrorCode = ops;
                    this.ErrorInfo = GetPrice().ToString();
                    return false;
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum >= GetPrice())
                    {
                        this.ErrorCode = ops;
                        ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, GetPrice(), int.MaxValue);
                        //ContextUser.Update();
                        cacheSet.Delete(userQueue);
                    }
                    else
                    {

                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return false;
                    }
                }
                else
                {
                    this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return false;
                }
            }
            return true;
        }
コード例 #33
0
ファイル: Action4008.cs プロジェクト: xushenghan/Scut-samples
        public override bool TakeAction()
        {
            UserQueue userQueue = null;
            int       energyNum;
            int       coleTime  = GetSweepColdTime(out energyNum);
            short     surEnergy = MathUtils.Addition(ContextUser.EnergyNum, ContextUser.SurplusEnergy, short.MaxValue);

            if ((ContextUser.EnergyNum == 0 && ContextUser.SurplusEnergy == 0) || surEnergy < energyNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            int goldNum = GetGoldNum(out userQueue);

            if (goldNum == 0)
            {
                return(false);
            }
            if (ops == 1)
            {
                //提示晶石操作
                ErrorCode = ops;
                ErrorInfo = string.Format(LanguageManager.GetLang().St4008_Tip, goldNum);
            }
            else if (ops == 2)
            {
                //使用晶石确认操作
                int userGoldNum = ContextUser.GoldNum;
                if (userGoldNum < goldNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                //晶石扫荡
                if (userQueue != null)
                {
                    DoAccelerateQueue(goldNum, userQueue.DoRefresh(), userQueue.GetTiming(), userQueue.TotalColdTime);
                    //加速完清除队列
                    var queueCacheSet = new PersonalCacheStruct <UserQueue>();
                    queueCacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    //ContextUser.Update();
                }
                else
                {
                    //清除扫荡池
                    var sweepCacheSet = new PersonalCacheStruct <UserSweepPool>();
                    List <UserSweepPool> sweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID);
                    foreach (UserSweepPool sweepPool in sweepPoolList)
                    {
                        if (sweepPool != null)
                        {
                            sweepCacheSet.Delete(sweepPool);
                        }
                    }
                    var itemList = UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);
                    if (itemList.Count >= ContextUser.GridNum)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St4007_BeiBaoTimeOut;
                        return(false);
                    }
                    DoAccelerateQueue(goldNum, coleTime, 0, coleTime);
                }
                DateTime startDate = userQueue != null ? userQueue.Timing : DateTime.Now;
                UserLogHelper.AppenRaidsLog(ContextUser.UserID, 2, startDate, DateTime.Now, (short)GetSweepEnergy(out energyNum), goldNum);
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            return(true);
        }
コード例 #34
0
ファイル: Action1608.cs プロジェクト: daneric/Scut-samples
        private static bool UseProps(string userID, ItemBaseInfo itemInfo)
        {
            var cacheSet = new PersonalCacheStruct<UserProps>();
            List<UserProps> propsArray = cacheSet.FindAll(userID, u => u.PropType == itemInfo.PropType);

            if (itemInfo.PropType == 9 && propsArray.Count > 0)
            {
                int refreshNum = propsArray[0].DoRefresh();
                if (refreshNum > 0)
                {
                    return false;
                }
            }
            bool isUsed = false;
            foreach (UserProps propse in propsArray)
            {
                if (propse.ItemID == 7003 || propse.ItemID == 5200)
                {
                    continue;
                }
                if (!isUsed && propse.ItemID == itemInfo.ItemID)
                {
                    isUsed = true;
                    propse.SurplusNum += itemInfo.EffectNum;
                    propse.ChangeTime = DateTime.Now;
                    //propse.Update();
                }
                else
                {
                    cacheSet.Delete(propse);
                }

            }
            //List<UserProps> propsArray1 = new PersonalCacheStruct<UserProps>().FindAll(UserProps.Index_UserID, u => u.PropType == itemInfo.PropType && u.ItemID == itemInfo.ItemID, userID);
            if (!isUsed)
            {
                UserProps uProps = new UserProps(userID, itemInfo.ItemID)
                {
                    SurplusNum = itemInfo.EffectNum,
                    ChangeTime = DateTime.Now
                };
                new PersonalCacheStruct<UserProps>().Add(uProps);
            }
            return true;
        }