-
Notifications
You must be signed in to change notification settings - Fork 1
/
RoomTile.cpp
154 lines (132 loc) · 2.58 KB
/
RoomTile.cpp
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
//RoomTile.cpp: implements the functions declared in RoomTile.h
#include <ncurses.h>
#include <iostream>
#include "RoomTile.h"
#include "Creature.h"
//See note 6
using namespace std;
//Constructor
RoomTile::RoomTile(bool bCollectable, bool bWalkable, char cDisplayChar)
{
m_iIntensity = 0;
m_bCollectable = bCollectable;
m_bWalkable = bWalkable;
m_cDisplayChar = cDisplayChar;
m_pCreature = NULL;
m_vItems;
}
//Destructor
RoomTile::~RoomTile()
{
for (auto itr = m_vItems.begin(); itr != m_vItems.end(); itr++)
{
delete (*itr);
}
}
//Getters
int RoomTile::getIntensity() const
{
return m_iIntensity;
}
bool RoomTile::getCollectable() const
{
return m_bCollectable;
}
bool RoomTile::getWalkable() const
{
return m_bWalkable;
}
char RoomTile::getDisplayChar() const
{
return m_cDisplayChar;
}
vector<Item*> RoomTile::getItems() const
{
return m_vItems;
}
Creature* RoomTile::getCreature() const
{
return m_pCreature;
}
//Setters
void RoomTile::setIntensity(int iIntensity)
{
/* addstr("set intensity was called");
addch('\n');
addstr("set intensity was called");
addch('\n');
addstr("set intensity was called");
addch('\n');
addstr("set intensity was called");
addch('\n');
addstr("set intensity was called");
addch('\n');
addstr("set intensity was called");
addch('\n');
getch();
getch();
getch();
getch();
getch();
getch();
getch();
getch();
getch();
getch();
*/
m_iIntensity = iIntensity;
}
void RoomTile::setItems(vector<Item*> vItems)
{
m_vItems = vItems;
}
void RoomTile::setCollectable(bool bCollectable)
{
m_bCollectable = bCollectable;
}
void RoomTile::setWalkable(bool bWalkable)
{
m_bWalkable = bWalkable;
}
void RoomTile::setDisplayChar(char cDisplayChar)
{
m_cDisplayChar = cDisplayChar;
}
void RoomTile::setCreature(Creature* aCreature)
{
// cout << "setCreature(): " << aCreature << endl; //debug
m_pCreature = aCreature;
}
//Other methods
/*
void RoomTile::remove(Entity* aContainedEntity)
{
// cout << "remove(): called" << endl; //debug
//if it's a creature, set m_Creature to NULL
if (static_cast<Creature*>(aContainedEntity) != NULL)
m_Creature = NULL;
//Otherwise, it's an item. Find the item and get rid of it!
else
{
for (auto itr = m_vItems.begin(); itr != m_vItems.end(); itr++)
{
if (aContainedEntity->getID() == (*itr)->getID())
m_vItems.erase(itr);
}
}
// cout << "remove(): completed" << endl;
}
*/
void RoomTile::add(Item* anItem)
{
m_vItems.push_back(anItem);
}
/*
void RoomTile::addIntensity(int iIntensity)
{
if (iIntensity + getIntensity() >= 2)
setIntensity(2);
else
setIntensity(iIntensity + getIntensity());
}
*/