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; }
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; }
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); } } }
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; }
bool GameUserProcess(GameUser gu, bool checkDataOk) { var persionCache = new PersonalCacheStruct<GameUser>(); if (requestPack.UserID <= 0) { gu.UserId = (int)persionCache.GetNextNo(); persionCache.Add(gu); } else { if (checkDataOk) { GameUser findGU = persionCache.FindKey(requestPack.UserID.ToString()); if (null == findGU) // maybe create by happyPoint { persionCache.Add(gu); } else if (requestPack.Score > findGU.Score) { findGU.ModifyLocked(() => { findGU.NickName = gu.NickName; findGU.Score = gu.Score; findGU.state = gu.state; findGU.version = gu.version; }); } } } return true; }
public override bool TakeAction() { if(requestPack.UserID <0 ) { var cache = new PersonalCacheStruct<GameUser>(); int UserId = (int)cache.GetNextNo(); GameUser gu = new GameUser(); gu.UserId = UserId; gu.Identify = requestPack.identify; gu.version = requestPack.version; } Action3000Data d = new Action3000Data(); d.data = int.MaxValue; responsePack.int_test = int.MaxValue; responsePack.float_test = 1.0f; responsePack.uint_test = uint.MaxValue; responsePack.list_int_test = new List<int>(); responsePack.list_class_test = new List<Action3000Data>(); responsePack.dic_int_test = new Dictionary<int, int>(); responsePack.dic_class_test = new Dictionary<int, Action3000Data>(); responsePack.list_int_test.Add(int.MaxValue); responsePack.list_class_test.Add(d); responsePack.dic_int_test.Add(0, int.MaxValue); responsePack.dic_class_test.Add(0, d); responsePack.ErrorCode = (int)GameErrorCode.Error_3000_Test01; //responsePack.dic_class_test[1].data = 2; return true; }
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; }
public override bool TakeAction() { if(requestPack.UserID<=0) { var persionCache = new PersonalCacheStruct<GameUser>(); GameUser gu = new GameUser(); gu.UserId = (int)persionCache.GetNextNo(); gu.CreateTime = System.DateTime.Now; gu.CompensationDate = gu.CreateTime; gu.NickName = ""; gu.Identify = requestPack.identify; gu.version = "1.09"; persionCache.Add(gu); // theUserId = gu.UserId; } else { theUserId = requestPack.UserID; } version = requestPack.version; //ConsoleLog.showErrorInfo(0, "acton1005:userid:"+requestPack.UserID+"#version:"+requestPack.version); if (requestPack.typeUser == "YYS_CP360") { Pay360(); } else if (requestPack.typeUser == "YYS_BaiDu") { PayBaiDu(); } else { responsePack.errorCode = (byte)Response1005Pack.EnumErrorCode.not_find_typeUser; } return true; }