Esempio n. 1
0
 public SavedBuffSet(String name, List <Buff> buffSet)
 {
     Name = name;
     if (buffSet != null)
     {
         List <Buff> toSave = new List <Buff>();
         if (SetAsString == null)
         {
             SetAsString = new List <string>();
         }
         else
         {
             SetAsString.Clear();
         }
         foreach (Buff b in buffSet)
         {
             if (b == null /*|| b.Group == null*/)
             {
                 continue;
             }
             // Remove these since they are tied to other stuff and will be auto-enforced by other means
             // We will also not be looking at them when doing an Equals check
             // null Group names are Improvements of other buffs, like Double Pot Tricks
             if (b.Group == null || b.Group == "Set Bonuses" || b.Group == "Profession Buffs")
             {
             }
             else
             {
                 toSave.Add(b);
             }
         }
         foreach (Buff b in toSave)
         {
             SetAsString.Add(b.Name);
         }
         BuffSet = toSave;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// This function is overridden to remove Set Bonuses and Professions Buffs. It will still compare the rest.
        /// </summary>
        /// <param name="otherBuffSet"></param>
        /// <returns></returns>
        public bool Equals(List <Buff> otherBuffSet)
        {
            // Fail on null sets
            if (otherBuffSet == null || SetAsString == null)
            {
                return(false);
            }

            List <string> otherset;

            // Fail on different sizes
            if (SetAsString.Count != (otherset = GenSetAsString(otherBuffSet)).Count)
            {
                return(false);
            }

            // If both are empty, we can stop processing here
            if ((SetAsString.Count + otherset.Count) == 0)
            {
                return(true);
            }

            // Check each array to see if the opposite one is missing a buff that the original contains
            bool noMatch = false;

            foreach (String t in SetAsString)
            {
                // Check other set to see if anything in this set isn't there
                if (!otherset.Contains(t))
                {
                    noMatch = true; break;
                }
            }
            if (noMatch)
            {
                return(false);
            }
            foreach (String o in otherset)
            {
                // Check this set to see if anything in other set isn't there
                if (!SetAsString.Contains(o))
                {
                    noMatch = true; break;
                }
            }
            if (noMatch)
            {
                return(false);
            }

            return(true);

            /* // Remove Buffs we don't want to verify in equality: Set Bonuses and Profession Buffs
             * List<Buff> clonedotherBuffSet = new List<Buff>();
             * List<Buff> toRemove = new List<Buff>();
             * foreach (Buff b in otherBuffSet) {
             *  if (b == null || b.Group == null) continue;
             *  if (b.Group == "Set Bonuses" || b.Group == "Profession Buffs") { } else { clonedotherBuffSet.Add(b); }
             * }
             * // Fail on not the same array size, this saves us some processing time when we already know it won't match
             * if (BuffSet.Count != clonedotherBuffSet.Count) {
             *  return false;
             * }
             * // Replicate the arrays for easier direct comparison
             * List<String> thisSetAsStrings = new List<String>(); foreach (Buff b in BuffSet) { thisSetAsStrings.Add(b.Name); } thisSetAsStrings.Sort();
             * List<String> otherSetAsStrings = new List<String>(); foreach (Buff b in clonedotherBuffSet) { otherSetAsStrings.Add(b.Name); } otherSetAsStrings.Sort();
             * // Check each array to see if the opposite one is missing a buff that the original contains
             * bool noMatch = false;
             * foreach (String t in thisSetAsStrings) {
             *  // Check other set to see if anything in this set isn't there
             *  if (!otherSetAsStrings.Contains(t)) { noMatch = true; break; }
             * }
             * if (noMatch) return false;
             * foreach (String o in otherSetAsStrings) {
             *  // Check this set to see if anything in other set isn't there
             *  if (!thisSetAsStrings.Contains(o)) { noMatch = true; break; }
             * }
             * if (noMatch) return false;
             *
             * // If nothing else failed, return true
             * return true;
             */
            //return thisSetAsStrings.Equals(otherSetAsStrings);
        }