]> git.localhorst.tv Git - l2e.git/blob - src/common/Item.h
Merge branch 'loader'
[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 "HeroGroup.h"
12 #include "TargetingMode.h"
13
14 #include <SDL.h>
15
16 namespace graphics {
17         class Animation;
18         class Sprite;
19 }
20
21 namespace common {
22
23 class Ikari;
24
25 class Item {
26
27 public:
28         Item();
29
30 public:
31         const char *Name() const { return name; }
32
33         bool IsMostUseful() const { return usability & USABILITY_MOST_USEFUL; }
34         bool IsEquipable() const { return usability & USABILITY_EQUIPABLE; }
35         bool IsCursed() const { return usability & USABILITY_CURSED; }
36         bool IsFruit() const { return usability & USABILITY_FRUIT; }
37         bool IsScenario() const { return usability & USABILITY_SCENARIO; }
38         bool CanSell() const { return !IsScenario(); }
39         bool CanDrop() const { return !IsScenario(); }
40         bool CanUseOnStatusScreen() const { return usability & USABILITY_STATUS; }
41         bool CanUseInBattle() const { return usability & USABILITY_BATTLE; }
42
43         TargetingMode &GetTargetingMode() { return targettingMode; }
44         const TargetingMode &GetTargetingMode() const { return targettingMode; }
45
46         bool HasMenuIcon() const { return menuIcon; }
47         const graphics::Sprite *MenuIcon() const { return menuIcon; }
48         bool HasChestIcon() const { return chestIcon; }
49         const graphics::Sprite *ChestIcon() const { return chestIcon; }
50
51         bool HasIkari() const { return ikari; }
52         const Ikari *GetIkari() const { return ikari; }
53
54         graphics::Animation *AttackAnimation() { return attackAnimation; }
55         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
56
57         Uint16 Value() const { return value; }
58
59         bool CanEquipWeapon() const { return equipable & EQUIPPABLE_WEAPON; }
60         bool CanEquipArmor() const { return equipable & EQUIPPABLE_ARMOR; }
61         bool CanEquipShield() const { return equipable & EQUIPPABLE_SHIELD; }
62         bool CanEquipHelmet() const { return equipable & EQUIPPABLE_HELMET; }
63         bool CanEquipRing() const { return equipable & EQUIPPABLE_RING; }
64         bool CanEquipJewel() const { return equipable & EQUIPPABLE_JEWEL; }
65
66         HeroGroup &EquipableBy() { return equipableBy; }
67         const HeroGroup &EquipableBy() const { return equipableBy; }
68
69         bool HasEffectOnStatusScreen() const { return properties & PROPERTY_HAS_EFFECT_STATUS; }
70         bool HasEffectInBattle() const { return properties & PROPERTY_HAS_EFFECT_BATTLE; }
71         bool HasWeaponEffect() const { return properties & PROPERTY_HAS_WEAPON_EFFECT; }
72         bool HasArmorEffect() const { return properties & PROPERTY_HAS_ARMOR_EFFECT; }
73         bool IncreasesATP() const { return properties & PROPERTY_INCREASE_ATP; }
74         bool IncreasesDFP() const { return properties & PROPERTY_INCREASE_DFP; }
75         bool IncreasesSTR() const { return properties & PROPERTY_INCREASE_STR; }
76         bool IncreasesAGL() const { return properties & PROPERTY_INCREASE_AGL; }
77         bool IncreasesINT() const { return properties & PROPERTY_INCREASE_INT; }
78         bool IncreasesGUT() const { return properties & PROPERTY_INCREASE_GUT; }
79         bool IncreasesMGR() const { return properties & PROPERTY_INCREASE_MGR; }
80         bool HasBattleAnimation() const { return properties & PROPERTY_HAS_BATTLE_ANIMATION; }
81         bool HasIkariEffect() const { return properties & PROPERTY_HAS_IKARI_EFFECT; }
82
83 // temporary setters
84 public:
85         void SetName(const char *n) { name = n; }
86         void SetMenuIcon(const graphics::Sprite *icon) { menuIcon = icon; }
87         void SetUsableInBattle() { usability |= USABILITY_BATTLE; }
88         void SetIkari(const Ikari *i) { ikari = i; }
89         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
90
91 private:
92         enum Usability {
93                 USABILITY_MOST_USEFUL = 1,
94                 USABILITY_EQUIPABLE = 2,
95                 // USABILITY_UNUSED = 4,
96                 USABILITY_CURSED = 8,
97                 USABILITY_FRUIT = 16,
98                 USABILITY_SCENARIO = 32,
99                 USABILITY_STATUS = 64,
100                 USABILITY_BATTLE = 128,
101         };
102         enum Equipable {
103                 EQUIPPABLE_NONE = 0,
104                 EQUIPPABLE_WEAPON = 1,
105                 EQUIPPABLE_ARMOR = 2,
106                 EQUIPPABLE_SHIELD = 4,
107                 EQUIPPABLE_HELMET = 8,
108                 EQUIPPABLE_RING = 16,
109                 EQUIPPABLE_JEWEL = 32,
110         };
111         enum Property {
112                 PROPERTY_HAS_EFFECT_STATUS = 1,
113                 PROPERTY_HAS_EFFECT_BATTLE = 2,
114                 PROPERTY_HAS_WEAPON_EFFECT = 4,
115                 PROPERTY_HAS_ARMOR_EFFECT = 8,
116                 PROPERTY_INCREASE_ATP = 16,
117                 PROPERTY_INCREASE_DFP = 32,
118                 PROPERTY_INCREASE_STR = 64,
119                 PROPERTY_INCREASE_AGL = 128,
120                 PROPERTY_INCREASE_INT = 256,
121                 PROPERTY_INCREASE_GUT = 512,
122                 PROPERTY_INCREASE_MGR = 1024,
123                 // PROPERTY_UNUSED = 2048,
124                 // PROPERTY_UNUSED = 4096,
125                 PROPERTY_HAS_BATTLE_ANIMATION = 8192,
126                 // PROPERTY_UNKNOWN = 16384,
127                 PROPERTY_HAS_IKARI_EFFECT = 32768,
128         };
129
130 private:
131         const char *name;
132         const graphics::Sprite *menuIcon;
133         const graphics::Sprite *chestIcon;
134         const Ikari *ikari;
135         graphics::Animation *attackAnimation;
136
137         Uint16 value;
138         Uint16 properties;
139
140         Uint8 usability;
141         TargetingMode targettingMode;
142         Uint8 equipable;
143         HeroGroup equipableBy;
144
145 };
146
147 }
148
149 #endif /* COMMON_ITEM_H_ */