-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarbarian.cpp
More file actions
62 lines (51 loc) · 1.28 KB
/
Copy pathBarbarian.cpp
File metadata and controls
62 lines (51 loc) · 1.28 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
/*********************************************************************
** Program name: Project4
** Author: James Scanlon
** Date: March 3, 2019
** Description: Implementation for the Barbarian class. Inherits from character and has no special conditions.
*********************************************************************/
#include <cstdlib>
#include "Character.hpp"
#include "Barbarian.hpp"
Barbarian::Barbarian() : Character::Character(){
attackValue = 6;
defenseValue = 6;
armor = 0;
strength = 12;
attackDice = 2;
defendDice = 2;
type = "Barbarian";
specialMessage = false;
}
int Barbarian::attack(){
int damage = 0;
for (int i = 0; i < attackDice; i++)
{
damage += ((rand() % attackValue) + 1);
}
currentAttack = damage;
return damage;
}
void Barbarian::defense(int damage){
int roll = 0;
for (int i = 0; i < defendDice; i++)
{
roll += ((rand() % defenseValue) + 1);
}
if (damage > (roll + armor))
{
strength -= (damage - roll - armor);
if (strength < 0)
{
strength = 0;
}
}
currentDefend = roll;
}
void Barbarian::recovery()
{
strength += .5 * (baseStrength - strength);
}
Barbarian::~Barbarian()
{
}