-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItem.h
284 lines (215 loc) · 7.21 KB
/
Item.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/**
* @file Item.h
* Item.h defines the methods for the Item.cpp source file.
*
* @brief Defines the Item class.
*
* @author Michael Abrams
* @author James Boocock
* @author Toby Herbert
* @author Tatai Nikora
* @version 0.3
*/
#ifndef _ITEM_H
#define _ITEM_H
//------------------------------------------------------------------------------
/* Include */
//------------------------------------------------------------------------------
#include <string>
#include <vector>
#include <cstring>
#include "StateDescriptor.h"
#include "ItemCommand.h"
#include "combine.h"
class Area;
class Item {
protected:
bool collectable; ///< Flag, whether item can be collected.
int num_descriptions; ///< Number of descriptions for the item.
int num_commands; ///< Number of commands for this item.
int num_items; ///< Number of items contained inside this item.
std::string id; ///< The item's id.
bool container; ///< Whether or not item is a container.
bool locked; ///< Whether or not the item is locked.
combine * combine_var; ///< Pointer to a combine object.
std::vector<Item *> contains; ///< Vector of items contained in this item.
std::string curr_desc_id; ///< The current description of this item.
std::vector<StateDescriptor*> description; ///< Vector of descriptions.
std::vector<ItemCommand*> commands; ///< Vector of commands for item.
std::vector<std::string> *synonyms; ///< Vector of synonyms for the item.
std::string depends; ///< What this item depends on (key).
std::string name; ///< The name of the item.
public:
/**
Removes an item from inside this item by id.
@param[in] item_id A string - the id of the item to remove.
*/
void remove_item(std::string item_id);
/**
Flips the locked variable for this item..
*/
void flip_locked();
/**
Checks whether the the Item is locked.
@return True if the item is locked otherwise false.
*/
bool is_locked();
/**
Checks whether the the Item is a container for
other items.
@return True if the item is a container or false if not.
*/
bool has_container();
/**
Returns a string with all items the item contains.
@return A string of items this item contains.
*/
std::string print_contained_items();
/**
Returns a pointer to an item by id or null if
it does not exist.
@param item_id The id of the item to get.
@return A pointer to an item.
*/
Item* get_item(std::string item_id);
/**
Adds an item to the contains vector.
@param[in] new_item The pointer to an item.
*/
void add_item(Item* new_item);
/**
Checks whether this Item can combine with another.
@return True if this item can be combined with another otherwise false.
*/
bool has_combine();
/**
Accessor for a combine object.
@return A pointer to a combine object.
*/
combine * get_combine();
/**
A mutator for a combine object.
@param[in] c A pointer to a combine object.
*/
void set_combine(combine * c);
/**
Check whether this item has a certain description id.
@param[in] desc_id A string of an item description id.
@return True if this item contains the discription otherwise false.
*/
bool has_description(std::string desc_id);
/**
Check whether this item has the current description.
Calls has_description method passing the curr_desc_id.
@return True if the item has the current description otherwise false.
*/
bool has_current_desc();
/**
Checks whether this item has a particular synonym.
@param[in] item A string that may be a synonym.
@return True if the item has the synonym otherwise false.
*/
bool has_synonym(std::string item);
/**
Gets the item description.
@return The description of the item.
*/
std::string get_description();
/**
Add a StateDescriptor for this item.
@param[in] desc A pointer to a StateDescriptor object to add.
*/
void add_description(StateDescriptor *desc);
/**
Flip the value of collectable for this item.
@param[in] flip True flips the value, false leaves it unchanged.
*/
void change_collectable(bool flip);
/**
Checks whether this item is collectable.
@return Description of returned value.
*/
bool is_collectable();
/**
Gets the id of the item.
@return A string - the id of the item.
*/
std::string get_id();
/**
Gets the number of commands for this item.
@return The number of commands this item has.
*/
int get_num_commands();
/**
Add a command to this item.
@param[in] command_name A pointer to an ItemCommand object.
*/
void add_command(ItemCommand *command_name);
/**
Gets a command from the commands vector for this item by index.
@param[in] index The index of the item in the vector.
@return An ItemCommand object at the specified index.
*/
ItemCommand *get_command(int index);
/**
Gets a command from the commands vector of this item by command_name.
@param[in] command_name A string - the name of the command.
@return An ItemCommand object with the specified name.
*/
ItemCommand *get_command(std::string command_name);
/**
Get the number of descriptions for this item.
@return The number of descriptions for this item.
*/
int get_num_descriptions();
/**
Get a StateDescriptor from the descriptions vector by index.
@param[in] index The index of the StateDescriptor in the vector.
@return A StateDescriptor at the specified index.
*/
StateDescriptor *get_descriptor(int index);
/**
Changes the state of the item.
@return Returns a string - what the item depends on.
*/
std::string get_depends();
/**
Changes the state of the item.
@param[in] to_change A string - to change the state of the item to.
*/
void state_change(std::string to_change);
/**
The constructor for an Item.
@param[in] collect Whether this item is collectable or not.
@param[in] identifier An identifier for this item.
@param[in] initial_state The initial state of the item.
@param[in] synonyms A vector of synonyms for the name of this item.
@param[in] depends An item this item depends on.
@param[in] container Whether this item is a container.
@param[in] locked Whether this item is locked.
@param[in] name The name of the item.
*/
Item(bool collect, const char *identifier, const char *initial_state,
std::vector<std::string> *synonyms, const char * depends, bool container, bool locked, const char* name);
/**
The destructor for an Item.
*/
~Item();
/**
Get the number of items inside this item.
@return The number of items inside this item.
*/
int get_num_items();
/**
Get the item inside this item by index.
@param[in] index The index of the item in the vector.
@return Pointer to an item.
*/
Item * get_item(int index);
/**
Get the name of the item.
@return The name of the item.
*/
std::string get_name();
};
#endif