예제 #1
0
        public override bool TakeAction()
        {
            var cache   = new ShareCacheStruct <UserRanking>();
            var ranking = cache.Find(m => m.UserName == UserName);

            if (ranking == null)
            {
                var user = new GameUser()
                {
                    UserId = (int)cache.GetNextNo(), NickName = UserName
                };
                new PersonalCacheStruct <GameUser>().Add(user);
                ranking          = new UserRanking();
                ranking.UserID   = user.UserId;
                ranking.UserName = UserName;
                ranking.Score    = Score;
                if (!cache.Add(ranking))
                {
                    ErrorCode = Language.Instance.ErrorCode;
                    ErrorInfo = string.Format("add fail, UserID {0} is exist.", ranking.UserID);
                    return(false);
                }
            }
            else
            {
                ranking.UserName = UserName;
                ranking.Score    = Score;
            }
            return(true);
        }
예제 #2
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);
        }
예제 #3
0
        string processAdd(string parm)
        {
            string info = "";

            string[] p        = parm.Split(',');
            string   addWhich = p[0];
            string   name     = p[1];
            int      score    = int.Parse(p[2]);

            if ("ranking" == addWhich)
            {
                var cache   = new PersonalCacheStruct <GameUser>();
                var urCache = new ShareCacheStruct <UserRanking>();

                var gu = new GameUser();
                gu.UserId   = (int)cache.GetNextNo();
                gu.NickName = name;
                gu.Score    = score;
                gu.Identify = "identify_" + name;
                var ur = new UserRanking();
                ur.UserID   = gu.UserId;
                ur.UserName = name;
                ur.Score    = score;

                cache.Add(gu);
                urCache.Add(ur);
                info = "增加排行榜数据成功";
            }
            return(info);
        }
예제 #4
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);
        }
예제 #5
0
        public override bool TakeAction()
        {
            var cache   = new ShareCacheStruct <UserRanking>();
            var ranking = cache.Find(m => m.UserName == requestPack.UserName);

            if (ranking == null)
            {
                var user = new GameUser()
                {
                    UserId = (int)cache.GetNextNo(), NickName = requestPack.UserName
                };
                new PersonalCacheStruct <GameUser>().Add(user);
                ranking          = new UserRanking();
                ranking.UserID   = user.UserId;
                ranking.UserName = requestPack.UserName;
                ranking.Score    = requestPack.Score;
                cache.Add(ranking);
            }
            else
            {
                ranking.UserName = requestPack.UserName;
                ranking.Score    = requestPack.Score;
            }
            return(true);
        }
예제 #6
0
        ///// <summary>
        ///// 奖励配置
        ///// </summary>
        ///// <param name="user"></param>
        //public static UserTakePrize GetUserTake(TreasureInfo prize, string userID)
        //{
        //    UserTakePrize userPrize = new UserTakePrize();
        //    userPrize.CreateDate = DateTime.Now;
        //    userPrize.ID = Guid.NewGuid().ToString();
        //    userPrize.UserID = Convert.ToInt32(userID);
        //    userPrize.MailContent = LanguageManager.GetLang().St12004_YouWheelOfFortune.Substring(0, 9);
        //    userPrize.IsTasked = false;
        //    userPrize.TaskDate = MathUtils.SqlMinDate;
        //    userPrize.ItemPackage = string.Empty;
        //    userPrize.SparePackage = string.Empty;
        //    userPrize.CrystalPackage = string.Empty;
        //    userPrize.OpUserID = 10000;
        //    switch (prize.Type)
        //    {
        //        case RewardType.GameGoin:
        //            userPrize.GameCoin = (int)prize.Num;
        //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GameCoin, userPrize.GameCoin) + ",";
        //            break;
        //        case RewardType.Obtion:
        //            userPrize.ObtainNum = (int)prize.Num;
        //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ObtionNum, userPrize.ObtainNum) + ",";
        //            break;
        //        case RewardType.ExpNum:
        //            userPrize.ExpNum = (int)prize.Num;
        //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ExpNum, userPrize.ExpNum) + ",";
        //            break;
        //        case RewardType.EnergyNum:
        //            userPrize.EnergyNum = (int)prize.Num;
        //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_EnergyNum, userPrize.EnergyNum) + ",";
        //            break;
        //        case RewardType.Experience:
        //            break;
        //        case RewardType.Gold:
        //            userPrize.Gold = (int)prize.Num;
        //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GiftGoldNum, userPrize.Gold) + ",";
        //            break;
        //        case RewardType.Item:
        //            ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(prize.ItemID);
        //            if (itemInfo != null)
        //            {
        //                userPrize.ItemPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
        //                userPrize.MailContent += string.Format("{0}*{1}", itemInfo.ItemName, (int)prize.Num) + ",";
        //            }
        //            break;
        //        case RewardType.CrystalId:
        //            CrystalInfo crystal = new ShareCacheStruct<CrystalInfo>().FindKey(prize.ItemID);
        //            if (crystal != null)
        //            {
        //                userPrize.CrystalPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
        //                userPrize.MailContent += string.Format("{0}*{1}", crystal.CrystalName, (int)prize.Num) + ",";
        //            }
        //            break;
        //        case RewardType.Spare:
        //            SparePartInfo spare = new ShareCacheStruct<SparePartInfo>().FindKey(prize.ItemID);
        //            if (spare != null)
        //            {
        //                userPrize.SparePackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
        //                userPrize.MailContent += string.Format("{0}*{1}", spare.Name, (int)prize.Num) + ",";
        //            }
        //            break;
        //        case RewardType.Enchant:
        //            EnchantInfo enchantInfo = new ShareCacheStruct<EnchantInfo>().FindKey(prize.ItemID);
        //            if (enchantInfo != null)
        //            {
        //                userPrize.EnchantPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
        //                userPrize.MailContent += string.Format("{0}*{1}", enchantInfo.EnchantName, (int)prize.Num) + ",";
        //            }
        //            break;
        //        default:
        //            break;
        //    }
        //    userPrize.MailContent = userPrize.MailContent.TrimEnd(',');
        //    return userPrize;
        //}

        /// <summary>
        /// 充值返还
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="goldNum"></param>
        /// <returns></returns>
        public static void ReturnRatioGold(string userID, int goldNum)
        {
            UserDial userDial = new PersonalCacheStruct <UserDial>().FindKey(userID);

            if (userDial != null && userDial.ReturnRatio > 0)
            {
                int           giftGold   = MathUtils.RoundCustom(goldNum * userDial.ReturnRatio);
                var           cachePrize = new ShareCacheStruct <UserTakePrize>();
                UserTakePrize userPrize  = new UserTakePrize();
                userPrize.CreateDate     = DateTime.Now;
                userPrize.ID             = Guid.NewGuid().ToString();
                userPrize.UserID         = Convert.ToInt32(userID);
                userPrize.MailContent    = string.Format(LanguageManager.GetLang().St12004_RechargeReturnGoldNum, GetTransformData(userDial.ReturnRatio), giftGold);
                userPrize.IsTasked       = false;
                userPrize.TaskDate       = MathUtils.SqlMinDate;
                userPrize.ItemPackage    = string.Empty;
                userPrize.SparePackage   = string.Empty;
                userPrize.CrystalPackage = string.Empty;
                userPrize.EnchantPackage = string.Empty;
                userPrize.OpUserID       = 10000;
                userPrize.GameCoin       = 0;
                userPrize.ObtainNum      = 0;
                userPrize.ExpNum         = 0;
                userPrize.EnergyNum      = 0;
                userPrize.Gold           = giftGold;
                userDial.ReturnRatio     = 0;
                cachePrize.Add(userPrize);
            }
        }
예제 #7
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);
        }
예제 #8
0
 public static void AddPrize(string UserID, int itemID, string mailContent)
 {
     string ItemPackage = itemID + "=1=1";
     var cacheset = new ShareCacheStruct<UserTakePrize>();
     UserTakePrize takeprize = new UserTakePrize()
     {
         CreateDate = DateTime.Now,
         CrystalPackage = string.Empty,
         EnergyNum = 0,
         ExpNum = 0,
         GainBlessing = 0,
         GameCoin = 0,
         Gold = 0,
         ID = Guid.NewGuid().ToString(),
         ItemPackage = ItemPackage,
         IsTasked = false,
         MailContent = mailContent,
         ObtainNum = 0,
         OpUserID = 0,
         SparePackage = string.Empty,
         UserID = UserID.ToInt(),
         VipLv = 0,
     };
     cacheset.Add(takeprize, GameEnvironment.CacheGlobalPeriod);
 }
예제 #9
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);
        }
예제 #10
0
        //private MiddlewareSection section;
        public ServersDataProvider()
        {
            if (_provider == null)
            {
                _provider = DbConnectionProvider.CreateDbProvider(ConnectKey);

                var command = _provider.CreateCommandStruct("StaticServer", CommandMode.Inquiry,"ServerId,Name,Ip,Port");

                command.Parser();

                using (var dr = _provider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
                {

                    var serversDatas = new ShareCacheStruct<StaticServer>();
                    while (dr.Read())
                    {
                        StaticServer oneServerModel = new StaticServer();
                        oneServerModel.ServerId = Convert.ToInt32(dr["ServerId"]) ;
                        oneServerModel.Name = dr["Name"].ToString();
                        oneServerModel.Ip = dr["Ip"].ToString();
                        oneServerModel.Port = Convert.ToInt32(dr["Port"]);
                        //ServerList.Add(oneServerModel);
                        serversDatas.Add(oneServerModel);

                    }
                }
                //this.AddATestCache();

            }
        }
예제 #11
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);
                }
            }
        }
예제 #12
0
 void doAdd_black(string parm)
 {
     string[] usridStr = parm.Split(',');
     for (int i = 0; i < usridStr.Length; ++i)
     {
         try
         {
             int index = int.Parse(usridStr[i]);
             var cache = new ShareCacheStruct <UserRanking>();
             List <UserRanking> lst = RankingFactorNew.Singleton().get <UserRanking>(typeof(RankingScore).ToString());
             UserRanking        ur  = null;
             if (lst != null && lst.Count > index)
             {
                 ur = lst[index];
             }
             var blackCache = new ShareCacheStruct <BlackListData>();
             if (ur != null)
             {
                 blackCache.Add(UR2BLD(ur));
                 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
        Response1001Pack cbFunc(object obj)
        {
            List <object> objList = obj as List <object>;

            if (objList.Count != 2)
            {
                return(null);
            }
            List <UserRanking> rankingList = objList[1] as List <UserRanking>;

            // save to ....where....
            var shareCache = new ShareCacheStruct <HistoryUserRanking>();
            int num        = (int)shareCache.GetNextNo();
            var saveData   = new HistoryUserRanking();

            saveData.ID = num;
            // get data
            if (rankingList.Count >= 3)
            {
                UserRanking first  = rankingList[0];
                UserRanking second = rankingList[1];
                UserRanking thrid  = rankingList[2];

                saveData.Items.Add(first);
                saveData.Items.Add(second);
                saveData.Items.Add(thrid);
            }
            shareCache.Add(saveData);

            return(null);
        }
예제 #14
0
 public override bool TakeAction()
 {
     var cache = new ShareCacheStruct<UserRanking>();
     var ranking = cache.Find(m => m.UserName == UserName);
     if (ranking == null)
     {
         var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = UserName};
         new PersonalCacheStruct<GameUser>().Add(user);
         ranking = new UserRanking();
         ranking.UserID = user.UserId;
         ranking.UserName = UserName;
         ranking.Score = Score;
         if (!cache.Add(ranking))
         {
             ErrorCode = Language.Instance.ErrorCode;
             ErrorInfo = string.Format("add fail, UserID {0} is exist.", ranking.UserID);
             return false;
         }
     }
     else
     {
         ranking.UserName = UserName;
         ranking.Score = Score;
     }
     return true;
 }
예제 #15
0
        //private MiddlewareSection section;

        public ServersDataProvider()
        {
            if (_provider == null)
            {
                _provider = DbConnectionProvider.CreateDbProvider(ConnectKey);

                var command = _provider.CreateCommandStruct("StaticServer", CommandMode.Inquiry, "ServerId,Name,Ip,Port");

                command.Parser();

                using (var dr = _provider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
                {
                    var serversDatas = new ShareCacheStruct <StaticServer>();
                    while (dr.Read())
                    {
                        StaticServer oneServerModel = new StaticServer();
                        oneServerModel.ServerId = Convert.ToInt32(dr["ServerId"]);
                        oneServerModel.Name     = dr["Name"].ToString();
                        oneServerModel.Ip       = dr["Ip"].ToString();
                        oneServerModel.Port     = Convert.ToInt32(dr["Port"]);
                        //ServerList.Add(oneServerModel);
                        serversDatas.Add(oneServerModel);
                    }
                }
                //this.AddATestCache();
            }
        }
예제 #16
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);
        }
예제 #17
0
파일: RoleFunc.cs 프로젝트: rongxiong/Scut
 /// <summary>
 /// 创始成功之后处理事件
 /// </summary>
 public void OnCreateAfter(GameUser user)
 {
     var cacheSet = new ShareCacheStruct<UserNickName>();
     UserNickName u = new UserNickName(user.UserId);
     u.NickName = user.NickName;
     cacheSet.Add(u);
 }
예제 #18
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;
        }
예제 #19
0
파일: RoleFunc.cs 프로젝트: zhukaixy/Scut
        /// <summary>
        /// 创始成功之后处理事件
        /// </summary>
        public void OnCreateAfter(GameUser user)
        {
            var          cacheSet = new ShareCacheStruct <UserNickName>();
            UserNickName u        = new UserNickName(user.UserId);

            u.NickName = user.NickName;
            cacheSet.Add(u);
        }
예제 #20
0
        private void CreatePchinkoData(int id)
        {
            var pachinkoData = new PachinkoData()
            {
                Id = id
            };

            _pachinkoCache.Add(pachinkoData);
        }
예제 #21
0
        void addLog(ShareCacheStruct <DataLog> cache, int userid, int dimond)
        {
            int     index = (int)cache.GetNextNo();
            DataLog dl    = new DataLog();

            dl.Index  = index;
            dl.UserID = userid;
            dl.Dimond = dimond;
            cache.Add(dl);
        }
예제 #22
0
        void addAuthory()
        {
            var       cache = new ShareCacheStruct <Authority>();
            Authority au    = new Authority();

            au.id    = (int)cache.GetNextNo();
            au.name  = "guccang";
            au.pwd   = ZyGames.Framework.Common.Security.CryptoHelper.MD5_Encrypt("Sally@123456");
            au.level = 0xfffffff;
            cache.Add(au);
        }
예제 #23
0
        public void AddSingleField()
        {
            var watch = Stopwatch.StartNew();
            var cache = new ShareCacheStruct <SingleData>();

            Assert.IsTrue(cache.Add(new SingleData()
            {
                ChildId = 1
            }));
            WaitEnd(watch);
        }
예제 #24
0
 private void AddATestCache()
 {
     var serversDatas = new ShareCacheStruct <StaticServer>();
     {
         StaticServer oneServerModel = new StaticServer();
         oneServerModel.ServerId = 5;
         oneServerModel.Name     = "MQ";
         oneServerModel.Ip       = "127.0.0.1";
         oneServerModel.Port     = 9001;
         serversDatas.Add(oneServerModel);
     }
 }
예제 #25
0
 private void AddATestCache()
 {
     var serversDatas = new ShareCacheStruct<StaticServer>();
     {
         StaticServer oneServerModel = new StaticServer();
         oneServerModel.ServerId = 5;
         oneServerModel.Name = "MQ";
         oneServerModel.Ip = "127.0.0.1";
         oneServerModel.Port = 9001;
         serversDatas.Add(oneServerModel);
     }
 }
예제 #26
0
        public override bool TakeAction()
        {
            // 存入数据库
            var      hmdCache      = new PersonalCacheStruct <HappyModeData>();
            var      cache         = new ShareCacheStruct <PayOrder>();
            int      index         = (int)cache.GetNextNo();
            PayOrder PayData       = new PayOrder();
            string   ServerOrderId = System.Guid.NewGuid().ToString("N");
            int      keyid         = utils.KeyUInt2Int(requestPack.the3rdUserId);

            PayData.Index            = index;
            PayData.UserId           = requestPack.UserID;
            PayData.Identify         = requestPack.identify;
            PayData.typeUser         = requestPack.typeUser; // 360Pay..maybe
            PayData.ProductId        = requestPack.productId;
            PayData.num              = requestPack.num;
            PayData.the3rdUserId     = keyid;// utils.KeyUInt2Int(requestPack.the3rdUserId);
            PayData.strThe3rdOrderId = requestPack.strThe3rdUserId;
            PayData.ServerOrderId    = ServerOrderId;
            PayData.the3rdOrderId    = "";
            cache.Add(PayData);

            // hmd persion
            HappyModeData hmd = hmdCache.FindKey(keyid.ToString());
            int           happyPointMaxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 3);

            if (null == hmd)
            {
                responsePack.errorCode = 1;
                return(true);
            }
            PayOrderPersion pop = new PayOrderPersion();

            pop.Index            = index;
            pop.UserId           = requestPack.UserID;
            pop.Identify         = requestPack.identify;
            pop.typeUser         = requestPack.typeUser; // 360Pay..maybe
            pop.ProductId        = requestPack.productId;
            pop.num              = requestPack.num;
            pop.the3rdUsrID      = (int)requestPack.the3rdUserId;// utils.KeyUInt2Int(requestPack.the3rdUserId);
            pop.strThe3rdOrderId = requestPack.strThe3rdUserId;
            pop.ServerOrderId    = ServerOrderId;
            pop.the3rdOrderId    = "";
            hmd.PayInfoDic.Add(ServerOrderId, pop);

            // end return
            responsePack.errorCode = 0;
            responsePack.typeUser  = requestPack.typeUser;
            responsePack.result    = PayData.ServerOrderId; // 服务器订单号

            ConsoleLog.showErrorInfo(0, "create order success" + requestPack.the3rdUserId + ":" + ServerOrderId);
            return(true);
        }
예제 #27
0
 private void InitNotice()
 {
     var cacheSet = new ShareCacheStruct<Notice>();
     for (int i = 0; i < 5; i++)
     {
         int id = (int)cacheSet.GetNextNo();
         Notice notice = new Notice(id);
         notice.Title = "tile" + id;
         notice.Content = "Content" + id;
         notice.CreateDate = DateTime.Now;
         cacheSet.Add(notice);
     }
 }
예제 #28
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);
            }
        }
예제 #29
0
        void setFake()
        {
            // add fake UserRanking Data at
            ConsoleLog.showNotifyInfo("setFake:" + fakeLst.Count);
            var cache = new ShareCacheStruct <UserRanking>();

            for (int i = 0; i < fakeLst.Count; ++i)
            {
                cache.Add(copy(fakeLst[i]));
            }
            fakeLst.Clear();
            fakeLst = null;
            RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString());
        }
예제 #30
0
        public void UpdateCache()
        {
            var cache = new ShareCacheStruct <ChildData>();
            var data  = cache.FindKey(1);

            if (data == null)
            {
                data = new ChildData()
                {
                    ChildId = 1, Age = 20
                };
                Assert.IsTrue(cache.Add(data), "add cache faild.");
            }
            int age = data.Age;

            age++;
            data.Age = age;
            cache.Add(data);
            Assert.IsFalse(data.HasChanged);
            cache.UnLoad();
            data = cache.FindKey(1);
            Assert.IsTrue(data != null && data.Age == age, "update data fail.");
        }
예제 #31
0
        public void AddExtendField()
        {
            var watch = Stopwatch.StartNew();
            var cache = new ShareCacheStruct <ChildData>();

            Assert.IsTrue(cache.Add(new ChildData()
            {
                ChildId = 1, Age = 20
            }));
            cache.UnLoad();
            Assert.IsNotNull(cache.FindKey(1));

            WaitEnd(watch);
        }
예제 #32
0
        private void InitNotice()
        {
            var cacheSet = new ShareCacheStruct <Notice>();

            for (int i = 0; i < 5; i++)
            {
                int    id     = (int)cacheSet.GetNextNo();
                Notice notice = new Notice(id);
                notice.Title      = "tile" + id;
                notice.Content    = "Content" + id;
                notice.CreateDate = DateTime.Now;
                cacheSet.Add(notice);
            }
        }
예제 #33
0
파일: Action1000.cs 프로젝트: daneric/Scut
 public override bool TakeAction() {
     var cache = new ShareCacheStruct<UserRanking>();
     var ranking = cache.Find(m => m.UserName == userName);
     if (ranking == null) {
         var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = userName };
         new PersonalCacheStruct<GameUser>().Add(user);
         ranking = new UserRanking();
         ranking.UserId = user.UserId;
         ranking.UserName = userName;
         ranking.Score = score;
         cache.Add(ranking);
     } else {
         ranking.UserName = userName;
         ranking.Score = score;
     }
     return true;
 }
예제 #34
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;
     }
 }
예제 #35
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);
        }
예제 #36
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;
        }
예제 #37
0
        public static void Set(ServerEnvKey envKey, Object value)
        {
            var          cacheSet = new ShareCacheStruct <ServerEnvSet>();
            ServerEnvSet envSet   = cacheSet.FindKey(envKey);

            if (envSet == null)
            {
                envSet = new ServerEnvSet()
                {
                    EnvKey = envKey, EnvValue = value.ToNotNullString()
                };
                cacheSet.Add(envSet, 0);
            }
            else
            {
                envSet.EnvValue = value.ToNotNullString();
            }
        }
예제 #38
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;
     }
 }
예제 #39
0
 public override bool TakeAction()
 {
     var cache = new ShareCacheStruct<UserRanking>();
     var ranking = cache.Find(m => m.UserName == UserName);
     if (ranking == null)
     {
         ranking = new UserRanking();
         ranking.UserID = (int)cache.GetNextNo();
         ranking.UserName = UserName;
         ranking.Score = Score;
         cache.Add(ranking);
     }
     else
     {
         ranking.UserName = UserName;
         ranking.Score = Score;
     }
     return true;
 }
예제 #40
0
        private User CreateUser(ShareCacheStruct <User> userCache)
        {
            var userData = new UserData()
            {
                UserId = (int)userCache.GetNextNo(), NickName = _loginData.Username, Hp = 100
            };

            _userData = userData;
            new PersonalCacheStruct <UserData>().Add(userData);

            var user = new User();

            user.UserId   = userData.UserId;
            user.Username = _loginData.Username;
            user.Password = _loginData.Password;
            userCache.Add(user);

            return(user);
        }
예제 #41
0
        void doAdd_allServerCompensation(string parm)
        {
            string[]         strS = parm.Split(',');
            CompensationInfo ci   = new CompensationInfo();
            var    cache          = new ShareCacheStruct <CompensationInfo>();
            int    index          = (int)cache.GetNextNo();
            byte   type           = byte.Parse(strS[0]);
            string message        = strS[1];
            string ItemInfo       = strS[2]; // 5012*1:5023*4

            //check

            ci.index    = index;
            ci.message  = message;
            ci.ItemInfo = ItemInfo;
            ci.type     = type;

            cache.Add(ci);
        }
예제 #42
0
 public override bool TakeAction()
 {
     var cache = new ShareCacheStruct<UserScore>();
     var ranking = cache.Find(m => m.username == _username);
     if (ranking == null)
     {
         var user = new User() { userid = (int)cache.GetNextNo(), nickname = _username };
         new PersonalCacheStruct<User>().Add(user);
         ranking = new UserScore();
         ranking.userid = user.userid;
         ranking.username = _username;
         ranking.score = _score;
         cache.Add(ranking);
     }
     else
     {
         ranking.username = _username;
         ranking.score = _score;
     }
     return true;
 }
예제 #43
0
파일: Action5107.cs 프로젝트: 0jpq0/Scut
 /// <summary>
 /// 增加仇敌
 /// </summary>
 /// <param name="user"></param>
 /// <param name="toUser"></param>
 private static void AddFoe(GameUser user, GameUser toUser)
 {
     var cacheSet = new ShareCacheStruct<UserFriends>();
     var friends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.Friend);
     var choudiFriends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi);
     if (friends == null && choudiFriends == null)
     {
         var list = cacheSet.FindAll(s => s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi);
         if (list.Count >= 50)
         {
             list.QuickSort((x, y) =>
             {
                 if (x == null && y == null) return 0;
                 if (x != null && y == null) return 1;
                 if (x == null) return -1;
                 return (x.FightTime).CompareTo(y.FightTime);
             });
             int count = list.Count - 49 + 1;
             for (int i = 0; i < count; i++)
             {
                 cacheSet.Delete(list[i]);
             }
         }
         var userFriends = new UserFriends();
         userFriends.UserID = toUser.UserID;
         userFriends.FriendID = user.UserID;
         userFriends.FightTime = DateTime.Now;
         userFriends.FriendType = FriendType.ChouDi;
         userFriends.ChatTime = DateTime.Now;
         cacheSet.Add(userFriends, GameEnvironment.CacheGlobalPeriod);
     }
 }
예제 #44
0
 void InitNotices()
 {
     /*
      * new ShareCacheStruct<Notice> 实际上不是一个存储空间,
      * 而是指向redis数据库的一个入口,
      * 这里通过指定类型Notice来获得Notice表的指针,
      * 然后就可以做查询或修改操作
      *
      *     public abstract class BaseCacheStruct<T> : BaseDisposable where T : AbstractEntity, new()
      *     {
      *            static BaseCacheStruct()
      *            {
      *            // 这里根据<T>中的类型来确定表的名字,
      *            // 再根据T上面的EntityTable来确定连接的数据库,
      *            // [EntityTable(CacheType.Entity, "TestGameData")]
      *            //
      *            // 如果已经有表就操作表,没有就新建后操作,
      *            // 如果使用这个接口来将数据直接保存到sql数据库中的话,需要连接数据库,而且可能操作磁盘
      *                EntitySchemaSet.InitSchema(typeof(T));
      *                CacheFactory.RegistUpdateNotify(new DefaultCacheStruct<T>());
      *            }
      *           ...
      *     }
      */
     var cacheSet = new ShareCacheStruct<Notice>();
     for (int i = 0; i < 50; i++)
     {
         int id = (int)cacheSet.GetNextNo();
         Notice notice = new Notice(id);
         notice.title = "tile" + id;
         notice.content = "Content" + id;
         notice.time = DateTime.Now;
         cacheSet.Add(notice);
     }
 }
예제 #45
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;
            }
        }
예제 #46
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);
                }
            }
        }
예제 #47
0
 void doAdd_black(string parm)
 {
     string[] usridStr = parm.Split(',');
     for (int i = 0; i < usridStr.Length; ++i)
     {
         try
         {
             int index = int.Parse(usridStr[i]);
             var cache = new ShareCacheStruct<UserRanking>();
             List<UserRanking> lst = RankingFactorNew.Singleton().get<UserRanking>(typeof(RankingScore).ToString());
             UserRanking ur = null;
             if(lst!=null && lst.Count>index)
             {
                 ur = lst[index];
             }
             var blackCache = new ShareCacheStruct<BlackListData>();
             if (ur != null)
             {
                 blackCache.Add(UR2BLD(ur));
                 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);
         }
     }
 }
예제 #48
0
 ///// <summary>
 ///// 奖励配置
 ///// </summary>
 ///// <param name="user"></param>
 //public static UserTakePrize GetUserTake(TreasureInfo prize, string userID)
 //{
 //    UserTakePrize userPrize = new UserTakePrize();
 //    userPrize.CreateDate = DateTime.Now;
 //    userPrize.ID = Guid.NewGuid().ToString();
 //    userPrize.UserID = Convert.ToInt32(userID);
 //    userPrize.MailContent = LanguageManager.GetLang().St12004_YouWheelOfFortune.Substring(0, 9);
 //    userPrize.IsTasked = false;
 //    userPrize.TaskDate = MathUtils.SqlMinDate;
 //    userPrize.ItemPackage = string.Empty;
 //    userPrize.SparePackage = string.Empty;
 //    userPrize.CrystalPackage = string.Empty;
 //    userPrize.OpUserID = 10000;
 //    switch (prize.Type)
 //    {
 //        case RewardType.GameGoin:
 //            userPrize.GameCoin = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GameCoin, userPrize.GameCoin) + ",";
 //            break;
 //        case RewardType.Obtion:
 //            userPrize.ObtainNum = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ObtionNum, userPrize.ObtainNum) + ",";
 //            break;
 //        case RewardType.ExpNum:
 //            userPrize.ExpNum = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_ExpNum, userPrize.ExpNum) + ",";
 //            break;
 //        case RewardType.EnergyNum:
 //            userPrize.EnergyNum = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_EnergyNum, userPrize.EnergyNum) + ",";
 //            break;
 //        case RewardType.Experience:
 //            break;
 //        case RewardType.Gold:
 //            userPrize.Gold = (int)prize.Num;
 //            userPrize.MailContent += string.Format(LanguageManager.GetLang().St_GiftGoldNum, userPrize.Gold) + ",";
 //            break;
 //        case RewardType.Item:
 //            ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(prize.ItemID);
 //            if (itemInfo != null)
 //            {
 //                userPrize.ItemPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
 //                userPrize.MailContent += string.Format("{0}*{1}", itemInfo.ItemName, (int)prize.Num) + ",";
 //            }
 //            break;
 //        case RewardType.CrystalId:
 //            CrystalInfo crystal = new ConfigCacheSet<CrystalInfo>().FindKey(prize.ItemID);
 //            if (crystal != null)
 //            {
 //                userPrize.CrystalPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
 //                userPrize.MailContent += string.Format("{0}*{1}", crystal.CrystalName, (int)prize.Num) + ",";
 //            }
 //            break;
 //        case RewardType.Spare:
 //            SparePartInfo spare = new ConfigCacheSet<SparePartInfo>().FindKey(prize.ItemID);
 //            if (spare != null)
 //            {
 //                userPrize.SparePackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
 //                userPrize.MailContent += string.Format("{0}*{1}", spare.Name, (int)prize.Num) + ",";
 //            }
 //            break;
 //        case RewardType.Enchant:
 //            EnchantInfo enchantInfo = new ConfigCacheSet<EnchantInfo>().FindKey(prize.ItemID);
 //            if (enchantInfo != null)
 //            {
 //                userPrize.EnchantPackage = string.Format("{0}={1}={2}", prize.ItemID, prize.ItemLv, (int)prize.Num);
 //                userPrize.MailContent += string.Format("{0}*{1}", enchantInfo.EnchantName, (int)prize.Num) + ",";
 //            }
 //            break;
 //        default:
 //            break;
 //    }
 //    userPrize.MailContent = userPrize.MailContent.TrimEnd(',');
 //    return userPrize;
 //}
 /// <summary>
 /// 充值返还
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="goldNum"></param>
 /// <returns></returns>
 public static void ReturnRatioGold(string userID, int goldNum)
 {
     UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID);
     if (userDial != null && userDial.ReturnRatio > 0)
     {
         int giftGold = MathUtils.RoundCustom(goldNum * userDial.ReturnRatio);
         var cachePrize = new ShareCacheStruct<UserTakePrize>();
         UserTakePrize userPrize = new UserTakePrize();
         userPrize.CreateDate = DateTime.Now;
         userPrize.ID = Guid.NewGuid().ToString();
         userPrize.UserID = Convert.ToInt32(userID);
         userPrize.MailContent = string.Format(LanguageManager.GetLang().St12004_RechargeReturnGoldNum, GetTransformData(userDial.ReturnRatio), giftGold);
         userPrize.IsTasked = false;
         userPrize.TaskDate = MathUtils.SqlMinDate;
         userPrize.ItemPackage = string.Empty;
         userPrize.SparePackage = string.Empty;
         userPrize.CrystalPackage = string.Empty;
         userPrize.EnchantPackage = string.Empty;
         userPrize.OpUserID = 10000;
         userPrize.GameCoin = 0;
         userPrize.ObtainNum = 0;
         userPrize.ExpNum = 0;
         userPrize.EnergyNum = 0;
         userPrize.Gold = giftGold;
         userDial.ReturnRatio = 0;
         cachePrize.Add(userPrize, GameEnvironment.CacheGlobalPeriod);
     }
 }
예제 #49
0
        public override bool TakeAction()
        {
            // 存入数据库
            var hmdCache = new PersonalCacheStruct<HappyModeData>();
            var cache    = new ShareCacheStruct<PayOrder>();
            int index = (int)cache.GetNextNo();
            PayOrder PayData    = new PayOrder();
            string ServerOrderId = System.Guid.NewGuid().ToString("N");
            int keyid = utils.KeyUInt2Int(requestPack.the3rdUserId);

            PayData.Index       = index;
            PayData.UserId      = requestPack.UserID;
            PayData.Identify    = requestPack.identify;
            PayData.typeUser    = requestPack.typeUser; // 360Pay..maybe
            PayData.ProductId   = requestPack.productId;
            PayData.num         = requestPack.num;
            PayData.the3rdUserId = keyid;// utils.KeyUInt2Int(requestPack.the3rdUserId);
            PayData.strThe3rdOrderId = requestPack.strThe3rdUserId;
            PayData.ServerOrderId = ServerOrderId;
            PayData.the3rdOrderId = "";
            cache.Add(PayData);

            // hmd persion
            HappyModeData hmd = hmdCache.FindKey(keyid.ToString());
            int happyPointMaxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 3);
            if (null == hmd)
            {
                responsePack.errorCode = 1;
                return true;
            }
            PayOrderPersion pop = new PayOrderPersion();
            pop.Index = index;
            pop.UserId = requestPack.UserID;
            pop.Identify = requestPack.identify;
            pop.typeUser = requestPack.typeUser; // 360Pay..maybe
            pop.ProductId = requestPack.productId;
            pop.num = requestPack.num;
            pop.the3rdUsrID = (int)requestPack.the3rdUserId;// utils.KeyUInt2Int(requestPack.the3rdUserId);
            pop.strThe3rdOrderId = requestPack.strThe3rdUserId;
            pop.ServerOrderId = ServerOrderId;
            pop.the3rdOrderId = "";
            hmd.PayInfoDic.Add(ServerOrderId, pop);

            // end return
            responsePack.errorCode = 0;
            responsePack.typeUser  = requestPack.typeUser;
            responsePack.result    = PayData.ServerOrderId; // 服务器订单号

            ConsoleLog.showErrorInfo(0,"create order success"+requestPack.the3rdUserId+":"+ServerOrderId);
            return true;
        }
예제 #50
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;
        }
예제 #51
0
 /// <summary>
 /// 只有三个公会或两个公会是配对
 /// </summary>
 /// <param name="No"></param>
 /// <param name="guildIDA"></param>
 /// <param name="guildIDB"></param>
 /// <param name="cityID"></param>
 public static void AppendServerFightGroup(int No, string guildIDA, string guildIDB, int cityID)
 {
     var cacheSet = new ShareCacheStruct<ServerFightGroup>();
     ServerFightGroup group = new ServerFightGroup(Guid.NewGuid().ToString());
     group.CityID = cityID;
     group.Stage = FightStage.semi_final;
     group.NO = No;
     group.Round = 1;
     group.FastID = info.FastID;
     group.GuildIDA = guildIDA;
     group.Awin = 0;
     group.GuildIDB = guildIDB;
     group.Bwin = 0;
     group.WinGuildID = string.Empty;
     group.IsRemove = false;
     UserGuild guildA = new ShareCacheStruct<UserGuild>().FindKey(group.GuildIDA);
     UserGuild guildB = new ShareCacheStruct<UserGuild>().FindKey(group.GuildIDB);
     string guildAName = guildA == null ? string.Empty : guildA.GuildName;
     string guildBName = guildB == null ? string.Empty : guildB.GuildName;
     TraceLog.ReleaseWriteFatal("Round={0},NameA={1},NameB={2},No={3},cityID={4}", 1, guildAName, guildBName, No, cityID);
     cacheSet.Add(group, GameEnvironment.CacheGlobalPeriod);
 }
예제 #52
0
        /// <summary>
        /// 随机分组
        /// </summary>
        public static void Grouping(int FastID, int Lenght, int round, int cityID, ServerFight[] fightList)
        {
            if (IsFightLenth(fightList))
            {
                return;
            }
            List<int> intList = new List<int>();
            for (int i = 0; i < fightList.Length; i++)
            {
                intList.Add(i);
            }
            int guildLenght = fightList.Length;
            int No = 1;
            int subNum = 0;
            while (guildLenght > 0)
            {
                if (fightList.Length == 2 && No == 2)
                {
                    No++;
                    continue;
                }
                var cacheSet = new ShareCacheStruct<ServerFightGroup>();
                ServerFightGroup group = new ServerFightGroup(Guid.NewGuid().ToString());
                group.NO = No;
                group.Stage = FightStage.quarter_final;
                group.Round = round;
                group.FastID = FastID;
                group.IsRemove = false;
                int indexA = GetIndex(intList);
                int indexB = -1;
                if ((guildLenght > 4 && No == 1) || (guildLenght > 3 && No == 2) || (guildLenght > 2 && No == 3) || (guildLenght > 1 && No == 4))
                {
                    indexB = GetIndex(intList);
                    subNum = 2;
                }
                else
                {
                    subNum = 1;
                }

                if (indexA < 0 && indexB < 0)
                {
                    break;
                }
                string guildIdA = string.Empty;
                if (indexA >= 0)
                {
                    ServerFight fightA = fightList[indexA];
                    guildIdA = fightA.GuildID;
                }
                group.GuildIDA = guildIdA;

                string guildIdB = string.Empty;
                if (indexB >= 0)
                {
                    ServerFight fightB = fightList[indexB];
                    guildIdB = fightB.GuildID;
                }
                group.GuildIDB = guildIdB;
                group.CityID = cityID;
                UserGuild guildA = new ShareCacheStruct<UserGuild>().FindKey(group.GuildIDA);
                UserGuild guildB = new ShareCacheStruct<UserGuild>().FindKey(group.GuildIDB);
                string guildAName = guildA == null ? string.Empty : guildA.GuildName;
                string guildBName = guildB == null ? string.Empty : guildB.GuildName;
                TraceLog.ReleaseWriteFatal("Round={0},IndexA={1},IndexB={2},NameA={3},NameB={4},No={5},cityID={6}",
                    round, indexA, indexB, guildAName, guildBName, No, cityID);
                cacheSet.Add(group, GameEnvironment.CacheGlobalPeriod);
                guildLenght = guildLenght - subNum;
                No++;
            }
        }
예제 #53
0
 public static void GetServerFightGroup(int cityID, string guildIDA, string guildIDB)
 {
     var cacheSet = new ShareCacheStruct<ServerFightGroup>();
     ServerFightGroup group = new ServerFightGroup(Guid.NewGuid().ToString());
     group.NO = 1;
     group.Stage = FightStage.final;
     group.Round = 1;
     group.FastID = info.FastID;
     group.IsRemove = false;
     group.GuildIDA = guildIDA;
     group.GuildIDB = guildIDB;
     group.CityID = cityID;
     group.WinGuildID = guildIDA;
     cacheSet.Add(group, GameEnvironment.CacheGlobalPeriod);
 }
예제 #54
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;
        }
예제 #55
0
 /// <summary>
 ///  公会城市争斗战冠军奖励
 /// </summary>
 /// <param name="guildID"></param>
 /// <param name="fightInfo"></param>
 public static void AwardWinner(string guildID, GuildFightInfo fightInfo)
 {
     CityInfo cityInfo = new ConfigCacheSet<CityInfo>().FindKey(fightInfo.CityID);
     if (cityInfo == null)
     {
         return;
     }
     var memberArray = new ShareCacheStruct<GuildMember>().FindAll(s => s.GuildID == guildID);
     foreach (var guildMember in memberArray)
     {
         var user = UserCacheGlobal.CheckLoadUser(guildMember.UserID);
         if (user == null)
         {
             continue;
         }
         var cachePrize = new ShareCacheStruct<UserTakePrize>();
         var takePrize = GetUserTake(fightInfo.Coefficient, user.UserID, user.UserLv, cityInfo.CityName);
         cachePrize.Add(takePrize, GameEnvironment.CacheGlobalPeriod);
     }
 }
예제 #56
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;
        }
예제 #57
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);
        }
예제 #58
0
        string processAdd(string parm)
        {
            string info = "";
            string[] p = parm.Split(',');
            string addWhich = p[0];
            string name = p[1];
            int score = int.Parse(p[2]) ;
            if("ranking"==addWhich)
            {
                var cache = new PersonalCacheStruct<GameUser>();
                var urCache =new ShareCacheStruct<UserRanking>();

                var gu = new GameUser();
                gu.UserId = (int)cache.GetNextNo();
                gu.NickName = name;
                gu.Score = score;
                gu.Identify = "identify_"+name;
                var ur = new UserRanking();
                ur.UserID = gu.UserId;
                ur.UserName = name;
                ur.Score = score;

                cache.Add(gu);
                urCache.Add(ur);
                info = "增加排行榜数据成功";
            }
            return info;
        }
예제 #59
0
 /// <summary>
 /// 玩家成员分组表
 /// </summary>
 /// <param name="cuser1"></param>
 /// <param name="cuser2"></param>
 /// <param name="isWin"></param>
 /// <param name="process"></param>
 public static void MemberGroupProcess(FightUser cuser1, FightUser cuser2, bool isWin, FightCombatProcess process)
 {
     GameUser user1 = new GameDataCacheSet<GameUser>().FindKey(cuser1.UserId);
     GameUser user2 = new GameDataCacheSet<GameUser>().FindKey(cuser2.UserId);
     if (user1 == null || user2 == null)
     {
         return;
     }
     var cacheSet = new ShareCacheStruct<MemberGroup>();
     MemberGroup memberGroup = new MemberGroup(Guid.NewGuid().ToString())
                                   {
                                       FastID = info.FastID,
                                       GuildIDA = cuser1.GuildID,
                                       GuildIDB = cuser2.GuildID,
                                       UserIDA = cuser1.UserId,
                                       UserIDB = cuser2.UserId,
                                       Win = isWin,
                                       CombatProcess = process,
                                       IsRemove = false,
                                   };
     cacheSet.Add(memberGroup, GameEnvironment.CacheGlobalPeriod);
 }
예제 #60
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);
         }
     }
 }