Exemple #1
0
        /// <summary>
        /// Gets highest Usergroup or a user
        /// </summary>
        /// <returns> The highest Usergroup object </returns>
        public Usergroup GetHighestRank()
        {
            var highestRank = new Usergroup();

            foreach (var rank in Usergroups)
            {
                if (rank > highestRank)
                {
                    highestRank = rank;
                }
            }

            return(highestRank);
        }
        /// <summary>
        /// Parses an url to a given badge file and returns the associated <c>Usergroup</c> object matching the file
        /// </summary>
        /// <param name="url"> URL to parse </param>
        /// <param name="group"> <c>Usergroup</c> object where the parsed result will be stored </param>
        /// <returns> true on success, false on failure </returns>
        public static bool FromUrl(string url, out Usergroup group)
        {
            group = new Usergroup();
            var match = Regex.Match(url, @"(?:http|https)+:\/\/(?:cdn|www)+\.elitepvpers\.(?:org|com)+\/forum\/images\/teamicons\/relaunch\/(\S+)");

            if (match.Groups.Count < 2)
            {
                return(false);
            }

            var availableUsergroups = typeof(Usergroup).GetProperties().Where(property => property.PropertyType == typeof(Usergroup));

            foreach (var reflectedUsergroup in availableUsergroups)
            {
                var usergroup = (reflectedUsergroup.GetValue(null, null) as Usergroup);
                if (usergroup.File == match.Groups[1].Value)
                {
                    group = usergroup;
                    return(true);
                }
            }

            return(false);
        }
Exemple #3
0
 /// <summary>
 /// Checks if a user got a specific Usergroup
 /// </summary>
 /// <param name="usergroup"></param>
 /// <returns></returns>
 public bool HasRank(Usergroup usergroup)
 {
     return(Usergroups.Any(userRank => userRank == usergroup));
 }