示例#1
0
 /// <summary>
 /// 答题奖励
 /// </summary>
 /// <param name="userGuild"></param>
 /// <param name="gameActive"></param>
 /// <param name="exuser"></param>
 /// <param name="user"></param>
 public static void DoPrize(UserGuild userGuild, GameActive gameActive, ExerciseUser exuser, GameUser user, ref int expNum, ref int Experience)
 {
     DateTime dt = DateTime.Now;
     if (dt < gameActive.BeginTime)
     {
         userGuild.GuildExercise.Status = 0;
         return;
     }
     if (exuser.Status == GuildExerciseStatus.All ||
         (userGuild.GuildExercise.QuestionNo == exuser.QuestionNo
         && exuser.AnswerStatus))
     {
         GuildExercisePrize prize = new ConfigCacheSet<GuildExercisePrize>().FindKey(userGuild.GuildExercise.Level);
         if (prize == null)
             return;
         decimal precent = GetExercisePrecent(userGuild);
         expNum = (int)Math.Floor((decimal)prize.ExpNum * precent);
         Experience = (int)Math.Floor((decimal)prize.Experience * precent);
         user.ExpNum = MathUtils.Addition(user.ExpNum, expNum, int.MaxValue);
         UserHelper.UserGeneralExp(user.UserID, Experience);
     }
 }
示例#2
0
 public override bool TakeAction()
 {
     ContextUser.UserLocation = Location.City;
     UserGuild guild = new ShareCacheStruct<UserGuild>().FindKey(ContextUser.MercenariesID);
     if (guild == null)
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         return false;
     }
     GameActive gameactive = new ShareCacheStruct<GameActive>().FindKey(11);
     if (gameactive == null || !gameactive.State)
     {
         return false;
     }
     gameactive.BeginTime = gameactive.EnablePeriod.ToDateTime(DateTime.MinValue);
     gameactive.EndTime = gameactive.BeginTime.AddMinutes(gameactive.Minutes);
     DateTime readytime = gameactive.BeginTime.AddMinutes(0 - gameactive.WaitMinutes);
     if (gameactive.BeginTime > DateTime.Now)
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         ErrorInfo = LanguageManager.GetLang().St6301_GuildExerciseNoOpen;
         return false;
     }
     if (gameactive.BeginTime.AddMinutes(gameactive.WaitMinutes) < DateTime.Now && gameactive.EndTime > DateTime.Now)
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         ErrorInfo = LanguageManager.GetLang().St6301_GuildExerciseIsOpen;
         return false;
     }
     if (gameactive.EndTime < DateTime.Now)
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
         ErrorInfo = LanguageManager.GetLang().St6301_GuildExerciseClose;
         return false;
     }
     if (guild.GuildExercise == null)
     {
         TraceLog.ReleaseWriteFatal("重新刷了6301接口1");
         guild.GuildExercise = new GuildExercise();
     }
     if (guild.GuildExercise.QuestionNo > 0)
     {
         TraceLog.ReleaseWriteFatal("重新刷了6301接口2");
         guild.GuildExercise = new GuildExercise();
     }
     if (guild.GuildExercise.UserList.Find(u => u.UserID == ContextUser.UserID) == null)
     {
         ExerciseUser exUser = new ExerciseUser();
         exUser.AnswerStatus = false;
         exUser.QuestionNo = 0;
         exUser.Status = GuildExerciseStatus.Default;
         exUser.UserID = ContextUser.UserID;
         guild.GuildExercise.UpdateNotify(obj =>
             {
                 guild.GuildExercise.UserList.Add(exUser);
                 return true;
             });
         //guild.Update();                
     }
     ContextUser.UserLocation = Location.GuildExercise;
     //ContextUser.Update();
     return true;
 }
示例#3
0
        public static GuildQuestion GetQuestion(UserGuild userGuild, GameActive gameActive, ExerciseUser exUser, ref int ColdTime)
        {
            DateTime dt = DateTime.Now;
            DateTime beginTime = gameActive.BeginTime.AddMinutes(gameActive.WaitMinutes);
            if (dt < gameActive.BeginTime.AddMinutes(gameActive.WaitMinutes))
            {
                ColdTime = (int)(beginTime - dt).TotalSeconds;
                userGuild.GuildExercise.UpdateNotify(obj =>
                    {
                        userGuild.GuildExercise.Status = 1;
                        return true;
                    });
                return null;
            }

            GuildQuestion Question = new GuildQuestion();
            if (userGuild.GuildExercise.QuesTime != null
                && dt < userGuild.GuildExercise.QuesTime.AddSeconds(QuestionWaitTime)
                && userGuild.GuildExercise.QuestionID != 0)
            {
                Question = new ConfigCacheSet<GuildQuestion>().FindKey(userGuild.GuildExercise.QuestionID);
            }
            else
            {
                int questionid = GetID(userGuild.GuildExercise.QuestionIDList.ToList());
                userGuild.GuildExercise.QuestionID = questionid;
                Question = new ConfigCacheSet<GuildQuestion>().FindKey(userGuild.GuildExercise.QuestionID);
                userGuild.GuildExercise.UpdateNotify(obj =>
                {
                    if (userGuild.GuildExercise.QuesTime < beginTime)
                        userGuild.GuildExercise.QuesTime = beginTime;
                    int count = ((int)(dt - userGuild.GuildExercise.QuesTime).TotalSeconds) / QuestionWaitTime;
                    if (count <= 0)
                    {
                        count = 0;
                    }
                    userGuild.GuildExercise.QuestionNo = MathUtils.Addition(userGuild.GuildExercise.QuestionNo, (count <= 1 ? 1 : count), int.MaxValue);
                    userGuild.GuildExercise.QuesTime = beginTime.AddSeconds((userGuild.GuildExercise.QuestionNo - 1) * QuestionWaitTime);
                    userGuild.GuildExercise.Status = 2; //已开始活动
                    userGuild.GuildExercise.CheckAllAnswer = 0;
                    return true;
                });//userGuild.Update();
                exUser.QuestionStatus = GuildQuestionStatus.ToAnswer;
            }
            ColdTime = QuestionWaitTime - (int)(dt - userGuild.GuildExercise.QuesTime).TotalSeconds;

            if (userGuild.GuildExercise.CheckAllAnswer == 0)
            {
                ColdTime -= 10;
            }

            if (ColdTime <= 0)
            {
                ColdTime = 0;
                return null;
            }
            return Question;
        }