/// <summary> /// 每日限制次数 /// </summary> /// <returns></returns> public static int GetVipUseNum(int vipLv, RestrainType restrainType) { int rType = (int)restrainType; int baseNum = 0; int MaxNum = 0; int vipNum = 0; DailyRestrainSet restrainSet = new ShareCacheStruct<DailyRestrainSet>().FindKey(restrainType); if (restrainSet != null) { baseNum = restrainSet.MaxNum; } VipLvInfo lvInfo = new ConfigCacheSet<VipLvInfo>().FindKey(vipLv); var restrainArray = new CacheList<DailyRestrain>(); if (lvInfo != null) { restrainArray = lvInfo.DailyRestrain; } foreach (DailyRestrain daily in restrainArray) { if (daily.ID == rType) { vipNum = daily.Num; } } MaxNum = MathUtils.Addition(baseNum, vipNum, int.MaxValue); return MaxNum; }
/// <summary> /// 每日限制次数 /// </summary> /// <returns></returns> public static int GetVipUseNum(int vipLv, RestrainType restrainType) { int rType = (int)restrainType; int baseNum = 0; int MaxNum = 0; int vipNum = 0; DailyRestrainSet restrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(restrainType); if (restrainSet != null) { baseNum = restrainSet.MaxNum; } VipLvInfo lvInfo = new ShareCacheStruct <VipLvInfo>().FindKey(vipLv); var restrainArray = new CacheList <DailyRestrain>(); if (lvInfo != null) { restrainArray = lvInfo.DailyRestrain; } foreach (DailyRestrain daily in restrainArray) { if (daily.ID == rType) { vipNum = daily.Num; } } MaxNum = MathUtils.Addition(baseNum, vipNum, int.MaxValue); return(MaxNum); }
/// <summary> /// 精力,金矿洞,免费猎命,竞技场挑战次数 /// </summary> /// <param name="user"></param> /// <returns></returns> public static HelperInfo GetDailyEnergy(GameUser user, RestrainType restrainType) { UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(user.UserID); int maxNum = VipHelper.GetVipUseNum(user.VipLv, restrainType); int currPayNum = 0; if (dailyRestrain != null && DateTime.Now.Date == dailyRestrain.RefreshDate.Date) { if (restrainType == RestrainType.GouMaiJingLi) { currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion4, 0); } else if (restrainType == RestrainType.WaJinKuang) { currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion3, 0); } else if (restrainType == RestrainType.MianFeiLieMing) { currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion2, 0); } else if (restrainType == RestrainType.JingJiChangTiaoZhan) { UserChallengeNum userChallenge = new GameDataCacheSet <UserChallengeNum>().FindKey(user.UserID); if (userChallenge != null && DateTime.Now.Date == userChallenge.InsertDate.Date) { //当日总挑战次数 currPayNum = MathUtils.Addition(maxNum, userChallenge.ChallengeNum, int.MaxValue); currPayNum = MathUtils.Subtraction(currPayNum, dailyRestrain.Funtion9, 0); } else { currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion9, 0); } } } else { currPayNum = maxNum; } //if (restrainType == RestrainType.JingJiChangTiaoZhan) //{ // UserChallengeNum userChallenge = new GameDataCacheSet<UserChallengeNum>().FindKey(user.UserID); // if (userChallenge != null && DateTime.Now.Date == userChallenge.InsertDate.Date) // { // currPayNum = currPayNum.Addition(userChallenge.ChallengeNum, int.MaxValue); //当日总挑战次数 // currPayNum = maxNum.Subtraction(currPayNum, 0); // } //} return(new HelperInfo() { Type = restrainType, SurplusNum = currPayNum, TotalNum = maxNum }); }
protected override object this[string index] { get { #region switch (index) { case "UserID": return(UserID); case "RestrainType": return(RestrainType); case "CurrNum": return(CurrNum); case "MaxNum": return(MaxNum); case "RefreshDate": return(RefreshDate); default: throw new ArgumentException(string.Format("UserRestrain index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "UserID": _UserID = value.ToNotNullString(); break; case "RestrainType": _RestrainType = value.ToEnum <RestrainType>(); break; case "CurrNum": _CurrNum = value.ToInt(); break; case "MaxNum": _MaxNum = value.ToInt(); break; case "RefreshDate": _RefreshDate = value.ToDateTime(); break; default: throw new ArgumentException(string.Format("UserRestrain index[{0}] isn't exist.", index)); } #endregion } }
/// <summary> /// 精力,金矿洞,免费猎命,竞技场挑战次数 /// </summary> /// <param name="user"></param> /// <returns></returns> public static HelperInfo GetDailyEnergy(GameUser user, RestrainType restrainType) { UserDailyRestrain dailyRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(user.UserID); int maxNum = VipHelper.GetVipUseNum(user.VipLv, restrainType); int currPayNum = 0; if (dailyRestrain != null && DateTime.Now.Date == dailyRestrain.RefreshDate.Date) { if (restrainType == RestrainType.GouMaiJingLi) { currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion4, 0); } else if (restrainType == RestrainType.WaJinKuang) { currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion3, 0); } else if (restrainType == RestrainType.MianFeiLieMing) { currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion2, 0); } else if (restrainType == RestrainType.JingJiChangTiaoZhan) { UserChallengeNum userChallenge = new GameDataCacheSet<UserChallengeNum>().FindKey(user.UserID); if (userChallenge != null && DateTime.Now.Date == userChallenge.InsertDate.Date) { //当日总挑战次数 currPayNum = MathUtils.Addition(maxNum, userChallenge.ChallengeNum, int.MaxValue); currPayNum = MathUtils.Subtraction(currPayNum, dailyRestrain.Funtion9, 0); } else { currPayNum = MathUtils.Subtraction(maxNum, dailyRestrain.Funtion9, 0); } } } else { currPayNum = maxNum; } //if (restrainType == RestrainType.JingJiChangTiaoZhan) //{ // UserChallengeNum userChallenge = new GameDataCacheSet<UserChallengeNum>().FindKey(user.UserID); // if (userChallenge != null && DateTime.Now.Date == userChallenge.InsertDate.Date) // { // currPayNum = currPayNum.Addition(userChallenge.ChallengeNum, int.MaxValue); //当日总挑战次数 // currPayNum = maxNum.Subtraction(currPayNum, 0); // } //} return new HelperInfo() { Type = restrainType, SurplusNum = currPayNum, TotalNum = maxNum }; }
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="user"></param> /// <returns></returns> public static int DailyRestrainSurplusNum(GameUser user, RestrainType restrainType, int restrainNum) { int surplusNum = 0; UserDailyRestrain dailyRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(user.UserID); DailyRestrainSet dailyRestrainSet = new ShareCacheStruct<DailyRestrainSet>().FindKey(restrainType); if (dailyRestrainSet != null && dailyRestrain != null) { if (dailyRestrain.UserExtend != null && DateTime.Now.Date == dailyRestrain.RefreshDate.Date) { surplusNum = MathUtils.Subtraction(GetVipUseNum(user.VipLv, restrainType), restrainNum, 0); } else { surplusNum = GetVipUseNum(user.VipLv, restrainType); } } return surplusNum; }
/// <summary> /// 每日限制剩余刷新次数 /// </summary> /// <param name="user"></param> /// <returns></returns> public static int DailyRestrainSurplusNum(GameUser user, RestrainType restrainType, int restrainNum) { int surplusNum = 0; UserDailyRestrain dailyRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(user.UserID); DailyRestrainSet dailyRestrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(restrainType); if (dailyRestrainSet != null && dailyRestrain != null) { if (dailyRestrain.UserExtend != null && DateTime.Now.Date == dailyRestrain.RefreshDate.Date) { surplusNum = MathUtils.Subtraction(GetVipUseNum(user.VipLv, restrainType), restrainNum, 0); } else { surplusNum = GetVipUseNum(user.VipLv, restrainType); } } return(surplusNum); }
protected override object this[string index] { get { #region switch (index) { case "RestrainID": return(RestrainID); case "RestrainDesc": return(RestrainDesc); case "MaxNum": return(MaxNum); default: throw new ArgumentException(string.Format("DailyRestrainSet index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "RestrainID": _RestrainID = value.ToEnum <RestrainType>(); break; case "RestrainDesc": _RestrainDesc = value.ToNotNullString(); break; case "MaxNum": _MaxNum = value.ToInt(); break; default: throw new ArgumentException(string.Format("DailyRestrainSet index[{0}] isn't exist.", index)); } #endregion } }
protected override object this[string index] { get { #region switch (index) { case "RestrainID": return RestrainID; case "RestrainDesc": return RestrainDesc; case "MaxNum": return MaxNum; default: throw new ArgumentException(string.Format("DailyRestrainSet index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "RestrainID": _RestrainID = value.ToEnum<RestrainType>(); break; case "RestrainDesc": _RestrainDesc = value.ToNotNullString(); break; case "MaxNum": _MaxNum = value.ToInt(); break; default: throw new ArgumentException(string.Format("DailyRestrainSet index[{0}] isn't exist.", index)); } #endregion } }
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; }
protected override object this[string index] { get { #region switch (index) { case "UserID": return UserID; case "RestrainType": return RestrainType; case "CurrNum": return CurrNum; case "MaxNum": return MaxNum; case "RefreshDate": return RefreshDate; default: throw new ArgumentException(string.Format("UserRestrain index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "UserID": _UserID = value.ToNotNullString(); break; case "RestrainType": _RestrainType = value.ToEnum<RestrainType>(); break; case "CurrNum": _CurrNum = value.ToInt(); break; case "MaxNum": _MaxNum = value.ToInt(); break; case "RefreshDate": _RefreshDate = value.ToDateTime(); break; default: throw new ArgumentException(string.Format("UserRestrain index[{0}] isn't exist.", index)); } #endregion } }
private Restrain(String key, Object[] values, RestrainType restrainType) { this.Key = key; this.Values = values; this.RestrainType = restrainType; }
private Restrain(String key,Object[] values,RestrainType restrainType) { this.Key = key; this.Values = values; this.RestrainType = restrainType; }