]> git.localhorst.tv Git - l2e.git/blob - src/common/Stats.h
put stat increments in level ladder
[l2e.git] / src / common / Stats.h
1 #ifndef COMMON_STATS_H_
2 #define COMMON_STATS_H_
3
4 namespace loader {
5         class TypeDescription;
6 }
7
8 #include <memory>
9 #include <SDL.h>
10
11 namespace common {
12
13 class Stats {
14
15 public:
16         static const int TYPE_ID = 305;
17
18 public:
19         Stats();
20         Stats(Uint16 attack, Uint16 defense, Uint16 strength, Uint16 agility, Uint16 intelligence, Uint8 gut, Uint16 magicResistance);
21
22 public:
23         Uint16 Attack() const { return attack; }
24         Uint16 Defense() const { return defense; }
25         Uint16 Strength() const { return strength; }
26         Uint16 Agility() const { return agility; }
27         Uint16 Intelligence() const { return intelligence; }
28         Uint8 Gut() const { return gut; }
29         Uint16 MagicResistance() const { return magicResistance; }
30
31         void SetAttack(Uint16 a) { attack = a; }
32         void SetDefense(Uint16 d) { defense = d; }
33         void SetStrength(Uint16 s) { strength = s; }
34         void SetAgility(Uint16 a) { agility = a; }
35         void SetIntelligence(Uint16 i) { intelligence = i; }
36         void SetGut(Uint8 g) { gut = g; }
37         void SetMagicResistance(Uint16 m) { magicResistance = m; }
38
39         static void CreateTypeDescription();
40         static void Construct(void *);
41
42 public:
43         Stats &operator +=(const Stats &other) {
44                 attack += other.attack;
45                 defense += other.defense;
46                 strength += other.strength;
47                 agility += other.agility;
48                 intelligence += other.intelligence;
49                 magicResistance += other.magicResistance;
50                 gut += other.gut;
51                 return *this;
52         }
53
54 protected:
55         static void AddFields(loader::TypeDescription &, const Stats &, std::ptrdiff_t offset);
56
57 private:
58         int attack;
59         int defense;
60         int strength;
61         int agility;
62         int intelligence;
63         int magicResistance;
64         int gut;
65
66 };
67
68
69 inline Stats operator +(const Stats &lhs, const Stats &rhs) {
70         Stats temp(lhs);
71         temp = rhs;
72         return temp;
73 }
74
75 }
76
77 #endif