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); }
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 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); }
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); }
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 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); } }
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); }
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() { 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); }
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"); } } }); }
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; } }); }