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