示例#1
0
        /// <summary>
        /// </summary>
        /// <param name="checkpoint"></param>
        /// <param name="cpScore"></param>
        /// <param name="update"></param>
        /// <returns></returns>
        public bool SetScore(int checkpoint, UpdateScore updateScore, ICycleScoreUpdater update)
        {
            var cpScore = new CpScore(updateScore.ResistanceScore.Value, updateScore.EnlightenedScore.Value);

            _scores[checkpoint] = cpScore;
            //this saves it
            return(update.UpdateScore(Cycle, checkpoint, long.Parse(updateScore.TimeStamp), cpScore));
        }
示例#2
0
 public bool HasExactScore(int cp, UpdateScore newScore)
 {
     CpScore existingScore;
     if (!_scores.TryGetValue(cp, out existingScore))
     {
         return false;
     }
     if (existingScore.EnlightenedScore == newScore.EnlightenedScore && existingScore.ResistanceScore == newScore.ResistanceScore)
     {
         return true;
     }
     return false;
 }
示例#3
0
        public bool HasExactScore(int cp, UpdateScore newScore)
        {
            CpScore existingScore;

            if (!_scores.TryGetValue(cp, out existingScore))
            {
                return(false);
            }
            if (existingScore.EnlightenedScore == newScore.EnlightenedScore && existingScore.ResistanceScore == newScore.ResistanceScore)
            {
                return(true);
            }
            return(false);
        }
示例#4
0
        /// <summary>
        ///     return reason not updatable
        /// </summary>
        /// <param name="cpScore"></param>
        /// <param name="checkpoint"></param>
        /// <param name="currentCheckPoint"></param>
        /// <returns></returns>
        public string IsUpdatable(UpdateScore cpScore, int checkpoint, CheckPoint currentCheckPoint)
        {
            if (Cycle.Id > currentCheckPoint.Cycle.Id)
            {
                return("Cannot set a cycle that is in the future");
            }
            if (currentCheckPoint.Cycle.Id == Cycle.Id && checkpoint > currentCheckPoint.CP)
            {
                //only check this if the cycle is the same, else it's probably a previous cycle? Add some testing to explore this.
                return("Cannot set a checkpoint that is in the future");
            }
            if (HasExactScore(checkpoint, cpScore))
            {
                return("has exact score");
            }

            if (long.Parse(cpScore.TimeStamp) != _timestampTicks)
            {
                return("timestamp invalid");
            }
            return(null);
        }
 /// <summary>
 /// </summary>
 /// <param name="checkpoint"></param>
 /// <param name="updateScore"></param>
 /// <param name="update"></param>
 /// <returns></returns>
 public bool SetScore(int checkpoint, UpdateScore updateScore, ICycleScoreUpdater update)
 {
     var cpScore = new CpScore(updateScore.ResistanceScore.Value, updateScore.EnlightenedScore.Value, updateScore.Kudos);
     _scores[checkpoint] = cpScore;
     //this persists it
     return update.UpdateScore(Cycle, checkpoint, updateScore.ConvertTimeStamp(), cpScore);
 }
        /// <summary>
        ///     return reason not updatable
        /// </summary>
        /// <param name="cpScore"></param>
        /// <param name="checkpoint"></param>
        /// <returns></returns>
        public string IsUpdatable(UpdateScore cpScore, int checkpoint)
        {
            //DO NOT CHANGE
            if (checkpoint > _maxCheckPoint)
            {
                //only check this if the cycle is the same, else it's probably a previous cycle? Add some testing to explore this.
                return "Cannot set a checkpoint that is in the future";
            }
            if (HasExactScore(checkpoint,cpScore))
            {
                return "has exact score";
            }

            if (cpScore.ConvertTimeStamp() != _timestampTicks)
            {
                return "timestamp invalid";
            }
            return null;
        }
        public string SetScore(int cycleId, int checkpoint, UpdateScore newScore)
        {
            //Do you need to explicitly overwrite
            //is it the same score?
            //was it okay?
            var cycle = GetScoreForCycle(cycleId);
            var reason = cycle.IsUpdatable(newScore, checkpoint, CheckPoint.Current());
            if (!string.IsNullOrEmpty(reason))
            {
                return reason;
            }
            if (!cycle.SetScore(checkpoint, newScore, _scoreUpdater))
            {
                return "SetScore Failed. Probably someone else updated it already.";
            }

            if (!cycle.HasMissingCPs())
            {
                PostToSlack(cycle);
                return "post to slack";
            }

            return "OK";
        }
示例#8
0
 /// <summary>
 /// </summary>
 /// <param name="checkpoint"></param>
 /// <param name="cpScore"></param>
 /// <param name="update"></param>
 /// <returns></returns>
 public bool SetScore(int checkpoint, UpdateScore updateScore, ICycleScoreUpdater update)
 {
     var cpScore = new CpScore(updateScore.ResistanceScore.Value, updateScore.EnlightenedScore.Value);
     _scores[checkpoint] = cpScore;
     //this saves it
     return update.UpdateScore(Cycle, checkpoint, long.Parse(updateScore.TimeStamp), cpScore);
 }
示例#9
0
        /// <summary>
        ///     return reason not updatable
        /// </summary>
        /// <param name="cpScore"></param>
        /// <param name="checkpoint"></param>
        /// <param name="currentCheckPoint"></param>
        /// <returns></returns>
        public string IsUpdatable(UpdateScore cpScore, int checkpoint, CheckPoint currentCheckPoint)
        {
            if (Cycle.Id > currentCheckPoint.Cycle.Id)
            {
                return "Cannot set a cycle that is in the future";
            }
            if (currentCheckPoint.Cycle.Id == Cycle.Id && checkpoint > currentCheckPoint.CP)
            {
                //only check this if the cycle is the same, else it's probably a previous cycle? Add some testing to explore this.
                return "Cannot set a checkpoint that is in the future";
            }
            if (HasExactScore(checkpoint,cpScore))
            {
                return "has exact score";
            }

            if (long.Parse(cpScore.TimeStamp) != _timestampTicks)
            {
                return "timestamp invalid";
            }
            return null;
        }