]> git.localhorst.tv Git - l2e.git/blob - src/common/Item.h
added constructors for described types
[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 mostUseful; }
34         bool IsEquipable() const { return equipable; }
35         bool IsCursed() const { return cursed; }
36         bool IsFruit() const { return fruit; }
37         bool IsScenario() const { return scenario; }
38         bool CanSell() const { return !IsScenario(); }
39         bool CanDrop() const { return !IsScenario(); }
40         bool CanUseOnStatusScreen() const { return status; }
41         bool CanUseInBattle() const { return 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 equipability & EQUIPPABLE_WEAPON; }
60         bool CanEquipArmor() const { return equipability & EQUIPPABLE_ARMOR; }
61         bool CanEquipShield() const { return equipability & EQUIPPABLE_SHIELD; }
62         bool CanEquipHelmet() const { return equipability & EQUIPPABLE_HELMET; }
63         bool CanEquipRing() const { return equipability & EQUIPPABLE_RING; }
64         bool CanEquipJewel() const { return equipability & 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() { battle = true; }
88         void SetIkari(const Ikari *i) { ikari = i; }
89         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
90
91         static void CreateTypeDescription();
92         static void Construct(void *);
93
94 private:
95         enum Equipable {
96                 EQUIPPABLE_NONE = 0,
97                 EQUIPPABLE_WEAPON = 1,
98                 EQUIPPABLE_ARMOR = 2,
99                 EQUIPPABLE_SHIELD = 4,
100                 EQUIPPABLE_HELMET = 8,
101                 EQUIPPABLE_RING = 16,
102                 EQUIPPABLE_JEWEL = 32,
103         };
104         enum Property {
105                 PROPERTY_HAS_EFFECT_STATUS = 1,
106                 PROPERTY_HAS_EFFECT_BATTLE = 2,
107                 PROPERTY_HAS_WEAPON_EFFECT = 4,
108                 PROPERTY_HAS_ARMOR_EFFECT = 8,
109                 PROPERTY_INCREASE_ATP = 16,
110                 PROPERTY_INCREASE_DFP = 32,
111                 PROPERTY_INCREASE_STR = 64,
112                 PROPERTY_INCREASE_AGL = 128,
113                 PROPERTY_INCREASE_INT = 256,
114                 PROPERTY_INCREASE_GUT = 512,
115                 PROPERTY_INCREASE_MGR = 1024,
116                 // PROPERTY_UNUSED = 2048,
117                 // PROPERTY_UNUSED = 4096,
118                 PROPERTY_HAS_BATTLE_ANIMATION = 8192,
119                 // PROPERTY_UNKNOWN = 16384,
120                 PROPERTY_HAS_IKARI_EFFECT = 32768,
121         };
122
123 private:
124         const char *name;
125         const graphics::Sprite *menuIcon;
126         const graphics::Sprite *chestIcon;
127         const Ikari *ikari;
128         graphics::Animation *attackAnimation;
129
130         Uint16 value;
131         Uint16 properties;
132
133         TargetingMode targettingMode;
134         Uint8 equipability;
135         HeroGroup equipableBy;
136
137         // TODO: turn these back into bits as soon as fields are implemented in the loader
138         bool mostUseful;
139         bool equipable;
140         bool cursed;
141         bool fruit;
142         bool scenario;
143         bool status;
144         bool battle;
145
146 };
147
148 }
149
150 #endif /* COMMON_ITEM_H_ */