forked from matkatmusic/PFMCPP_Project7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDragonSlayer.cpp
More file actions
48 lines (41 loc) · 1.45 KB
/
Copy pathDragonSlayer.cpp
File metadata and controls
48 lines (41 loc) · 1.45 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
#include "DragonSlayer.h"
#include "Dragon.h"
#include "Utility.h"
DragonSlayer::DragonSlayer(std::string name_, int hp_, int armor_) : Character(hp_, armor_, 4), name(name_)
{
helpfulItems = makeHelpfulItems(3);
defensiveItems = makeDefensiveItems(1);
}
const std::string& DragonSlayer::getName()
{
return name;
}
void DragonSlayer::attack(Character& other)
{
std::cout << name << " is attacking " << other.getName() << " !!" << std::endl;
if( auto* dragon = dynamic_cast<Dragon*>(&other) )
{
//DragonSlayers get a 10x boost when attacking dragons, from their attack item.
//so they should USE their attack item before attacking the dragon...
//note: they should only use the item if the dragon's hitpoints are > 0...
//note: items are single-use only, so you need to reset it after use.
//look in the Character class for how the other item types are reset after use.
if( attackItem != nullptr )
{
if (dragon->getHP() > 0)
{
attackItem->use(this);
attackItem.reset();
}
}
while( dragon->getHP() > 0 )
{
dragon->takeDamage(attackDamage);
}
}
Character::attack(other);
}
std::string DragonSlayer::getStats() // using function from Utility.h
{
return getCharacterStats(this); // pass the DragonSlayer instance to getCharacterStats
}