1 #ifndef RANGECONDITION_H_
2 #define RANGECONDITION_H_
8 class RangeCondition: public Condition
12 typedef typename Traits::Type Type;
20 RangeCondition(Type, Type);
22 virtual Condition *clone() const;
23 virtual void add_lines(std::list<FilterStatement> &) const;
30 static Rarity get_min() { return NORMAL; }
31 static Rarity get_max() { return UNIQUE; }
32 static const char *get_keyword() { return "Rarity"; }
35 typedef RangeCondition<RarityTraits> RarityCondition;
40 typedef unsigned Type;
41 static unsigned get_min() { return 0; }
42 static unsigned get_max() { return 20; }
43 static const char *get_keyword() { return "Quality"; }
46 typedef RangeCondition<QualityTraits> QualityCondition;
49 struct ItemLevelTraits
51 typedef unsigned Type;
52 static unsigned get_min() { return 0; }
53 static unsigned get_max() { return 100; }
54 static const char *get_keyword() { return "ItemLevel"; }
57 typedef RangeCondition<ItemLevelTraits> ItemLevelCondition;
60 struct DropLevelTraits
62 typedef unsigned Type;
63 static unsigned get_min() { return 0; }
64 static unsigned get_max() { return 100; }
65 static const char *get_keyword() { return "DropLevel"; }
68 typedef RangeCondition<DropLevelTraits> DropLevelCondition;
73 typedef unsigned Type;
74 static unsigned get_min() { return 1; }
75 static unsigned get_max() { return 2; }
76 static const char *get_keyword() { return "Width"; }
79 typedef RangeCondition<WidthTraits> WidthCondition;
84 typedef unsigned Type;
85 static unsigned get_min() { return 1; }
86 static unsigned get_max() { return 4; }
87 static const char *get_keyword() { return "Height"; }
90 typedef RangeCondition<HeightTraits> HeightCondition;
95 typedef unsigned Type;
96 static unsigned get_min() { return 1; }
97 static unsigned get_max() { return 6; }
98 static const char *get_keyword() { return "Sockets"; }
101 typedef RangeCondition<SocketsTraits> SocketsCondition;
104 struct LinkedSocketsTraits
106 typedef unsigned Type;
107 static unsigned get_min() { return 1; }
108 static unsigned get_max() { return 6; }
109 static const char *get_keyword() { return "LinkedSockets"; }
112 typedef RangeCondition<LinkedSocketsTraits> LinkedSocketsCondition;
115 template<typename Traits>
116 RangeCondition<Traits>::RangeCondition(Type v):
121 template<typename Traits>
122 RangeCondition<Traits>::RangeCondition(Type n, Type x):
127 template<typename Traits>
128 Condition *RangeCondition<Traits>::clone() const
130 return new RangeCondition<Traits>(min, max);
133 template<typename Traits>
134 void RangeCondition<Traits>::add_lines(std::list<FilterStatement> &st) const
136 const char *keyword = Traits::get_keyword();
138 FilterStatement::add_line(st, Msp::format("%s %s", keyword, min));
141 if(min!=Traits::get_min())
142 FilterStatement::add_line(st, Msp::format("%s >= %s", keyword, min));
143 if(max!=Traits::get_max())
144 FilterStatement::add_line(st, Msp::format("%s <= %s", keyword, max));