ActivEarth.Objects.Profile.User.GetStatistic C# (CSharp) Method

GetStatistic() public method

public GetStatistic ( Statistic statToGet ) : float
statToGet Statistic
return float
        public float GetStatistic(Statistic statToGet)
        {
            if (_stats.ContainsKey(statToGet))
            {
                return _stats[statToGet].Value;
            }
            else
            {
                return 0;
            }
        }

Usage Example

Esempio n. 1
0
 /// <summary>
 /// Gets the progress made by a user in the challenge.
 /// </summary>
 /// <param name="user">The user to evaluate.</param>
 /// <returns>Minimum of the user's progress and the challenge's requirement 
 /// (for use in a progress bar).</returns>
 public float GetProgress(User user)
 {
     if (user.ChallengeInitialValues.ContainsKey(this.ID))
     {
         float startingPoint = user.ChallengeInitialValues[this.ID];
         return Math.Min(user.GetStatistic(this.StatisticBinding) - startingPoint,
             this.Requirement);
     }
     else
     {
         //TODO: Throw an exception here?
         return -1;
     }
 }