/// <summary> /// 增加刷新次数 /// </summary> /// <param name="userID"></param> /// <param name="cityID"></param> /// <returns></returns> public static void HeroRefreshNum(string userID, int cityID) { var cacheSet = new GameDataCacheSet <UserDailyRestrain>(); UserDailyRestrain dailyRestrain = cacheSet.FindKey(userID); if (dailyRestrain != null) { DailyUserExtend userExtend = new DailyUserExtend(); List <HeroPlot> heroList = new List <HeroPlot>(); if (dailyRestrain.UserExtend != null) { userExtend = dailyRestrain.UserExtend; if (dailyRestrain.UserExtend.HeroPlot.Count > 0) { heroList = dailyRestrain.UserExtend.HeroPlot; } } HeroPlot plot = heroList.Find(m => m.CityID.Equals(cityID)); if (plot != null) { plot.HeroNum = MathUtils.Addition(plot.HeroNum, 1); } else { heroList.Add(new HeroPlot() { CityID = cityID, HeroNum = 1, HeroList = new List <FunPlot>() }); } userExtend.HeroPlot = heroList; dailyRestrain.UserExtend = userExtend; } cacheSet.Update(); }
/// <summary> /// 精英副本挑战次数 /// </summary> /// <param name="plotNPCInfo"></param> private void EliteDailyRestrain(PlotNPCInfo plotNPCInfo) { UserDailyRestrain userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid); if (userRestrain == null) { userRestrain = new UserDailyRestrain() { UserID = Uid, FunPlot = new CacheList <FunPlot>() }; } int plotNum = 0; FunPlot funPlot = null; if (userRestrain.FunPlot.Count > 0) { funPlot = userRestrain.FunPlot.Find(m => m.PlotID == plotNPCInfo.PlotID); } if (funPlot == null) { plotNum = 1; } else { plotNum = MathUtils.Addition(funPlot.Num, 1, int.MaxValue); userRestrain.FunPlot.Remove(funPlot); } funPlot = new FunPlot { PlotID = plotNPCInfo.PlotID, Num = plotNum }; userRestrain.FunPlot.Add(funPlot); }
public static void RefreshRestrain(UserDailyRestrain restrain) { if (restrain.RefreshDate.Date != DateTime.Now.Date) { restrain.RestrainProperty.Init(); restrain.RefreshDate = DateTime.Now; } }
private GameUser CreateRole() { GameUser user = new GameUser(UserId); user.SessionID = Sid; user.Pid = Pid; user.HeadIcon = HeadID; user.RetailId = RetailID; user.NickName = UserName; user.RealName = ""; user.Hobby = ""; user.Profession = ""; user.Sex = Sex.ToBool(); user.UserLv = (short)ConfigEnvSet.GetInt("User.Level", 1); user.GiftGold = ConfigEnvSet.GetInt("User.GiftGold", 100); user.GameCoin = ConfigEnvSet.GetInt("User.GameCoin", 1000); user.VipLv = ConfigEnvSet.GetInt("User.VipLv"); user.UserStatus = UserStatus.Normal; user.MsgState = true; user.MobileType = MobileType; user.ScreenX = ScreenX; user.ScreenY = ScreenY; user.ClientAppVersion = ReqAppVersion; user.LoginDate = DateTime.Now; user.CreateDate = DateTime.Now; user.TitleId = 1001; user.Property.GameId = GameID; user.Property.ServerId = ServerID; user.Birthday = new DateTime(1970, 1, 1); user.RemoteAddress = httpGet.RemoteAddress; var cacheSet = new GameDataCacheSet <GameUser>(); cacheSet.Add(user); cacheSet.Update(); //增加初始背包、玩家任务表、玩家成就表 var itemCacheSet = new GameDataCacheSet <UserItemPackage>(); itemCacheSet.Add(new UserItemPackage(UserId)); itemCacheSet.Update(); var taskCacheSet = new GameDataCacheSet <UserTask>(); taskCacheSet.Add(new UserTask(UserId)); taskCacheSet.Update(); var achieveCacheSet = new GameDataCacheSet <UserAchieve>(); achieveCacheSet.Add(new UserAchieve(UserId)); achieveCacheSet.Update(); UserDailyRestrain restrain = new UserDailyRestrain(UserId); restrain.RefreshDate = DateTime.Now.AddDays(-1); var restrainCacheSet = new GameDataCacheSet <UserDailyRestrain>(); restrainCacheSet.Add(restrain); restrainCacheSet.Update(); return(user); }
private bool IsRefreshKalpa(UserDailyRestrain dailyRestrain, RestrainType refresh, int useGold) { if (dailyRestrain.UserExtend != null) { int kalpaNum = 0; if (refresh == RestrainType.RefreshKalpa) { kalpaNum = dailyRestrain.UserExtend.KalpaNum; } else if (refresh == RestrainType.RefreshLastKalpa) { kalpaNum = dailyRestrain.UserExtend.LastKalpaNum; } if (VipHelper.DailyRestrainSurplusNum(ContextUser, refresh, kalpaNum) > 0) { //DailyUserExtend userExtend = dailyRestrain.UserExtend; dailyRestrain.UserExtend.UpdateNotify(obj => { dailyRestrain.UserExtend.KalpaDate = DateTime.Now; if (refresh == RestrainType.RefreshKalpa) { dailyRestrain.UserExtend.KalpaNum = MathUtils.Addition(dailyRestrain.UserExtend.KalpaNum, 1, int.MaxValue); } else if (refresh == RestrainType.RefreshLastKalpa) { dailyRestrain.UserExtend.LastKalpaNum = MathUtils.Addition(dailyRestrain.UserExtend.LastKalpaNum, 1, int.MaxValue); } dailyRestrain.UserExtend.KalpaPlot = new CacheList <FunPlot>(); return(true); }); //dailyRestrain.Update(); if (ContextUser.UserExtend != null) { ContextUser.UserExtend.UpdateNotify(obj => { if (refresh == RestrainType.RefreshLastKalpa) { ContextUser.UserExtend.LayerNum = MathUtils.Subtraction(ContextUser.UserExtend.LayerNum, 1, 1); } ContextUser.UserExtend.HurdleNum = 1; return(true); }); ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold); //ContextUser.Update(); } return(true); } } return(false); }
/// <summary> /// 天地劫挑战次数 /// </summary> /// <param name="plotNPCInfo"></param> private void KalpaDailyRestrain(PlotNPCInfo plotNPCInfo) { UserDailyRestrain userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid); if (userRestrain == null) { userRestrain = new UserDailyRestrain() { UserID = Uid, FunPlot = new CacheList <FunPlot>() }; } if (userRestrain.UserExtend == null) { userRestrain.UserExtend = new DailyUserExtend(); userRestrain.UserExtend.KalpaPlot = new CacheList <FunPlot>(); } int plotNum = 0; FunPlot funPlot = userRestrain.UserExtend.KalpaPlot.Find(m => m.PlotID == plotNPCInfo.PlotID); if (funPlot == null) { plotNum = 1; } else { plotNum = MathUtils.Addition(funPlot.Num, 1, int.MaxValue); userRestrain.UserExtend.UpdateNotify(obj => { userRestrain.UserExtend.KalpaPlot.Remove(funPlot); return(true); }); } funPlot = new FunPlot { PlotID = plotNPCInfo.PlotID, Num = plotNum }; userRestrain.UserExtend.UpdateNotify(obj => { userRestrain.UserExtend.KalpaPlot.Add(funPlot); return(true); }); }
private void DoPrecess(UserDailyRestrain restrain, int petUseGold) { if (ContextUser.GoldNum >= petUseGold) { petId = ContextUser.UserExtend.LightPetID; restrain.UserID = Uid; if (restrain.UserExtend == null) { restrain.UserExtend = new DailyUserExtend(); } restrain.UserExtend.UpdateNotify(obj => { restrain.UserExtend.PetRefeshNum++; return(true); }); //restrain.Update(); ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, petUseGold, int.MaxValue); //ContextUser.Update(); } }
private void CreateDailyRestrain() { if (new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid) == null) { UserDailyRestrain dailyRestrain = new UserDailyRestrain(); dailyRestrain.UserID = Uid; dailyRestrain.RefreshDate = DateTime.Now; dailyRestrain.Funtion1 = 0; dailyRestrain.Funtion2 = 0; dailyRestrain.Funtion3 = 0; dailyRestrain.Funtion4 = 0; dailyRestrain.Funtion5 = 0; dailyRestrain.Funtion6 = 0; dailyRestrain.Funtion7 = 0; dailyRestrain.Funtion8 = 0; dailyRestrain.Funtion9 = 0; var cacheSet = new GameDataCacheSet <UserDailyRestrain>(); cacheSet.Add(dailyRestrain); cacheSet.Update(); } }
private void CreateDailyRestrain() { if (new PersonalCacheStruct <UserDailyRestrain>().FindKey(UserId.ToString()) == null) { UserDailyRestrain dailyRestrain = new UserDailyRestrain(); dailyRestrain.UserID = UserId.ToString(); dailyRestrain.RefreshDate = DateTime.Now; dailyRestrain.Funtion1 = 0; dailyRestrain.Funtion2 = 0; dailyRestrain.Funtion3 = 0; dailyRestrain.Funtion4 = 0; dailyRestrain.Funtion5 = 0; dailyRestrain.Funtion6 = 0; dailyRestrain.Funtion7 = 0; dailyRestrain.Funtion8 = 0; dailyRestrain.Funtion9 = 0; var cacheSet = new PersonalCacheStruct <UserDailyRestrain>(); cacheSet.Add(dailyRestrain); cacheSet.Update(); } }
/// <summary> /// 天地劫挑战次数 /// </summary> /// <param name="plotNPCInfo"></param> private void KalpaDailyRestrain(PlotNPCInfo plotNPCInfo) { var cacheSet = new GameDataCacheSet <UserDailyRestrain>(); UserDailyRestrain userRestrain = cacheSet.FindKey(Uid); if (userRestrain == null) { userRestrain = new UserDailyRestrain() { UserID = Uid }; cacheSet.Add(userRestrain, GameEnvironment.CacheUserPeriod); userRestrain = cacheSet.FindKey(Uid); } if (userRestrain.UserExtend == null) { userRestrain.UserExtend = new DailyUserExtend(); //userRestrain.UserExtend.KalpaPlot = new List<FunPlot>(); } int plotNum = 0; FunPlot funPlot = userRestrain.UserExtend.KalpaPlot.Find(m => m.PlotID == plotNPCInfo.PlotID); if (funPlot == null) { plotNum = 1; funPlot = new FunPlot { PlotID = plotNPCInfo.PlotID, Num = plotNum }; userRestrain.UserExtend.UpdateNotify(obj => { userRestrain.UserExtend.KalpaPlot.Add(funPlot); return(true); }); } }
public override bool TakeAction() { int energyNum = ConfigEnvSet.GetInt("User.EnergyNum"); UserHelper.ChechDailyRestrain(ContextUser.UserID); var cacheSet = new PersonalCacheStruct <UserDailyRestrain>(); double addNum = FestivalHelper.SurplusPurchased(ContextUser.UserID, FestivalType.PurchasedEnergy);//活动加成 int payNum = FestivalHelper.SurplusEnergyNum(ContextUser.UserID); UserDailyRestrain userRestrain = cacheSet.FindKey(ContextUser.UserID); if (payNum == 0) { if (userRestrain != null && DateTime.Now.Date != userRestrain.RefreshDate.Date) { userRestrain.Funtion4 = 0; } if (userRestrain != null && userRestrain.Funtion4 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.GouMaiJingLi) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St1010_JingliFull; return(false); } } int useGold = (GetPayEnergyGold(ContextUser.UserID, ContextUser.VipLv, payType) * addNum).ToInt(); if (payType == 1) { if (ops == 1) { this.ErrorCode = 1; this.ErrorInfo = string.Format(LanguageManager.GetLang().St1010_PayEnergyUseGold, useGold, energyNum); return(false); } else if (ops == 2) { if (ContextUser.GoldNum < useGold) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue); ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, GetEnergyNum(ContextUser.UserID, ContextUser.VipLv, payType), short.MaxValue); if (payNum == 0) { if (userRestrain != null) { userRestrain.Funtion4 = MathUtils.Addition(userRestrain.Funtion4, 1, int.MaxValue); } else { userRestrain = new UserDailyRestrain(); userRestrain.UserID = ContextUser.UserID; userRestrain.RefreshDate = DateTime.Now; userRestrain.Funtion4 = 1; cacheSet.Add(userRestrain); } } UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, 0, userRestrain.Funtion4, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue)); FestivalHelper.PurchasedEnergy(ContextUser.UserID); } } else if (payType == 2) { short payEnergy = GetEnergyNum(ContextUser.UserID, ContextUser.VipLv, payType); if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.ZiDongGouMaiJingLi)) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion; return(false); } if (ops == 1) { this.ErrorCode = 1; this.ErrorInfo = string.Format(LanguageManager.GetLang().St1010_PayEnergyUseGold, useGold, payEnergy); return(false); } else if (ops == 2) { if (ContextUser.GoldNum < useGold) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue); ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, payEnergy, short.MaxValue); if (userRestrain != null) { userRestrain.Funtion4 = MathUtils.Addition(userRestrain.Funtion4, 1, int.MaxValue); } else { userRestrain = new UserDailyRestrain(); userRestrain.UserID = ContextUser.UserID; userRestrain.RefreshDate = DateTime.Now; userRestrain.Funtion4 = 1; cacheSet.Add(userRestrain); } UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, userRestrain.Funtion4, 1, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue)); } } return(true); }
public override bool TakeAction() { UserHelper.ChechDailyRestrain(ContextUser.UserID); int maxNum = 0; int useNum = 0; DailyRestrainSet restrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.DragonHolyWater); if (restrainSet != null) { maxNum = restrainSet.MaxNum; } int _itemID = 5050; UserGeneral general = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID); if (general == null || general.SaturationNum == 0) { return(false); } var package = UserItemPackage.Get(ContextUser.UserID); var userItemArray = package.ItemPackage.FindAll(m => m.ItemID.Equals(_itemID)); UserItemInfo useritem = new UserItemInfo(); if (userItemArray.Count > 0) { useritem = userItemArray[0]; } else { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1423_UserItemNotEnough; return(false); } ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(useritem.ItemID); if (itemInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1107_UserItemNotEnough; return(false); } var cacheSet = new GameDataCacheSet <UserDailyRestrain>(); UserDailyRestrain userRestrain = cacheSet.FindKey(ContextUser.UserID); if (userRestrain != null && userRestrain.UserExtend != null && userRestrain.UserExtend.WaterNum.Count > 0) { List <DailyRestrain> daliyrestrainList = userRestrain.UserExtend.WaterNum.FindAll(m => m.ID == generalID); useNum = daliyrestrainList.Count; } if (ops == 1) { ErrorCode = ops; ErrorInfo = string.Format(LanguageManager.GetLang().St1423_ClearCurrSatiation, itemInfo.ItemName); return(false); } else if (ops == 2) { if (useNum >= maxNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1423_DragonHolyWater; return(false); } if (general.SaturationNum > 0) { ErrorCode = ops; general.SaturationNum = 0; //general.SaturationNum.Subtraction(itemInfo.SatiationNum, 0); DailyRestrain restrain = new DailyRestrain(); restrain.ID = generalID; if (userRestrain != null) { userRestrain.UserExtend.UpdateNotify(obj => { userRestrain.UserExtend.WaterNum.Add(restrain); return(true); }); } UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1); } } return(true); }