public bool Equals(ChallengeRating obj)
        {
            // STEP 1: Check for null if nullable (e.g., a reference type)
            if (obj == null)
            {
                return(false);
            }
            // STEP 2: Check for ReferenceEquals if this is a reference type
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }

            // STEP 6: Compare identifying fields for equality.
            return(this.Total == obj.Total);
        }
Exemplo n.º 2
0
        public void CleanAndAssignData(MonsterData data)
        {
            Regex toUpperPat = new Regex("\\b[A-Z]", RegexOptions.IgnoreCase);// from website
            Regex HDPat      = new Regex("(\\d+?)d(\\d+) \\+ (\\d+)|(\\d+)d(\\d+)");
            Regex CRFracPat  = new Regex("([0-9])/([0-9])");
            Match HDMatch    = HDPat.Match(data.hit_dice);
            Match CRMatch    = CRFracPat.Match(data.challenge_rating);

            if (HDMatch.Groups[3].Value == "")//the way the match is set up, the third value is the modifer. if it doesnt have it, go with the standard formula
            {
                HD    = new Die(Convert.ToInt32(HDMatch.Groups[4].Value), Convert.ToInt32(HDMatch.Groups[5].Value));
                ModHD = 0;
            }
            else
            {
                HD    = new Die(Convert.ToInt32(HDMatch.Groups[1].Value), Convert.ToInt32(HDMatch.Groups[2].Value));
                ModHD = Convert.ToInt32(HDMatch.Groups[3].Value);
            }

            if (CRMatch.Success)
            {
                CR = new ChallengeRating(Convert.ToInt32(CRMatch.Groups[1].Value), Convert.ToInt32(CRMatch.Groups[2].Value));
            }
            else
            {
                CR = new ChallengeRating(Convert.ToInt32(data.challenge_rating));
            }

            //making source/types look nice, original format: system-reference-document
            MainType = toUpperPat.Replace(MainType, m => m.ToString().ToUpper());
            if (Subtype != null)
            {
                Subtype = toUpperPat.Replace(Subtype, m => m.ToString().ToUpper());
            }
            if (MonsterGroup != null)
            {
                MonsterGroup = toUpperPat.Replace(MonsterGroup, m => m.ToString().ToUpper());
            }
            Source = Source.Replace('-', ' ');
            Source = toUpperPat.Replace(Source, m => m.ToString().ToUpper());
        }