]> git.localhorst.tv Git - l2e.git/blobdiff - src/common/Stats.h
put stat increments in level ladder
[l2e.git] / src / common / Stats.h
index f07528a2f5db86331cf9cd088eb51d9da66b8cdb..f2eed68089d991ef884838f20e6a645bc172bb2c 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef COMMON_STATS_H_
 #define COMMON_STATS_H_
 
+namespace loader {
+       class TypeDescription;
+}
+
+#include <memory>
 #include <SDL.h>
 
 namespace common {
@@ -34,6 +39,21 @@ public:
        static void CreateTypeDescription();
        static void Construct(void *);
 
+public:
+       Stats &operator +=(const Stats &other) {
+               attack += other.attack;
+               defense += other.defense;
+               strength += other.strength;
+               agility += other.agility;
+               intelligence += other.intelligence;
+               magicResistance += other.magicResistance;
+               gut += other.gut;
+               return *this;
+       }
+
+protected:
+       static void AddFields(loader::TypeDescription &, const Stats &, std::ptrdiff_t offset);
+
 private:
        int attack;
        int defense;
@@ -47,14 +67,9 @@ private:
 
 
 inline Stats operator +(const Stats &lhs, const Stats &rhs) {
-       return Stats(
-                       lhs.Attack() + rhs.Attack(),
-                       lhs.Defense() + rhs.Defense(),
-                       lhs.Strength() + rhs.Strength(),
-                       lhs.Agility() + rhs.Agility(),
-                       lhs.Intelligence() + rhs.Intelligence(),
-                       lhs.Gut() + rhs.Gut(),
-                       lhs.MagicResistance() + rhs.MagicResistance());
+       Stats temp(lhs);
+       temp = rhs;
+       return temp;
 }
 
 }