]> git.localhorst.tv Git - l2e.git/blob - src/common/Item.h
279235572768662e820ea60b3fd15533f31a099a
[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 "HeroGroup.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 equipable; }
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 CanEquipWeapon() const { return equipability & EQUIPPABLE_WEAPON; }
58         bool CanEquipArmor() const { return equipability & EQUIPPABLE_ARMOR; }
59         bool CanEquipShield() const { return equipability & EQUIPPABLE_SHIELD; }
60         bool CanEquipHelmet() const { return equipability & EQUIPPABLE_HELMET; }
61         bool CanEquipRing() const { return equipability & EQUIPPABLE_RING; }
62         bool CanEquipJewel() const { return equipability & EQUIPPABLE_JEWEL; }
63
64         HeroGroup &EquipableBy() { return equipableBy; }
65         const HeroGroup &EquipableBy() const { return equipableBy; }
66
67         bool HasEffectOnStatusScreen() const { return properties & PROPERTY_HAS_EFFECT_STATUS; }
68         bool HasEffectInBattle() const { return properties & PROPERTY_HAS_EFFECT_BATTLE; }
69         bool HasWeaponEffect() const { return properties & PROPERTY_HAS_WEAPON_EFFECT; }
70         bool HasArmorEffect() const { return properties & PROPERTY_HAS_ARMOR_EFFECT; }
71         bool IncreasesATP() const { return properties & PROPERTY_INCREASE_ATP; }
72         bool IncreasesDFP() const { return properties & PROPERTY_INCREASE_DFP; }
73         bool IncreasesSTR() const { return properties & PROPERTY_INCREASE_STR; }
74         bool IncreasesAGL() const { return properties & PROPERTY_INCREASE_AGL; }
75         bool IncreasesINT() const { return properties & PROPERTY_INCREASE_INT; }
76         bool IncreasesGUT() const { return properties & PROPERTY_INCREASE_GUT; }
77         bool IncreasesMGR() const { return properties & PROPERTY_INCREASE_MGR; }
78         bool HasBattleAnimation() const { return properties & PROPERTY_HAS_BATTLE_ANIMATION; }
79         bool HasIkariEffect() const { return properties & PROPERTY_HAS_IKARI_EFFECT; }
80
81 // temporary setters
82 public:
83         void SetName(const char *n) { name = n; }
84         void SetMenuIcon(const graphics::Sprite *icon) { menuIcon = icon; }
85         void SetUsableInBattle() { battle = true; }
86         void SetIkari(const Ikari *i) { ikari = i; }
87         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
88
89         static void CreateTypeDescription();
90         static void Construct(void *);
91
92 private:
93         enum Equipable {
94                 EQUIPPABLE_NONE = 0,
95                 EQUIPPABLE_WEAPON = 1,
96                 EQUIPPABLE_ARMOR = 2,
97                 EQUIPPABLE_SHIELD = 4,
98                 EQUIPPABLE_HELMET = 8,
99                 EQUIPPABLE_RING = 16,
100                 EQUIPPABLE_JEWEL = 32,
101         };
102         enum Property {
103                 PROPERTY_HAS_EFFECT_STATUS = 1,
104                 PROPERTY_HAS_EFFECT_BATTLE = 2,
105                 PROPERTY_HAS_WEAPON_EFFECT = 4,
106                 PROPERTY_HAS_ARMOR_EFFECT = 8,
107                 PROPERTY_INCREASE_ATP = 16,
108                 PROPERTY_INCREASE_DFP = 32,
109                 PROPERTY_INCREASE_STR = 64,
110                 PROPERTY_INCREASE_AGL = 128,
111                 PROPERTY_INCREASE_INT = 256,
112                 PROPERTY_INCREASE_GUT = 512,
113                 PROPERTY_INCREASE_MGR = 1024,
114                 // PROPERTY_UNUSED = 2048,
115                 // PROPERTY_UNUSED = 4096,
116                 PROPERTY_HAS_BATTLE_ANIMATION = 8192,
117                 // PROPERTY_UNKNOWN = 16384,
118                 PROPERTY_HAS_IKARI_EFFECT = 32768,
119         };
120
121 private:
122         const char *name;
123         const graphics::Sprite *menuIcon;
124         const graphics::Sprite *chestIcon;
125         const Ikari *ikari;
126         graphics::Animation *attackAnimation;
127
128         Uint16 value;
129         Uint16 properties;
130
131         TargetingMode targettingMode;
132         Uint8 equipability;
133         HeroGroup equipableBy;
134
135         // TODO: turn these back into bits as soon as fields are implemented in the loader
136         bool mostUseful;
137         bool equipable;
138         bool cursed;
139         bool fruit;
140         bool scenario;
141         bool status;
142         bool battle;
143
144 };
145
146 }
147
148 #endif /* COMMON_ITEM_H_ */