-
Notifications
You must be signed in to change notification settings - Fork 2
/
Player.hpp
56 lines (46 loc) · 899 Bytes
/
Player.hpp
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
#ifndef PLAYER_HPP
#define PLAYER_HPP
#include <iostream>
class Player
{
public:
Player(const char* name, unsigned int health) :
m_Name(name),
m_Health(health)
{
}
void info()
{
std::cout << m_Name << " have " << m_Health << " HP" << std::endl;
}
void say(const char* text)
{
std::cout << m_Name << ": " << text << std::endl;
}
void heal(Player* target)
{
target->setHealth(100);
}
const char* getName()
{
return m_Name;
}
unsigned int getHealth()
{
return m_Health;
}
bool setHealth(unsigned int health)
{
if (health >= 0 && health <= 100)
{
m_Health = health;
return true;
}
else
return false;
}
private:
const char* m_Name;
unsigned int m_Health;
};
#endif // PLAYER_HPP