Пример #1
0
        /// <summary>
        /// 业务逻辑处理
        /// </summary>
        /// <returns>false:中断后面的方式执行并返回Error</returns>
        public override bool TakeAction()
        {
            _isSuccess = 1;

            var         cacheSet    = new ShareCacheStruct <UserFriends>();
            UserFriends userFriend  = cacheSet.FindKey(ContextUser.UserId, _friendID);
            UserFriends userFriend1 = cacheSet.FindKey(_friendID, ContextUser.UserId);

            if (userFriend == null)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St9104_NotFriendsUserID;
                return(false);
            }

            //Console.WriteLine("***" + userFriend1.UserID);
            //如果原来是好友 要将对方的状态改为关注 其他的直接删除
            if (userFriend.FriendType == FriendType.Friend)
            {
                cacheSet.Delete(userFriend);
                if (userFriend1 != null)
                {
                    userFriend1.FriendType = FriendType.Attention;
                }
            }
            else
            {
                cacheSet.Delete(userFriend);
            }

            return(true);
        }
Пример #2
0
        public void AddandGet()
        {
            var watch  = Stopwatch.StartNew();
            int userId = 138001;
            var cache  = new ShareCacheStruct <KeyData>();

            cache.AddOrUpdate(new KeyData()
            {
                Key = userId.ToString(), Value = "aa"
            });
            var list = cache.FindKey(userId.ToString());

            Assert.IsNotNull(list);

            var key = userId + cache.GetNextNo();

            cache.Add(new KeyData()
            {
                Key = key.ToString(), Value = "aa"
            });
            Assert.IsNotNull(cache.FindKey(key.ToString()));

            key = userId + cache.GetNextNo();
            cache.AddOrUpdate(new KeyData()
            {
                Key = key.ToString(), Value = "aa"
            });
            Assert.IsNotNull(cache.FindKey(key.ToString()));
            WaitEnd(watch);
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="guideId"></param>
 /// <param name="progress"></param>
 /// <returns></returns>
 protected bool TryGetProgress(int guideId, out GuideProgressItem progress)
 {
     progress = null;
     if (_guideSet.FindKey(guideId) == null)
     {
         return(false);
     }
     progress = _userGuide.GuideProgress.Find(m => m.GuideId == guideId);
     return(progress != null);
 }
Пример #4
0
        /// <summary>
        /// 初始化背包
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static void AddBack(GameUser user)
        {
            var cacheSet = new PersonalCacheStruct<UserPack>();
            var cacheSetBackPack = new ShareCacheStruct<BackpackConfigInfo>();
            var userPack = cacheSet.FindKey(user.UserID);

            if (userPack == null)
            {
                userPack = new UserPack();

                userPack.UserID = user.UserID.ToInt();
                userPack.CreateDate = DateTime.Now;
                var backpackConfig = cacheSetBackPack.FindKey(BackpackType.ZhuangBei);
                if (backpackConfig != null)
                {
                    var packType = new PackType();
                    packType.BackpackType = BackpackType.ZhuangBei;
                    packType.OpenNum = 0;
                    packType.Position = backpackConfig.DefaultNum;
                }

                backpackConfig = cacheSetBackPack.FindKey(BackpackType.YongBing);
                if (backpackConfig != null)
                {
                    var packType = new PackType();
                    packType.BackpackType = BackpackType.YongBing;
                    packType.OpenNum = 0;
                    packType.Position = backpackConfig.DefaultNum;
                }

                backpackConfig = cacheSetBackPack.FindKey(BackpackType.HunJi);
                if (backpackConfig != null)
                {
                    var packType = new PackType();
                    packType.BackpackType = BackpackType.HunJi;
                    packType.OpenNum = 0;
                    packType.Position = backpackConfig.DefaultNum;
                }

                backpackConfig = cacheSetBackPack.FindKey(BackpackType.BeiBao);
                if (backpackConfig != null)
                {
                    var packType = new PackType();
                    packType.BackpackType = BackpackType.BeiBao;
                    packType.OpenNum = 0;
                    packType.Position = backpackConfig.DefaultNum;
                    user.GridNum = MathUtils.Addition(user.GridNum, backpackConfig.DefaultNum);
                }
            }

        }
Пример #5
0
        /// <summary>
        /// 初始化背包
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static void AddBack(GameUser user)
        {
            var cacheSet         = new PersonalCacheStruct <UserPack>();
            var cacheSetBackPack = new ShareCacheStruct <BackpackConfigInfo>();
            var userPack         = cacheSet.FindKey(user.UserID);

            if (userPack == null)
            {
                userPack = new UserPack();

                userPack.UserID     = user.UserID.ToInt();
                userPack.CreateDate = DateTime.Now;
                var backpackConfig = cacheSetBackPack.FindKey(BackpackType.ZhuangBei);
                if (backpackConfig != null)
                {
                    var packType = new PackType();
                    packType.BackpackType = BackpackType.ZhuangBei;
                    packType.OpenNum      = 0;
                    packType.Position     = backpackConfig.DefaultNum;
                }

                backpackConfig = cacheSetBackPack.FindKey(BackpackType.YongBing);
                if (backpackConfig != null)
                {
                    var packType = new PackType();
                    packType.BackpackType = BackpackType.YongBing;
                    packType.OpenNum      = 0;
                    packType.Position     = backpackConfig.DefaultNum;
                }

                backpackConfig = cacheSetBackPack.FindKey(BackpackType.HunJi);
                if (backpackConfig != null)
                {
                    var packType = new PackType();
                    packType.BackpackType = BackpackType.HunJi;
                    packType.OpenNum      = 0;
                    packType.Position     = backpackConfig.DefaultNum;
                }

                backpackConfig = cacheSetBackPack.FindKey(BackpackType.BeiBao);
                if (backpackConfig != null)
                {
                    var packType = new PackType();
                    packType.BackpackType = BackpackType.BeiBao;
                    packType.OpenNum      = 0;
                    packType.Position     = backpackConfig.DefaultNum;
                    user.GridNum          = MathUtils.Addition(user.GridNum, backpackConfig.DefaultNum);
                }
            }
        }
Пример #6
0
        public static void UpdateRankingAwardCache()
        {
            var       gameCache  = new ShareCacheStruct <GameCache>();
            GameCache levelCache = gameCache.FindKey(LevelRankingAwardCacheKey);

            levelCache.Value = MathUtils.ToJson(LevelRankingAwardCacheList);

            GameCache fightValueCache = gameCache.FindKey(FightValueRankingAwardCacheKey);

            fightValueCache.Value = MathUtils.ToJson(FightValueRankingAwardCacheList);

            GameCache comboCache = gameCache.FindKey(ComboRankingAwardCacheKey);

            comboCache.Value = MathUtils.ToJson(ComboRankingAwardCacheList);
        }
Пример #7
0
        bool cbFuncRankingTotal(List <UserRankingTotal> rankingList)
        {
            if (null == rankingList || rankingList.Count == 0)
            {
                return(false);
            }
            // self
            UserRanking      ur      = new UserRanking();
            var              cache   = new ShareCacheStruct <UserRankingTotal>();
            UserRankingTotal selfURT = new UserRankingTotal();
            UserRankingTotal findURT = cache.FindKey(requestPack.UserID);
            int              selfPos = rankingList.FindIndex((o) =>
            {
                if (o.UserID == requestPack.UserID)
                {
                    return(true);
                }
                return(false);
            });

            if (findURT == null)
            {
                selfURT.UserID = requestPack.UserID;
                selfURT.Total  = -1;
            }
            else
            {
                selfURT.UserID = findURT.UserID;
                selfURT.Total  = findURT.Total;
            }

            selfPos = formatPos(selfPos);
            responsePack.ItemsExScore.Add(new RankData()
            {
                pos = selfPos, UserName = selfPos + "," + selfURT.Total, Score = selfURT.Total, UserID = selfURT.UserID
            });

            int maxSend     = GameConfigMgr.Instance().getInt("rank_send_num_total", 10);
            var personCache = new PersonalCacheStruct <GameUser>();
            var person      = personCache.FindKey(selfURT.UserID.ToString());

            for (int i = 0; i < rankingList.Count; ++i)
            {
                if (i >= maxSend)
                {
                    break;
                }
                person = personCache.FindKey(rankingList[i].UserID.ToString());
                if (null == person)
                {
                    continue;
                }
                responsePack.ItemsExScore.Add(new RankData()
                {
                    pos = formatPos(i), UserName = person.NickName, Score = rankingList[i].Total, UserID = rankingList[i].UserID
                });
            }

            return(true);
        }
Пример #8
0
        /// <summary>
        /// 奖励物品
        /// </summary>
        /// <param name="prize"></param>
        /// <returns></returns>
        public static void ChestGainTreasureInfo(GameUser user, DialInfo dialInfo, int count)
        {
            var treasure = new TreasureInfo();

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

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

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

            if (dialInfo.IsBroadcast && !string.IsNullOrEmpty(dialInfo.BroadContent))
            {
                TjxChatService chatService = new TjxChatService();
                chatService.SystemSend(ChatType.World, string.Format(dialInfo.BroadContent, user.NickName));
            }
            if (dialInfo.RewardType == RewardType.Again || dialInfo.RewardType == RewardType.Mood || dialInfo.RewardType == RewardType.Recharge)
            {
                if (dialInfo.RewardType == RewardType.Recharge)
                {
                    userDial.ReturnRatio = treasure.Num;
                }
                return;
            }
            ChestGetUserTake(treasure, user);
        }
Пример #9
0
        void UserRankingProcess(GameUser gu)
        {
            var cache        = new ShareCacheStruct <UserRanking>();
            var cacheRanking = cache.FindKey(gu.UserId);

            if (cacheRanking != null)
            {
                if (gu.Score > cacheRanking.Score)
                {
                    cacheRanking.ModifyLocked(() =>
                    {
                        cacheRanking.Score = gu.Score;
                    });
                }
            }
            else
            {
                // 只有>某个值的时候才加。保证10w数据即可。
                if (gu.Score >= RankingScore.limitScoreAdd)
                {
                    UserRanking ur = new UserRanking();
                    ur.UserID   = gu.UserId;
                    ur.Score    = gu.Score;
                    ur.UserName = gu.NickName;
                    cache.Add(ur);
                }
            }
        }
Пример #10
0
        public override bool TakeAction()
        {
            var skillSet = new ShareCacheStruct <Config_Skill>();
            var skillcfg = skillSet.FindKey(skillId);

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

            var skill = GetSkill.SkillList.Find(t => t.ID == skillId);

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

            int carryMaxCount = ConfigEnvSet.GetInt("User.CarrySkillNum");

            if (GetSkill.CarryList.Count >= carryMaxCount || GetSkill.CarryList.Find(t => t == skillId) != 0)
            {
                return(false);
            }

            GetSkill.CarryList.Add(skillId);
            receipt = true;
            return(true);
        }
Пример #11
0
        string processModify(string parm)
        {
            string info = "";

            string[] p           = parm.Split(',');
            string   modifyWhich = p[0];
            int      index       = int.Parse(p[1]) - 1;
            int      score       = int.Parse(p[2]);

            if ("ranking" == modifyWhich)
            {
                UserRanking ur = RankingFactorNew.Singleton().getRankingData <UserRanking, RankingScore>(index);
                if (null == ur)
                {
                    info = "要修改的数据不存在";
                }
                else
                {
                    var         cache = new ShareCacheStruct <UserRanking>();
                    UserRanking theUR = cache.FindKey(ur.UserID);
                    theUR.ModifyLocked(() =>
                    {
                        theUR.Score = score;
                    });

                    info = "修改数据成功";
                }
            }
            return(info);
        }
Пример #12
0
 void doAdd_black(string parm)
 {
     string[] usridStr = parm.Split(',');
     for (int i = 0; i < usridStr.Length; ++i)
     {
         try
         {
             int         UserId     = int.Parse(usridStr[i]);
             var         cache      = new ShareCacheStruct <UserRanking>();
             UserRanking ur         = cache.FindKey(UserId);
             var         personal   = new PersonalCacheStruct <GameUser>();
             GameUser    gu         = personal.FindKey(UserId.ToString());
             var         blackCache = new ShareCacheStruct <BlackListData>();
             if (ur != null && gu != null)
             {
                 blackCache.AddOrUpdate(UR2BLD(gu));
                 ConsoleLog.showNotifyInfo("add to black list id:" + UserId);
             }
             else
             {
                 ConsoleLog.showErrorInfo(0, "not find userRanking id:" + UserId);
             }
         }
         catch (System.Exception e)
         {
             ConsoleLog.showErrorInfo(0, "black list exception:" + e.Message);
         }
     }
 }
Пример #13
0
        public override bool TakeAction()
        {

            if (new GameDataCacheSet<UserFunction>().FindKey(Uid, FunctionEnum.PetRun) == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_NoFun;
                return false;
            }
            UserDailyRestrain restrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(Uid);
            if (restrain != null && restrain.UserExtend != null)
            {
                var dailyCacheSet = new ShareCacheStruct<DailyRestrainSet>();
                if (dailyCacheSet.FindKey(RestrainType.PetRun) != null)
                    _runTimes = MathUtils.Subtraction(dailyCacheSet.FindKey(RestrainType.PetRun).MaxNum, restrain.UserExtend.PetRunTimes, 0);
                if (dailyCacheSet.FindKey(RestrainType.PetIntercept) != null)
                    _interceptTimes = MathUtils.Subtraction(dailyCacheSet.FindKey(RestrainType.PetIntercept).MaxNum, restrain.UserExtend.PetIntercept, 0);
                if (dailyCacheSet.FindKey(RestrainType.PetHelp) != null)
                    _helpTimes = MathUtils.Subtraction(dailyCacheSet.FindKey(RestrainType.PetHelp).MaxNum, restrain.UserExtend.PetHelp, 0);
            }
            var petRun = new ShareCacheStruct<PetRunPool>().FindKey(Uid);
            if (petRun != null)
            {
                //问题:在赛跑时有重刷点亮宠物后,等赛跑完服务端与客户端记录宠物ID不一致,原因是赛跑完有将宠物ID清除
                if (petRun.PetID > 0 && petRun.ColdTime == 0)
                {
                    UserHelper.ProcessPetPrize(petRun);
                }
                _coldTime = petRun.ColdTime;
                _petHead = (new ConfigCacheSet<PetInfo>().FindKey(petRun.PetID) ?? new PetInfo()).PetHead;
                if (ContextUser.UserExtend != null)
                    _petId = ContextUser.UserExtend.LightPetID;
            }
            return true;
        }
Пример #14
0
        /// <summary>
        /// ����ճ�������������
        /// ��ʽ���Ǽ� * ��ɫ�ȼ� * ϵ��
        /// </summary>
        /// <returns></returns>
        public int GetDailyExpNum(short userLv)
        {
            var cacheSet = new ShareCacheStruct <DailyTaskInfo>();
            int num      = (int)Math.Floor((short)TaskStar * userLv * cacheSet.FindKey(TaskID).ExpRatioNum);

            return(num.IsValid(0, int.MaxValue) ? num : 0);
        }
Пример #15
0
        public static List <SkillLvInfo> CreateSkillLvInfo(CombatGeneral general)
        {
            List <SkillLvInfo> _skillLvList = new List <SkillLvInfo>();

            if (general.GeneralID == LanguageManager.GetLang().GameUserGeneralID)
            {
                var       abilityCacheSet = new ShareCacheStruct <AbilityInfo>();
                var       skillLvSet      = new ShareCacheStruct <SkillLvInfo>();
                UserTrump userTrump       = new PersonalCacheStruct <UserTrump>().FindKey(general.UserID, TrumpInfo.CurrTrumpID) ?? new UserTrump();
                if (userTrump.LiftNum > 0)
                {
                    userTrump.SkillInfo.Foreach(obj =>
                    {
                        var abilityInfo = abilityCacheSet.FindKey(obj.AbilityID) ?? new AbilityInfo();
                        if (abilityInfo.AttackType == AttackType.Trigger)
                        {
                            var temp = skillLvSet.FindKey(obj.AbilityID, obj.AbilityLv);
                            if (temp != null)
                            {
                                _skillLvList.Add(temp);
                            }
                        }
                        return(true);
                    });
                }
            }
            return(_skillLvList);
        }
Пример #16
0
        public bool Add(int type, int index, string code)
        {
            var cache = new ShareCacheStruct <ExchangeCode>();
            int key   = UniqueKey(type, index);
            //if (null != cache.FindKey(key)) return false; // this type has been added
            ExchangeCode ec = cache.FindKey(key);

            if (null != ec)
            {
                return(true);
            }
            else
            {
                ec       = new ExchangeCode();
                ec.key   = key;
                ec.Type  = (byte)type;
                ec.Index = index;
                ec.Code  = code;
                if (ec.Type == (byte)GameConfigExchangeCode.ExchangeCodeType.ASType_NSNSDuiHuan_AnHuiTai_1 ||
                    ec.Type == (byte)GameConfigExchangeCode.ExchangeCodeType.ASType_NSNSDuiHuan_JiaRi_1)
                {
                    ec.cnt = int.MaxValue;
                }
                cache.Add(ec);
            }
            return(true);
        }
Пример #17
0
 public static List<SkillLvInfo> CreateSkillLvInfo(CombatGeneral general)
 {
     List<SkillLvInfo> _skillLvList = new List<SkillLvInfo>();
     if (general.GeneralID == LanguageManager.GetLang().GameUserGeneralID)
     {
         var abilityCacheSet = new ShareCacheStruct<AbilityInfo>();
         var skillLvSet = new ShareCacheStruct<SkillLvInfo>();
         UserTrump userTrump = new PersonalCacheStruct<UserTrump>().FindKey(general.UserID, TrumpInfo.CurrTrumpID) ?? new UserTrump();
         if (userTrump.LiftNum > 0)
         {
             userTrump.SkillInfo.Foreach(obj =>
             {
                 var abilityInfo = abilityCacheSet.FindKey(obj.AbilityID) ?? new AbilityInfo();
                 if (abilityInfo.AttackType == AttackType.Trigger)
                 {
                     var temp = skillLvSet.FindKey(obj.AbilityID, obj.AbilityLv);
                     if (temp != null)
                     {
                         _skillLvList.Add(temp);
                     }
                 }
                 return true;
             });
         }
     }
     return _skillLvList;
 }
Пример #18
0
        /// <summary>
        /// ����ճ�������Ʒ����
        /// </summary>
        /// <param name="userLv"></param>
        /// <returns></returns>
        public UserItemInfo GetDailyItem(short userLv)
        {
            UserItemInfo  userItem  = null;
            int           index     = (int)TaskStar - 1;
            var           cacheSet  = new ShareCacheStruct <DailyTaskInfo>();
            DailyTaskInfo dtaskInfo = cacheSet.FindKey(TaskID);

            string[] NumRank = dtaskInfo.QishiNumRank.ToNotNullString().Split(new char[] { ',' });
            int      num     = NumRank.Length > index && index >= 0 ? NumRank[index].ToInt() : 0;

            if (num <= 0)
            {
                return(userItem);
            }

            string[] QishiRank  = dtaskInfo.QishiRank.ToNotNullString().Split(new char[] { ',' });
            string[] UserLvRank = dtaskInfo.UserLvRank.ToNotNullString().Split(new char[] { ',' });
            if (QishiRank.Length > 0 && QishiRank.Length == UserLvRank.Length)
            {
                int          itemIndex = GetItemIndex(UserLvRank, userLv);
                int          itemID    = QishiRank.Length > itemIndex ? QishiRank[itemIndex].ToInt() : 0;
                ItemBaseInfo itemInfo  = new ShareCacheStruct <ItemBaseInfo>().FindKey(itemID);
                if (itemInfo != null)
                {
                    userItem        = new UserItemInfo();
                    userItem.ItemID = itemInfo.ItemID;
                    userItem.Num    = num;
                }
            }
            return(userItem);
        }
Пример #19
0
        protected override IList <UserRank> GetCacheList()
        {
            rankList.Clear();
            if (rankingData.RankList.Count == 0)
            {
                var gameCache = new ShareCacheStruct <GameCache>();
                var levelrank = gameCache.FindKey("LevelRanking");
                if (levelrank == null)
                {
                    levelrank       = new GameCache();
                    levelrank.Key   = "LevelRanking";
                    levelrank.Value = "";
                    gameCache.Add(levelrank);
                    gameCache.Update();
                }

                LevelRankingData data = null;
                data = JsonUtils.Deserialize <LevelRankingData>(levelrank.Value);
                if (data == null)
                {
                    data = new LevelRankingData();
                }
            }

            foreach (var v in rankingData.RankList)
            {
                UserRank rank = new UserRank(v);
                rankList.Add(rank);
            }

            return(rankList);
        }
Пример #20
0
        public override bool TakeAction()
        {
            var guildsSet = new ShareCacheStruct <GuildsCache>();

            var guild = guildsSet.FindKey(GetGuild.GuildID);

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

            var member = guild.FindMember(Current.UserId);

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

            if (GetGuild.IsSignIn)
            {
                receipt = RequestGuildResult.HadSignIn;
                return(true);
            }
            GetGuild.IsSignIn = true;
            int addLiveness = ConfigEnvSet.GetInt("Guild.SignInLiveness") * 500;

            member.Liveness = MathUtils.Addition(member.Liveness, addLiveness, int.MaxValue);
            guild.Liveness  = MathUtils.Addition(guild.Liveness, addLiveness, int.MaxValue);

            GuildLogData log = new GuildLogData()
            {
                UserId   = Current.UserId,
                UserName = GetBasis.NickName,
                LogTime  = DateTime.Now,
                Content  = string.Format("玩家 {0} 进行了签到。", GetBasis.NickName),
            };

            guild.NewLog(log);

            foreach (var v in guild.MemberList)
            {
                PushMessageHelper.GuildMemberChangeNotification(GameSession.Get(v.UserID), Current.UserId);
                PushMessageHelper.NewGuildLogNotification(GameSession.Get(v.UserID));
            }

            int newlv = guild.ConvertLevel();

            if (guild.Lv < newlv)
            {
                guild.Lv = newlv;
                foreach (var v in guild.MemberList)
                {
                    PushMessageHelper.GuildBasisChangeNotification(GameSession.Get(v.UserID));
                }
            }


            receipt = RequestGuildResult.Successfully;
            return(true);
        }
Пример #21
0
        public int isOk(int type, int index, string code)
        {
            var          cache = new ShareCacheStruct <ExchangeCode>();
            int          key   = UniqueKey(type, index);
            ExchangeCode ec    = cache.FindKey(key);

            if (null == ec)
            {
                return(1);                      // not find
            }
            if (type != ec.Type)
            {
                return(2);
            }
            if (index != ec.Index)
            {
                return(3);
            }
            if (code != ec.Code)
            {
                return(4);
            }
            if (ec.cnt <= 0)
            {
                return(5);                      // used...
            }
            ec.ModifyLocked(() =>
            {
                ec.cnt -= 1;
            });
            return(0);
        }
Пример #22
0
        /// <summary>
        ///  获取自身魂技
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="gentralId"></param>
        /// <param name="abilityId"></param>
        /// <returns></returns>
        public static List <AbilityInfo> GetSelfAbilityList(string userId, int gentralId, int abilityId, out decimal SelfEffectValue)
        {
            SelfEffectValue = 0;
            decimal            effectNum       = 0;
            List <AbilityInfo> abilityInfoList = new List <AbilityInfo>();
            var userAbility = _cacheSetUserAbility.FindKey(userId);

            if (userAbility != null && userAbility.AbilityList != null)
            {
                var abilityList = userAbility.AbilityList.FindAll(s => s.GeneralID == gentralId && s.AbilityID != abilityId);
                abilityList.ForEach(ability =>
                {
                    var abilityInfo = _cacheSetAbility.FindKey(ability.AbilityID);
                    var abilityLv   = _cacheSetAbilityLv.FindKey(ability.AbilityID, ability.AbilityLv);
                    if (abilityInfo != null && abilityInfo.IsActive == 1)
                    {
                        abilityInfoList.Add(abilityInfo);
                        effectNum = MathUtils.Addition(effectNum, abilityInfo.RatioNum);
                    }
                    if (abilityLv != null)
                    {
                        effectNum = MathUtils.Addition(effectNum, abilityLv.EffectValue);
                    }
                });
            }
            SelfEffectValue = effectNum;
            return(abilityInfoList);
        }
Пример #23
0
 public CombatStatus GuildBossRefreshStatus()
 {
     if (CombatStatus != CombatStatus.NoStart && CombatStatus != CombatStatus.Over)
     {
         var        cacheSet = new ShareCacheStruct <GameActive>();
         DateTime   currTime = DateTime.Now;
         GameActive active   = cacheSet.FindKey(ActiveID);
         if (active != null)
         {
             if (GuildBossInfo != null)
             {
                 BeginTime = GuildBossInfo.EnablePeriod.ToDateTime(DateTime.MinValue);
                 EndTime   = BeginTime.AddMinutes(active.Minutes);
                 if (BeginTime > currTime)
                 {
                     lock (this)
                     {
                         CombatStatus = CombatStatus.NoStart;
                     }
                 }
                 else if (EndTime < currTime)
                 {
                     lock (this)
                     {
                         CombatStatus = CombatStatus.Over;
                     }
                 }
             }
         }
     }
     return(CombatStatus);
 }
Пример #24
0
        public bool Add(int type,int index,string code)
        {
            var cache = new ShareCacheStruct<ExchangeCode>();
            int key = UniqueKey(type, index);
            //if (null != cache.FindKey(key)) return false; // this type has been added
            ExchangeCode ec = cache.FindKey(key);
            if (null != ec)
            {
                return true;
            }
            else
            {
                ec = new ExchangeCode();
                ec.key = key;
                ec.Type = (byte)type;
                ec.Index = index;
                ec.Code = code;
                if (ec.Type == (byte)GameConfigExchangeCode.ExchangeCodeType.ASType_NSNSDuiHuan_AnHuiTai_1 ||
                    ec.Type == (byte)GameConfigExchangeCode.ExchangeCodeType.ASType_NSNSDuiHuan_JiaRi_1)
                {
                    ec.cnt = int.MaxValue;

                }
                cache.Add(ec);
            }
            return true;
        }
Пример #25
0
 public override bool TakeAction()
 {
     if (string.IsNullOrEmpty(ContextUser.MercenariesID))
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         return false;
     }
     var cacheSet = new ShareCacheStruct<ServerFight>();
     FightCombat combat = new FightCombat();
     ServerFight fight = cacheSet.FindKey(combat.FastID, ContextUser.MercenariesID);
     if (fight != null)
     {
         if (!string.IsNullOrEmpty(fight.CombatMember))
         {
             fight.CombatMember = fight.CombatMember.Replace(ContextUser.UserID, "").Replace(",,", ",");
             if (fight.CombatMember == ",")
             {
                 fight.CombatMember = string.Empty;
             }
         }
         FightUser fightUser = GuildFightCombat._fightUserList.Find(m => m.UserId == ContextUser.UserID);
         if (fightUser != null)
         {
             GuildFightCombat._fightUserList.Remove(fightUser);
         }
         ContextUser.UserStatus = UserStatus.Normal;
     }
     else
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         ErrorInfo = LanguageManager.GetLang().St6411_FailedToExit;
         return false;
     }
     return true;
 }
Пример #26
0
        public void AddFieldAll()
        {
            var watch = Stopwatch.StartNew();
            var cache = new ShareCacheStruct <FieldTypeData>();
            var t     = cache.FindKey(1);

            if (t != null)
            {
            }
            Assert.IsTrue(cache.Add(new FieldTypeData()
            {
                Id            = cache.GetNextNo(),
                FieldBool     = true,
                FieldByte     = 98,
                FieldBytes    = new byte[] { 100, 102 },
                FieldDateTime = DateTime.Now,
                FieldDecimal  = 1.0001m,
                FieldDouble   = 1.000001d,
                FieldFloat    = 1.0000001f,
                FieldGuid     = Guid.NewGuid(),
                FieldInt      = -1000001,
                FieldShort    = -2555,
                FieldStr      = "hello",
                FieldUint     = 10000,
                FieldUlong    = 100000000,
                FieldUshort   = 6222,
            }));

            WaitEnd(watch);
        }
Пример #27
0
        public override bool TakeAction()
        {
            var skillSet      = new ShareCacheStruct <Config_Skill>();
            var skillGradeSet = new ShareCacheStruct <Config_SkillGrade>();
            var skillcfg      = skillSet.FindKey(skillId);

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

            var skill = GetSkill.SkillList.Find(t => t.ID == skillId);

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

            if (GetSkill.CarryList.Find(t => t == skillId) == 0)
            {
                return(false);
            }
            GetSkill.CarryList.Remove(skillId);
            receipt = true;
            return(true);
        }
Пример #28
0
        public override void BuildPacket()
        {
            PushIntoStack(_userMagicArray.Count);
            foreach (UserMagic userMagic in _userMagicArray)
            {
                MagicInfo  magicInfo = new ConfigCacheSet <MagicInfo>().FindKey(userMagic.MagicID);
                short      repostion = GeneralHelper.ReplacePostion(ContextUser.UserID, userMagic.MagicID);
                DataStruct ds        = new DataStruct();
                ds.PushIntoStack(userMagic.MagicID);
                ds.PushIntoStack(magicInfo == null ? string.Empty : magicInfo.MagicName.ToNotNullString());
                ds.PushIntoStack((short)userMagic.MagicLv);
                ds.PushIntoStack(userMagic.IsEnabled == false ? 0 : 1);
                ds.PushIntoStack(magicInfo == null ? string.Empty : magicInfo.MagicDesc.ToNotNullString());
                string      gridPostion = string.Empty;
                string[]    gridRanges  = new string[0];
                MagicLvInfo magicLv     = new ConfigCacheSet <MagicLvInfo>().FindKey(userMagic.MagicID, userMagic.MagicLv);
                if (magicLv != null)
                {
                    var userFunction = new GameDataCacheSet <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.ReplaceGeneral);
                    gridPostion = magicLv.GridRange;
                    if (magicLv.ReplacePostion > 0 && userFunction != null)
                    {
                        gridPostion = gridPostion.TrimEnd(',') + "," + magicLv.ReplacePostion;
                    }
                }
                gridRanges = gridPostion.Split(',');
                ds.PushIntoStack(gridRanges.Length);

                foreach (string gridRang in gridRanges)
                {
                    int          isDisplace   = repostion == gridRang.ToInt() ? 1 : 0;
                    UserEmbattle userEmbattle = new GameDataCacheSet <UserEmbattle>().FindKey(ContextUser.UserID, userMagic.MagicID, gridRang.ToShort());
                    UserGeneral  uGeneral     = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, userEmbattle == null ? 0 : userEmbattle.GeneralID);

                    DataStruct ds1 = new DataStruct();
                    ds1.PushIntoStack(uGeneral == null ? (short)0 : (short)1);
                    ds1.PushIntoStack(gridRang.ToShort());
                    ds1.PushIntoStack(uGeneral == null ? 0 : uGeneral.GeneralID);
                    ds1.PushIntoStack(uGeneral == null ? string.Empty : uGeneral.HeadID.ToNotNullString());
                    ds1.PushIntoStack((short)isDisplace);
                    ds1.PushShortIntoStack(uGeneral == null ? (short)0 : MathUtils.ToShort(uGeneral.GeneralQuality));
                    ds.PushIntoStack(ds1);
                }
                PushIntoStack(ds);
            }
            // 获取佣兵品质
            var generalInfoCacheSet = new ShareCacheStruct <GeneralInfo>();

            PushIntoStack(_userGeneralArray.Count);
            foreach (UserGeneral general in _userGeneralArray)
            {
                GeneralInfo generalInfo = generalInfoCacheSet.FindKey(general.GeneralID);
                DataStruct  ds          = new DataStruct();
                ds.PushIntoStack(general.GeneralID);
                ds.PushIntoStack(general.HeadID.ToNotNullString());
                ds.PushShortIntoStack(generalInfo == null ? (short)0 : MathUtils.ToShort(generalInfo.GeneralQuality));
                PushIntoStack(ds);
            }
        }
Пример #29
0
        public override bool TakeAction()
        {
            var cache = new ShareCacheStruct <testUpdate>();
            var tu    = new testUpdate();

            tu.index  = (int)cache.GetNextNo();
            tu.itemID = 0;

            tu.ModifyLocked(() => {
                tu.itemID = 1;
            });

            tu = cache.FindKey(tu.index);

            tu        = new testUpdate();
            tu.index  = (int)cache.GetNextNo();
            tu.itemID = 100;
            cache.Add(tu);
            tu = cache.FindKey(tu.index);
            //   try
            //   {
            //       var UA = new UserAnalysis();
            //       foreach (logData d in requestPack.items)
            //       {
            //           UA.DeviceId = d.DeviceID;
            //           UA.Channel = d.Channel;
            //           UA.SimType = d.SimType;
            //           UA.ActionType = (UserAnalysis.E_ActionType)d.ActionType;
            //           UA.ProductionId = d.ProductionId;
            //           UA.ActionTime = System.DateTime.Now;
            //           //DataSyncQueueManager.SendToDb(UA);
            //           Console.WriteLine("{0}GameSession:{1}", DateTime.Now.ToString("HH:mm:ss"), GameSession.Count);
            //       }
            //       responsePack = new ResponsePack();
            //       responsePack.ActionId = 80000;
            //       responsePack.ErrorCode = 101;
            //       responsePack.ErrorInfo = "Success";
            //       return true;
            //   }
            //   catch (Exception ex)
            //   {
            //       TraceLog.WriteError("TakeAction:{0} error:{1}", actionId, ex);
            //       return false;
            //   }
            return(true);
        }
Пример #30
0
 public override bool TakeAction()
 {
     var cacheSet = new ShareCacheStruct<UserFriends>();
     UserFriends userFriend = cacheSet.FindKey(ContextUser.UserID, friendID);
     UserFriends userFriend1 = cacheSet.FindKey(friendID, ContextUser.UserID);
     //如果原来是好友 要将对方的状态改为关注 其他的直接删除
     if (userFriend.FriendType == FriendType.Friend)
     {
         cacheSet.Delete(userFriend);
         userFriend1.FriendType = FriendType.Attention;
     }else
     {
         cacheSet.Delete(userFriend);
     }
    
     return true;
 }
Пример #31
0
        public override bool TakeAction()
        {
            var cache = new ShareCacheStruct<testUpdate>();
            var tu = new testUpdate();
            tu.index = (int)cache.GetNextNo();
            tu.itemID = 0;

            tu.ModifyLocked(() => {
                tu.itemID = 1;
            });

            tu = cache.FindKey(tu.index);

            tu = new testUpdate();
            tu.index = (int)cache.GetNextNo();
            tu.itemID = 100;
            cache.Add(tu);
            tu = cache.FindKey(tu.index);
            //   try
            //   {
            //       var UA = new UserAnalysis();
            //       foreach (logData d in requestPack.items)
            //       {
            //           UA.DeviceId = d.DeviceID;
            //           UA.Channel = d.Channel;
            //           UA.SimType = d.SimType;
            //           UA.ActionType = (UserAnalysis.E_ActionType)d.ActionType;
            //           UA.ProductionId = d.ProductionId;
            //           UA.ActionTime = System.DateTime.Now;
            //           //DataSyncQueueManager.SendToDb(UA);
            //           Console.WriteLine("{0}GameSession:{1}", DateTime.Now.ToString("HH:mm:ss"), GameSession.Count);
            //       }
            //       responsePack = new ResponsePack();
            //       responsePack.ActionId = 80000;
            //       responsePack.ErrorCode = 101;
            //       responsePack.ErrorInfo = "Success";
            //       return true;
            //   }
            //   catch (Exception ex)
            //   {
            //       TraceLog.WriteError("TakeAction:{0} error:{1}", actionId, ex);
            //       return false;
            //   }
            return true;
        }
Пример #32
0
        public override bool TakeAction()
        {
            int totalDate = (ConfigEnvSet.GetInt("UserQueue.GuildMemberDel") * 60 * 60);
            var memberSet = new ShareCacheStruct <GuildMember>();
            List <GuildMember> memberArray = memberSet.FindAll(m => m.GuildID == guildID);
            GuildMember        userMember  = memberSet.FindKey(guildID, ContextUser.UserID);

            if (userMember != null && userMember.PostType == PostType.Chairman && memberArray.Count > 1)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6010_Chairman;
                return(false);
            }
            if (userMember != null)
            {
                if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
                {
                    memberSet.Delete(userMember);
                    ContextUser.MercenariesID = string.Empty;
                    //ContextUser.Update();
                    CombatHelper.RemoveGuildAbility(ContextUser);
                }
                var       guildSet  = new ShareCacheStruct <UserGuild>();
                UserGuild guildInfo = guildSet.FindKey(guildID);
                if (guildInfo != null && userMember.PostType == PostType.Chairman && memberArray.Count <= 1)
                {
                    guildSet.Delete(guildInfo);
                }

                List <UserQueue> queueArray = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TuiChuGongHui);
                if (queueArray.Count > 0)
                {
                    UserQueue queue = queueArray[0];
                    queue.Timing        = DateTime.Now;
                    queue.TotalColdTime = totalDate;
                    queue.ColdTime      = totalDate;
                    //queue.Update();
                }
                else
                {
                    UserQueue userQueue = new UserQueue()
                    {
                        QueueID =
                            Guid.NewGuid().ToString(),
                        QueueName     = QueueType.TuiChuGongHui.ToString(),
                        QueueType     = QueueType.TuiChuGongHui,
                        TotalColdTime = totalDate,
                        ColdTime      = totalDate,
                        Timing        = DateTime.Now,
                        IsSuspend     = false,
                        UserID        = ContextUser.UserID
                    };
                    new PersonalCacheStruct <UserQueue>().Add(userQueue);
                }
            }
            return(true);
        }
Пример #33
0
 public void SendNotice(GameNotice notice, bool isRemove)
 {
     try
     {
         var        cacheSet   = new ShareCacheStruct <GameNotice>();
         GameNotice gameNotice = cacheSet.FindKey(notice.NoticeID);
         if (isRemove)
         {
             if (gameNotice != null)
             {
                 cacheSet.Delete(gameNotice);
             }
         }
         else
         {
             if (gameNotice == null)
             {
                 gameNotice          = new GameNotice();
                 gameNotice.NoticeID = Guid.NewGuid().ToString();
                 cacheSet.Add(gameNotice);
                 gameNotice = cacheSet.FindKey(gameNotice.NoticeID);
             }
             gameNotice.Title       = notice.Title;
             gameNotice.Content     = notice.Content;
             gameNotice.ExpiryDate  = notice.ExpiryDate;
             gameNotice.IsTop       = notice.IsTop;
             gameNotice.IsBroadcast = notice.IsBroadcast;
             gameNotice.Creater     = notice.Creater;
             gameNotice.CreateDate  = notice.CreateDate;
             gameNotice.NoticeType  = notice.NoticeType;
             if (gameNotice.IsBroadcast)
             {
                 var broadcastService = new TjxBroadcastService(null);
                 var msg = broadcastService.Create(NoticeType.System, gameNotice.Content);
                 broadcastService.Send(msg);
             }
         }
     }
     catch (Exception ex)
     {
         new BaseLog().SaveLog("保存公告出错:", ex);
         throw;
     }
 }
Пример #34
0
        public override bool TakeAction()
        {
            int totalDate = (ConfigEnvSet.GetInt("UserQueue.GuildMemberDel") * 60 * 60);
            var memberSet = new ShareCacheStruct<GuildMember>();
            List<GuildMember> memberArray = memberSet.FindAll(m => m.GuildID == guildID);
            GuildMember userMember = memberSet.FindKey(guildID, ContextUser.UserID);
            if (userMember != null && userMember.PostType == PostType.Chairman && memberArray.Count > 1)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6010_Chairman;
                return false;
            }
            if (userMember != null)
            {
                if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
                {
                    memberSet.Delete(userMember);
                    ContextUser.MercenariesID = string.Empty;
                    //ContextUser.Update();
                    CombatHelper.RemoveGuildAbility(ContextUser);
                }
                var guildSet = new ShareCacheStruct<UserGuild>();
                UserGuild guildInfo = guildSet.FindKey(guildID);
                if (guildInfo != null && userMember.PostType == PostType.Chairman && memberArray.Count <= 1)
                {
                    guildSet.Delete(guildInfo);
                }

                List<UserQueue> queueArray = new PersonalCacheStruct<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TuiChuGongHui);
                if (queueArray.Count > 0)
                {
                    UserQueue queue = queueArray[0];
                    queue.Timing = DateTime.Now;
                    queue.TotalColdTime = totalDate;
                    queue.ColdTime = totalDate;
                    //queue.Update();
                }
                else
                {
                    UserQueue userQueue = new UserQueue()
                    {
                        QueueID =
                            Guid.NewGuid().ToString(),
                        QueueName = QueueType.TuiChuGongHui.ToString(),
                        QueueType = QueueType.TuiChuGongHui,
                        TotalColdTime = totalDate,
                        ColdTime = totalDate,
                        Timing = DateTime.Now,
                        IsSuspend = false,
                        UserID = ContextUser.UserID
                    };
                    new PersonalCacheStruct<UserQueue>().Add(userQueue);
                }
            }
            return true;
        }
Пример #35
0
        /// <summary>
        /// 创始成功之后处理事件
        /// </summary>
        public void OnCreateAfter(UserBasisCache user)
        {
            var            cacheSet = new ShareCacheStruct <UserCenterUser>();
            UserCenterUser ucu      = cacheSet.FindKey(user.UserID);

            if (ucu != null)
            {
                ucu.NickName = user.NickName;
            }
        }
Пример #36
0
        public override bool TakeAction()
        {
            var         cacheSet    = new ShareCacheStruct <UserFriends>();
            UserFriends userFriend  = cacheSet.FindKey(ContextUser.UserID, friendID);
            UserFriends userFriend1 = cacheSet.FindKey(friendID, ContextUser.UserID);

            //如果原来是好友 要将对方的状态改为关注 其他的直接删除
            if (userFriend.FriendType == FriendType.Friend)
            {
                cacheSet.Delete(userFriend);
                userFriend1.FriendType = FriendType.Attention;
            }
            else
            {
                cacheSet.Delete(userFriend);
            }

            return(true);
        }
Пример #37
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            FightCombat fightCombat = new FightCombat();
            var         cacheSet    = new ShareCacheStruct <ServerFight>();
            ServerFight fight       = cacheSet.FindKey(fightCombat.FastID, ContextUser.MercenariesID);

            if (fight != null)
            {
                if (GuildFightCombat.IsFightDate())
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St6412_FightWarDate;
                    return(false);
                }

                var fightUser = GuildFightCombat._fightUserList.Find(m => !m.IsRemove && m.UserId == ContextUser.UserID);
                if (fightUser == null)
                {
                    fightUser                = new FightUser();
                    fightUser.GuildID        = fight.GuildID;
                    fightUser.UserId         = ContextUser.UserID;
                    fightUser.UserName       = ContextUser.NickName;
                    fightUser.WinCount       = 0;
                    fightUser.CityID         = fight.CityID;
                    fightUser.ObtainNum      = 0;
                    fightUser.InspirePercent = 0;
                    fightUser.IsRemove       = false;
                    fightUser.IsNotEnough    = false;
                    GuildFightCombat._fightUserList.Add(fightUser);
                }
                if (!string.IsNullOrEmpty(fight.CombatMember) && !GuildFightCombat.IsFightWar(ContextUser.UserID, fight.CombatMember))
                {
                    fight.CombatMember = fight.CombatMember + ContextUser.UserID + ",";
                }
                else
                {
                    fight.CombatMember = ContextUser.UserID + ",";
                }
                ContextUser.UserStatus = UserStatus.FightCombat;
                ErrorCode = 0;
                ErrorInfo = LanguageManager.GetLang().St6412_FightWarSuccess;
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6412_HaveSignedUp;
                return(false);
            }
            return(true);
        }
Пример #38
0
        public override bool TakeAction()
        {
            var cacheSet = new ShareCacheStruct<UserApply>();
            UserApply apply = cacheSet.FindKey(guildID, ContextUser.UserID);
            if (apply != null)
            {
                cacheSet.Delete(apply);
            }

            return true;
        }
Пример #39
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            FightCombat fightCombat = new FightCombat();
            var cacheSet = new ShareCacheStruct<ServerFight>();
            ServerFight fight = cacheSet.FindKey(fightCombat.FastID, ContextUser.MercenariesID);
            if (fight != null)
            {
                if (GuildFightCombat.IsFightDate())
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St6412_FightWarDate;
                    return false;
                }

                var fightUser = GuildFightCombat._fightUserList.Find(m => !m.IsRemove && m.UserId == ContextUser.UserID);
                if (fightUser == null)
                {
                    fightUser = new FightUser();
                    fightUser.GuildID = fight.GuildID;
                    fightUser.UserId = ContextUser.UserID;
                    fightUser.UserName = ContextUser.NickName;
                    fightUser.WinCount = 0;
                    fightUser.CityID = fight.CityID;
                    fightUser.ObtainNum = 0;
                    fightUser.InspirePercent = 0;
                    fightUser.IsRemove = false;
                    fightUser.IsNotEnough = false;
                    GuildFightCombat._fightUserList.Add(fightUser);
                }
                if (!string.IsNullOrEmpty(fight.CombatMember) && !GuildFightCombat.IsFightWar(ContextUser.UserID, fight.CombatMember))
                {
                    fight.CombatMember = fight.CombatMember + ContextUser.UserID + ",";
                }
                else
                {
                    fight.CombatMember = ContextUser.UserID + ",";
                }
                ContextUser.UserStatus = UserStatus.FightCombat;
                ErrorCode = 0;
                ErrorInfo = LanguageManager.GetLang().St6412_FightWarSuccess;
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6412_HaveSignedUp;
                return false;
            }
            return true;
        }
Пример #40
0
        public static int GetInt(ServerEnvKey envKey, int defaultValue)
        {
            var cacheSet = new ShareCacheStruct <ServerEnvSet>();

            if (cacheSet.FindKey(envKey) == null)
            {
                Set(envKey, defaultValue);
                return(defaultValue);
            }
            return(new ShareCacheStruct <ServerEnvSet>().FindKey(envKey).EnvValue.ToInt());
        }
Пример #41
0
        public override bool TakeAction()
        {
            GameUser gameUser = new GameDataCacheSet<GameUser>().FindKey(memberID);
            var guildCacheSet = new ShareCacheStruct<GuildMember>();
            GuildMember member = guildCacheSet.FindKey(guildID, memberID);
            if (member != null)
            {
                if (string.IsNullOrEmpty(gameUser.MercenariesID))
                {
                    return false;
                }
                guildCacheSet.Delete(member);
                //gameUser.UserLocation = Location.City;
                gameUser.MercenariesID = string.Empty;
                //gameUser.Update();
                CombatHelper.RemoveGuildAbility(gameUser);
            }
            int totalDate = (ConfigEnvSet.GetInt("UserQueue.GuildMemberDel") * 60 * 60);
            List<UserQueue> queueArray = new GameDataCacheSet<UserQueue>().FindAll(memberID, m => m.QueueType == QueueType.TuiChuGongHui);
            if (queueArray.Count > 0)
            {
                //new UserQueue().ReLoadUser(memberID);
                queueArray = new GameDataCacheSet<UserQueue>().FindAll(memberID, m => m.QueueType == QueueType.TuiChuGongHui);
            }
            if (queueArray.Count > 0)
            {
                UserQueue queue = queueArray[0];
                queue.Timing = DateTime.Now;
                queue.TotalColdTime = totalDate;
                queue.ColdTime = totalDate;
                //queue.Update();
            }
            else
            {
                UserQueue userQueue = new UserQueue()
                {
                    QueueID = Guid.NewGuid().ToString(),
                    QueueName = QueueType.TuiChuGongHui.ToString(),
                    QueueType = QueueType.TuiChuGongHui,
                    TotalColdTime = totalDate,
                    ColdTime = totalDate,
                    Timing = DateTime.Now,
                    IsSuspend = false,
                    UserID = ContextUser.UserID
                };
                new GameDataCacheSet<UserQueue>().Add(userQueue);

            }
            return true;
        }
Пример #42
0
        void Init()
        {
            var cache = new ShareCacheStruct<ShareRealItemCnt>();
            List<int> itemIds = GameConfigMgr.Instance().getHappyDataKeys();
            memoryRealInfoDataModel.HappyData hd = null;
            for(int i=0;i<itemIds.Count; ++i)
            {
               if( null ==  cache.FindKey(itemIds[i])) // first add
               {
                   ShareRealItemCnt sric = new ShareRealItemCnt();
                   hd = GameConfigMgr.Instance().getHappyData(itemIds[i]);
                   sric.itemID  = hd.itemID;
                   sric.num     = hd.RefleshNum;
                   cache.Add(sric);
               }
            }

            string timestr = GameConfigMgr.Instance().getString("timer_item_cnt", "600000,600000");
            string[] tt = timestr.Split(',');
            int b0 = int.Parse(tt[0]);
            int b1 = int.Parse(tt[1]);
            TimerMgr.Singleton().add(typeof(RealItemCntUpdate).ToString(), actionrealItemCnt,b0,b1);

            bool openDebug = GameConfigMgr.Instance().getInt("timer_open_debug",0)==1;
            if(openDebug)
            {
                timestr = GameConfigMgr.Instance().getString("time_hdm_cnt", "600000,600000");
                tt = timestr.Split(',');
                 b0 = int.Parse(tt[0]);
                 b1 = int.Parse(tt[1]);
                TimerMgr.Singleton().add("HappyModeData_EnterNum", action_HappyModeData_enterNum, b0, b1);
            }
            else
            {
                //每天05点执行
                try
                {
                    timestr = GameConfigMgr.Instance().getString("time_hdm_cnt_timming", "05:15");
                }
                catch
                {
                    timestr = "05:15";
                }
                TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryDayExecute, "EveryDayTask", timestr));
                ConsoleLog.showNotifyInfo("HappyModeData_EnterNum begin:" + timestr);
            }
        }
Пример #43
0
        public static ItemBaseInfo ShowLairReward(LairTreasure lairTreasure, GameUser gameUser, LairTreasureType lairTreasureType)    //��ʾ��õ���Ʒ
        {
            var cacheSetItem = new ShareCacheStruct<ItemBaseInfo>();
            ItemBaseInfo itemBaseInfo = null;
            var lairRewardList = new ShareCacheStruct<LairRewardInfo>().FindAll(s => s.LairPosition == lairTreasure.LairPosition && s.LairTreasureType == lairTreasureType.ToInt());
            if (lairRewardList.Count >0)
            {
                var lairRewardInfo = lairRewardList[RandomUtils.GetRandom(0, lairRewardList.Count)];
                itemBaseInfo = cacheSetItem.FindKey(lairRewardInfo.ItemID);
                if (itemBaseInfo != null)
                {
                    UserItemHelper.AddUserItem(gameUser.UserID, lairRewardInfo.ItemID, lairTreasure.Num);
                }
            }

            return itemBaseInfo;
        }
Пример #44
0
 /// <summary>
 /// 生成Id
 /// </summary>
 /// <returns></returns>
 public static int GenerateId()
 {
     lock (SyncRoot)
     {
         string userCode = "USER_CODE";
         var userCache = new ShareCacheStruct<UserSet>();
         UserSet userSet = userCache.FindKey(userCode);
         if (userSet == null)
         {
             userSet = new UserSet() { Code = userCode, CurrUserId = 1000 };
             userCache.Add(userSet);
         }
         userSet.CurrUserId++;
         userCache.Update();
         return userSet.CurrUserId;
     }
 }
Пример #45
0
        public int isOk(int type,int index,string code)
        {
            var cache = new ShareCacheStruct<ExchangeCode>();
            int key = UniqueKey(type, index);
            ExchangeCode ec = cache.FindKey(key);
            if (null == ec)        return 1;    // not find
            if (type  != ec.Type)  return 2;
            if (index != ec.Index) return 3;
            if (code  != ec.Code)  return 4;
            if (ec.cnt <= 0)       return 5;    // used...

            ec.ModifyLocked(() =>
            {
                ec.cnt -= 1;
            });
            return 0;
        }
Пример #46
0
        public void SendNotice(GameNotice notice, bool isRemove)
        {
            try
            {
                var cacheSet = new ShareCacheStruct<GameNotice>();
                GameNotice gameNotice = cacheSet.FindKey(notice.NoticeID);
                if (isRemove)
                {
                    if (gameNotice != null)
                    {
                        cacheSet.Delete(gameNotice);
                    }
                }
                else
                {
                    if (gameNotice == null)
                    {
                        gameNotice = new GameNotice();
                        gameNotice.NoticeID = Guid.NewGuid().ToString();
                        cacheSet.Add(gameNotice);
                        gameNotice = cacheSet.FindKey(gameNotice.NoticeID);
                    }
                    gameNotice.Title = notice.Title;
                    gameNotice.Content = notice.Content;
                    gameNotice.ExpiryDate = notice.ExpiryDate;
                    gameNotice.IsTop = notice.IsTop;
                    gameNotice.IsBroadcast = notice.IsBroadcast;
                    gameNotice.Creater = notice.Creater;
                    gameNotice.CreateDate = notice.CreateDate;
                    gameNotice.NoticeType = notice.NoticeType;
                    if (gameNotice.IsBroadcast)
                    {
                        var broadcastService = new TjxBroadcastService(null);
                        var msg = broadcastService.Create(NoticeType.System, gameNotice.Content);
                        broadcastService.Send(msg);
                    }

                }
            }
            catch (Exception ex)
            {
                new BaseLog().SaveLog("保存公告出错:", ex);
                throw;
            }
        }
Пример #47
0
        /// <summary>
        /// 获取技能等级加成
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="generalId"></param>
        /// <param name="abilityId"></param>
        /// <returns></returns>
        public static decimal GetAbilityEffect(string userId, int generalId, int abilityId)
        {

            var userAbility = _cacheSetUserAbility.FindKey(userId);
            decimal effectValue = 0;
            if (userAbility != null && userAbility.AbilityList != null)
            {
                var ability2 =
                    userAbility.AbilityList.Find(
                        s => s.AbilityID == abilityId && s.GeneralID == generalId);
                if (ability2 != null)
                {
                    var cacheSetAbilityLv = new ShareCacheStruct<AbilityLvInfo>();
                    var abilityLv = cacheSetAbilityLv.FindKey(ability2.AbilityID, ability2.AbilityLv);
                    if (abilityLv != null)
                    {
                        effectValue = abilityLv.EffectValue;
                    }
                }
            }
            return effectValue;
        }
Пример #48
0
 void UserRankingProcess(GameUser gu)
 {
     var cache         = new ShareCacheStruct<UserRanking>();
     var cacheRanking  = cache.FindKey(gu.UserId);
     if (cacheRanking != null)
     {
         if(gu.Score>cacheRanking.Score  )
         {
             cacheRanking.ModifyLocked(() =>
             {
                 cacheRanking.Score = gu.Score;
             });
         }
     }
     else
     {
         // ֻ��>ij��ֵ��ʱ��żӡ���֤10w���ݼ��ɡ�
         if(gu.Score>=RankingScore.limitScoreAdd)
         {
             UserRanking ur = new UserRanking();
             ur.UserID = gu.UserId;
             ur.Score = gu.Score;
             ur.UserName = gu.NickName;
             cache.Add(ur);
         }
     }
 }
Пример #49
0
        public override void Process(JsonParameter[] paramList)
        {
            JsonParameterList parameters = JsonParameter.Convert(paramList);
            string op = parameters["op"];
            string[] UserList = Convert.ToString(parameters["UserID"]).Split(new char[] { ',' });
            string itemPackage = Convert.ToString(parameters["Item"]);
            string crystalList = Convert.ToString(parameters["Crystal"]);
            string sparePackage = Convert.ToString(parameters["SparePackage"]);
            string enchantPackage = Convert.ToString(parameters["EnchantPackage"]);

            int obtainNum = 0;
            if (parameters["ObtainNum"].Length > 0)
            {
                obtainNum = Convert.ToInt32(parameters["ObtainNum"]);
            }
            short energyNum = 0;
            if (parameters["EnergyNum"].Length > 0)
            {
                energyNum = Convert.ToInt16(parameters["EnergyNum"]);
            }
            int gameCoin = 0;
            if (parameters["GameCoin"].Length > 0)
            {
                gameCoin = Convert.ToInt32(parameters["GameCoin"]);
            }
            int gold = 0;
            if (parameters["Gold"].Length > 0)
            {
                gold = Convert.ToInt32(parameters["Gold"]);
            }
            int expNum = 0;
            if (parameters["ExpNum"].Length > 0)
            {
                expNum = Convert.ToInt32(parameters["ExpNum"]);
            }
            int vipLv = 0;
            if (parameters["VipLv"].Length > 0)
            {
                vipLv = Convert.ToInt32(parameters["VipLv"]);
            }
            int gainBlessing = 0;
            if (parameters["GainBlessing"].Length > 0)
            {
                gainBlessing = Convert.ToInt32(parameters["GainBlessing"]);
            }
            int honourNum = 0;
            if (parameters["HonourNum"].Length > 0)
            {
                honourNum = Convert.ToInt32(parameters["HonourNum"]);
            }
            string mailContent = Convert.ToString(parameters["MailContent"]);
            int opUserID = Convert.ToInt32(parameters["OpUserID"]);
            //var cacheSetUserItem = new GameDataCacheSet<UserItemPackage>();
            var cacheSetItemInfo = new ShareCacheStruct<ItemBaseInfo>();
            var itemArray = itemPackage.Split(',');
            foreach (string str in UserList)
            {
                try
                {
                    int userID = str.Trim().ToInt();

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

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

                    };
                    var cacheSet = new ShareCacheStruct<UserTakePrize>();
                    cacheSet.Add(userPrizeLog, GameEnvironment.CacheGlobalPeriod);
                    cacheSet.Update();
                    PutCrystal(crystalList.Split(','), str);

                    // 发送系统信件
                    UserMail userMail = new UserMail(newGuid);
                    userMail.UserId = userID;
                    userMail.MailType = (int)MailType.System;
                    userMail.Title = LanguageManager.GetLang().St_SystemMailTitle;
                    userMail.Content = mailContent;
                    userMail.SendDate = DateTime.Now;
                    TjxMailService mailService=new TjxMailService(user);
                    mailService.Send(userMail);
                }
                catch (Exception ex)
                {
                    new BaseLog().SaveLog(ex);
                }
            }
        }
Пример #50
0
        public override bool TakeAction()
        {
            var cacheSet = new ShareCacheStruct<UserFriends>();
            if (_friendId != "" && _friendId != ContextUser.UserID)
            {
                //找到本玩家的数据
                List<UserFriends> friendArray = cacheSet.FindAll(m => m.UserID == ContextUser.UserID);
                int friendNum = ConfigEnvSet.GetInt("UserFriends.MaxFriendNum");
                //添加的好友上限
                if (friendArray.Count >= friendNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St9103_TheMaximumReachedAFriend;
                    return false;
                }

                //查看是否在user库中有该玩家
                GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(_friendId);
                if (userInfo == null)
                {
                    UserCacheGlobal.LoadOffline(_friendId);
                    userInfo = new GameDataCacheSet<GameUser>().FindKey(_friendId);
                }
                if (userInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St9103_NotFriendsUserID;
                    return false;
                }

                //在好友表中查找本玩家 和添加好友的关系
                var userFriend = cacheSet.FindKey(ContextUser.UserID, _friendId);
                var userFriend1 = cacheSet.FindKey(_friendId, ContextUser.UserID);
                //同意
                if (_ops == 1)
                {
                   //有信息表 没信息表
                   if (userFriend == null)
                   {
                       //创建新的数据 并且添加成关注类型
                       var friends = new UserFriends
                       {
                           UserID = ContextUser.UserID,
                           FriendID = _friendId,
                           FriendType = FriendType.Friend
                       };
                       cacheSet.Add(friends);
                       //todo test
                       friends.ChatTime = DateTime.Now;

                   }else
                   {
                       //玩家原来就有数据
                       //判断两个玩家的关系
                       if (userFriend.FriendType == FriendType.Friend)
                       {
                           ErrorCode = LanguageManager.GetLang().ErrorCode;
                           ErrorInfo = LanguageManager.GetLang().St9103_TheUserHasAFriendIn;
                           return false;
                       }
                       userFriend.FriendType = FriendType.Friend;
                   }

                   //判断对方是否有和本玩家的数据 如果没有创建 有改状态
                   if (userFriend1 == null)
                   {
                       var friends2 = new UserFriends
                       {
                           UserID = _friendId,
                           FriendID = ContextUser.UserID,
                           FriendType = FriendType.Friend,
                       };
                       cacheSet.Add(friends2);
                       //todo test
                       friends2.ChatTime = DateTime.Now;
                   }
                   else
                   {
                         userFriend1.FriendType = FriendType.Friend;
                    }

                    //加为好友成功后发送一条邮件
                   try
                   {
                       Guid newGuid = Guid.NewGuid();
                       UserMail userMail = new UserMail(newGuid);
                       userMail.UserId = Int32.Parse(_friendId);
                       userMail.MailType = (int)MailType.Friends;
                       userMail.Title = LanguageManager.GetLang().St_AskFirendMailTitle;
                       userMail.Content = string.Format(LanguageManager.GetLang().St_FirendNotice, ContextUser.NickName);
                       userMail.SendDate = DateTime.Now;
                       userMail.FromUserId = Int32.Parse(ContextUser.UserID);
                       userMail.FromUserName = ContextUser.NickName;
                       TjxMailService mailService = new TjxMailService(ContextUser);
                       mailService.Send(userMail);

                       var noticeMail = mailService.ReadMail(ContextUser.UserID, _mailId);
                       noticeMail.ReplyStatus = 1;

                   }
                   catch (Exception)
                   {

                   }

                }else
                {

                    //不同意
                    TjxMailService mailService = new TjxMailService(ContextUser);
                    var noticeMail = mailService.ReadMail(ContextUser.UserID, _mailId);
                    noticeMail.ReplyStatus = 1;

                }
            }
            return true;
        }
Пример #51
0
        public override bool TakeAction()
        {

            //if (ContextUser.EnergyNum <= 0)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            //if (ContextUser.EnergyNum <= 0 && ContextUser.TempEnergyNum == 0)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            if (ContextUser.UserStatus == UserStatus.SaoDang)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return false;
            }
            if (ContextUser.UseMagicID == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic;
                return false;
            }
            if (new PersonalCacheStruct<UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty;
                return false;
            }

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

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

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

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

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

                var cacheSetUserPlot = new PersonalCacheStruct<UserPlotPackage>();
                var cacheSetItemInfo = new ShareCacheStruct<ItemBaseInfo>();
                var cacheSet = new PersonalCacheStruct<UserPlotCombat>();
                var userPlotPack = cacheSetUserPlot.FindKey(ContextUser.UserID);
                var userPlot = userPlotPack != null ? userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null;
                //PlotHelper.IsKill(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID)
                if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum)
                {
                    if (plotInfo.PlotType == PlotType.Elite)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed;
                        return false;
                    }
                    else if (plotInfo.PlotType == PlotType.HeroPlot)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum;
                        return false;
                    }
                }

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

                        }
                        if (!ContextUser.IsItem)
                        {
                            prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID);
                        }
                        TaskHelper.KillPlotMonster(Uid, npcInfo.PlotID, PlotNpcID);

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

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

                    }
                    else
                    {

                        ContextUser.GeneralAllCount = 0;
                        ContextUser.GeneralKillCount = 0;
                    }


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

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

                        }
                        ContextUser.IsItem = true;
                    }
                }
                var a = userPlot.ItemList;
            }
            finally
            {
                ContextUser.UserStatus = UserStatus.Normal;
            }
            //日志
            UserCombatLog log = new UserCombatLog();
            log.CombatLogID = Guid.NewGuid().ToString("N");
            log.UserID = userPlotCombat.UserID;
            log.CityID = ContextUser.CityID;
            log.PlotID = userPlotCombat.PlotID;
            log.NpcID = userPlotCombat.PlotNpcID;
            log.CombatType = CombatType.Plot;
            log.HostileUser = string.Empty;
            log.IsWin = userPlotCombat.IsWin;
            log.CombatProcess = JsonUtils.Serialize(combatProcessList);
            log.PrizeItem = prizeItems;
            log.CreateDate = DateTime.Now;
            var sender = DataSyncManager.GetDataSender();
            sender.Send(log);

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

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

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

            return true;
        }
Пример #52
0
 ///// <summary>
 ///// 获取大转盘列表ID
 ///// </summary>
 ///// <param name="userID"></param>
 ///// <returns></returns>
 //public static int DialGroupID(string userID)
 //{
 //    int groupID = 0;
 //    int postion = 0;
 //    var dialFreeList = new ConfigCacheSet<DialInfo>().FindAll(m => m.DialType == 1);
 //    var dialGoldList = new ConfigCacheSet<DialInfo>().FindAll(m => m.DialType == 2);
 //    if (dialFreeList.Count == 0 || dialGoldList.Count == 0)
 //    {
 //        return groupID;
 //    }
 //    UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID);
 //    if (userDial != null)
 //    {
 //        int freeNum = GameConfigSet.FreeSweepstakes;
 //        if (userDial.RefreshDate.Date == DateTime.Now.Date)
 //        {
 //            freeNum = MathUtils.Subtraction(freeNum, userDial.DialNum);
 //            if (userDial.GroupID > 0)
 //            {
 //                groupID = userDial.GroupID;
 //            }
 //            else if (freeNum > 0 && userDial.GroupID == 0)
 //            {
 //                postion = RandomUtils.GetRandom(0, dialFreeList.Count);
 //                var dialpostion = dialFreeList[postion];
 //                if (dialpostion != null)
 //                {
 //                    groupID = dialpostion.GroupID;
 //                }
 //            }
 //            else
 //            {
 //                postion = RandomUtils.GetRandom(0, dialGoldList.Count);
 //                var dialpostion = dialGoldList[postion];
 //                if (dialpostion != null)
 //                {
 //                    groupID = dialpostion.GroupID;
 //                }
 //            }
 //        }
 //        else
 //        {
 //            userDial.RefreshDate = DateTime.Now;
 //            postion = RandomUtils.GetRandom(0, dialFreeList.Count);
 //            var dialpostion = dialFreeList[postion];
 //            if (dialpostion != null)
 //            {
 //                groupID = dialpostion.GroupID;
 //            }
 //        }
 //        userDial.GroupID = groupID;
 //    }
 //    else
 //    {
 //        var cacheSet = new GameDataCacheSet<UserDial>();
 //        postion = RandomUtils.GetRandom(0, dialFreeList.Count);
 //        var dialpostion = dialFreeList[postion];
 //        if (dialpostion != null)
 //        {
 //            groupID = dialpostion.GroupID;
 //        }
 //        userDial = new UserDial();
 //        userDial.UserID = userID;
 //        userDial.HeadID = string.Empty;
 //        userDial.ReturnRatio = 0;
 //        userDial.DialNum = 0;
 //        cacheSet.Add(userDial, GameEnvironment.CacheUserPeriod);
 //    }
 //    userDial.GroupID = groupID;
 //    userDial.RefreshDate = DateTime.Now;
 //    return groupID;
 //}
 ///// <summary>
 ///// 奖励物品
 ///// </summary>
 ///// <param name="prize"></param>
 ///// <returns></returns>
 //public static void GainTreasureInfo(string userID, DialInfo dialInfo, int count)
 //{
 //    var treasure = new TreasureInfo();
 //    treasure.UserID = userID;
 //    treasure.Type = dialInfo.RewardType;
 //    treasure.ItemID = dialInfo.ItemID;
 //    treasure.Num = dialInfo.ItemNum;
 //    treasure.ItemLv = 1;
 //    UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID);
 //    if (userDial == null)
 //    {
 //        userDial = new UserDial();
 //    }
 //    userDial.GroupID = 0;
 //    userDial.RefreshDate = DateTime.Now;
 //    userDial.Treasure.Add(treasure);
 //    if (count == 0)
 //    {
 //        userDial.PrizeInfo = treasure;
 //        userDial.HeadID = dialInfo.HeadID;
 //    }
 //    if (GameConfigSet.Treasure > 0 && userDial.Treasure.Count > GameConfigSet.Treasure)
 //    {
 //        for (int i = 0; i < userDial.Treasure.Count - GameConfigSet.Treasure; i++)
 //        {
 //            userDial.Treasure.Remove(userDial.Treasure[i]);
 //        }
 //    }
 //    if (dialInfo.IsShow)
 //    {
 //        var cacheSet = new ShareCacheStruct<ServerEnvSet>();
 //        var serverEnvSet = cacheSet.FindKey(ServerEnvKey.UserTreasure);
 //        if (serverEnvSet == null)
 //        {
 //            serverEnvSet = new ServerEnvSet();
 //            serverEnvSet.EnvKey = ServerEnvKey.UserTreasure;
 //            cacheSet.Add(serverEnvSet, GameEnvironment.CacheGlobalPeriod);
 //        }
 //        var treasureInfoList = ServerEnvSetTreasure(treasure);
 //        serverEnvSet.EnvValue = JsonUtils.Serialize(treasureInfoList);
 //    }
 //    if (dialInfo.IsBroadcast && !string.IsNullOrEmpty(dialInfo.BroadContent))
 //    {
 //        GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID);
 //        if (user != null)
 //        {
 //            TjxChatService chatService = new TjxChatService();
 //            chatService.SystemSend(ChatType.World, string.Format(dialInfo.BroadContent, user.NickName));
 //        }
 //    }
 //    if (dialInfo.RewardType == RewardType.Again || dialInfo.RewardType == RewardType.Mood || dialInfo.RewardType == RewardType.Recharge)
 //    {
 //        if (dialInfo.RewardType == RewardType.Recharge)
 //        {
 //            userDial.ReturnRatio = treasure.Num;
 //        }
 //        return;
 //    }
 //    var cachePrize = new ShareCacheStruct<UserTakePrize>();
 //    var takePrize = GetUserTake(treasure, userID);
 //    cachePrize.Add(takePrize, GameEnvironment.CacheGlobalPeriod);
 //}
 private static List<TreasureInfo> ServerEnvSetTreasure(TreasureInfo treasure)
 {
     List<TreasureInfo> treasureList = new List<TreasureInfo>();
     var cacheSet = new ShareCacheStruct<ServerEnvSet>();
     var serverEnvSet = cacheSet.FindKey(ServerEnvKey.UserTreasure);
     if (serverEnvSet != null && !string.IsNullOrEmpty(serverEnvSet.EnvValue))
     {
         treasureList = JsonUtils.Deserialize<List<TreasureInfo>>(serverEnvSet.EnvValue);
     }
     treasureList.Add(treasure);
     if (GameConfigSet.UserTreasureNum > 0 && treasureList.Count > GameConfigSet.UserTreasureNum)
     {
         for (int i = 0; i < treasureList.Count - GameConfigSet.UserTreasureNum; i++)
         {
             treasureList.Remove(treasureList[i]);
         }
     }
     return treasureList;
 }
Пример #53
0
        public override bool TakeAction()
        {
            if (!string.IsNullOrEmpty(_friendId) && new GameDataCacheSet<GameUser>().FindKey(_friendId) == null)
            {
                UserCacheGlobal.LoadOffline(_friendId);
            }
            if (ContextUser.UserExtend == null || (_petId != petMinLevel && ContextUser.UserExtend.LightPetID != _petId))
            {
                //SaveLog(string.Format("宠物赛跑开始接口请求ID{0},当前点亮ID{1}", _petId, ContextUser.UserExtend.LightPetID));
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3204_PetNoEnable;
                return false;
            }

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

            decimal minusNum = (decimal)FestivalHelper.TortoiseHare(ContextUser.UserID);
            ContextUser.UserExtend.UpdateNotify(obj =>
                {
                    ContextUser.UserExtend.LightPetID = 0;
                    return true;
                }
                );
            //ContextUser.Update();
            var petCacheSet = new ShareCacheStruct<PetRunPool>();
            var petInfo = new ConfigCacheSet<PetInfo>().FindKey(_petId) ?? new PetInfo();
            if (petRunPool == null)
            {
                petRunPool = new PetRunPool(Uid);
                petCacheSet.Add(petRunPool, GameEnvironment.CacheGlobalPeriod);
                petRunPool = petCacheSet.FindKey(Uid);
            }
            petRunPool.FriendID = _friendId;
            petRunPool.PetID = _petId;
            petRunPool.StartDate = DateTime.Now;
            petRunPool.EndDate = DateTime.Now.AddSeconds(petInfo.ColdTime);
            petRunPool.GameCoin = (int)Math.Floor(petInfo.CoinRate * ContextUser.UserLv * minusNum);
            petRunPool.ObtainNum = (int)Math.Floor(petInfo.ObtainRate * ContextUser.UserLv * minusNum);
            petRunPool.InterceptUser = string.Empty;

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

            if (new GameDataCacheSet<UserDailyRestrain>().FindKey(petRunPool.FriendID) != null)
            {
                var userRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(petRunPool.FriendID);
                if (userRestrain.UserExtend == null) userRestrain.UserExtend = new DailyUserExtend();
                userRestrain.UserExtend.UpdateNotify(obj =>
                    {
                        userRestrain.UserExtend.PetHelp = MathUtils.Addition(userRestrain.UserExtend.PetHelp, 1);
                        return true;
                    });
                //userRestrain.Update();
            }
            return true;
        }
Пример #54
0
        public override bool TakeAction()
        {
            Int16 potenceNum = 0;
            Int16 thoughtNum = 0;
            Int16 intelligenceNum = 0;
            var cacheSetUserGeneral = new PersonalCacheStruct<UserGeneral>();
            var cacheSetUserItem = new PersonalCacheStruct<UserItemPackage>();
            var cacheSetBringUp = new ShareCacheStruct<BringUpInfo>();
            if (_ops == 1)
            {
                var attributeSetArray = ConfigEnvSet.GetString("UserBringUp.Set").Split(',');
                short multiple = attributeSetArray[_multipleType.ToShort() - 1].ToShort();
                var bringUpInfo = cacheSetBringUp.FindKey(_bringUpType.ToInt());
                var userItem = cacheSetUserItem.FindKey(UserId.ToString());
                var item = userItem != null && userItem.ItemPackage != null
                               ? userItem.ItemPackage.Find(s => s.ItemID == ConfigEnvSet.GetInt("User.DrugItemID"))
                               : null;
                var userGeneral = cacheSetUserGeneral.FindKey(UserId.ToString(), _generalId);
                if (_bringUpType == BringUpType.BaiJinPeiYang && ContextUser.VipLv < 3)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1217_NotBaiJin;
                    return false;
                }
                if (_bringUpType == BringUpType.ZhiZunPeiYang && ContextUser.VipLv < 5)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1217_NotZhiZhun;
                    return false;
                }
                if (userGeneral == null || bringUpInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().LoadDataError;
                    return false;
                }
                if (userGeneral.Potential <= 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1217_NotPotential;
                    return false;
                }

                if (bringUpInfo.UseUpType == 2 && ContextUser.GoldNum < (bringUpInfo.UseUpNum * multiple))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return false;
                }
                if (bringUpInfo.UseUpType == 1 && (item == null || item.Num < (bringUpInfo.UseUpNum * multiple)))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1217_NotItem;
                    return false;
                }
                var attributeChancePren = new int[3];
                var attributeChance = bringUpInfo.AttributeChance;
                attributeChancePren[0] = attributeChance.PotenceNum * 10;
                attributeChancePren[1] = attributeChance.ThoughtNum * 10;
                attributeChancePren[2] = attributeChance.IntelligenceNum * 10;
                GetGeneralAttribute(attributeChancePren);
                
                foreach (var attributeIndex in _attributeIndexD)
                {
                    switch (attributeIndex.Value)
                    {
                        //力量
                        case 0:
                            var potenceValueArray = bringUpInfo.AttributeValueChance.PotenceValue.Split(',');
                            var potenceNumArray = bringUpInfo.AttributeValueChance.PotenceNum.Split(',');
                            potenceNum = GetAttributeValue(potenceValueArray, potenceNumArray);
                            potenceNum = (potenceNum * multiple).ToShort();

                            break;
                        //魂力
                        case 1:
                            var thoughtValueArray = bringUpInfo.AttributeValueChance.ThoughtValue.Split(',');
                            var thoughtNumArray = bringUpInfo.AttributeValueChance.ThoughtNum.Split(',');
                            thoughtNum = GetAttributeValue(thoughtValueArray, thoughtNumArray);
                            thoughtNum = (thoughtNum * multiple).ToShort();
                            break;
                        //智力
                        case 2:
                            var intelligenceValueArray = bringUpInfo.AttributeValueChance.IntelligenceValue.Split(',');
                            var intelligenceNumArray = bringUpInfo.AttributeValueChance.IntelligenceNum.Split(',');
                            intelligenceNum = GetAttributeValue(intelligenceValueArray, intelligenceNumArray);
                            intelligenceNum = (intelligenceNum * multiple).ToShort();
                            break;
                    }
                }
                userGeneral.PotenceNum = potenceNum;
                userGeneral.ThoughtNum = thoughtNum;
                userGeneral.IntelligenceNum = intelligenceNum;
                _potenceNum = userGeneral.PowerNum + potenceNum;
                _thoughtNum = userGeneral.SoulNum + thoughtNum;
                _intelligenceNum = userGeneral.IntellectNum + intelligenceNum;
                if (userGeneral.Potential <= 0 || userGeneral.Potential < (userGeneral.PotenceNum + userGeneral.ThoughtNum + userGeneral.IntelligenceNum))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1217_NotPotential;
                    return false;
                }
                switch (bringUpInfo.UseUpType)
                {
                    case 1:
                        UserItemHelper.UseUserItem(ContextUser.UserID, item.ItemID, (bringUpInfo.UseUpNum * multiple));
                        break;
                    case 2:
                        ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, (bringUpInfo.UseUpNum * multiple));
                        break;
                }
                _potential = userGeneral.Potential;
            }
            else
            {
                if (_ops == 2)
                {
                    var userGeneral = cacheSetUserGeneral.FindKey(UserId.ToString(), _generalId);
                    if (userGeneral == null)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().LoadDataError;
                        return false;
                    }
                    int attributeValue = userGeneral.PotenceNum + userGeneral.ThoughtNum + userGeneral.IntelligenceNum;
                    if (attributeValue > 0)
                    {
                        userGeneral.PowerNum = MathUtils.Addition(userGeneral.PowerNum, userGeneral.PotenceNum);
                        userGeneral.SoulNum = MathUtils.Addition(userGeneral.SoulNum, userGeneral.ThoughtNum);
                        userGeneral.IntellectNum = MathUtils.Addition(userGeneral.IntellectNum, userGeneral.IntelligenceNum);
                        userGeneral.Potential = MathUtils.Subtraction(userGeneral.Potential, attributeValue);
                    }
                    else
                    {
                        userGeneral.Potential = MathUtils.Addition(userGeneral.Potential, -attributeValue);
                    }
                    userGeneral.PotenceNum = 0;
                    userGeneral.ThoughtNum = 0;
                    userGeneral.IntelligenceNum = 0;
                    _potential = userGeneral.Potential;
                }

            }

            return true;
        }
Пример #55
0
        /// <summary>
        /// 奖励物品
        /// </summary>
        /// <param name="prize"></param>
        /// <returns></returns>
        public static void ChestGainTreasureInfo(GameUser user, DialInfo dialInfo, int count)
        {
            var treasure = new TreasureInfo();
            treasure.UserID = user.UserID;
            treasure.Type = dialInfo.RewardType;
            treasure.ItemID = dialInfo.ItemID;
            treasure.Num = dialInfo.ItemNum;
            treasure.ItemLv = 1;
            UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(user.UserID);
            if (userDial == null)
            {
                userDial = new UserDial();
            }
            userDial.GroupID = 0;
            userDial.RefreshDate = DateTime.Now;
            userDial.Treasure.Add(treasure);
            if (count == 0)
            {
                userDial.PrizeInfo = treasure;
                userDial.HeadID = dialInfo.HeadID;
            }
            if (GameConfigSet.Treasure > 0 && userDial.Treasure.Count > GameConfigSet.Treasure)
            {
                for (int i = 0; i < userDial.Treasure.Count - GameConfigSet.Treasure; i++)
                {
                    userDial.Treasure.Remove(userDial.Treasure[i]);
                }
            }

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

            if (dialInfo.IsBroadcast && !string.IsNullOrEmpty(dialInfo.BroadContent))
            {
                TjxChatService chatService = new TjxChatService();
                chatService.SystemSend(ChatType.World, string.Format(dialInfo.BroadContent, user.NickName));

            }
            if (dialInfo.RewardType == RewardType.Again || dialInfo.RewardType == RewardType.Mood || dialInfo.RewardType == RewardType.Recharge)
            {
                if (dialInfo.RewardType == RewardType.Recharge)
                {
                    userDial.ReturnRatio = treasure.Num;
                }
                return;
            }
            ChestGetUserTake(treasure, user);
        }
Пример #56
0
        string processModify(string parm)
        {
            string info = "";
            string[] p = info.Split(',');
            string modifyWhich= p[0];
            int index = int.Parse(p[1]);
            int score = int.Parse(p[2]);

            if("modify"==modifyWhich)
            {
                UserRanking ur = RankingFactorNew.Singleton().getRankingData<UserRanking, RankingScore>(index);
                if(null==ur)
                {
                    info = "要修改的数据不存在";
                }
                else
                {
                    var cache = new ShareCacheStruct<UserRanking>();
                    UserRanking theUR = cache.FindKey(ur.UserID);
                    theUR.ModifyLocked(() => {
                        ur.Score = score;
                     });

                    info = "修改数据成功";
                }
            }
            return info;
        }
Пример #57
0
        /// <summary>
        /// ˢ����ȴʱ��
        /// </summary>
        /// <returns>����ʣ����ȴʱ��</returns>
        public int DoRefresh()
        {
            int coldTime = 0;
            var cache = new ShareCacheStruct<ItemBaseInfo>();
            ItemBaseInfo itemInfo = cache.FindKey(ItemID);
            if (itemInfo != null && (itemInfo.PropType == 3 || itemInfo.PropType == 9))
            {
                TimeSpan ts = DateTime.Now - ChangeTime;

                coldTime = MathUtils.Subtraction(itemInfo.EffectNum, (int)Math.Floor(ts.TotalSeconds), 0);
                coldTime = MathUtils.Addition(coldTime, 0, itemInfo.EffectNum);
            }
            return coldTime;
        }
Пример #58
0
        string processUserInfo(string parm)
        {
            string[] p = parm.Split(',');
            string subcmd = p[0];
            string userid = p[1];

            var gu_cache = new PersonalCacheStruct<GameUser>();
            var ur_cache = new ShareCacheStruct<UserRanking>();
            var urt_cache = new ShareCacheStruct<UserRankingTotal>();

            var gu = gu_cache.FindKey(userid);
            var ur = ur_cache.FindKey(userid);
            var urt = urt_cache.FindKey(userid);

            string info = "";

            if(gu!=null)
            {

                if(subcmd=="get")
                {
                    info += gu.UserId+","+gu.NickName+","+gu.Identify +",";
                }
                else if(subcmd=="set")
                {
                    gu.ModifyLocked(() => {
                        gu.NickName = p[2];
                    });
                }
            }
            else
            {
                info += "-1,None,None,";
            }

            if(null != ur)
            {
                if(subcmd=="get")
                {

                    info +=  ur.Score + ",";
                }
                else if(subcmd=="set")
                {
                    ur.ModifyLocked(() => {
                        ur.Score = int.Parse(p[3]);
                        ur.UserName = p[2];
                    });
                }
            }
            else
            {
                info += "0,";
            }

            if(null != urt)
            {
                if(subcmd=="get")
                {
                    info += urt.Total;
                }
                else if(subcmd=="set")
                {
                    urt.ModifyLocked(() => {

                        urt.Total = int.Parse(p[4]);

                    });

                }
            }
            else
            {
                info += "0";
            }
            if("set"==subcmd)
            {
                info = "set success";
            }
            return info;
        }
Пример #59
0
 /// <summary>
 /// 被动魂技效果
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public static List<SelfAbilityEffect> GetSelfAbilityEffectList(string userId, short role)
 {
     List<SelfAbilityEffect> selfAbilityEffectList = new List<SelfAbilityEffect>();
     var cacheSetUserAbility = new PersonalCacheStruct<UserAbility>();
     var cacheSetUserEmbattle = new PersonalCacheStruct<UserEmbattle>();
     var cacheSetAbilityInfo = new ShareCacheStruct<AbilityInfo>();
     var userAbility = cacheSetUserAbility.FindKey(userId);
     var userMagic = new PersonalCacheStruct<UserMagic>().Find(userId, s => s.IsEnabled);
     if (userAbility != null && userAbility.AbilityList != null)
     {
         var userEmbattleList = cacheSetUserEmbattle.FindAll(userId, s => s.MagicID == userMagic.MagicID);
         userEmbattleList.ForEach(obj =>
         {
             if (obj.GeneralID > 0)
             {
                 var abilityList =
                     userAbility.AbilityList.FindAll(s => s.GeneralID == obj.GeneralID);
                 abilityList.ForEach(ability =>
                 {
                     var abilityInfo = cacheSetAbilityInfo.FindKey(ability.AbilityID);
                     if (abilityInfo != null && abilityInfo.IsActive == 1)
                     {
                         SelfAbilityEffect selfAbilityEffect = new SelfAbilityEffect();
                         selfAbilityEffect.GeneralID = obj.GeneralID;
                         selfAbilityEffect.EffectID1 = abilityInfo.EffectID1;
                         selfAbilityEffect.FntHeadID = abilityInfo.FntHeadID;
                         selfAbilityEffect.IsIncrease = abilityInfo.IsIncrease;
                         selfAbilityEffect.Position = obj.Position;
                         selfAbilityEffect.Role = role;
                         selfAbilityEffectList.Add(selfAbilityEffect);
                     }
                 });
             }
         });
     }
     return selfAbilityEffectList;
 }
Пример #60
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6203_GuildMemberNotEnough;
                return false;
            }
            GuildMember member = new ShareCacheStruct<GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);
            if (member == null || member.PostType == PostType.Member)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_OrdinaryMemberNotCompetence;
                return false;
            }
            UserGuild guild = new ShareCacheStruct<UserGuild>().FindKey(ContextUser.MercenariesID);
            if (guild == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }

            FightCombat fightCombat = new FightCombat();
            var cacheSet = new ShareCacheStruct<ServerFight>();
            ServerFight fight = cacheSet.FindKey(fightCombat.FastID, ContextUser.MercenariesID);
            if (fight != null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_HaveSignedUp;
                return false;
            }

            DateTime nextDate;
            FightStage stage = GuildFightCombat.GetStage(out nextDate);
            if (GuildFightCombat.IsFightDate())
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CityABattleTime;
                return false;
            }

            if (stage != FightStage.Apply)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CityABattleTime;
                return false;
            }

            //if (DateTime.Now > fightCombat.GuildEndTime && DateTime.Now < fightCombat.GuildStartTime)
            //{
            //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    ErrorInfo = LanguageManager.GetLang().St6404_OutRegistrationTime;
            //    return false;
            //}

            GuildFightInfo fightInfo = new ConfigCacheSet<GuildFightInfo>().FindKey(cityID);
            if (fightInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            if (guild.GuildLv < fightInfo.GuildLv)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_GuildLvNotEnough;
                return false;
            }
            if (guild.CurrDonateNum < fightInfo.SkillNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6404_CurrDonateNumNotEnough;
                return false;
            }
            guild.CurrDonateNum = MathUtils.Subtraction(guild.CurrDonateNum, fightInfo.SkillNum);

            fight = new ServerFight(fightCombat.FastID, ContextUser.MercenariesID);
            fight.GuildBanner = string.Empty;
            fight.CityID = cityID;
            fight.RankID = 0;
            fight.ApplyDate = DateTime.Now;
            fight.IsRemove = false;
            fight.IsBanner = false;
            cacheSet.Add(fight, GameEnvironment.CacheGlobalPeriod);
            ErrorCode = 0;
            ErrorInfo = LanguageManager.GetLang().St6401_SuccessfulRegistration;
            return true;
        }