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); }
// 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); }
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); }
static bool addHappyDataMap(HappyModeData hmd, int newId) { var happMapCache = new PersonalCacheStruct <The3rdUserIDMap>(); var map = happMapCache.FindKey("888"); string type = "YYS_CP360"; uint id = utils.KeyInt2Uint(hmd.the3rdUserId); int mapID = newId; if (hmd.the3rdUserId > 0) { mapID = hmd.the3rdUserId; } string mapKey = Action1005.getMapKey(type, id.ToString()); if (map.the3rdMap.ContainsKey(mapKey)) { return(false); } map.ModifyLocked(() => { map.the3rdMap.Add(mapKey, mapID); }); if (hmd.the3rdUserId > 0) { return(false); } return(true); }
public bool update_HappyModeData_enterNum(string s0,string s1,HappyModeData hmd) { int maxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 3); hmd.ModifyLocked(() => { hmd.EnterNum = maxEnterNum; }); return true; }
public bool update_HappyModeData_enterNum(string s0, string s1, HappyModeData hmd) { int maxEnterNum = GameConfigMgr.Instance().getInt("happyPointMaxEnterNum", 3); hmd.ModifyLocked(() => { hmd.EnterNum = maxEnterNum; }); return(true); }
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); }
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); }
public override bool TakeAction() { int happyPointFromClient = requestPack.happyPoint; if (happyPointFromClient < 0) { responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.error_data; 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)Response1008Pack.EnumErrorCode.not_find_data; return(true); } int happyPointIndex = requestPack.index; if (false == hmd.ActionEnterHappyPoint.ContainsKey(happyPointIndex)) { responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.error_userActionIndex; return(true); } UserActionInfo uai = hmd.ActionEnterHappyPoint[happyPointIndex]; if (0 != uai.status) { responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.error_has_sendThis; return(true); } // check if (false == check()) { return(true); } hmd.ModifyLocked(() => { hmd.HappyPoint += happyPointFromClient; uai.status = 1; }); responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.ok; responsePack.happyPoint = hmd.HappyPoint; return(true); }
bool ProcessHMD(string orderId, bool bSuccess, string jrRet) { // hmd var hmdCache = new PersonalCacheStruct <HappyModeData>(); int keyid = Action1005.getHappyIndex("YYS_BaiDu", app_uid); HappyModeData hmd = hmdCache.FindKey(keyid.ToString()); if (null == hmd) { // errorcode ConsoleLog.showErrorInfo(0, "PayLog ProcessHMD hmd is null"); TraceLog.WriteError("PayLog ProcessHMD hmd is null"); return(false); } else { if (false == hmd.PayInfoDic.ContainsKey(server_orderid)) { // errorcode ConsoleLog.showErrorInfo(0, "PayLog ProcessHMD server_orderid not find :" + server_orderid + "/nbaidu orderID" + order_id); TraceLog.WriteError("PayLog ProcessHMD server_orderid not find :" + server_orderid + "baidu orderID" + order_id); return(false); } else { hmd.PayInfoDic[server_orderid].userParms = urlParams; hmd.PayInfoDic[server_orderid].the3rdOrderId = order_id; } } PayOrderPersion payDataPersion = hmd.PayInfoDic[server_orderid]; bool hasGetPayReward = false; if (false == payDataPersion.process) { if (bSuccess) { hasGetPayReward = addProductOnServer(payDataPersion, hmd); } hmd.PayInfoDic.ModifyLocked(() => { payDataPersion.state = bSuccess ? PayOrderPersion.PayStatus.paySuccess : PayOrderPersion.PayStatus.payFailed; payDataPersion.process = true; payDataPersion.typeUser = "******"; payDataPersion.jrRet = jrRet; payDataPersion.hasGetPayReward = hasGetPayReward; }); } return(hasGetPayReward); }
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); }
void doReflesh(HappyModeData hmd, List <int> happyKeys) { if (null == hmd) { return; } if (hmd.realItemBuyCntInRefleshTime.Count != happyKeys.Count) { hmd.ModifyLocked(() => { hmd.realItemBuyCntInRefleshTime.Clear(); foreach (int k in happyKeys) { RefleshCacheInfo info = new RefleshCacheInfo(); info.itemId = k; info.cnt = 0; hmd.realItemBuyCntInRefleshTime.Add(k, info); } }); } var shareCacheRealItemCnt = new ShareCacheStruct <ShareRealItemCnt>(); hmd.ModifyLocked(() => { for (int k = 0; k < happyKeys.Count; ++k) { int id = happyKeys[k]; ShareRealItemCnt cntData = shareCacheRealItemCnt.FindKey(id.ToString()); if (cntData != null && hmd.realItemBuyCntInRefleshTime.ContainsKey(id)) { if (hmd.realItemBuyCntInRefleshTime[id].preRefleshDate <= cntData.preUpdateTime) { hmd.realItemBuyCntInRefleshTime[id].cnt = 0; hmd.realItemBuyCntInRefleshTime[id].preRefleshDate = cntData.preUpdateTime.AddSeconds(1); } } else { ConsoleLog.showErrorInfo(0, "Refresh Acton1009"); TraceLog.WriteError("Refresh Acton1009"); } } }); }
static HappyModeData copyHMD(HappyModeData hmd) { var cache = new PersonalCacheStruct <HappyModeData>(); HappyModeData d = new HappyModeData(); d.the3rdUserId = (int)cache.GetNextNo(); d.EnterNum = hmd.EnterNum; d.HappyPoint = hmd.HappyPoint; d.HappyReliveNum = hmd.HappyReliveNum; d.PreRefleshTime = hmd.PreRefleshTime; d.realItemBuyCntInRefleshTime = clone <CacheDictionary <int, RefleshCacheInfo> >(hmd.realItemBuyCntInRefleshTime); d.ActionEnterHappyPoint = clone <CacheDictionary <int, UserActionInfo> >(hmd.ActionEnterHappyPoint); d.RealItemInfoLst = clone <CacheList <persionRealItemInfo> >(hmd.RealItemInfoLst); d.PayInfoDic = clone <CacheDictionary <string, PayOrderPersion> >(hmd.PayInfoDic); return(d); }
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; } }); }
void test() { HappyModeData hmd = new HappyModeData(); PayOrderPersion pop = new PayOrderPersion(); pop.Index = 1; pop.UserId = 2; pop.Identify = "1"; pop.typeUser = "******"; // 360Pay..maybe pop.ProductId = "1"; pop.num = 1; pop.the3rdUsrID = 1;// utils.KeyUInt2Int(requestPack.the3rdUserId); pop.strThe3rdOrderId = "1"; pop.ServerOrderId = "1"; pop.the3rdOrderId = "1"; hmd.PayInfoDic.Add("1", pop); HappyModeData d = new HappyModeData(); persionRealItemInfo prii = new persionRealItemInfo(); prii.Index = 1; hmd.RealItemInfoLst.Add(prii); UserActionInfo uai = new UserActionInfo(); uai.index = 1; hmd.ActionEnterHappyPoint.Add(1, uai); RefleshCacheInfo rci = new RefleshCacheInfo(); rci.itemId = 1; hmd.realItemBuyCntInRefleshTime.Add(1, rci); d.realItemBuyCntInRefleshTime = clone <CacheDictionary <int, RefleshCacheInfo> >(hmd.realItemBuyCntInRefleshTime); d.ActionEnterHappyPoint = clone <CacheDictionary <int, UserActionInfo> >(hmd.ActionEnterHappyPoint); d.RealItemInfoLst = clone <CacheList <persionRealItemInfo> >(hmd.RealItemInfoLst); d.PayInfoDic = clone <CacheDictionary <string, PayOrderPersion> >(hmd.PayInfoDic); }
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); }
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); } }
void doReflesh(HappyModeData hmd, List<int> happyKeys) { if (null == hmd) return; if (hmd.realItemBuyCntInRefleshTime.Count != happyKeys.Count) { hmd.ModifyLocked(() => { hmd.realItemBuyCntInRefleshTime.Clear(); foreach (int k in happyKeys) { RefleshCacheInfo info = new RefleshCacheInfo(); info.itemId = k; info.cnt = 0; hmd.realItemBuyCntInRefleshTime.Add(k, info); } }); } var shareCacheRealItemCnt = new ShareCacheStruct<ShareRealItemCnt>(); hmd.ModifyLocked(() => { for (int k = 0; k < happyKeys.Count; ++k) { int id = happyKeys[k]; ShareRealItemCnt cntData = shareCacheRealItemCnt.FindKey(id.ToString()); if (cntData != null && hmd.realItemBuyCntInRefleshTime.ContainsKey(id)) { if (hmd.realItemBuyCntInRefleshTime[id].preRefleshDate <= cntData.preUpdateTime) { hmd.realItemBuyCntInRefleshTime[id].cnt = 0; hmd.realItemBuyCntInRefleshTime[id].preRefleshDate = cntData.preUpdateTime.AddSeconds(1); } } else { ConsoleLog.showErrorInfo(0, "Refresh Acton1009"); TraceLog.WriteError("Refresh Acton1009"); } } }); }
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); }
bool addProductOnServer(PayOrderPersion payData, HappyModeData hmd) { string hd = GameConfigMgr.Instance().getProductInfo(payData.ProductId, payData.ServerOrderId); //ConsoleLog.showNotifyInfo(hd); string[] itemInfos = hd.Split(','); bool add = false; for(int i=0; i<itemInfos.Length; ++i) { string[] infos = itemInfos[i].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") { add = true; } } return add; }
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); }
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; }
// 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; }
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); }
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; } }); }