-
Notifications
You must be signed in to change notification settings - Fork 297
Expand file tree
/
Copy pathUtility.cpp
More file actions
108 lines (97 loc) · 3.31 KB
/
Copy pathUtility.cpp
File metadata and controls
108 lines (97 loc) · 3.31 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
#include "Utility.h"
#include "HelpfulItem.h"
#include "DefensiveItem.h"
#include "Character.h"
std::vector<std::unique_ptr<Item>> makeHelpfulItems(int num)
{
std::vector<std::unique_ptr<Item>> items;
while( num-- >= 0 )
{
items.push_back( std::unique_ptr<HelpfulItem>(new HelpfulItem()) );
}
std::cout << "made " << items.size() << " helpful items" << std::endl;
return items;
}
std::vector<std::unique_ptr<Item>> makeDefensiveItems(int num)
{
std::vector<std::unique_ptr<Item>> items;
while( num-- >= 0 )
{
items.push_back( std::unique_ptr<DefensiveItem>(new DefensiveItem()) );
}
std::cout << "made " << items.size() << " defensive items" << std::endl;
return items;
}
std::string getCharacterStats(Character* ch)
{
std::string str;
str += " hitPoints: " + std::to_string(ch->getHP()) + "\n";
str += " armor: " + std::to_string(ch->getArmorLevel()) + "\n";
str += " attack damage: " + std::to_string(ch->getAttackDamage()) + "\n";
str += " is defending: " + std::string((ch->getIsDefending() ? "true" : "false" )) + "\n";
str += " " + std::to_string(ch->getHelpfulItems().size()) + " helpful items, " + std::to_string(ch->getDefensiveItems().size()) + " defensive items";
return str;
}
void useDefensiveItem(Character*, Item& item)
{
//dwarves, paladins, and DragonSlayers get extra boosts from defensive item.
if( auto* ch = dynamic_cast<Dwarf*>(character) )
{
ch->boostArmor( item.getBoost() * 1.1 );
}
else if( auto* ch = dynamic_cast<Paladin*>(character) )
{
//same with paladins
ch->boostArmor( item.getBoost() * 1.3 );
}
else if( auto* ch = dynamic_cast<DragonSlayer*>(character))
{
ch->boostArmor( item.getBoost() * 1.5 );
}
else if( auto* ch = dynamic_cast<Dragon*>(character) )
{
//dragons don't need defensive items
}
}
void useHelpfulItem(Character*, Item* item)
{
if( auto* ch = dynamic_cast<Dwarf*>(character) )
{
ch->boostHitPoints(item->getBoost() * 2);
}
else if( auto* ch = dynamic_cast<Paladin*>(character) )
{
ch->boostHitPoints(item->getBoost() * 1.5);
}
else if( auto* ch = dynamic_cast<DragonSlayer*>(character))
{
ch->boostHitPoints(item->getBoost() * 1.25);
}
else if( auto* ch = dynamic_cast<Dragon*>(character) )
{
//dragons don't carry helpful items!
}
}
void useAttackItem(Character*, Item* item)
{
if( auto* ch = dynamic_cast<Dwarf*>(character) )
{
ch->boostAttackDamage(item->getBoost() * 1.5);
}
else if( auto* ch = dynamic_cast<Paladin*>(character) )
{
ch->boostAttackDamage(item->getBoost() * 1.33);
}
else if( auto* ch = dynamic_cast<DragonSlayer*>(character))
{
assert(false);
//DragonSlayers get a 10x boost when attacking dragons, from their attack item.
//so their attack item should boost their attack damage by a factor of 10
//this means you need to GET the attack damage, multiply it by the item's boost, and BOOST the attackDamage with that multiplied value.
//check Character.h for available member functions you can use.
}
else if( auto* ch = dynamic_cast<Dragon*>(character) )
{
//dragons don't carry attack items!
}
}