示例#1
0
 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);
 }