-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapObjects.cpp
More file actions
183 lines (164 loc) · 6.28 KB
/
MapObjects.cpp
File metadata and controls
183 lines (164 loc) · 6.28 KB
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
/*******************************************************************************
* ** Author: Gavin Slusher
* ** Date: 6/2/2019
* ** Description: MapObject class implementation file. Contains logic to define
* the objects that will be put in the "map" (2D array) of any
* space class or subclass. Has methods and a constuctor
* to define an object icon, description, and whether or not
* the object is solid, an item, or interactable.
* ** *************************************************************************/
#include <iostream>
#include <string>
#include "MapObjects.hpp"
#include "displayMenu.hpp"
#include "inputValidation.hpp"
using std::cout;
using std::cin;
using std::endl;
/*******************************************************************************
* MapObjects::MapObjects()
* Constructor. Set's the default icon to GRASS, and by default the object is
* not interactable, solid, or an item.
*******************************************************************************/
MapObjects::MapObjects()
: icon(GRASS), interactable(false), solid(false), item(false)
{
}
/*******************************************************************************
* MapObjects::MapObjects()
* Constructor. Let's the user set the object's traits.
*******************************************************************************/
MapObjects::MapObjects(char iconIn, bool interIn, bool solidIn, bool itemIn,
string nameIn)
: icon(iconIn), interactable(interIn), solid(solidIn), item(itemIn),
name(nameIn)
{
}
/*******************************************************************************
* void MapObjects::interact()
* Method to let the user interact with objects. Can be overriden, but by
* default, displays the object's description.
*******************************************************************************/
void MapObjects::interact()
{
if (!interactable)
{
cout << endl << "You can't interact with that." << endl;
}
else
{
cout << getDescription() << endl;
}
}
/*******************************************************************************
* string MapObjects::getDescription()
* Get the Map Object's description
*******************************************************************************/
string MapObjects::getDescription()
{
return description;
}
/*******************************************************************************
* void MapObjects::setDescription()
* Set the Map Object's description
*******************************************************************************/
void MapObjects::setDescription(string &descriptionIn)
{
description = descriptionIn;
}
/*******************************************************************************
* char MapObjects::getIcon()
* Get the Map Object's Icon
*******************************************************************************/
char MapObjects::getIcon()
{
return icon;
}
/*******************************************************************************
* void MapObjects::setIcon()
* Set the Map Objects Icon
*******************************************************************************/
void MapObjects::setIcon(char iconIn)
{
icon = iconIn;
}
/*******************************************************************************
* void MapObjects::setInteractable(bool boolIn)
* Set whether the object is interactable or not
*******************************************************************************/
void MapObjects::setInteractable(bool boolIn)
{
interactable = boolIn;
}
/*******************************************************************************
* void MapObjects::setSolid(bool boolIn)
* Set whether the object is a solid
*******************************************************************************/
void MapObjects::setSolid(bool boolIn)
{
solid = boolIn;
}
/*******************************************************************************
* void MapObjects::setItem(bool boolIn)
* Set whether the object is is an item
*******************************************************************************/
void MapObjects::setItem(bool boolIn)
{
item = boolIn;
}
/*******************************************************************************
* void MapObjects::getInteractable(bool boolIn)
* Returns whether or not the object is interactable
*******************************************************************************/
bool MapObjects::getInteractable()
{
return interactable;
}
/*******************************************************************************
* void MapObjects::getSolid(bool boolIn)
* Returns whether or not the object is a solid
*******************************************************************************/
bool MapObjects::getSolid()
{
return solid;
}
/*******************************************************************************
* void MapObjects::getItem(bool boolIn)
* Returns whether or not the object is an item
*******************************************************************************/
bool MapObjects::getItem()
{
return item;
}
/*******************************************************************************
* MapObjects::getName()
* Returns the MapObjects name
*******************************************************************************/
string MapObjects::getName()
{
return name;
}
/*******************************************************************************
* MapObjects::setName()
* Sets the MapObject's Name
*******************************************************************************/
void MapObjects::setName(string nameIn)
{
name = nameIn;
}
/*******************************************************************************
* virtual void addItem(MapObjects *&);
* Placeholder for functions inherited
*******************************************************************************/
void MapObjects::addItem(MapObjects *&objectIn)
{
cout << "You shouldn't be seeing this" << endl;
}
/*******************************************************************************
* virtual void displayInv();
* Placeholder for functions inherited
*******************************************************************************/
void MapObjects::displayInv()
{
cout << "You shouldn't be seeing this" << endl;
}