]> git.tdb.fi Git - poefilter.git/blobdiff - source/rangecondition.h
Correctly merge icon and light beam appearances
[poefilter.git] / source / rangecondition.h
index a72fec2d1475db075baffbeb1ed46aa3979480e0..7d85125b6dae6392be187bf4932bf14b54f57867 100644 (file)
@@ -20,6 +20,7 @@ public:
        RangeCondition(Type, Type);
 
        virtual RangeCondition<T> *clone() const;
+       virtual bool equals(const Condition &) const;
        virtual bool can_merge(const Condition &, const CompoundCondition &) const;
        virtual RangeCondition<T> *merge(const std::vector<const Condition *> &, const CompoundCondition &) const;
        virtual bool is_viable() const { return min<=max; }
@@ -71,6 +72,17 @@ struct DropLevelTraits
 typedef RangeCondition<DropLevelTraits> DropLevelCondition;
 
 
+struct MapTierTraits
+{
+       typedef unsigned Type;
+       static unsigned get_min() { return 1; }
+       static unsigned get_max() { return 17; }
+       static const char *get_keyword() { return "MapTier"; }
+};
+
+typedef RangeCondition<MapTierTraits> MapTierCondition;
+
+
 struct WidthTraits
 {
        typedef unsigned Type;
@@ -133,6 +145,16 @@ RangeCondition<T> *RangeCondition<T>::clone() const
        return new RangeCondition<T>(min, max);
 }
 
+template<typename T>
+bool RangeCondition<T>::equals(const Condition &other) const
+{
+       const RangeCondition<T> *other_range = dynamic_cast<const RangeCondition<T> *>(&other);
+       if(!other_range)
+               return false;
+
+       return (min==other_range->min && max==other_range->max);
+}
+
 template<typename T>
 bool RangeCondition<T>::can_merge(const Condition &other, const CompoundCondition &parent) const
 {