-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacter.cpp
More file actions
135 lines (111 loc) · 2.3 KB
/
Copy pathcharacter.cpp
File metadata and controls
135 lines (111 loc) · 2.3 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
#include "character.h"
#include "eventmanager.h"
#include "item.h"
Character::Character(string name)
//initializer list
:health(100), stamina(100), damage(10), hPotionCount(0), sPotionCount(0), daggerCount(0), swordCount(0), currentRoom(nullptr)
{
this->name = name; // We need to use "this->" to differentiate between the "name" argument and the "name" from the class.
}
string Character::getName()
{
return name;
}
int Character::getHealth()
{
return health;
}
int Character::getStamina()
{
return stamina;
}
string Character::getInventory()
{
string temp = "";
if(inventory.size() > 0)
{
for (int i = 0; i < inventory.size(); i++)
{
temp = temp + (this->inventory[i]->getShortDescription()) + ", ";
}
return temp;
}
else
{
return temp;
}
}
void Character::emptyInventory()
{
this->inventory.clear();
}
void Character::giveItem(Item* inItem) {
this->inventory.push_back(inItem);
}
int Character::getDamage() {
return damage;
}
Room* Character::getCurrentRoom()
{
return currentRoom;
}
void Character::setName(string name)
{
this->name = name;
}
void Character::setHealth(int health)
{
if (health <= 0) {
health = 0;
EventManager::getInstance().trigger("characterDeath", this);
}
this->health = health;
}
void Character::setStamina(int stamina)
{
if (stamina <= 0) {
stamina = 0;
EventManager::getInstance().trigger("characterDeath", this);
}
this->stamina = stamina;
}
void Character::setDamage(int damage)
{
this->damage = damage;
}
void Character::setCurrentRoom(Room* next)
{
currentRoom = next;
}
int Character::getHPotionCount()
{
return hPotionCount;
}
void Character::setHPotionCount(int set)
{
hPotionCount = set;
}
int Character::getSPotionCount()
{
return sPotionCount;
}
void Character::setSPotionCount(int set)
{
sPotionCount = set;
}
int Character::getDaggerCount()
{
return daggerCount;
}
void Character::setDaggerCount(int set)
{
daggerCount = set;
}
int Character::getSwordCount()
{
return swordCount;
}
void Character::setSwordCount(int set)
{
swordCount = set;
}