-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.cpp
57 lines (48 loc) · 1.4 KB
/
player.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
#include "player.h"
#include "terminal.h"
#include <iostream>
#include <sstream>
namespace da_game {
Player::Player(Environment * room) : Human(false, 500) {
this->current_room = room;
this->hp = 100;
this->strength = 2;
}
Player::Player(Environment * room, int hp, int strength, bool has_heart, int max_health) :
Human(has_heart, max_health) {
this->current_room = room;
this->hp = hp;
this->strength = strength;
}
Player::~Player() {
// Player has lost :(
// Varför körs inte den här dekonstruktorn när man dör?
std::cerr << "Destrukting player" << std::endl;
}
void Player::run(){
std::stringstream s;
s << "HP " << hp;
Terminal::print(s.str());
}
std::string Player::get_type() const{
return "Player";
}
std::string Player::get_name() const{
return "Klas-Göran";
}
void Player::fight(Actor &){}
void Player::talk_to(Actor & actor){
if (&actor == this) {
std::cout << "Hej på mig O_o" << std::endl;
return;
}
std::cout << "Hello dear " << actor.get_name() << std::endl;
actor.talk_to(*this);
}
Environment * Player::get_room() const {
return current_room;
}
std::string Player::serialize() const {
return Human::serialize();
}
}