forked from matkatmusic/PFMCPP_Project7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDragon.cpp
More file actions
35 lines (28 loc) · 773 Bytes
/
Copy pathDragon.cpp
File metadata and controls
35 lines (28 loc) · 773 Bytes
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
#include "Dragon.h"
#include "DragonSlayer.h"
#include "Utility.h"
// did the exact same thing as Dwarf and Paladin
Dragon::Dragon(std::string name_, int hp_, int armor_) : Character(hp_, armor_, 80), name(name_)
{
}
void Dragon::attack(Character &other)
{
std::cout << name << " is attacking " << other.getName() << "!!!" << std::endl;
if( auto* slayer = dynamic_cast<DragonSlayer*>(&other) )
{
//dragons can't attack dragon slayers
slayer->defend();
}
else
{
Character::attack(other);
}
}
const std::string& Dragon::getName()
{
return name;
}
std::string Dragon::getStats() // using function from Utility.h
{
return getCharacterStats(this); // pass the Dragon instance to getCharacterStats
}