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 doAdd_HappyDataAddItem(string parm) { string[] stringS = parm.Split(','); int UserID = int.Parse(stringS[0]); int the3rdUserID = int.Parse(stringS[1]); int itemId = int.Parse(stringS[2]); var cache = new PersonalCacheStruct <HappyModeData>(); var hmd = cache.FindKey(stringS[1]); if (null == hmd) { return; } persionRealItemInfo rii = new persionRealItemInfo(); rii.Index = hmd.RealItemInfoLst.Count; rii.UserId = UserID; rii.the3rdUserId = the3rdUserID; rii.Identify = "GM_ADD"; rii.happyPoint = hmd.HappyPoint; rii.needHappyPoint = 0; rii.realItemID = itemId; hmd.RealItemInfoLst.Add(rii); // save to db for .... var shareRealItemCache = new ShareCacheStruct <shareRealItemInfo>(); shareRealItemInfo shareRII = new shareRealItemInfo(); shareRII.Index = (int)shareRealItemCache.GetNextNo(); shareRII.UserId = UserID; shareRII.the3rdUserId = the3rdUserID; shareRII.Identify = "GM_ADD"; shareRII.happyPoint = hmd.HappyPoint; shareRII.needHappyPoint = 0; shareRII.realItemID = itemId; shareRealItemCache.Add(shareRII); }
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() { 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); }