1 //       _________ __                 __
2 //      /   _____//  |_____________ _/  |______     ____  __ __  ______
3 //      \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
4 //      /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ |
5 //     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
6 //             \/                  \/          \//_____/            \/
7 //  ______________________                           ______________________
8 //                        T H E   W A R   B E G I N S
9 //         Stratagus - A free fantasy real time strategy game engine
10 //
11 /**@name item.h - The item headerfile. */
12 //
13 //      (c) Copyright 2015-2019 by Andrettin
14 //
15 //      This program is free software; you can redistribute it and/or modify
16 //      it under the terms of the GNU General Public License as published by
17 //      the Free Software Foundation; only version 2 of the License.
18 //
19 //      This program is distributed in the hope that it will be useful,
20 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
21 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 //      GNU General Public License for more details.
23 //
24 //      You should have received a copy of the GNU General Public License
25 //      along with this program; if not, write to the Free Software
26 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 //      02111-1307, USA.
28 //
29 
30 #ifndef __ITEM_H__
31 #define __ITEM_H__
32 
33 //@{
34 
35 /*----------------------------------------------------------------------------
36 --  Includes
37 ----------------------------------------------------------------------------*/
38 
39 #include <vector>
40 
41 #include "icons.h"
42 
43 /*----------------------------------------------------------------------------
44 --  Declarations
45 ----------------------------------------------------------------------------*/
46 
47 class CCharacter;
48 class CConfigData;
49 class CUnitType;
50 class CUpgrade;
51 class CSpell;
52 class CVariable;
53 
54 /**
55 **  Indexes into item class array.
56 */
57 enum ItemSlots {
58 	WeaponItemSlot,
59 	ShieldItemSlot,
60 	HelmetItemSlot,
61 	ArmorItemSlot,
62 	GlovesItemSlot,
63 	BootsItemSlot,
64 	BeltItemSlot,
65 	AmuletItemSlot,
66 	RingItemSlot,
67 	ArrowsItemSlot,
68 
69 	MaxItemSlots
70 };
71 
72 /**
73 **  Indexes into item class array.
74 */
75 enum ItemClasses {
76 	DaggerItemClass,
77 	SwordItemClass,
78 	ThrustingSwordItemClass,
79 	AxeItemClass,
80 	MaceItemClass,
81 	SpearItemClass,
82 	BowItemClass,
83 	ThrowingAxeItemClass,
84 	JavelinItemClass,
85 	GunItemClass,
86 
87 	ShieldItemClass,
88 	HornItemClass,
89 
90 	HelmetItemClass,
91 	ArmorItemClass,
92 	CloakItemClass,
93 	GlovesItemClass,
94 	BeltItemClass,
95 	BootsItemClass,
96 
97 	AmuletItemClass,
98 	RingItemClass,
99 
100 	ArrowsItemClass,
101 
102 	FoodItemClass,
103 	PotionItemClass,
104 	ScrollItemClass,
105 	BookItemClass,
106 
107 	MaxItemClasses
108 };
109 
110 class CUniqueItem
111 {
112 public:
CUniqueItem()113 	CUniqueItem() :
114 		ResourcesHeld(0), Type(nullptr), Prefix(nullptr), Suffix(nullptr), Set(nullptr), Spell(nullptr), Work(nullptr), Elixir(nullptr)
115 	{
116 	}
117 
118 	bool CanDrop() const;				/// Check whether this unique item can drop
119 	int GetMagicLevel() const;			/// Get this unique item's magic level
120 	IconConfig GetIcon() const;
121 
122 	int ResourcesHeld;
123 	std::string Ident;
124 	std::string Name;
125 	std::string Description;
126 	std::string Background;
127 	std::string Quote;
128 	IconConfig Icon;			/// Unique item's icon (if it differs from that of its type)
129 	CUnitType *Type;			/// Item type of the item
130 	CUpgrade *Prefix;
131 	CUpgrade *Suffix;
132 	CUpgrade *Set;
133 	CSpell *Spell;
134 	CUpgrade *Work;
135 	CUpgrade *Elixir;
136 };
137 
138 class CPersistentItem
139 {
140 public:
141 	void ProcessConfigData(const CConfigData *config_data);
142 
143 	std::string Name;
144 	bool Bound = false;			/// Whether the item is bound to its owner and can't be dropped
145 	bool Identified = true;		/// Whether the item has been identified
146 	CUnitType *Type = nullptr;	/// Item type of the item
147 	CUpgrade *Prefix = nullptr;
148 	CUpgrade *Suffix = nullptr;
149 	CSpell *Spell = nullptr;
150 	CUpgrade *Work = nullptr;
151 	CUpgrade *Elixir = nullptr;
152 	CUniqueItem *Unique = nullptr;
153 	CCharacter *Owner = nullptr;
154 };
155 
156 /*----------------------------------------------------------------------------
157 -- Variables
158 ----------------------------------------------------------------------------*/
159 
160 extern std::vector<CUniqueItem *> UniqueItems;
161 
162 /*----------------------------------------------------------------------------
163 -- Functions
164 ----------------------------------------------------------------------------*/
165 
166 extern int GetItemSlotIdByName(const std::string &item_slot);
167 extern std::string GetItemSlotNameById(int item_slot);
168 extern int GetItemClassIdByName(const std::string &item_class);
169 extern std::string GetItemClassNameById(int item_class);
170 extern int GetItemClassSlot(int item_class);
171 extern bool IsItemClassConsumable(int item_class);
172 extern void CleanUniqueItems();
173 extern CUniqueItem *GetUniqueItem(const std::string &item_ident);
174 extern std::string GetItemEffectsString(const std::string &item_ident);
175 extern std::string GetUniqueItemEffectsString(const std::string &item_ident);
176 extern void ItemCclRegister();
177 
178 //@}
179 
180 #endif // !__ITEM_H__
181