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