]> git.localhorst.tv Git - l2e.git/blob - src/common/Item.h
bacdfb090614f37956062327d27a1e75f58a25c7
[l2e.git] / src / common / Item.h
1 #ifndef COMMON_ITEM_H_
2 #define COMMON_ITEM_H_
3
4 namespace common {
5         class Ikari;
6 }
7 namespace graphics {
8         class Animation;
9         class Sprite;
10 }
11
12 #include "Hero.h"
13 #include "TargetingMode.h"
14
15 #include <SDL.h>
16
17 namespace common {
18
19 class Item {
20
21 public:
22         static const int TYPE_ID = 303;
23
24 public:
25         Item();
26
27 public:
28         const char *Name() const { return name; }
29
30         bool IsMostUseful() const { return mostUseful; }
31         bool IsEquipable() const { return equipability; }
32         bool IsCursed() const { return cursed; }
33         bool IsFruit() const { return fruit; }
34         bool IsScenario() const { return scenario; }
35         bool CanSell() const { return !IsScenario(); }
36         bool CanDrop() const { return !IsScenario(); }
37         bool CanUseOnStatusScreen() const { return status; }
38         bool CanUseInBattle() const { return battle; }
39
40         TargetingMode &GetTargetingMode() { return targettingMode; }
41         const TargetingMode &GetTargetingMode() const { return targettingMode; }
42
43         bool HasMenuIcon() const { return menuIcon; }
44         const graphics::Sprite *MenuIcon() const { return menuIcon; }
45         bool HasChestIcon() const { return chestIcon; }
46         const graphics::Sprite *ChestIcon() const { return chestIcon; }
47
48         bool HasIkari() const { return ikari; }
49         const Ikari *GetIkari() const { return ikari; }
50
51         graphics::Animation *AttackAnimation() { return attackAnimation; }
52         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
53
54         Uint16 Value() const { return value; }
55
56         bool EquipableAt(Hero::EquipSlot slot) const { return equipability & (1 << slot); }
57
58         int HeroMask() const { return heroMask; }
59
60         bool HasEffectOnStatusScreen() const { return properties & PROPERTY_HAS_EFFECT_STATUS; }
61         bool HasEffectInBattle() const { return properties & PROPERTY_HAS_EFFECT_BATTLE; }
62         bool HasWeaponEffect() const { return properties & PROPERTY_HAS_WEAPON_EFFECT; }
63         bool HasArmorEffect() const { return properties & PROPERTY_HAS_ARMOR_EFFECT; }
64         bool IncreasesATP() const { return properties & PROPERTY_INCREASE_ATP; }
65         bool IncreasesDFP() const { return properties & PROPERTY_INCREASE_DFP; }
66         bool IncreasesSTR() const { return properties & PROPERTY_INCREASE_STR; }
67         bool IncreasesAGL() const { return properties & PROPERTY_INCREASE_AGL; }
68         bool IncreasesINT() const { return properties & PROPERTY_INCREASE_INT; }
69         bool IncreasesGUT() const { return properties & PROPERTY_INCREASE_GUT; }
70         bool IncreasesMGR() const { return properties & PROPERTY_INCREASE_MGR; }
71         bool HasBattleAnimation() const { return properties & PROPERTY_HAS_BATTLE_ANIMATION; }
72         bool HasIkariEffect() const { return properties & PROPERTY_HAS_IKARI_EFFECT; }
73
74         static bool Less(const Item &, const Item &);
75
76 // temporary setters
77 public:
78         void SetName(const char *n) { name = n; }
79         void SetMenuIcon(const graphics::Sprite *icon) { menuIcon = icon; }
80         void SetUsableInBattle() { battle = true; }
81         void SetIkari(const Ikari *i) { ikari = i; }
82         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
83
84         static void CreateTypeDescription();
85         static void Construct(void *);
86
87 private:
88         enum Property {
89                 PROPERTY_HAS_EFFECT_STATUS = 1,
90                 PROPERTY_HAS_EFFECT_BATTLE = 2,
91                 PROPERTY_HAS_WEAPON_EFFECT = 4,
92                 PROPERTY_HAS_ARMOR_EFFECT = 8,
93                 PROPERTY_INCREASE_ATP = 16,
94                 PROPERTY_INCREASE_DFP = 32,
95                 PROPERTY_INCREASE_STR = 64,
96                 PROPERTY_INCREASE_AGL = 128,
97                 PROPERTY_INCREASE_INT = 256,
98                 PROPERTY_INCREASE_GUT = 512,
99                 PROPERTY_INCREASE_MGR = 1024,
100                 // PROPERTY_UNUSED = 2048,
101                 // PROPERTY_UNUSED = 4096,
102                 PROPERTY_HAS_BATTLE_ANIMATION = 8192,
103                 // PROPERTY_UNKNOWN = 16384,
104                 PROPERTY_HAS_IKARI_EFFECT = 32768,
105         };
106
107 private:
108         const char *name;
109         const graphics::Sprite *menuIcon;
110         const graphics::Sprite *chestIcon;
111         const Ikari *ikari;
112         graphics::Animation *attackAnimation;
113
114         Uint16 value;
115         Uint16 properties;
116
117         TargetingMode targettingMode;
118         int equipability;
119         int heroMask;
120
121         // TODO: turn these back into bits as soon as fields are implemented in the loader
122         bool mostUseful;
123         bool cursed;
124         bool fruit;
125         bool scenario;
126         bool status;
127         bool battle;
128
129 };
130
131 }
132
133 #endif /* COMMON_ITEM_H_ */