BF2Statistics.MedalData.AwardCache.AddAward C# (CSharp) Method

AddAward() public static method

Used by the parser to add found awards to the list
public static AddAward ( Award A ) : void
A Award The Award Object To Add
return void
        public static void AddAward(Award A)
        {
            // Add award to individual award type collection
            switch (Award.GetType(A.Id))
            {
                case AwardType.Badge:
                    Badges.Add(A);
                    break;
                case AwardType.Medal:
                    Medals.Add(A);
                    break;
                case AwardType.Ribbon:
                    Ribbons.Add(A);
                    break;
            }

            // Add the award to the overall awards cache
            Awards.Add(A.Id, A);

            // Build the award tree here to Initially check for condition errors
            A.ToTree();
        }

Usage Example

Example #1
0
        /// <summary>
        /// This method builds the award cache with the given data from the medal data file.
        /// This method WILL CLEAR the award cache from any existing medals
        /// </summary>
        /// <param name="MedalsMatches"></param>
        /// <param name="RanksMatches"></param>
        public static void BuildAwardCache(MatchCollection MedalsMatches, MatchCollection RanksMatches)
        {
            // Clear out the award cache!
            AwardCache.Clear();

            // Convert each medal match into an object, and add it to the award cache
            foreach (Match ArrayMatch in MedalsMatches)
            {
                AwardCache.AddAward(
                    new Award(
                        ArrayMatch.Groups["MedalIntId"].Value,
                        ArrayMatch.Groups["MedalStrId"].Value,
                        ArrayMatch.Groups["RewardType"].Value,
                        ParseCondition(ArrayMatch.Groups["Conditions"].Value)
                        )
                    );
            }

            // Convert ranks into objects, and also add them to the award cache
            foreach (Match ArrayMatch in RanksMatches)
            {
                AwardCache.AddRank(
                    new Rank(
                        Int32.Parse(ArrayMatch.Groups["RankId"].Value),
                        ParseCondition(ArrayMatch.Groups["Conditions"].Value)
                        )
                    );
            }
        }