-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArea.h
220 lines (170 loc) · 5.63 KB
/
Area.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
/**
* @file Area.h
* Area.h defines the methods for the Area.cpp source file.
*
* @brief Defines the Area class.
*
* @author Michael Abrams
* @author James Boocock
* @author Toby Herbert
* @author Tatai Nikora
* @version 0.3
*/
#ifndef _AREA_H
#define _AREA_H
//------------------------------------------------------------------------------
/* Include */
//------------------------------------------------------------------------------
#include <string>
#include <vector>
#include <iostream>
#include <cstring>
#include "Item.h"
#include "StateDescriptor.h"
#include "AreaCommand.h"
class Area {
protected:
std::vector<Item*> items; ///< A vector to hold the area's items.
int num_descriptions; ///< The number of descriptions for the area.
int num_commands; ///< The number of commands for the area.
int num_items; ///< The number of items in the area.
std::string status; ///< The status of the area.
std::string id; ///< The area's id.
std::string name; ///< The name of the area.
std::string curr_desc_id; ///< The id of the area's current description.
std::vector<StateDescriptor*> description; ///< A vector of all the descriptions
///< of the area
std::vector<AreaCommand*> commands;///< A vector of all the commands for the area.
public:
/**
Checks if an area has this description.
@param[in] desc_id A description ID.
@return Returns true if 'description' holds desc_id, otherwise returns false.
*/
bool has_description(std::string desc_id);
/**
This accessor method returns the status of the area.
@return The status of the Area.
*/
std::string get_status();
/**
Calls the has_description method.
The function arguments listed with "param" will be compared
to the declaration and verified.
@see has_description();
@return True if the area has the current description otherwise false.
*/
bool has_current_desc();
/**
Accessor for the number of items in the Area.
@return The number of items in the area.
*/
int get_num_items();
/**
Get the area description.
@return String description of the area.
*/
std::string get_description();
/**
Remove an item from the area by index.
@param[in] index The index of the item to remove.
@return Description of returned value.
*/
void remove_item(int index);
/**
Removes an item from the area by the item id.
@param[in] item_id The id of the item to be removed.
*/
void remove_item(std::string item_id);
/**
Adds an item to the area.
@param[in] new_item A pointer to the item to add to the items vector.
*/
void add_item(Item *new_item);
/**
Get the item in the area from items vector by index.
@param[in] index The index of the item in the vector.
@return A pointer to the item.
*/
Item *get_item(int index);
/**
Get the area id.
@return The id of the area.
*/
std::string get_id();
/**
Checks whether the area has an item.
@param[in] item_to_find The name of the item to find.
@return True if the area (items vector) contains the item.
*/
bool has_item(std::string item_to_find);
/**
Gets a pointer to the item by item id and sets index to the
index of the item in the vector.
@param[in] item_id The id of the item.
@param[out] item The address of the item's index member variable.
@return A pointer to the item.
*/
Item *get_item(std::string item_id, unsigned int &item);
/**
Adds a StateDescriptor to an area.
@param[in] desc A pointer to a StateDescriptor object.
*/
void add_description(StateDescriptor *desc);
/**
Adds an AreaCommand to an area.
@param[in] command_name A pointer to an AreaCommand.
*/
void add_command(AreaCommand *command_name);
/**
Get the number of commands for this area.
@return The number of AreaCommands for this area.
*/
int get_num_commands();
/**
Get an AreaCommand for this area by index.
@param[in] index The index of the AreaCommand in the commands vector.
@return A pointer to the AreaCommand or null if it doesn't exist.
*/
AreaCommand *get_command(int index);
/**
Gets an AreaCommand for this area by name.
@param[in] command_name The name of the command to get.
@return A pointer to the AreaCommand or null if it doesn't exist.
*/
AreaCommand *has_command(std::string command_name);
/**
Get the number if descriptions for the area.
@return The number of descriptions for this area.
*/
int get_num_descriptions();
/**
Gets a StateDescriptor for the area by index.
@param[in] index The index of the StateDescriptor in the description vector.
@return A pointer to the StateDescriptor or null if it doesn't exist.
*/
StateDescriptor *get_descriptor(int index);
/**
Unlocks an AreaCommand of this area.
@param[in] area_command_id The id of an AreaCommand to unlock.
*/
void unlock(std::string area_command_id);
/**
The constructor for an Area object.
@param[in] id The id of the area.
@param[in] desc_id The id of the area description.
@param[in] status The status of the area.
@param[in] name The name of the area.
*/
Area(const char *id, const char *desc_id, const char* status, const char* name);
/**
Area Deconstructor.
*/
~Area();
/**
Gets the name of the area.
@return The name of the area.
*/
std::string get_area_name();
};
#endif