#ifndef COMMON_STATS_H_
#define COMMON_STATS_H_
+namespace loader {
+ class TypeDescription;
+}
+
+#include <memory>
#include <SDL.h>
namespace common {
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;
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;
}
}
-#endif /* COMMON_STATS_H_ */
+#endif