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() { var cache = new PersonalCacheStruct <GameUser>(); _user = cache.FindKey(_uid.ToString()); if (_user != null) { _user.ModifyLocked(() => { _user.RoomId = string.Empty; _user.Searching = false; }); } return(true); }
void getFake() { ConsoleLog.showNotifyInfo("get fake begin"); fakeLst = new List <UserRanking>(); int num = GameConfigMgr.Instance().getInt("rank_send_num", 10); float percent = GameConfigMgr.Instance().getInt("rankclear_perscent", 1) / 100.0f; int reduceScore = GameConfigMgr.Instance().getInt("rank_score_redice", 1); List <UserRanking> urlst = RankingFactorNew.Singleton().get <UserRanking>(typeof(RankingScore).ToString()); if (null == urlst) { TraceLog.WriteError("getFake()"); ConsoleLog.showErrorInfo(0, "getFake()"); return; } var rankCache = new ShareCacheStruct <UserRanking>(); var userCache = new PersonalCacheStruct <GameUser>(); for (int i = 0; i < urlst.Count; ++i) { if (i > num) { break; } UserRanking ur = urlst[i]; if (ur.Score > reduceScore) { ur.Score = (int)((float)urlst[i].Score * percent); UserRanking cacheUR = rankCache.FindKey(ur.UserID); if (null != cacheUR) { cacheUR.ModifyLocked(() => { cacheUR.Score = ur.Score; }); } GameUser cacheGU = userCache.FindKey(ur.UserID.ToString()); if (null != cacheGU) { cacheGU.ModifyLocked(() => { cacheGU.Score = ur.Score; }); } } fakeLst.Add(copy(ur)); } ConsoleLog.showNotifyInfo("getFake:" + fakeLst.Count); ConsoleLog.showNotifyInfo("get fake end"); }
public override bool TakeAction() { var cache = new PersonalCacheStruct <GameUser>(); _user = (GameUser)Current.User;//cache.FindKey(_uid.ToString()); if (_user != null) { _user.ModifyLocked(() => { // _user.RoomId =Guid.NewGuid().ToString(); _user.Searching = true; }); //Console.WriteLine(string.Format("来申请了,UserId:{0}",_uid)); } return(true); }
void doCheck_compensation() { var persionCache = new PersonalCacheStruct <GameUser>(); GameUser gu = persionCache.FindKey(requestPack.UserID.ToString()); if (null == gu) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.compensation_not_findUser; return; } var compensationCache = new ShareCacheStruct <CompensationInfo>(); List <CompensationInfo> Lstcsi = compensationCache.FindAll((o) => { return(gu.CompensationDate < o.CreateDate); }, true); if (Lstcsi.Count <= 0) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.no_data01; return; } CompensationInfo csi = Lstcsi[Lstcsi.Count - 1]; if (null == csi) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.no_data02; return; } // has got the new Compensation gu.ModifyLocked(() => { gu.CompensationDate = csi.CreateDate; }); responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok; string info = csi.type + "," + csi.CreateDate.ToString() + "," + csi.message + "," + csi.ItemInfo; responsePack.extInfo = info; }
static bool addRankingReward(List <UserRanking> rankingList) { if (null == rankingList) { ConsoleLog.showErrorInfo(135, "addRankingReward:Error"); TraceLog.WriteError("Error : addRankingReward"); return(false); } int scoreNum = GameConfigMgr.Instance().getInt("rankclear_scoreNum", 20); int DemoNum = GameConfigMgr.Instance().getInt("rankclear_dimondNum", 10000); int max = Math.Max(scoreNum, DemoNum); // get Score accounding to Ranking var totalCache = new ShareCacheStruct <UserRankingTotal>(); var personCache = new PersonalCacheStruct <GameUser>(); for (int i = 0; i < rankingList.Count; ++i) { if (i < DemoNum) { UserRanking ur = rankingList[i]; int score = getScore(i); UserRankingTotal urt = totalCache.FindKey(ur.UserID); if (null == urt) { UserRankingTotal newUrt = new UserRankingTotal(); newUrt.UserID = ur.UserID; newUrt.Total = score; totalCache.Add(newUrt); } else { urt.ModifyLocked(() => { urt.Total += score; }); } } int UserId = rankingList[i].UserID; GameUser gu = personCache.FindKey(UserId.ToString()); if (i < DemoNum) { if (null != gu) { gu.ModifyLocked(() => { gu.Diamond += getDiamond(i); gu.theTotal += getScore(i); }); } } if (null != gu) { gu.ModifyLocked(() => { gu.preRanking = i + 1; }); } } return(true); }