Esempio n. 1
0
        bool addProductOnServer(PayOrderPersion payData, HappyModeData hmd)
        {
            string hd = GameConfigMgr.Instance().getProductInfo(payData.ProductId, payData.ServerOrderId);

            string[] infos   = hd.Split('*');
            int      itemID  = int.Parse(infos[0]);
            int      itemNum = int.Parse(infos[1]);
            string   infoLog = string.Format("add item:{0}num:{1}", itemID, payData.num * itemNum);

            ConsoleLog.showNotifyInfo(infoLog);
            TraceLog.WriteInfo(infoLog);
            hmd.ModifyLocked(() => {
                if (payData.ProductId == "5019")
                {
                    hmd.HappyPoint += payData.num * itemNum;
                }
                if (payData.ProductId == "5020")
                {
                    hmd.HappyReliveNum += payData.num * itemNum;
                }
                if (payData.ProductId == "5021")
                {
                    hmd.HappyReliveNum += payData.num * itemNum;
                }
            });
            if (payData.ProductId == "5019" ||
                payData.ProductId == "5020" ||
                payData.ProductId == "5021")
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        // caret map . the3rdUserid and happyData....
        public static int getHappyIndex(string type, string id)
        {
            var    happMapCache = new PersonalCacheStruct <The3rdUserIDMap>();
            var    map          = happMapCache.FindKey("888");
            int    index        = -1;
            string mapKey       = getMapKey(type, id);

            if (false == map.the3rdMap.ContainsKey(mapKey))
            {
                var happyCache = new PersonalCacheStruct <HappyModeData>();
                var hmd        = new HappyModeData();
                hmd.the3rdUserId = (int)happyCache.GetNextNo() + 10000;
                int maxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 3);
                hmd.EnterNum = maxEnterNum;
                happyCache.Add(hmd);
                map.ModifyLocked(() =>
                {
                    map.the3rdMap.Add(mapKey, hmd.the3rdUserId);
                });

                index = hmd.the3rdUserId;
            }
            else
            {
                index = map.the3rdMap[mapKey];
            }
            return(index);
        }
Esempio n. 3
0
        void doCheck_order()
        {
            string   orderId  = requestPack.infoExt;
            var      payCache = new ShareCacheStruct <PayOrder>();
            PayOrder payData  = payCache.Find((o) =>
            {
                if (orderId == o.ServerOrderId)
                {
                    return(true);
                }
                return(false);
            });

            if (payData == null)
            {
                responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.order_not_find;
                return;
            }

            if (payData.hasGetPayReward)
            {
                responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.hasGetPayReward;
                return;
            }

            string productId = payData.ProductId;

            responsePack.extInfo   = GameConfigMgr.Instance().getProductInfo(productId, orderId); // add 道具发放信息。
            responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok;
        }
Esempio n. 4
0
        bool addProductOnServer(PayOrder payData)
        {
            var           persionHMDCache = new PersonalCacheStruct <HappyModeData>();
            HappyModeData hmd             = persionHMDCache.FindKey(payData.the3rdUserId.ToString());

            if (hmd == null)
            {
                hmd = new HappyModeData();
                hmd.the3rdUserId = payData.the3rdUserId;
                persionHMDCache.Add(hmd);
            }
            string hd = GameConfigMgr.Instance().getProductInfo(payData.ProductId, payData.ServerOrderId);

            string[] infos   = hd.Split('*');
            int      itemID  = int.Parse(infos[0]);
            int      itemNum = int.Parse(infos[1]);
            string   infoLog = string.Format("add item:{0}num:{1}", itemID, payData.num * itemNum);

            ConsoleLog.showNotifyInfo(infoLog);
            TraceLog.WriteInfo(infoLog);
            if (payData.ProductId == "5100")
            {
                hmd.HappyPoint += payData.num * itemNum;
                return(true);
            }
            if (payData.ProductId == "5101")
            {
                hmd.HappyReliveNum += payData.num * itemNum;
                return(true);
            }
            return(false);
        }
Esempio n. 5
0
        bool check()
        {
            //data
            int check_1008_result = GameConfigMgr.Instance().getInt("check_1008_result", 400);
            int check_1008_dis    = GameConfigMgr.Instance().getInt("check_ext_dis", 500);

            if (requestPack.Rate <= 0 ||
                requestPack.Distance <= 0 ||
                requestPack.happyPoint <= 0)
            {
                responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.parm_error;
                return(false);
            }

            float rate = requestPack.Rate / 100.0f;
            int   ret  = (int)(10000 * requestPack.happyPoint / rate / (requestPack.Distance + check_1008_dis));

            if (ret < check_1008_result)
            {
                return(true);
            }
            //string infos = "ret:"+ret+"#checkResult:"+check_1008_result+"#happPoint:" + requestPack.happyPoint + "#Rate:" + rate + "#Distance:" + requestPack.Distance + "#check_1008_dis:" + check_1008_dis;
            //ConsoleLog.showErrorInfo(0, infos);
            responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.check_failed;
            return(false);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public static string getReturnInfo(returnJson jr)
        {
            string url  = GameConfigMgr.Instance().getString("360UrlCb", "http://www.youyisigame.com:8036/Service.aspx/Pay360");
            string info = getReturnInfo(jr.id, jr.name, url);

            return(info);
        }
Esempio n. 8
0
 public Action2500(ActionGetter actionGetter)
     : base(2500, actionGetter)
 {
     urlParams  = "";
     _appKey    = GameConfigMgr.Instance().getString("360AppKey", "");
     appSecret  = GameConfigMgr.Instance().getString("360AppSecret", "");
     urlVerfily = GameConfigMgr.Instance().getString("360UrlVerfily", "");
 }
Esempio n. 9
0
        void doAdd_HMD(string parm)
        {
            var happyCache = new PersonalCacheStruct <HappyModeData>();
            var hmd        = new HappyModeData();

            hmd.the3rdUserId = int.Parse(parm);
            int maxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 3);

            hmd.EnterNum = maxEnterNum;
            happyCache.Add(hmd);
        }
Esempio n. 10
0
        public override bool TakeAction()
        {
            string version = requestPack.Version;
            string ip      = actionGetter.Session.RemoteAddress;

            {
                //   ActionConfigMgr.Instance().getData(cbFunc, version,ip);
                GameConfigMgr.Instance().getData(cbFunc, version, ip);
            }
            return(true);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        private bool ProcessActionNew()
        {
            if (string.IsNullOrEmpty(requestPack.UserName))
            {
                return(responsePackBuild(1, "UserName is null"));
            }

            string[] pams     = requestPack.Identify.Split('#');
            string   Identify = requestPack.Identify;
            string   version  = requestPack.version;

            if (false == GameConfigMgr.Instance().isSupportVersion(version))
            {
                return(responsePackBuild(2, "not support version"));
            }

            int checkDataError = checkData();

            checkDataError |= checkBlack();

            GameUser gu = new GameUser();

            gu.UserId   = requestPack.UserID;
            gu.Score    = requestPack.Score;
            gu.version  = version;
            gu.state    = checkDataError;
            gu.NickName = requestPack.UserName;
            gu.Identify = Identify;

            bool checkDataOk = 0 == checkDataError;

            // update GameUser
            if (false == GameUserProcess(gu, checkDataOk))
            {
                return(responsePackBuild(3, "User Id not Fund"));
            }
            if (false == checkDataOk)
            {
                return(responsePackBuild(4, "check data error"));
            }

            // update and or into userRanking
            UserRankingProcess(gu);

            responsePack.MsgId     = requestPack.UserID <= 0 ? gu.UserId : requestPack.UserID; // send to client.
            responsePack.ErrorCode = 0;
            responsePack.ErrorInfo = "save success";
            responsePack.ActionId  = actionId;
            responsePack.UserID    = gu.UserId;
            return(true);
        }
Esempio n. 13
0
        bool checkRefleshReplace(HappyModeData hmd, memoryRealInfoDataModel.HappyData happyData)
        {
            List <int> happyKeys = GameConfigMgr.Instance().getHappyDataKeys();

            if (happyKeys.Count <= 0)
            {
                ConsoleLog.showErrorInfo(0, "checkRefleshReplace: happyKeys.Count");
                responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.inner_error;
                return(false);
            }

            // clear the buyItemReflesh.
            int itemID = requestPack.realItemID;

            if (hmd.realItemBuyCntInRefleshTime.Count == happyKeys.Count)
            {
                // reflesh
                int buyNumInRefleshTime = int.MaxValue;
                if (hmd.realItemBuyCntInRefleshTime.ContainsKey(requestPack.realItemID))
                {
                    buyNumInRefleshTime = hmd.realItemBuyCntInRefleshTime[itemID].cnt;
                }
                if (happyData.timeRefleshCng <= buyNumInRefleshTime)
                {
                    responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.error_timeRefleshCnt;
                    return(false);
                }

                if (0 == happyData.canReplace) // once time ~~~
                {
                    persionRealItemInfo prii = hmd.RealItemInfoLst.Find((o) =>
                    {
                        return(o.realItemID == requestPack.realItemID);
                    });
                    if (null != prii)
                    {
                        responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.error_replaceBuy;
                        return(false);
                    }
                }
            }
            else
            {
                ConsoleLog.showErrorInfo(0, "checkRefleshReplace: hmd.realItemBuyCntInRefleshTime.Count!= happyKeys.Count");
                responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.inner_error02;
                return(false);
            }
            return(true);
        }
Esempio n. 14
0
        void doRefleshEnterTimer(HappyModeData hmd)
        {
            if (null == hmd)
            {
                return;
            }

            string timestr = GameConfigMgr.Instance().getString("time_hdm_cnt_timming", "05:15");

            System.DateTime tody        = System.Convert.ToDateTime(timestr);
            int             maxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 3);

            hmd.ModifyLocked(() =>
            {
                if (System.DateTime.Now > tody && hmd.PreRefleshTime < tody)
                {
                    hmd.PreRefleshTime = tody;
                    hmd.EnterNum       = maxEnterNum;
                }
            });
        }
Esempio n. 15
0
        void doCheck_rank_dimond()
        {
            int userID      = requestPack.UserID;
            var personCache = new PersonalCacheStruct <GameUser>();
            var user        = personCache.FindKey(userID.ToString());

            if (null == user)
            {
                return;
            }

            responsePack.UserID = requestPack.UserID;
            int dimond = user.Diamond;

            if (dimond > 0)
            {
                responsePack.Result.Add(dimond); // 钻石

                int afterGetDimondScore = user.Score;
                int reduceScore         = GameConfigMgr.Instance().getInt("rank_score_redice", 1);
                if (user.Score > reduceScore)
                {
                    afterGetDimondScore = GameConfigMgr.Instance().getInt("rank_clear_after", 500);
                }
                responsePack.Result.Add(afterGetDimondScore); // 消减后的名次
                responsePack.Result.Add(user.theTotal);       // 积分
                int rank    = user.preRanking;
                int MaxRank = 99999;
                if (rank > MaxRank)
                {
                    rank = MaxRank;
                }
                responsePack.Result.Add(rank);   // 上次排名
            }
            else
            {
                responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok_but_not_dimond;
            }
        }
Esempio n. 16
0
        public override bool TakeAction()
        {
            // 存入数据库
            var cache = new PersonalCacheStruct <HappyModeData>();

            ConsoleLog.showErrorInfo(0, "index:" + cache.GetNextNo());
            int           keyid = utils.KeyUInt2Int(requestPack.the3rdUserID);
            HappyModeData hmd   = cache.FindKey(keyid.ToString());
            int           happyPointMaxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 3);

            if (null == hmd)
            {
                responsePack.errorCode = (byte)Response1007Pack.EnumErrorCode.not_findHMD;
                return(true);
            }

            doRefleshEnterTimer(hmd); // 刷新enterNum
            responsePack.errorCode      = (byte)Response1007Pack.EnumErrorCode.ok;
            responsePack.enterNum       = hmd.EnterNum;
            responsePack.happyPoint     = hmd.HappyPoint;
            responsePack.happyReLiveNum = hmd.HappyReliveNum;
            responsePack.maxEnterNum    = happyPointMaxEnterNum;


            if (requestPack.dateType != 1)
            {
                return(true);                           // not return realitem infos
            }
            foreach (var rii in hmd.RealItemInfoLst)
            {
                Action1007RealItem timeInfo = new Action1007RealItem();
                timeInfo.id      = rii.realItemID;
                timeInfo.theTime = rii.CreateDate;
                responsePack.realItemsIds.Add(timeInfo);
            }

            return(true);
        }
Esempio n. 17
0
        void doAdd_enterCnt(string parm)
        {
            ConsoleLog.showNotifyInfo("doAdd_enterCnt:" + parm);
            var cache       = new PersonalCacheStruct <HappyModeData>();
            int maxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 2);

            string[]      ppp        = parm.Split(',');
            HappyModeData hmd        = cache.FindKey(ppp[0]);
            int           happyPoint = int.Parse(ppp[1]);

            if (hmd != null)
            {
                hmd.ModifyLocked(() => {
                    hmd.EnterNum   += maxEnterNum;
                    hmd.HappyPoint += happyPoint;
                });
                ConsoleLog.showNotifyInfo("doAdd_enterCnt End " + parm + ":" + hmd.EnterNum);
            }
            else
            {
                ConsoleLog.showNotifyInfo("doAdd_enterCnt failed hmd is null" + parm);
            }
        }
Esempio n. 18
0
 public override bool TakeAction()
 {
     responsePack.errorCode = 0;
     responsePack.result    = GameConfigMgr.Instance().getString("message", "");
     return(true);
 }
Esempio n. 19
0
        public override bool TakeAction()
        {
            if (false == GameConfigMgr.Instance().ActivityIsOpen(requestPack.version, 106))
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_open;
                return(true);
            }

            int opt = requestPack.actionID;

            if (opt != (int)Request1010Pack.EnumOptType.use_enterNum &&
                opt != (int)Request1010Pack.EnumOptType.use_happyRelive)
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.error_actionid;
                return(true);
            }

            var           cache = new PersonalCacheStruct <HappyModeData>();
            int           keyId = utils.KeyUInt2Int(requestPack.the3rdUserID);
            HappyModeData hmd   = cache.FindKey(keyId.ToString());

            if (null == hmd)
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_find_happyModeData;
                return(true);
            }

            int actionIndexForHappy = -1;

            if (opt == (int)Request1010Pack.EnumOptType.use_enterNum)
            {
                if (hmd.EnterNum <= 0)
                {
                    responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_enought_enterNum;
                    return(true);
                }
                hmd.ModifyLocked(() =>
                {
                    hmd.EnterNum      -= 1;
                    int cnt            = hmd.ActionEnterHappyPoint.Count;
                    UserActionInfo uai = new UserActionInfo();
                    uai.index          = cnt;
                    uai.type           = 0;
                    hmd.ActionEnterHappyPoint.Add(cnt, uai);
                    actionIndexForHappy = cnt;
                });
            }

            if (opt == (int)Request1010Pack.EnumOptType.use_happyRelive)
            {
                if (hmd.HappyReliveNum <= 0)
                {
                    responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_enought_happyReliveNum;
                    return(true);
                }
                hmd.ModifyLocked(() => {
                    hmd.HappyReliveNum -= 1;
                });
            }

            responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.ok;
            responsePack.actionId  = (int)requestPack.actionID;
            responsePack.index     = actionIndexForHappy;
            return(true);
        }
Esempio n. 20
0
        bool cbFuncDuang(object obj)
        {
            List <UserRanking> objList     = obj as List <UserRanking>;
            List <UserRanking> rankingList = null;

            if (null == objList)
            {
                return(false);
            }
            else
            {
                rankingList = objList;
            }

            if (null == rankingList || rankingList.Count == 0)
            {
                return(false);
            }

            int         selfScore = requestPack.PageIndex;
            UserRanking ur        = new UserRanking();

            ur.Score = selfScore;
            int pos = rankingList.BinarySearch(ur, new comp());
            int h, l, maxPaiHangNum;

            maxPaiHangNum = objList.Count;

            //self
            pos = formatPos(pos);
            h   = rankingList[0].Score;
            l   = rankingList[rankingList.Count - 1].Score > selfScore ? selfScore : rankingList[rankingList.Count - 1].Score;
            responsePack.hightScore  = h;
            responsePack.lowScore    = l;
            responsePack.totalPlayer = rankingList.Count;
            responsePack.youPos      = pos + 1;
            RankData self = null;

            if (requestPack.UserID > 0)
            {
                self = new RankData()
                {
                    pos = responsePack.youPos, UserName = "******", Score = selfScore, UserID = requestPack.UserID
                };
                responsePack.Items.Add(self);
            }

            string sendIndex = GameConfigMgr.Instance().getString("rank_send_num_index", "1,2,3,500,1000,2000,5000,10000,20000,30000");

            string[] sendS = sendIndex.Split(',');
            for (int i = 0; i < sendS.Length; ++i)
            {
                int index = int.Parse(sendS[i]) - 1;
                if (index < 0 || index > rankingList.Count - 1)
                {
                    continue;
                }
                if (requestPack.UserID == rankingList[index].UserID)
                {
                    if (index + 1 < responsePack.youPos)
                    {
                        responsePack.youPos = index + 1;
                    }
                    foreach (var v in responsePack.Items)
                    {
                        if (v.UserID == requestPack.UserID)
                        {
                            v.pos = index + 1;
                            break;
                        }
                    }
                    continue;
                }
                RankData rd = new RankData();
                rd.Score    = rankingList[index].Score;
                rd.UserName = rankingList[index].UserName;
                rd.UserID   = rankingList[index].UserID;
                rd.pos      = formatPos(index + 1);
                responsePack.Items.Add(rd);
            }
            //responsePack.Items.Sort(new compRD());
            return(true);
        }
Esempio n. 21
0
        bool cbFunc8self8(object obj)
        {
            List <UserRanking> objList     = obj as List <UserRanking>;
            List <UserRanking> rankingList = null;

            if (null == objList)
            {
                return(true);
            }
            else
            {
                rankingList = objList;
            }

            if (null == rankingList || rankingList.Count == 0)
            {
                return(true);
            }

            int         selfScore = requestPack.PageIndex;
            UserRanking ur = new UserRanking(); ur.Score = selfScore;
            int         pos = rankingList.BinarySearch(ur, new comp());
            int         h, l, maxPaiHangNum;

            maxPaiHangNum = objList.Count;

            //self
            responsePack.Items.Add(new RankData()
            {
                UserName = "", Score = int.MaxValue
            });
            h = rankingList[0].Score;
            l = rankingList[rankingList.Count - 1].Score > selfScore ? selfScore : rankingList[rankingList.Count - 1].Score;

            int maxSend = GameConfigMgr.Instance().getInt("rank_send_num", 10);

            if (maxSend > rankingList.Count)
            {
                maxSend = 20;
            }

            if (pos < 0)
            {
                pos = ~pos;
            }

            int theNumOf3 = (maxSend - 3);
            int half      = theNumOf3 / 2;

            int begin = pos - half;
            int end   = pos + half;

            if (begin < 0)
            {
                begin = 0;
                end   = maxSend;
            }

            if (end > rankingList.Count)
            {
                end   = rankingList.Count;
                begin = end - theNumOf3;
                if (begin < 0)
                {
                    begin = 0;
                    ConsoleLog.showErrorInfo(0, "Action1001,begin<0.UserID:" + requestPack.UserID);
                }
                if (pos == rankingList.Count)
                {
                    begin += 1;
                }
            }

            int cnt = Math.Min(begin, 3);

            for (int i = 0; i < cnt; ++i)
            {
                if (rankingList[i].UserID == requestPack.UserID)
                {
                    continue;
                }
                RankData rd = new RankData();
                rd.Score    = rankingList[i].Score;
                rd.UserName = rankingList[i].UserName;
                rd.UserID   = rankingList[i].UserID;
                responsePack.Items.Add(rd);
            }

            for (int i = begin; i < end; ++i)
            {
                if (rankingList[i].UserID == requestPack.UserID)
                {
                    continue;
                }
                RankData rd = new RankData();
                rd.Score    = rankingList[i].Score;
                rd.UserName = rankingList[i].UserName;
                rd.UserID   = rankingList[i].UserID;
                responsePack.Items.Add(rd);
            }

            RankData self = new RankData();

            self.UserID   = requestPack.UserID;
            self.UserName = "******";
            self.Score    = selfScore;
            responsePack.Items.Add(self);
            responsePack.Items.Sort(new compRD());

            if (pos < 0)
            {
                pos = ~pos;
                if (pos + 1 > 99999)
                {
                    pos = 99998;
                }
            }
            if (pos >= 99999)
            {
                pos = 99998;
            }
            if (begin >= 99999)
            {
                begin = 99998 - maxSend;
            }
            if (end >= 99999)
            {
                end = 99998;
            }
            responsePack.Items[0].UserName = h + "," + l + "," + rankingList.Count + "," + pos + "," + begin + "," + end; // ��߷֣���ͷ֣��������Լ�����
            //ConsoleLog.showNotifyInfo(responsePack.Items[0].UserName);
            return(true);
        }
Esempio n. 22
0
        public override bool TakeAction()
        {
            int itemIndex = requestPack.realItemID;
            // int
            var           happyPersionCache = new PersonalCacheStruct <HappyModeData>();
            int           keyId             = utils.KeyUInt2Int(requestPack.the3rdUserID);
            HappyModeData hmd = happyPersionCache.FindKey(keyId.ToString());

            if (hmd == null)
            {
                responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.not_find_happymodedata;
                return(true);
            }

            // happData 01
            memoryRealInfoDataModel.HappyData happyData = GameConfigMgr.Instance().getHappyData(requestPack.realItemID);
            if (null == happyData)
            {
                responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.not_find_happPointConfig;
                return(true);
            }

            // share realitem modify 02
            var itemcntCache      = new ShareCacheStruct <ShareRealItemCnt>();
            ShareRealItemCnt sric = itemcntCache.FindKey(requestPack.realItemID);

            if (null == sric)
            {
                responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.not_find_item_cnt_data;
                return(true);
            }

            if (false == checkRefleshReplace(hmd, happyData))
            {
                return(true);
            }

            int needHappyPoint = happyData.needHappyPoint; // 配置文件总获得

            if (hmd.HappyPoint < needHappyPoint)
            {
                responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.not_enought_happyPoint;
                return(true);
            }

            if (sric.num <= 0)
            {
                responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.realitem_is_empty;
                return(true);
            }

            bool buyOK = false;

            if (sric.num > 0)
            {
                sric.ModifyLocked(() =>
                {
                    sric.num -= 1;
                    if (sric.num >= 0)
                    {
                        buyOK = true;
                    }
                });
            }

            if (false == buyOK)
            {
                responsePack.errorCode = (byte)Response1009Pack.EnumErrorCode.realitem_is_empty;
                return(true);
            }

            persionRealItemInfo rii = new persionRealItemInfo();

            rii.Index          = hmd.RealItemInfoLst.Count;
            rii.UserId         = requestPack.UserID;
            rii.the3rdUserId   = utils.KeyUInt2Int(requestPack.the3rdUserID);
            rii.Identify       = requestPack.identify;
            rii.happyPoint     = hmd.HappyPoint;
            rii.needHappyPoint = needHappyPoint;
            rii.realItemID     = requestPack.realItemID;
            hmd.RealItemInfoLst.Add(rii);

            // save to db for ....
            var shareRealItemCache     = new ShareCacheStruct <shareRealItemInfo>();
            shareRealItemInfo shareRII = new shareRealItemInfo();

            shareRII.Index          = (int)shareRealItemCache.GetNextNo();
            shareRII.UserId         = requestPack.UserID;
            shareRII.the3rdUserId   = utils.KeyUInt2Int(requestPack.the3rdUserID);
            shareRII.Identify       = requestPack.identify;
            shareRII.happyPoint     = hmd.HappyPoint;
            shareRII.needHappyPoint = needHappyPoint;
            shareRII.realItemID     = requestPack.realItemID;
            shareRealItemCache.Add(shareRII);

            hmd.ModifyLocked(() =>
            {
                hmd.HappyPoint -= needHappyPoint;
                hmd.realItemBuyCntInRefleshTime[itemIndex].cnt = hmd.realItemBuyCntInRefleshTime[itemIndex].cnt + 1;
            });
            responsePack.errorCode  = (byte)Response1009Pack.EnumErrorCode.ok;
            responsePack.realItemID = rii.realItemID;
            return(true);
        }
Esempio n. 23
0
        public override bool TakeAction()
        {
            var           cache        = new ShareCacheStruct <ShareRealItemCnt>();
            var           persionCache = new PersonalCacheStruct <HappyModeData>();
            int           keyId        = utils.KeyUInt2Int(requestPack.the3rdUserID);
            HappyModeData hmd          = persionCache.FindKey(keyId.ToString());
            List <int>    keys         = GameConfigMgr.Instance().getHappyDataKeys();

            if (hmd != null)
            {
                doReflesh(hmd, keys);
            }

            for (int i = 0; i < keys.Count; ++i)
            {
                memoryRealInfoDataModel.HappyData hd = GameConfigMgr.Instance().getHappyData(keys[i]);
                ShareRealItemCnt sric = cache.FindKey(keys[i]);
                if (null != hd && null != sric)
                {
                    RealItemData rid = new RealItemData();
                    rid.id             = hd.itemID;
                    rid.name           = hd.name;
                    rid.happyPoint     = hd.needHappyPoint;
                    rid.num            = sric.num;
                    rid.timeForReflesh = (sric.preUpdateTime.AddMinutes(hd.MinuteForReflesh) - System.DateTime.Now);
                    rid.uiStatus       = 0;

                    if (0 == rid.num)
                    {
                        rid.uiStatus = 1;
                    }
                    if (null != hmd)
                    {
                        bool findIt = false;
                        if (hmd.realItemBuyCntInRefleshTime.ContainsKey(rid.id))
                        {
                            findIt = hmd.realItemBuyCntInRefleshTime[rid.id].cnt > 0;
                        }

                        bool canReplace = hd.canReplace == 1;
                        if (false == canReplace)
                        {
                            if (hmd.RealItemInfoLst.Exists((o) => { return(o.realItemID == rid.id); }))
                            {
                                rid.uiStatus = 2;
                            }
                        }
                        else
                        {
                            if (findIt)
                            {
                                rid.uiStatus = 2;
                            }
                        }
                    }
                    responsePack.Data.Add(rid);
                }
                else
                {
                    ConsoleLog.showErrorInfo(0, "is null" + (null == hd).ToString() + ":" + (null == sric).ToString());
                }
            }
            //ConsoleLog.showErrorInfo(0, "responsePack cnt:"+responsePack.Data.Count);
            responsePack.errorCode = 0;
            return(true);
        }